From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Juxin Gao <gaojuxin@loongson.cn>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.4 057/101] MIPS: Make sparse_init() using top-down allocation
Date: Fri, 19 Jun 2020 16:32:46 +0200 [thread overview]
Message-ID: <20200619141617.029873739@linuxfoundation.org> (raw)
In-Reply-To: <20200619141614.001544111@linuxfoundation.org>
From: Tiezhu Yang <yangtiezhu@loongson.cn>
[ Upstream commit 269b3a9ac538c4ae87f84be640b9fa89914a2489 ]
In the current code, if CONFIG_SWIOTLB is set, when failed to get IO TLB
memory from the low pages by plat_swiotlb_setup(), it may lead to the boot
process failed with kernel panic.
(1) On the Loongson and SiByte platform
arch/mips/loongson64/dma.c
arch/mips/sibyte/common/dma.c
void __init plat_swiotlb_setup(void)
{
swiotlb_init(1);
}
kernel/dma/swiotlb.c
void __init
swiotlb_init(int verbose)
{
...
vstart = memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE);
if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
return;
...
pr_warn("Cannot allocate buffer");
no_iotlb_memory = true;
}
phys_addr_t swiotlb_tbl_map_single()
{
...
if (no_iotlb_memory)
panic("Can not allocate SWIOTLB buffer earlier ...");
...
}
(2) On the Cavium OCTEON platform
arch/mips/cavium-octeon/dma-octeon.c
void __init plat_swiotlb_setup(void)
{
...
octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
if (!octeon_swiotlb)
panic("%s: Failed to allocate %zu bytes align=%lx\n",
__func__, swiotlbsize, PAGE_SIZE);
...
}
Because IO_TLB_DEFAULT_SIZE is 64M, if the rest size of low memory is less
than 64M when call plat_swiotlb_setup(), we can easily reproduce the panic
case.
In order to reduce the possibility of kernel panic when failed to get IO
TLB memory under CONFIG_SWIOTLB, it is better to allocate low memory as
small as possible before plat_swiotlb_setup(), so make sparse_init() using
top-down allocation.
Reported-by: Juxin Gao <gaojuxin@loongson.cn>
Co-developed-by: Juxin Gao <gaojuxin@loongson.cn>
Signed-off-by: Juxin Gao <gaojuxin@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/kernel/setup.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8fa30516f39d..33f5aeaf0024 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -769,7 +769,17 @@ static void __init arch_mem_init(char **cmdline_p)
BOOTMEM_DEFAULT);
#endif
device_tree_init();
+
+ /*
+ * In order to reduce the possibility of kernel panic when failed to
+ * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate
+ * low memory as small as possible before plat_swiotlb_setup(), so
+ * make sparse_init() using top-down allocation.
+ */
+ memblock_set_bottom_up(false);
sparse_init();
+ memblock_set_bottom_up(true);
+
plat_swiotlb_setup();
paging_init();
--
2.25.1
next prev parent reply other threads:[~2020-06-19 14:37 UTC|newest]
Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 14:31 [PATCH 4.4 000/101] 4.4.228-rc1 review Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 001/101] ipv6: fix IPV6_ADDRFORM operation logic Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 002/101] vxlan: Avoid infinite loop when suppressing NS messages with invalid options Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 003/101] scsi: return correct blkprep status code in case scsi_init_io() fails Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 004/101] net: phy: marvell: Limit 88m1101 autoneg errata to 88E1145 as well Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 005/101] pwm: fsl-ftm: Use flat regmap cache Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 006/101] igb: improve handling of disconnected adapters Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 007/101] ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 008/101] sched/fair: Dont NUMA balance for kthreads Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 009/101] ath9k_htc: Silence undersized packet warnings Greg Kroah-Hartman
2020-06-19 14:31 ` [PATCH 4.4 010/101] x86_64: Fix jiffies ODR violation Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 011/101] x86/speculation: Prevent rogue cross-process SSBD shutdown Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 012/101] x86/reboot/quirks: Add MacBook6,1 reboot quirk Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 013/101] efi/efivars: Add missing kobject_put() in sysfs entry creation error path Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 014/101] ALSA: es1688: Add the missed snd_card_free() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 015/101] ALSA: usb-audio: Fix inconsistent card PM state after resume Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 016/101] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 017/101] ACPI: PM: Avoid using power resources if there are none for D0 Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 018/101] cgroup, blkcg: Prepare some symbols for module and !CONFIG_CGROUP usages Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 019/101] nilfs2: fix null pointer dereference at nilfs_segctor_do_construct() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 020/101] spi: bcm2835aux: Fix controller unregister order Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 021/101] ALSA: pcm: disallow linking stream to itself Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 022/101] x86/speculation: Change misspelled STIPB to STIBP Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 023/101] x86/speculation: Add support for STIBP always-on preferred mode Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 024/101] x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 025/101] x86/speculation: PR_SPEC_FORCE_DISABLE enforcement for indirect branches Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 026/101] spi: dw: fix possible race condition Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 027/101] spi: dw: Fix controller unregister order Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 028/101] spi: No need to assign dummy value in spi_unregister_controller() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 029/101] spi: Fix controller unregister order Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 030/101] spi: pxa2xx: " Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 031/101] spi: bcm2835: " Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 032/101] ovl: initialize error in ovl_copy_xattr Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 033/101] proc: Use new_inode not new_inode_pseudo Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 034/101] video: fbdev: w100fb: Fix a potential double free Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 035/101] KVM: nSVM: leave ASID aside in copy_vmcb_control_area Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 036/101] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 037/101] KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 038/101] ath9k: Fix use-after-free Read in ath9k_wmi_ctrl_rx Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 039/101] ath9k: Fix use-after-free Write in ath9k_htc_rx_msg Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 040/101] ath9x: Fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 041/101] ath9k: Fix general protection fault " Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 042/101] Smack: slab-out-of-bounds in vsscanf Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 043/101] mm/slub: fix a memory leak in sysfs_slab_add() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 044/101] fat: dont allow to mount if the FAT length == 0 Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 045/101] can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 046/101] spi: dw: Zero DMA Tx and Rx configurations on stack Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 047/101] Bluetooth: Add SCO fallback for invalid LMP parameters error Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 048/101] kgdb: Prevent infinite recursive entries to the debugger Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 049/101] spi: dw: Enable interrupts in accordance with DMA xfer mode Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 050/101] clocksource: dw_apb_timer_of: Fix missing clockevent timers Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 051/101] btrfs: do not ignore error from btrfs_next_leaf() when inserting checksums Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 052/101] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 053/101] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 054/101] staging: android: ion: use vmap instead of vm_map_ram Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 055/101] e1000: Distribute switch variables for initialization Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 056/101] media: dvb: return -EREMOTEIO on i2c transfer failure Greg Kroah-Hartman
2020-06-19 14:32 ` Greg Kroah-Hartman [this message]
2020-06-19 14:32 ` [PATCH 4.4 058/101] netfilter: nft_nat: return EOPNOTSUPP if type or flags are not supported Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 059/101] lib/mpi: Fix 64-bit MIPS build with Clang Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 060/101] net: lpc-enet: fix error return code in lpc_mii_init() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 061/101] net: allwinner: Fix use correct return type for ndo_start_xmit() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 062/101] powerpc/spufs: fix copy_to_user while atomic Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 063/101] mips: cm: Fix an invalid error code of INTVN_*_ERR Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 064/101] kgdb: Fix spurious true from in_dbg_master() Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 065/101] md: dont flush workqueue unconditionally in md_open Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 066/101] mwifiex: Fix memory corruption in dump_station Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 067/101] mips: Add udelay lpj numbers adjustment Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 068/101] x86/mm: Stop printing BRK addresses Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 069/101] m68k: mac: Dont call via_flush_cache() on Mac IIfx Greg Kroah-Hartman
2020-06-19 14:32 ` [PATCH 4.4 070/101] macvlan: Skip loopback packets in RX handler Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 071/101] PCI: Dont disable decoding when mmio_always_on is set Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 072/101] MIPS: Fix IRQ tracing when call handle_fpe() and handle_msa_fpe() Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 073/101] ixgbe: fix signed-integer-overflow warning Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 074/101] spi: dw: Return any value retrieved from the dma_transfer callback Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 075/101] cpuidle: Fix three reference count leaks Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 076/101] ima: Fix ima digest hash table key calculation Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 077/101] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 078/101] Btrfs: fix unreplayable log after snapshot delete + parent dir fsync Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 079/101] btrfs: send: emit file capabilities after chown Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 080/101] btrfs: fix error handling when submitting direct I/O bio Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 081/101] ima: Directly assign the ima_default_policy pointer to ima_rules Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 082/101] PCI: Program MPS for RCiEP devices Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 083/101] e1000e: Relax condition to trigger reset for ME workaround Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 084/101] carl9170: remove P2P_GO support Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 085/101] media: go7007: fix a miss of snd_card_free Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 086/101] b43legacy: Fix case where channel status is corrupted Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 087/101] b43: Fix connection problem with WPA3 Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 088/101] b43_legacy: " Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 089/101] igb: Report speed and duplex as unknown when device is runtime suspended Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 090/101] power: vexpress: add suppress_bind_attrs to true Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 091/101] pinctrl: samsung: Save/restore eint_mask over suspend for EINT_TYPE GPIOs Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 092/101] sparc32: fix register window handling in genregs32_[gs]et() Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 093/101] kernel/cpu_pm: Fix uninitted local in cpu_pm Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 094/101] ARM: tegra: Correct PL310 Auxiliary Control Register initialization Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 095/101] drivers/macintosh: Fix memleak in windfarm_pm112 driver Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 096/101] kbuild: force to build vmlinux if CONFIG_MODVERSION=y Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 097/101] sunrpc: svcauth_gss_register_pseudoflavor must reject duplicate registrations Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 098/101] sunrpc: clean up properly in gss_mech_unregister() Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 099/101] w1: omap-hdq: cleanup to add missing newline for some dev_dbg Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 100/101] perf probe: Do not show the skipped events Greg Kroah-Hartman
2020-06-19 14:33 ` [PATCH 4.4 101/101] perf symbols: Fix debuginfo search for Ubuntu Greg Kroah-Hartman
2020-06-19 16:40 ` [PATCH 4.4 000/101] 4.4.228-rc1 review Guenter Roeck
2020-06-20 7:46 ` Greg Kroah-Hartman
2020-06-20 14:04 ` Guenter Roeck
2020-06-20 15:06 ` Greg Kroah-Hartman
2020-06-19 23:45 ` Guenter Roeck
2020-06-20 8:18 ` Naresh Kamboju
2020-06-20 9:49 ` Jon Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200619141617.029873739@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=gaojuxin@loongson.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=yangtiezhu@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).