Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1227632pxb; Sat, 17 Apr 2021 10:27:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5IZMkmIxRxE+H/6xYrHUlnnN2Tj8phrIrnvl2lbOTM3oeyOZfisIPe6acQqSi7vxlkvbv X-Received: by 2002:a17:906:3d41:: with SMTP id q1mr13577174ejf.282.1618680438486; Sat, 17 Apr 2021 10:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618680438; cv=none; d=google.com; s=arc-20160816; b=lTVc2LsKTAxAjMTFJyENgny2TAL0C5SownwtchDTX31gu3vR1otJ/pw9VuiZ49MRCk w14KI9KBJyPWUlrkq5nZC8sOZAvOTzs1uRFIbO3go3Q4LW4ZWDxRVmC80QAAurlAIhej CEZaYzireRMGZQ8gLq6T2n44eBbye1BDZMNZFp7SI6pL4BLW1j0mygVzD5UUkRKyUkoW r9H67opwBUdejF8iqLpkB1p5NrgE0rAmgR8XV408hZqreVoz9/YQ95iwPHk5K11IUkJW PH3EwBlmBW6kzicPIliMcH0Qj8eDVPM+BT8+LaEzk4fG4mwPeXt7IbkCtr1dk64ucsez sjDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=S0cSJjkUH/S8SZSJwUfAt3HMwfoA8lXcrgWomg/s0p8=; b=CEpTVUuOqMVtp32LFYXZ+ZGg5JGoZsDMt5YtwMmcpdy6pswyuBIbnIBDrVIk0ub93k VnazKFVmGUORoTt/4XUByQjUJ5eUQETKbWdmmF+dmU6r8fSPOIuAtrgfEOa+dy70ACBA 9EtUtcmKmYDFT3rOe03tCD8uH5/HIzWsGkFskwMpEuohELtSnfnMsd8fbiW56JdF+Wt0 RGnVrzdo7/EavOw77CRev5iOqAVi51qUPzWd/nkRanke8Y1Dd4b3g6SfuCVA4tpckiKR HsiQeM28hR1mKYKh7GkTNLAVLHRfHJJD3v3VstjzdKLxjgVr2639cE6MXDorG1Q4uHJz pfRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p15si6974804ejj.88.2021.04.17.10.26.55; Sat, 17 Apr 2021 10:27:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236754AbhDQRYI (ORCPT + 99 others); Sat, 17 Apr 2021 13:24:08 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:41019 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236620AbhDQRYH (ORCPT ); Sat, 17 Apr 2021 13:24:07 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, Le 4/16/21 ? 2:51 PM, Guenter Roeck a ?crit?: > 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 base >> address will be different from PAGE_OFFSET and since in the linear mapping, >> two different virtual addresses cannot point to the same physical address, >> 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 right >> before the kernel, so BPF and modules regions do not overlap. KASLR >> implementation will simply have to move the kernel in the last 2GB range >> and just take care of leaving enough space for BPF. >> >> In addition, by moving the kernel to the end of the address space, both >> 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 > > In next-20210416, when booting a riscv32 image in qemu, this patch results in: > > [ 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 allocate 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: Failed to allocate 160 bytes ]--- > > 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 still > crashes with the same error message. > I completely neglected 32b kernel in this series, I fixed that here: Thank you for testing and reporting, Alex > Guenter > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >