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 X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF19CC433ED for ; Sat, 17 Apr 2021 17:23:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E356611AC for ; Sat, 17 Apr 2021 17:23:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E356611AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7E6206B006C; Sat, 17 Apr 2021 13:23:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB506B006E; Sat, 17 Apr 2021 13:23:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 683D26B0070; Sat, 17 Apr 2021 13:23:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 4BD9A6B006C for ; Sat, 17 Apr 2021 13:23:40 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0D1D7180AD838 for ; Sat, 17 Apr 2021 17:23:40 +0000 (UTC) X-FDA: 78042531000.39.571C15A Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by imf20.hostedemail.com (Postfix) with ESMTP id 4A4D413A for ; Sat, 17 Apr 2021 17:23:33 +0000 (UTC) X-Originating-IP: 2.7.49.219 Received: from [192.168.1.12] (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C6153E0003; Sat, 17 Apr 2021 17:23:33 +0000 (UTC) Subject: Re: [PATCH v4 1/3] riscv: Move kernel mapping outside of linear mapping To: Guenter Roeck Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-mm@kvack.org References: <20210409061500.14673-1-alex@ghiti.fr> <20210409061500.14673-2-alex@ghiti.fr> <20210416185139.GA42339@roeck-us.net> From: Alex Ghiti Message-ID: <8c23ed42-d8c7-70be-71d8-0eb74ace8e67@ghiti.fr> Date: Sat, 17 Apr 2021 13:23:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210416185139.GA42339@roeck-us.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr X-Rspamd-Queue-Id: 4A4D413A X-Stat-Signature: fryifm5jutx4gq7rf3cgknhoym144oob X-Rspamd-Server: rspam02 Received-SPF: none (ghiti.fr>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=relay4-d.mail.gandi.net; client-ip=217.70.183.196 X-HE-DKIM-Result: none/none X-HE-Tag: 1618680213-867184 Content-Transfer-Encoding: quoted-printable 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: Hi Guenter, Le 4/16/21 =E0 2:51 PM, Guenter Roeck a =E9crit=A0: > On Fri, Apr 09, 2021 at 02:14:58AM -0400, Alexandre Ghiti wrote: >> This is a preparatory patch for relocatable kernel and sv48 support. >> >> The kernel used to be linked at PAGE_OFFSET address therefore we could= use >> the linear mapping for the kernel mapping. But the relocated kernel ba= se >> address will be different from PAGE_OFFSET and since in the linear map= ping, >> two different virtual addresses cannot point to the same physical addr= ess, >> the kernel mapping needs to lie outside the linear mapping so that we = don't >> have to copy it at the same physical offset. >> >> The kernel mapping is moved to the last 2GB of the address space, BPF >> is now always after the kernel and modules use the 2GB memory range ri= ght >> before the kernel, so BPF and modules regions do not overlap. KASLR >> implementation will simply have to move the kernel in the last 2GB ran= ge >> and just take care of leaving enough space for BPF. >> >> In addition, by moving the kernel to the end of the address space, bot= h >> sv39 and sv48 kernels will be exactly the same without needing to be >> relocated at runtime. >> >> Suggested-by: Arnd Bergmann >> Signed-off-by: Alexandre Ghiti >=20 > In next-20210416, when booting a riscv32 image in qemu, this patch resu= lts in: >=20 > [ 0.000000] Linux version 5.12.0-rc7-next-20210416 (groeck@desktop) = (riscv32-linux-gcc (GCC) 10.3.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP Fri= Apr 16 10:38:09 PDT 2021 > [ 0.000000] OF: fdt: Ignoring memory block 0x80000000 - 0xa0000000 > [ 0.000000] Machine model: riscv-virtio,qemu > [ 0.000000] earlycon: uart8250 at MMIO 0x10000000 (options '115200') > [ 0.000000] printk: bootconsole [uart8250] enabled > [ 0.000000] efi: UEFI not found. > [ 0.000000] Kernel panic - not syncing: init_resources: Failed to al= locate 160 bytes > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.12.0-rc7-next-= 20210416 #1 > [ 0.000000] Hardware name: riscv-virtio,qemu (DT) > [ 0.000000] Call Trace: > [ 0.000000] [<80005292>] walk_stackframe+0x0/0xce > [ 0.000000] [<809f4db8>] dump_backtrace+0x38/0x46 > [ 0.000000] [<809f4dd4>] show_stack+0xe/0x16 > [ 0.000000] [<809ff1d0>] dump_stack+0x92/0xc6 > [ 0.000000] [<809f4fee>] panic+0x10a/0x2d8 > [ 0.000000] [<80c02b24>] setup_arch+0x2a0/0x4ea > [ 0.000000] [<80c006b0>] start_kernel+0x90/0x628 > [ 0.000000] ---[ end Kernel panic - not syncing: init_resources: Fai= led to allocate 160 bytes ]--- >=20 > Reverting it fixes the problem. I understand that the version in -next = is > different to this version of the patch, but I also tried v4 and it stil= l > crashes with the same error message. >=20 I completely neglected 32b kernel in this series, I fixed that here: Thank you for testing and reporting, Alex > Guenter >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >=20