Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751060AbeAPCes (ORCPT + 1 other); Mon, 15 Jan 2018 21:34:48 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:53317 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750837AbeAPCer (ORCPT ); Mon, 15 Jan 2018 21:34:47 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="35348691" Subject: Re: [PATCH] x86/jailhouse: fix building without X86_X2APIC To: Arnd Bergmann , Jan Kiszka , Thomas Gleixner , CC: , Ingo Molnar , "H. Peter Anvin" , Juergen Gross , References: <20180115202335.1645883-1-arnd@arndb.de> From: Dou Liyang Message-ID: <4284ee79-a87c-a47d-7e96-682bdd8754e1@cn.fujitsu.com> Date: Tue, 16 Jan 2018 10:34:42 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 4814449F5B3B.A94CF X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Arnd, At 01/16/2018 09:25 AM, Dou Liyang wrote: > Hi Arnd, > > At 01/16/2018 04:23 AM, Arnd Bergmann wrote: >> When CONFIG_X86_X2APIC is disabled, jailhouse fails to build: >> >> arch/x86/kernel/jailhouse.c: In function 'jailhouse_get_smp_config': >> arch/x86/kernel/jailhouse.c:73:3: error: 'x2apic_phys' undeclared >> (first use in this function); did you mean 'x2apic_mode'? >> >> The code is protected by an appropriate x2apic_enabled() check that leads >> to the assignment being optimized out without a link-time reference to >> x2apic_phys, so we just lack a declaration. >> >> Let's move x2apic_mode and x2apic_phys outside of the #ifdef together, >> for consistency. >> >> Fixes: 11c8dc419bbc ("x86/jailhouse: Enable APIC and SMP support") >> Signed-off-by: Arnd Bergmann >> --- >>   arch/x86/include/asm/apic.h | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h >> index 98722773391d..0317d635d9ba 100644 >> --- a/arch/x86/include/asm/apic.h >> +++ b/arch/x86/include/asm/apic.h >> @@ -188,6 +188,8 @@ static inline void >> lapic_assign_system_vectors(void) { } >>   static inline void lapic_assign_legacy_vector(unsigned int i, bool >> r) { } >>   #endif /* !CONFIG_X86_LOCAL_APIC */ >> +extern int x2apic_mode; >> +extern int x2apic_phys; > We can't do that, adding a macro for the X2APIC=n case is enough > I am sorry when I looked into your code in tip tree. I found this measure is not true. please try the the following v2 patch. The reason I don't want to expose the x2apic_mode and x2apic_phys is that they may be misused in X2APIC=n case. So I create an interface to wrap it. do you think so? ;-) Thanks, dou. --- arch/x86/include/asm/apic.h | 10 +++++++++- arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/jailhouse.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 98722773391d..ac25ac2e49af 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -251,6 +251,11 @@ static inline u64 native_x2apic_icr_read(void) extern int x2apic_mode; extern int x2apic_phys; +static inline void apic_set_x2apic_phys(void) +{ + x2apic_phys = 1; +} + extern void __init check_x2apic(void); extern void x2apic_setup(void); static inline int x2apic_enabled(void) @@ -265,7 +270,10 @@ static inline void x2apic_setup(void) { } static inline int x2apic_enabled(void) { return 0; } #define x2apic_mode (0) -#define x2apic_supported() (0) +#define x2apic_phys (0) +#define x2apic_supported() (0) + +static inline void apic_set_x2apic_phys(void){} #endif /* !CONFIG_X86_X2APIC */ struct irq_data; diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 25ddf02598d2..440ff200104f 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1746,7 +1746,7 @@ static __init void try_to_enable_x2apic(int remap_mode) * without IR all CPUs can be addressed by IOAPIC/MSI * only in physical mode */ - x2apic_phys = 1; + apic_set_x2apic_phys(); } x2apic_enable(); } diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c index d6d5976a9b51..ce62162efcf2 100644 --- a/arch/x86/kernel/jailhouse.c +++ b/arch/x86/kernel/jailhouse.c @@ -70,7 +70,7 @@ static void __init jailhouse_get_smp_config(unsigned int early) * We do not have access to IR inside Jailhouse non-root cells. * So we have to run in physical mode. */ - x2apic_phys = 1; + apic_set_x2apic_phys(); /* * This will trigger the switch to apic_x2apic_phys. -- > Thanks, >     dou > > -------------------------8<---------------------- > > Subject: [PATCH] x86/apic: Add a macro named x2apic_phys for the > X2APIC=n case > > The x86 system may build failed in the X2APIC=n case, due to the missing of > x2apic_phys. > > So add a macro named x2apic_phys for the X2APIC=n case. > > Signed-off-by: Dou Liyang > --- >  arch/x86/include/asm/apic.h | 3 ++- >  1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h > index a9e57f08bfa6..ca5940fb995a 100644 > --- a/arch/x86/include/asm/apic.h > +++ b/arch/x86/include/asm/apic.h > @@ -264,7 +264,8 @@ static inline void x2apic_setup(void) { } >  static inline int x2apic_enabled(void) { return 0; } > >  #define x2apic_mode        (0) > -#define    x2apic_supported()    (0) > +#define x2apic_phys        (0) > +#define x2apic_supported()    (0) >  #endif /* !CONFIG_X86_X2APIC */ > >  struct irq_data;