Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32750C4332F for ; Fri, 2 Dec 2022 02:49:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0w68-0002o6-2a; Thu, 01 Dec 2022 21:48:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0w66-0002ny-S5 for qemu-devel@nongnu.org; Thu, 01 Dec 2022 21:48:18 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0w63-0001S6-LN for qemu-devel@nongnu.org; Thu, 01 Dec 2022 21:48:18 -0500 Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NNcmY2pzVz15N3G; Fri, 2 Dec 2022 10:47:25 +0800 (CST) Received: from [10.40.193.166] (10.40.193.166) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 2 Dec 2022 10:48:07 +0800 Subject: Re: regression: insmod module failed in VM with nvdimm on To: Ard Biesheuvel References: <87r0xkubcp.wl-maz@kernel.org> <706965d2-60cb-847d-b30e-6074c8ca5fe4@hisilicon.com> CC: Marc Zyngier , , , , chenxiang via , "linuxarm@huawei.com" Message-ID: <21cf7de2-27e8-8d1f-9efc-aa68cefbad50@hisilicon.com> Date: Fri, 2 Dec 2022 10:48:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.40.193.166] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.255; envelope-from=chenxiang66@hisilicon.com; helo=szxga08-in.huawei.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.257, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: "chenxiang (M)" From: "chenxiang (M)" via Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hi Ard, 在 2022/12/1 19:07, Ard Biesheuvel 写道: > On Thu, 1 Dec 2022 at 09:07, Ard Biesheuvel wrote: >> On Thu, 1 Dec 2022 at 08:15, chenxiang (M) wrote: >>> Hi Ard, >>> >>> >>> 在 2022/11/30 16:18, Ard Biesheuvel 写道: >>>> On Wed, 30 Nov 2022 at 08:53, Marc Zyngier wrote: >>>>> On Wed, 30 Nov 2022 02:52:35 +0000, >>>>> "chenxiang (M)" wrote: >>>>>> Hi, >>>>>> >>>>>> We boot the VM using following commands (with nvdimm on) (qemu >>>>>> version 6.1.50, kernel 6.0-r4): >>>>> How relevant is the presence of the nvdimm? Do you observe the failure >>>>> without this? >>>>> >>>>>> qemu-system-aarch64 -machine >>>>>> virt,kernel_irqchip=on,gic-version=3,nvdimm=on -kernel >>>>>> /home/kernel/Image -initrd /home/mini-rootfs/rootfs.cpio.gz -bios >>>>>> /root/QEMU_EFI.FD -cpu host -enable-kvm -net none -nographic -m >>>>>> 2G,maxmem=64G,slots=3 -smp 4 -append 'rdinit=init console=ttyAMA0 >>>>>> ealycon=pl0ll,0x90000000 pcie_ports=native pciehp.pciehp_debug=1' >>>>>> -object memory-backend-ram,id=ram1,size=10G -device >>>>>> nvdimm,id=dimm1,memdev=ram1 -device ioh3420,id=root_port1,chassis=1 >>>>>> -device vfio-pci,host=7d:01.0,id=net0,bus=root_port1 >>>>>> >>>>>> Then in VM we insmod a module, vmalloc error occurs as follows (kernel >>>>>> 5.19-rc4 is normal, and the issue is still on kernel 6.1-rc4): >>>>>> >>>>>> estuary:/$ insmod /lib/modules/$(uname -r)/hnae3.ko >>>>>> [ 8.186563] vmap allocation for size 20480 failed: use >>>>>> vmalloc= to increase size >>>>> Have you tried increasing the vmalloc size to check that this is >>>>> indeed the problem? >>>>> >>>>> [...] >>>>> >>>>>> We git bisect the code, and find the patch c5a89f75d2a ("arm64: kaslr: >>>>>> defer initialization to initcall where permitted"). >>>>> I guess you mean commit fc5a89f75d2a instead, right? >>>>> >>>>>> Do you have any idea about the issue? >>>>> I sort of suspect that the nvdimm gets vmap-ed and consumes a large >>>>> portion of the vmalloc space, but you give very little information >>>>> that could help here... >>>>> >>>> Ouch. I suspect what's going on here: that patch defers the >>>> randomization of the module region, so that we can decouple it from >>>> the very early init code. >>>> >>>> Obviously, it is happening too late now, and the randomized module >>>> region is overlapping with a vmalloc region that is in use by the time >>>> the randomization occurs. >>>> >>>> Does the below fix the issue? >>> The issue still occurs, but it seems decrease the probability, before it >>> occured almost every time, after the change, i tried 2-3 times, and it >>> occurs. >>> But i change back "subsys_initcall" to "core_initcall", and i test more >>> than 20 times, and it is still ok. >>> >> Thank you for confirming. I will send out a patch today. >> > ...but before I do that, could you please check whether the change > below fixes your issue as well? > > diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c > index 6ccc7ef600e7c1e1..c8c205b630da1951 100644 > --- a/arch/arm64/kernel/kaslr.c > +++ b/arch/arm64/kernel/kaslr.c > @@ -20,7 +20,11 @@ > #include > #include > > -u64 __ro_after_init module_alloc_base; > +/* > + * Set a reasonable default for module_alloc_base in case > + * we end up running with module randomization disabled. > + */ > +u64 __ro_after_init module_alloc_base = (u64)_etext - MODULES_VSIZE; > u16 __initdata memstart_offset_seed; > > struct arm64_ftr_override kaslr_feature_override __initdata; > @@ -30,12 +34,6 @@ static int __init kaslr_init(void) > u64 module_range; > u32 seed; > > - /* > - * Set a reasonable default for module_alloc_base in case > - * we end up running with module randomization disabled. > - */ > - module_alloc_base = (u64)_etext - MODULES_VSIZE; > - > if (kaslr_feature_override.val & kaslr_feature_override.mask & 0xf) { > pr_info("KASLR disabled on command line\n"); > return 0; > . We have tested this change, the issue is still and it doesn't fix the issue.