On Fri, Jul 03, 2020 at 10:02:55AM -0700, Andy Lutomirski wrote:
> On Xen PV, #DB doesn't use IST.  We still need to correctly route it
> depending on whether it came from user or kernel mode.
> 
> This patch gets rid of DECLARE/DEFINE_IDTENTRY_XEN -- it was too
> hard to follow the logic.  Instead, route #DB and NMI through
> DECLARE/DEFINE_IDTENTRY_RAW on Xen, and do the right thing for #DB.
> Also add more warnings to the exc_debug* handlers to make this type
> of failure more obvious.
> 
> This fixes various forms of corruption that happen when usermode
> triggers #DB on Xen PV.
> 
> Fixes: 4c0dcd8350a0 ("x86/entry: Implement user mode C entry points for #DB 
> and #MCE")
> Signed-off-by: Andy Lutomirski <l...@kernel.org>
> ---
>  arch/x86/include/asm/idtentry.h | 24 ++++++------------------
>  arch/x86/kernel/traps.c         | 12 ++++++++++++
>  arch/x86/xen/enlighten_pv.c     | 28 ++++++++++++++++++++++++----
>  arch/x86/xen/xen-asm_64.S       |  5 ++---
>  4 files changed, 44 insertions(+), 25 deletions(-)
> 
> diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> index cf51c50eb356..94333ac3092b 100644
> --- a/arch/x86/include/asm/idtentry.h
> +++ b/arch/x86/include/asm/idtentry.h
[...]
> @@ -570,11 +554,15 @@ DECLARE_IDTENTRY_MCE(X86_TRAP_MC,       
> exc_machine_check);
>  
>  /* NMI */
>  DECLARE_IDTENTRY_NMI(X86_TRAP_NMI,   exc_nmi);
> -DECLARE_IDTENTRY_XEN(X86_TRAP_NMI,   nmi);
> +#ifdef CONFIG_XEN_PV
> +DECLARE_IDTENTRY_RAW(X86_TRAP_NMI,   xenpv_exc_nmi);
> +#endif
>  
>  /* #DB */
>  DECLARE_IDTENTRY_DEBUG(X86_TRAP_DB,  exc_debug);
> -DECLARE_IDTENTRY_XEN(X86_TRAP_DB,    debug);
> +#ifdef CONFIG_XEN_PV
> +DECLARE_IDTENTRY_RAW(X86_TRAP_DB,    xenpv_exc_debug);
> +#endif
>  
>  /* #DF */
>  DECLARE_IDTENTRY_DF(X86_TRAP_DF,     exc_double_fault);

Hello,

this patch - now in mainline as commit 13cbc0cd4a30 ("x86/entry/32: Fix
#MC and #DB wiring on x86_32") - seems to break i586 builds with
CONFIG_XEN_PV=y as xenpv_exc_nmi and xenpv_exc_debug are only defined
with CONFIG_X86_64:

[ 1279s] ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_nmi':
[ 1279s] 
/home/abuild/rpmbuild/BUILD/kernel-pae-5.8.rc4/linux-5.8-rc4/linux-obj/../arch/x86/include/asm/idtentry.h:557:
 undefined reference to `xenpv_exc_nmi'
[ 1279s] ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_debug':
[ 1279s] 
/home/abuild/rpmbuild/BUILD/kernel-pae-5.8.rc4/linux-5.8-rc4/linux-obj/../arch/x86/include/asm/idtentry.h:567:
 undefined reference to `xenpv_exc_debug'

Michal Kubecek

Reply via email to