lkml.org 
[lkml]   [2021]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] x86/paravirt: Fix build PARAVIRT_XXL=y without XEN_PV
From
Date
On 19.11.21 11:20, Kirill A. Shutemov wrote:
> On Fri, Nov 19, 2021 at 03:51:44PM +0800, Lai Jiangshan wrote:
>> On Thu, Nov 18, 2021 at 7:14 AM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>>>
>>> TDX is going to use CONFIG_PARAVIRT_XXL, but kernel fails to compile if
>>> XEN_PV is not enabled:
>>>
>>> ld.lld: error: undefined symbol: xen_iret
>>>
>>> It happens because INTERRUPT_RETURN defined to use xen_iret if
>>> CONFIG_PARAVIRT_XXL enabled regardless of CONFIG_XEN_PV.
>>>
>>> The issue is not visible in the current kernel because CONFIG_XEN_PV is
>>> the only user of CONFIG_PARAVIRT_XXL and there's no way to enable them
>>> separately.
>>>
>>> Rework code to define INTERRUPT_RETURN based on CONFIG_XEN_PV, not
>>> CONFIG_PARAVIRT_XXL.
>>>
>>> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>>> Cc: Juergen Gross <jgross@suse.com>
>>> Cc: Deep Shah <sdeep@vmware.com>
>>> Cc: "VMware, Inc." <pv-drivers@vmware.com>
>>> ---
>>> arch/x86/include/asm/irqflags.h | 7 +++++--
>>> arch/x86/include/asm/paravirt.h | 5 -----
>>> 2 files changed, 5 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
>>> index b794b6da3214..3b8ddcb7be76 100644
>>> --- a/arch/x86/include/asm/irqflags.h
>>> +++ b/arch/x86/include/asm/irqflags.h
>>> @@ -118,8 +118,6 @@ static __always_inline unsigned long arch_local_irq_save(void)
>>> #define SAVE_FLAGS pushfq; popq %rax
>>> #endif
>>>
>>> -#define INTERRUPT_RETURN jmp native_iret
>>> -
>>> #endif
>>>
>>> #endif /* __ASSEMBLY__ */
>>> @@ -147,8 +145,13 @@ static __always_inline void arch_local_irq_restore(unsigned long flags)
>>> #ifdef CONFIG_X86_64
>>> #ifdef CONFIG_XEN_PV
>>> #define SWAPGS ALTERNATIVE "swapgs", "", X86_FEATURE_XENPV
>>> +#define INTERRUPT_RETURN \
>>> + ANNOTATE_RETPOLINE_SAFE; \
>>> + ALTERNATIVE_TERNARY("jmp *paravirt_iret(%rip);", \
>>> + X86_FEATURE_XENPV, "jmp xen_iret;", "jmp native_iret;")
>>
>> It is part of what CONFIG_PARAVIRT_XXL was designed for to enable
>> pv-aware INTERRUPT_RETURN.
>
> That's very vague statement.
>
> Could you elaborate on what is wrong with proposed fix?
>
>> I would prefer xen_iret is defined as a weak symbol unconditionally.
>> Like:
>>
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index e38a4cf795d9..c0953f1b4559 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -635,6 +635,7 @@ SYM_INNER_LABEL_ALIGN(native_iret, SYM_L_GLOBAL)
>> jnz native_irq_return_ldt
>> #endif
>>
>> +SYM_INNER_LABEL(xen_iret, SYM_L_WEAK) /* placeholder */
>> SYM_INNER_LABEL(native_irq_return_iret, SYM_L_GLOBAL)
>> /*
>> * This may fault. Non-paranoid faults on return to userspace are
>>
>> It will work when !CONFIG_XEN_PV
>
> It pollutes namespace for no particular reason. I don't see it justified.
>

I agree. IMO weak symbols should be avoided if easily possible, and the
patch here shows that it IS possible without any problem.


Juergen
[unhandled content-type:application/pgp-keys][unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2021-11-19 11:27    [W:0.147 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site