Re: [PATCH v3 45/75] x86/dumpstack/64: Handle #VC exception stacks

From: Borislav Petkov
Date: Fri May 22 2020 - 09:07:01 EST


On Tue, Apr 28, 2020 at 05:16:55PM +0200, Joerg Roedel wrote:
> diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
> index 14db05086bbf..2f3534ef4b5f 100644
> --- a/arch/x86/include/asm/stacktrace.h
> +++ b/arch/x86/include/asm/stacktrace.h
> @@ -21,6 +21,10 @@ enum stack_type {
> STACK_TYPE_ENTRY,
> STACK_TYPE_EXCEPTION,
> STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1,
> +#ifdef CONFIG_X86_64

CONFIG_AMD_MEM_ENCRYPT

> + STACK_TYPE_VC,
> + STACK_TYPE_VC_LAST = STACK_TYPE_VC + N_VC_STACKS - 1,
> +#endif
> };
>
> struct stack_info {
> diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
> index 87b97897a881..2468963c1424 100644
> --- a/arch/x86/kernel/dumpstack_64.c
> +++ b/arch/x86/kernel/dumpstack_64.c
> @@ -18,6 +18,7 @@
>
> #include <asm/cpu_entry_area.h>
> #include <asm/stacktrace.h>
> +#include <asm/sev-es.h>
>
> static const char * const exception_stack_names[] = {
> [ ESTACK_DF ] = "#DF",
> @@ -47,6 +48,9 @@ const char *stack_type_name(enum stack_type type)
> if (type >= STACK_TYPE_EXCEPTION && type <= STACK_TYPE_EXCEPTION_LAST)
> return exception_stack_names[type - STACK_TYPE_EXCEPTION];
>
> + if (type >= STACK_TYPE_VC && type <= STACK_TYPE_VC_LAST)

That test can be inside vc_stack_name() so that it gets optimized away
for !CONFIG_AMD_MEM_ENCRYPT and there's no need for ifdeffery.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette