public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Joerg Roedel <jroedel@suse.de>,
	Brijesh Singh <brijesh.singh@amd.com>
Subject: Re: [PATCH] x86/sev: Fully map the #VC exception stacks
Date: Fri, 1 Oct 2021 10:57:57 +0200	[thread overview]
Message-ID: <YVbNlXwiASQEsG+x@zn.tnic> (raw)
In-Reply-To: <113eca80a14cd280540c38488fd31ac0fa7bf36c.1633063250.git.thomas.lendacky@amd.com>

On Thu, Sep 30, 2021 at 11:40:50PM -0500, Tom Lendacky wrote:
> The size of the exception stacks was recently increased, resulting in
> stack sizes greater than a page in size. The #VC exception handling was
> only mapping the first (bottom) page, resulting in an SEV-ES guest failing
> to boot.
> 
> Update setup_vc_stacks() to map all the pages of both the IST stack area
> and the fallback stack area.
> 
> Fixes: 7fae4c24a2b8 ("x86: Increase exception stack sizes")
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  arch/x86/kernel/sev.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
> index a6895e440bc3..33e4704164cc 100644
> --- a/arch/x86/kernel/sev.c
> +++ b/arch/x86/kernel/sev.c
> @@ -99,25 +99,33 @@ DEFINE_STATIC_KEY_FALSE(sev_es_enable_key);
>  /* Needed in vc_early_forward_exception */
>  void do_early_exception(struct pt_regs *regs, int trapnr);
>  
> +static void __init map_vc_stack(unsigned long bot, unsigned long top,
> +				phys_addr_t pa)
> +{
> +	while (bot < top) {
> +		cea_set_pte((void *)bot, pa, PAGE_KERNEL);
> +		bot += PAGE_SIZE;
> +		pa += PAGE_SIZE;
> +	}
> +}
> +
>  static void __init setup_vc_stacks(int cpu)
>  {
>  	struct sev_es_runtime_data *data;
>  	struct cpu_entry_area *cea;
> -	unsigned long vaddr;
> -	phys_addr_t pa;
>  
>  	data = per_cpu(runtime_data, cpu);
>  	cea  = get_cpu_entry_area(cpu);
>  
>  	/* Map #VC IST stack */
> -	vaddr = CEA_ESTACK_BOT(&cea->estacks, VC);
> -	pa    = __pa(data->ist_stack);
> -	cea_set_pte((void *)vaddr, pa, PAGE_KERNEL);
> +	map_vc_stack(CEA_ESTACK_BOT(&cea->estacks, VC),
> +		     CEA_ESTACK_TOP(&cea->estacks, VC),
> +		     __pa(data->ist_stack));

So this would not have broken if it would've used EXCEPTION_STKSZ or
EXCEPTION_STACK_ORDER rather since we're mapping pages.

Please use those defines so that this keeps working when someone mad
decides to increase those exception stack sizes again because everything
*and* the kitchen sink wants to instrument the damn kernel. Nothing to
see here people...

-- 
Regards/Gruss,
    Boris.

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

  parent reply	other threads:[~2021-10-01  8:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01  4:40 [PATCH] x86/sev: Fully map the #VC exception stacks Tom Lendacky
2021-10-01  4:49 ` Tom Lendacky
2021-10-01  8:57 ` Borislav Petkov [this message]
2021-10-01 11:50   ` Joerg Roedel
2021-10-01 12:58     ` Borislav Petkov
2021-10-01 13:00       ` Joerg Roedel
2021-10-01 13:29         ` Peter Zijlstra
2021-10-01 13:52         ` Borislav Petkov
2021-10-01 20:39           ` Borislav Petkov
2021-10-04 15:08             ` [PATCH] x86/sev: Make the #VC exception stacks part of the default stacks storage Borislav Petkov
2021-10-04 21:41               ` [PATCH -v2] " Borislav Petkov
2021-10-05 16:28                 ` Tom Lendacky
2021-10-05 20:32                 ` Brijesh Singh
2021-10-06 19:56                 ` [tip: x86/core] " tip-bot2 for Borislav Petkov

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=YVbNlXwiASQEsG+x@zn.tnic \
    --to=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=hpa@zytor.com \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --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