From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68E81C47DB3 for ; Thu, 18 Jan 2024 08:23:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4CE56B007D; Thu, 18 Jan 2024 03:23:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CFD106B0080; Thu, 18 Jan 2024 03:23:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC52A6B0081; Thu, 18 Jan 2024 03:23:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AB5C16B007D for ; Thu, 18 Jan 2024 03:23:56 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7DB58807C2 for ; Thu, 18 Jan 2024 08:23:56 +0000 (UTC) X-FDA: 81691743672.13.777DC31 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf24.hostedemail.com (Postfix) with ESMTP id 944F9180009 for ; Thu, 18 Jan 2024 08:23:53 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=iAwAdxWU; spf=pass (imf24.hostedemail.com: domain of nylon.chen@sifive.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=nylon.chen@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705566233; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=welEo0/WJxuhwoTNRxCpfyX7sfk5voOc4sTxJMWj2Aw=; b=UR8ZfSuUVWaoMczgdICl0JwgSD0zdpYGzb5pFo2QXaF3yPRhSCp3WFxMSO4dqiiUy0ij41 wNPpVcyng8MzRR1ZCOY6vJPTtOI0jU6yQVEmH+DC/UOCvGlBfLJTO1kRsyNdolFBSYmpbK WSX2yU8tujOPjcsl2e5QCTZxOB1j3e8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705566233; a=rsa-sha256; cv=none; b=iOgfCtxWHzh4nBMo95lFu3oBjtKp+k3MXQFHB7sV2LkWHJbUujRr+HG4DsGMnJXTnwWgrV RVFQxBVwF3XhJPdnpbXfiMkiWxkNCZDj5UHouJuMqjYnAWpxZkrgNgujSPAFy3YqGuTvRb s4qkTcpwz7FknknuKutJqrzLdA/i2tQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=iAwAdxWU; spf=pass (imf24.hostedemail.com: domain of nylon.chen@sifive.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=nylon.chen@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5cd8667c59eso8374039a12.2 for ; Thu, 18 Jan 2024 00:23:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1705566232; x=1706171032; darn=kvack.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=welEo0/WJxuhwoTNRxCpfyX7sfk5voOc4sTxJMWj2Aw=; b=iAwAdxWUn3w1Xh5a5AA+65YRu04UeAnH8U+V2P9+Jh/IZNYCdALzAigSoyL2W5CBoo iu7Nv/T10YgGTkn8YoDAu0huysDAHsXHwHPgKau/9lcZWIex0oF2Tu3jRCwd5Y8CxLOk 9GUTVffsJfRvzMhKSoAxw3HvmXt3bsFnlI1TCN+kkOmMKN16Pg17YJ/yU8bXE9PFTPE0 zBpqc61WmveBEm8yykuUaAvBlEI3/lNsHByhVJIVhLtK+vric7fNHN5QxpBGIjISPI1K PD7MvrUd1dzcwhZbfid8ST7kbdj86oChMcgs/dsGmXIwJONv4ZhTeQCleo9MeIE8Rx2E ULQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705566232; x=1706171032; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=welEo0/WJxuhwoTNRxCpfyX7sfk5voOc4sTxJMWj2Aw=; b=UyjPDCG2UaPgOaaoIOBQQKKhVFLNoaGFSM2L8oyAq8kfEDfh6hNTXMXLW1VNzCLJxS wQd9XYso17kxuhBsXf3TN0GJ000DvyMbKtFw3y2JasJiJa0wlzpS0gyhHaWBu9GkXjnb lJD8GcBymdUvJ5M4+kNasko3Of8jciD897T3lborEFfM3HSk6Om2dPFNHXf4FSUU0XzU U+Cr7t5n1npFriJxn8OxsJjTzP5QAO3Nmbl1diAaVshqUk5idrUmFvWUhvcgg1VFEB6t 0DWRyo9sVD7IMsrFMDJb7HRtVvd5bXBlAKXpaHrEqrXCKmHCXZwZn3rR6cg6XtxgBgKm 0gbg== X-Gm-Message-State: AOJu0YzHKBKFq3PJkbFFoU7/PVgafd6U2jhn9hXLr7QRBYEDqzvvbDei PhWXfDgUnOyARjGSupYqL864Vm4Tn2MCfjSHsPeb/2Xb8SDa3CqlJ2SMbyRObIQ= X-Google-Smtp-Source: AGHT+IGaoDDx9aDO0YNH0g7XdpqbNuTcRdbMFDYtV1SQWylCAw0oi0AjU/zcDHvavTfmpNNLtZt26w== X-Received: by 2002:a05:6a20:43a7:b0:19b:7e77:7279 with SMTP id i39-20020a056a2043a700b0019b7e777279mr643544pzl.18.1705566232336; Thu, 18 Jan 2024 00:23:52 -0800 (PST) Received: from hsinchu15 (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id fc13-20020a056a002e0d00b006d9cf4b56edsm2812458pfb.175.2024.01.18.00.23.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2024 00:23:51 -0800 (PST) Date: Thu, 18 Jan 2024 16:23:47 +0800 From: Nylon Chen To: alex@ghiti.fr Cc: apatel@ventanamicro.com, alexghiti@rivosinc.com, catalin.marinas@arm.com, will@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh+dt@kernel.org, frowand.list@gmail.com, rppt@kernel.org, akpm@linux-foundation.org, anup@brainfault.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-mm@kvack.org, zong.li@sifive.com, nylon7717@gmail.com Subject: Re: Fwd: [PATCH v8 0/4] riscv: Use PUD/P4D/PGD pages for the linear mapping Message-ID: <20240118082346.GB31078@hsinchu15> References: <20230316131711.1284451-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Stat-Signature: m5qz1bqrw73sbxd4toiny7pko3gq635i X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 944F9180009 X-Rspam-User: X-HE-Tag: 1705566233-900995 X-HE-Meta: U2FsdGVkX1+iPZquoalebNepA+tHGIqCXj86TWkCaWT7PNH2zAWsOTmoQ2WDaSE8gmVLSDnGSMvWt1Y5o+gHv8CTOsQdmnH7LiN31oXV6znq42eWvZ6eiw3H0HawmQ6ulQPAiGL/6uI5vpJz8IO6vQJpRg1Quk2Toy6L8dzE5NuCq20Dx/GTfGKB1wd2OpQ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M9D7XEcfQFDkAa3Yc6xk2fP6QSek2ul9oURHAkiXvhRd4Kd/TdImzaSEGvK4d3sj2ocKYaGC5eCv6iTs79+RWwX7RGcuu/K/wqM9qaIbjKYdpeVE3TP90jjRe7rAYbwILzVDIr2FbkOnT07px9jOe2LNgjhpNK1UD13a6MdV5NiWmW4WgvsbRbYzGSZePfjcRtshcrvjZ9O+AXQNCbq0jdowm+DriPAyVu46D4ETo6bFI0SOk57gDwsSmpsyL41AVuXmJjJFMgm7ZThyF4WPh6ANAKyV84E1J+uxygXKFVf1CHnEM6Ix1CfvyR0c0ufSJRfVMB0PjRIGzrLFzY3PECoBmA10xnNzQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: > On 3/23/23 15:55, Anup Patel wrote: > > On Thu, Mar 23, 2023 at 6:24 PM Alexandre Ghiti wrote: > >> Hi Anup, > >> > >> On Thu, Mar 23, 2023 at 1:18 PM Anup Patel wrote: > >>> Hi Alex, > >>> > >>> On Thu, Mar 16, 2023 at 6:48 PM Alexandre Ghiti wrote: > >>>> This patchset intends to improve tlb utilization by using hugepages for > >>>> the linear mapping. > >>>> > >>>> As reported by Anup in v6, when STRICT_KERNEL_RWX is enabled, we must > >>>> take care of isolating the kernel text and rodata so that they are not > >>>> mapped with a PUD mapping which would then assign wrong permissions to > >>>> the whole region: it is achieved by introducing a new memblock API. > >>>> > >>>> Another patch makes use of this new API in arm64 which used some sort of > >>>> hack to solve this issue: it was built/boot tested successfully. > >>>> > >>>> base-commit-tag: v6.3-rc1 > >>>> > >>>> v8: > >>>> - Fix rv32, as reported by Anup > >>>> - Do not modify memblock_isolate_range and fixes comment, as suggested by Mike > >>>> - Use the new memblock API for crash kernel too in arm64, as suggested by Andrew > >>>> - Fix arm64 double mapping (which to me did not work in v7), but ends up not > >>>> being pretty at all, will wait for comments from arm64 reviewers, but > >>>> this patch can easily be dropped if they do not want it. > >>>> > >>>> v7: > >>>> - Fix Anup bug report by introducing memblock_isolate_memory which > >>>> allows us to split the memblock mappings and then avoid to map the > >>>> the PUD which contains the kernel as read only > >>>> - Add a patch to arm64 to use this newly introduced API > >>>> > >>>> v6: > >>>> - quiet LLVM warning by casting phys_ram_base into an unsigned long > >>>> > >>>> v5: > >>>> - Fix nommu builds by getting rid of riscv_pfn_base in patch 1, thanks > >>>> Conor > >>>> - Add RB from Andrew > >>>> > >>>> v4: > >>>> - Rebase on top of v6.2-rc3, as noted by Conor > >>>> - Add Acked-by Rob > >>>> > >>>> v3: > >>>> - Change the comment about initrd_start VA conversion so that it fits > >>>> ARM64 and RISCV64 (and others in the future if needed), as suggested > >>>> by Rob > >>>> > >>>> v2: > >>>> - Add a comment on why RISCV64 does not need to set initrd_start/end that > >>>> early in the boot process, as asked by Rob > >>>> > >>>> Alexandre Ghiti (4): > >>>> riscv: Get rid of riscv_pfn_base variable > >>>> mm: Introduce memblock_isolate_memory > >>>> arm64: Make use of memblock_isolate_memory for the linear mapping > >>>> riscv: Use PUD/P4D/PGD pages for the linear mapping > >>> Kernel boot fine on RV64 but there is a failure which is still not > >>> addressed. You can see this failure as following message in > >>> kernel boot log: > >>> 0.000000] Failed to add a System RAM resource at 80200000 > >> Hmmm I don't get that in any of my test configs, would you mind > >> sharing yours and your qemu command line? > > Try alexghiti_test branch at > > https://github.com/avpatel/linux.git > > > > I am building the kernel using defconfig and my rootfs is > > based on busybox. > > > > My QEMU command is: > > qemu-system-riscv64 -M virt -m 512M -nographic -bios > > opensbi/build/platform/generic/firmware/fw_dynamic.bin -kernel > > ./build-riscv64/arch/riscv/boot/Image -append "root=/dev/ram rw > > console=ttyS0 earlycon" -initrd ./rootfs_riscv64.img -smp 4 > > > So splitting memblock.memory is the culprit, it "confuses" the resources > addition and I can only find hacky ways to fix that... Hi Alexandre, We encountered the same error as Anup. After adding your patch (3335068f87217ea59d08f462187dc856652eea15), we will not encounter the error again. What I have observed so far is - before your patch When merging consecutive memblocks, if the memblock types are different, they will be merged into reserved - after your patch When consecutive memblocks are merged, if the memblock types are different, they will be merged into memory. Such a result will cause the memory location of OpenSBI to be changed from reserved to memory. Will this have any side effects? > > So given that the arm64 patch with the new API is not pretty and that > the simplest solution is to re-merge the memblock regions afterwards > (which is done by memblock_clear_nomap), I'll drop the new API and the > arm64 patch to use the nomap API like arm64: I'll take advantage of that > to clean setup_vm_final which I have wanted to do for a long time. > > @Mike Thanks for you reviews! > > @Anup Thanks for all your bug reports on this patchset, I have to > improve my test flow (it is in the work :)). > > > > Regards, > > Anup > > > >> Thanks > >> > >>> Regards, > >>> Anup > >>> > >>>> arch/arm64/mm/mmu.c | 25 +++++++++++------ > >>>> arch/riscv/include/asm/page.h | 19 +++++++++++-- > >>>> arch/riscv/mm/init.c | 53 ++++++++++++++++++++++++++++------- > >>>> arch/riscv/mm/physaddr.c | 16 +++++++++++ > >>>> drivers/of/fdt.c | 11 ++++---- > >>>> include/linux/memblock.h | 1 + > >>>> mm/memblock.c | 20 +++++++++++++ > >>>> 7 files changed, 119 insertions(+), 26 deletions(-) > >>>> > >>>> -- > >>>> 2.37.2 > >>>> > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv