mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Lai Jiangshan <jiangshanlai+lkml@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Kuppuswamy Sathyanarayanan 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Peter Zijlstra <peterz@infradead.org>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Deep Shah <sdeep@vmware.com>,
	"VMware, Inc." <pv-drivers@vmware.com>
Subject: Re: [PATCH] x86/paravirt: Fix build PARAVIRT_XXL=y without XEN_PV
Date: Fri, 19 Nov 2021 11:27:39 +0100	[thread overview]
Message-ID: <42361b9b-da86-dce2-eb17-fe36c9329347@suse.com> (raw)
In-Reply-To: <20211119102048.hjm46edvhryjgluy@box.shutemov.name>


[-- Attachment #1.1.1: Type: text/plain, Size: 3285 bytes --]

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

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2021-11-19 10:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 18:14 Kirill A. Shutemov
2021-11-17 18:35 ` Peter Zijlstra
2021-11-17 18:42   ` Kirill A. Shutemov
2021-11-17 18:46     ` Sathyanarayanan Kuppuswamy
2021-11-17 18:48       ` Borislav Petkov
2021-11-17 19:11         ` Dave Hansen
2021-11-17 19:13         ` Sathyanarayanan Kuppuswamy
2021-11-17 19:57           ` Dave Hansen
2021-11-17 20:54             ` Sathyanarayanan Kuppuswamy
2021-11-17 21:09               ` Borislav Petkov
2021-11-17 23:04                 ` Sathyanarayanan Kuppuswamy
2021-11-17 23:23                   ` Peter Zijlstra
2021-11-17 23:57                     ` Sathyanarayanan Kuppuswamy
2021-11-17 23:33                   ` Dave Hansen
2021-11-18  1:26                     ` Sathyanarayanan Kuppuswamy
2021-11-18  9:13                       ` Borislav Petkov
2021-11-17 19:02       ` Peter Zijlstra
2021-11-18  6:23 ` Juergen Gross
2021-11-19 10:21   ` Kirill A. Shutemov
2021-11-19  7:51 ` Lai Jiangshan
2021-11-19 10:20   ` Kirill A. Shutemov
2021-11-19 10:27     ` Juergen Gross [this message]
2021-11-20  1:23     ` Lai Jiangshan
2021-11-22 12:55       ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42361b9b-da86-dce2-eb17-fe36c9329347@suse.com \
    --to=jgross@suse.com \
    --cc=ak@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=jiangshanlai+lkml@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pv-drivers@vmware.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=sdeep@vmware.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®