Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2889753img; Sun, 24 Mar 2019 22:28:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/HDrtwuGK9EAboOlJ8GdyHIlCkxtTnrEzxTgrwndzxKCFGbCbB7R1p+8oVij/KQ5LpaLV X-Received: by 2002:a62:415d:: with SMTP id o90mr22051577pfa.236.1553491688279; Sun, 24 Mar 2019 22:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553491688; cv=none; d=google.com; s=arc-20160816; b=PoGCrTn4UcgqBt9eFay0xNJ2sL9qX0/Yml4FNJFHFAXrw4z16dR4DlxSQWaRprv8Ex gDR9GeZl9NORfrnmmXYngJ1tEydgG6Q/3+2v1A0gwbZ8GzyoxW3o3pmGIZkNCW352cyv 4pOG/EIV2T/E8qDkv0DCX87rMzVs3XlFivaFmL/vq0mV76Jp/+p547xqrPtcqMpCkDkv BcMkWjQu9svqK/jG4W1Yk4Z2+lhMlhVGkaoA6S4ttXbAXEPCnKT0twTb0Qs6APWyZ3wO uEEgHo8Wdf0gcWUJiwkPwmFqcMSnG8ZxhfG3d4FkFifGudbXuHXrV+CMu4QhK2kIWGkz z4cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=LbTMVQbYoYH49JPqmTvPWV4lBBoX0S/p41GHPi78Txw=; b=pP3LMb1fJ65R9BklM1hvrHKo/mxaKPTlOoq5fXDTcApKSp3pYnHPS9MqtjbxjFxGY5 CzMk5SXsX8h9dDeJYKDea/1zzJDn2Tm+b0/UKj44knvByMoPVSLlVgfqGal9jyHCunT6 ymdf1hdNbLK4X2IQZmsTqUDnQ0CO8ajudaCMoFK5lBbsKbZnUUUb+nTogM36uPbH1waE XkNI/zYs3mqknrgqdjbvZoq1d/UpvuaHGJCnNpogBbYbfdg9n9ojhFRdEw8KrZxM0ZZS DYmUvsS+nczxov8iz/kMGJlWvFaHaMreRgfiB+34IxCwvDp6sbg4o3cOBdKGzt8VPXFB dPEA== ARC-Authentication-Results: i=1; mx.google.com; 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 k7si11633544pgi.451.2019.03.24.22.27.35; Sun, 24 Mar 2019 22:28:08 -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; 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 S1729293AbfCYF0k (ORCPT + 99 others); Mon, 25 Mar 2019 01:26:40 -0400 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:29535 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726242AbfCYF0k (ORCPT ); Mon, 25 Mar 2019 01:26:40 -0400 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id x2P5PPRR037015; Mon, 25 Mar 2019 13:25:25 +0800 (GMT-8) (envelope-from alankao@andestech.com) Received: from andestech.com (10.0.15.65) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Mon, 25 Mar 2019 13:25:49 +0800 Date: Mon, 25 Mar 2019 13:25:50 +0800 From: Alan Kao To: Anup Patel CC: Palmer Dabbelt , Albert Ou , "linux-kernel@vger.kernel.org" , Mike Rapoport , Christoph Hellwig , Atish Patra , Paul Walmsley , "linux-riscv@lists.infradead.org" Subject: Re: [PATCH v2] RISC-V: Always compile mm/init.c with cmodel=medany Message-ID: <20190325052550.GA30996@andestech.com> References: <20190325033648.16171-1-anup.patel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190325033648.16171-1-anup.patel@wdc.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.0.15.65] X-DNSRBL: X-MAIL: ATCSQR.andestech.com x2P5PPRR037015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anup, Sorry for being late to the party. I think one more thing should move together with setup_vm(): On Mon, Mar 25, 2019 at 03:37:38AM +0000, Anup Patel wrote: > The Linux RISC-V 32bit kernel is broken after we moved setup_vm() from > kernel/setup.c to mm/init.c because Linux RISC-V 32bit kernel by default > uses cmodel=medlow which results in a non-position-independent setup_vm(). > > This patch fixes Linux RISC-V 32bit kernel booting by: > 1. Forcing cmodel=medany for mm/init.c > 2. Moving remaing MM-related stuff va_pa_offset, pfn_base and > empty_zero_page from kernel/setup.c to mm/init.c > > Fixes: 6f1e9e946f0b ("RISC-V: Move setup_vm() to mm/init.c") > Suggested-by: Christoph Hellwig > Suggested-by: Mike Rapoport > Signed-off-by: Anup Patel > --- > v2: Removed CFLAGS_setup.o from kernel/Makefile and replaced SoBs > --- > arch/riscv/kernel/Makefile | 2 -- > arch/riscv/kernel/setup.c | 8 -------- > arch/riscv/mm/Makefile | 2 ++ > arch/riscv/mm/init.c | 9 +++++++++ > 4 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile > index f13f7f276639..8b9780b6bd7f 100644 > --- a/arch/riscv/kernel/Makefile > +++ b/arch/riscv/kernel/Makefile earlier in this file, there are four lines about ftrace, 5 ifdef CONFIG_FTRACE 6 CFLAGS_REMOVE_ftrace.o = -pg 7 CFLAGS_REMOVE_setup.o = -pg 8 endif removing "-pg" flag from setup.o was necessary for ftrace to work, since setup_vm() cannot process the trampoline of ftrace properly. As setup_vm() is being moved to mm/init.c, you may either mark it with a "notrace" attribute with its declaration, or adding corresponding CFLAGS_REMOVE* to mm/Makefile. > @@ -29,8 +29,6 @@ obj-y += vdso.o > obj-y += cacheinfo.o > obj-y += vdso/ > > -CFLAGS_setup.o := -mcmodel=medany > - > obj-$(CONFIG_FPU) += fpu.o > obj-$(CONFIG_SMP) += smpboot.o > obj-$(CONFIG_SMP) += smp.o > diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c > index ecb654f6a79e..540a331d1376 100644 > --- a/arch/riscv/kernel/setup.c > +++ b/arch/riscv/kernel/setup.c > @@ -48,14 +48,6 @@ struct screen_info screen_info = { > }; > #endif > > -unsigned long va_pa_offset; > -EXPORT_SYMBOL(va_pa_offset); > -unsigned long pfn_base; > -EXPORT_SYMBOL(pfn_base); > - > -unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss; > -EXPORT_SYMBOL(empty_zero_page); > - > /* The lucky hart to first increment this variable will boot the other cores */ > atomic_t hart_lottery; > unsigned long boot_cpu_hartid; > diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile > index eb22ab49b3e0..7307609d405b 100644 > --- a/arch/riscv/mm/Makefile > +++ b/arch/riscv/mm/Makefile > @@ -3,3 +3,5 @@ obj-y += fault.o > obj-y += extable.o > obj-y += ioremap.o > obj-y += cacheflush.o > + > +CFLAGS_init.o := -mcmodel=medany > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index b379a75ac6a6..7a7c454378cb 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -25,6 +25,10 @@ > #include > #include > > +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] > + __page_aligned_bss; > +EXPORT_SYMBOL(empty_zero_page); > + > static void __init zone_sizes_init(void) > { > unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; > @@ -143,6 +147,11 @@ void __init setup_bootmem(void) > } > } > > +unsigned long va_pa_offset; > +EXPORT_SYMBOL(va_pa_offset); > +unsigned long pfn_base; > +EXPORT_SYMBOL(pfn_base); > + > pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; > pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); > > -- > 2.17.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv Alan