lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhGHyBRcAg33DxxGGpbnT+O7CGKp6Ktr3PtCZ0j50oTJ4fgrg@mail.gmail.com>
Date:   Fri, 19 Nov 2021 15:51:44 +0800
From:   Lai Jiangshan <jiangshanlai+lkml@...il.com>
To:     "Kirill A. Shutemov" <kirill@...temov.name>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Peter Zijlstra <peterz@...radead.org>, X86 ML <x86@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Juergen Gross <jgross@...e.com>, Deep Shah <sdeep@...are.com>,
        "VMware, Inc." <pv-drivers@...are.com>
Subject: Re: [PATCH] x86/paravirt: Fix build PARAVIRT_XXL=y without XEN_PV

On Thu, Nov 18, 2021 at 7:14 AM Kirill A. Shutemov <kirill@...temov.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@...ux.intel.com>
> Cc: Juergen Gross <jgross@...e.com>
> Cc: Deep Shah <sdeep@...are.com>
> Cc: "VMware, Inc." <pv-drivers@...are.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.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ