Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3869264img; Mon, 25 Mar 2019 21:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwL3/LW6gx/cFDEjaevButAfdejfAt9oaenwLcTL26gbrfD7+GiSukKMcaUddFzyvxmOVNN X-Received: by 2002:a65:6241:: with SMTP id q1mr27255842pgv.340.1553572950027; Mon, 25 Mar 2019 21:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553572950; cv=none; d=google.com; s=arc-20160816; b=tRErjumHqTxijgJDh4z7KvOGYXp5Cw8l2Unqe1N4DDb2FbV56ejPh3/Mvba/iJPj0S OjWhQdTIp5S2JBcdyv5Ob+s97iXYVLR3EScRRoKofk3p1SFOZtaFjXCgnKNl77nrICD2 FH/sMlwvY3IlSse6+Npga97A4P1PndFJpi08MY+AaXI5qvWPcM/RZUcAHWXeA9Yp6jVY 1A3/szZcXfBIWV9ASx4OSIAvf8a97VywE/yYmbJ0AKAdfP2to5EcxCI4bqJ0O4TAtk2V C5hKn0UwOzn/calRNLUXmIUh03JgFu/8XBXCcvhZi9GsTfmJqRHNdQ1R9WTzE7MuiR9x MCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oFufxt99trQk1HrJ4DBQy+Tki5RtsOLE22J4daML9P4=; b=QgxEVKjMhNPwdaOlP8I9GvJ3f0lq3Tx4qdd9Iw7XAvteu7F0rG/q5qAXqbU2mWTXpj Iod2UkV75ENeSmtGiB6vUYd1thQ90rvB1kr3LIGbf7179KAq2Pm0Jc48oQ74rlhnlKUE yEFmgSkGte0qjKzF3gN3+MXYNUX8D1Mm+QZALRh0eGtXq526AvCs5msESY19bTlDyDnL wrQIn6mf7QaMfeGlAI9lNxFAcRWbz/m7E2LN8pvErCeYhk9WUgJoQt7UdZ1OYJ18xDj6 kuGSGYpC0+PPYLx3A4/g24QqrhwmH7ry3mGmB5XdTlkb69/vKvSuUqMB21HcZz6VaRjg 4AIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=A9VeeXFq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si15563063plk.359.2019.03.25.21.02.14; Mon, 25 Mar 2019 21:02:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=A9VeeXFq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725948AbfCZEBk (ORCPT + 99 others); Tue, 26 Mar 2019 00:01:40 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44035 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfCZEBk (ORCPT ); Tue, 26 Mar 2019 00:01:40 -0400 Received: by mail-wr1-f66.google.com with SMTP id y7so8483991wrn.11 for ; Mon, 25 Mar 2019 21:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oFufxt99trQk1HrJ4DBQy+Tki5RtsOLE22J4daML9P4=; b=A9VeeXFqjsG81fFSUA9hMLPRtVGYZKYYzkZLKEU4RLZ3dHQhZYtk/mzXr0J/fMWwRd /X8MEpkRsr0FRmmfEjfmKMUBv+9d0zPL3TS4VbcR2Un6ePOYO75E8OOv1YqiyeABE0vP eZCSyI1TCvlvAupaiL03MdO/Z/H+4RugYJJLji2pN+CrGcp+XkRe079drkx054hpjTxf umvaGW3zh+S2PbfAXQ5rt1tQ/JmN7sIKtY9W+d+Q9iLkktCWEkxRzPeQuEla+/U7h36y uGRmDB6LHDCwhojFwJ7RKxFaZqilQdq7yG8nxgzcmaTVGVIOJLUHL3Z4+go3PXTPYDoq sYhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oFufxt99trQk1HrJ4DBQy+Tki5RtsOLE22J4daML9P4=; b=X8BOnVXBPWuP3IMV6CyGtTXkDBhbsE4GQscFD9Ul5tLs8xe546+Vgh3uHJoiQ/newY ca0EufrlcAZYJuXg5Ft36Vsbz4t74iSSl9iWFXnhy99kfZhzIw6Siy9rTYe2ZE82fMnN rps5UJePRH5eKKqYzAC6j0CAO7+F1ekNu4LY1fqb9ZWGq/dOzIbtMUNkZmUtqBTApnFK 1lIe2n2atI3pEU8XNb3K9ITY7Wum/zEij5i/narJuVyhwrc7nk/L8D4e31wMwgauqT0t GQmj+J98eYq/3kXnAEGznfJyHx0rUx7eabCYfbfNCYR5CCgJAt42cw1aPgGz66NMLwn+ zsPA== X-Gm-Message-State: APjAAAUJdyb4Sd/TIBgmuOMgSUrtEq7RLdIrP3hYvzwb03aPAwuKmMrg sfyx/kmv8EYD6+Dg6q/lOZzZ0/XNghMgorG6hOYgrg== X-Received: by 2002:a05:6000:120c:: with SMTP id e12mr4272556wrx.187.1553572897984; Mon, 25 Mar 2019 21:01:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anup Patel Date: Tue, 26 Mar 2019 09:31:26 +0530 Message-ID: Subject: Re: [PATCH v2] RISC-V: Always compile mm/init.c with cmodel=medany To: Palmer Dabbelt Cc: Christoph Hellwig , Alan Kao , Anup Patel , Albert Ou , "linux-kernel@vger.kernel.org List" , Mike Rapoport , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 7:52 AM Palmer Dabbelt wrote: > > On Mon, 25 Mar 2019 00:01:45 PDT (-0700), anup@brainfault.org wrote: > > On Mon, Mar 25, 2019 at 12:18 PM Christoph Hellwig wrote: > >> > >> On Mon, Mar 25, 2019 at 01:25:50PM +0800, Alan Kao wrote: > >> > Hi Anup, > >> > > >> > Sorry for being late to the party. I think one more thing should > >> > move together with setup_vm(): > >> > >> Ah, I wonded about that yesterday but wasn't sure. Maybe notrace > >> is a little cleaner? Either way we should probably document both > >> the mcmodel and notrace assumptions in source comments for the next > >> person touching this code. > > > > The setup_vm() should be allowed to call other functions within mm/init.c > > so let's go with file-level notrace (just like how it was done) for > > kernel/setup.c > > > > I certainly add comments for setup_vm() based on all our findings so far. > > Sorry for being slow here, but this is the right approach: setup_vm is called > before relocate, which means the page tables won't be set up correctly for > absolute addressing. We instead build setup_vm with medany, which causes all > addressing to be PC-relative. This is all a bit of a hack, but it's the only > way we have to do this right now. > > You should be able to add a preprocessor #error to check the code model with > something like this > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index b379a75ac6a6..d6fde6af8d75 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -172,6 +172,9 @@ void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot) > } > } > > +#ifndef __riscv_cmodel_medany > +#error "setup_vm() is called from head.S before relocate and must not make any absolute references." > +#endif > asmlinkage void __init setup_vm(void) > { > extern char _start; > > Marking this notrace is the right thing to do, as it can't call into any > functions that aren't medany (there's probably other issues as well, since this > is so early). Thanks for the suggestion, I will add "#error" in v4 of this patch. > > Sorry I missed this the first time around, I wasn't paying enough attention. > > Can someone add instructions for 32-bit boots to the QEMU wiki? It sounds like > it's time to add that to the testing list... To start with, I have send a patch for adding rv32_defconfig which is right now "defconfig" plus "CONFIG_ARCH_RV32I=y" Regards, Anup