mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Thorsten Blum <blum@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Ahmed S. Darwish" <darwi@linutronix.de>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Andreas Larsson <andreas@gaisler.com>,
	Yeoreum Yun <yeoreum.yun@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] x86/boot: Fix off-by-one error in sme_clear_pgd()
Date: Thu, 5 Nov 2026 08:12:55 -0600	[thread overview]
Message-ID: <0d8720d6-97b2-405a-a97d-d4c78887c431@amd.com> (raw)
In-Reply-To: <20260918142714.242711-2-blum@kernel.org>

On 9/18/26 09:27, Thorsten Blum wrote:
> The mapping helpers __sme_map_range_pmd() and __sme_map_range_pte(), and
> therefore sme_encrypt_kernel(), use exclusive end addresses and stop
> before vaddr reaches vaddr_end.
> 
> However, sme_clear_pgd() treats vaddr_end as inclusive when calculating
> the last PGD entry to clear. If vaddr_end is PGD-aligned, the first PGD
> entry outside the range is cleared too.
> 
> Use vaddr_end - 1 to calculate the last PGD entry within the range.
> 
> Fixes: 6ebcb060713f ("x86/mm: Add support to encrypt the kernel in-place")
> Signed-off-by: Thorsten Blum <blum@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  arch/x86/boot/startup/sme.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/boot/startup/sme.c b/arch/x86/boot/startup/sme.c
> index c07a2c381ed1..2d5cb3f7eee6 100644
> --- a/arch/x86/boot/startup/sme.c
> +++ b/arch/x86/boot/startup/sme.c
> @@ -99,7 +99,7 @@ static void __init sme_clear_pgd(struct sme_populate_pgd_data *ppd)
>  	pgd_t *pgd_p;
>  
>  	pgd_start = ppd->vaddr & PGDIR_MASK;
> -	pgd_end = ppd->vaddr_end & PGDIR_MASK;
> +	pgd_end = (ppd->vaddr_end - 1) & PGDIR_MASK;
>  
>  	pgd_size = (((pgd_end - pgd_start) / PGDIR_SIZE) + 1) * sizeof(pgd_t);
>  


  parent reply	other threads:[~2026-11-05 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 14:27 Thorsten Blum
2026-10-31  1:46 ` Andrew Morton
2026-11-04 20:14   ` Thorsten Blum
2026-11-05 14:12 ` Tom Lendacky [this message]
2026-11-05 19:07 ` [tip: x86/boot] " tip-bot2 for Thorsten Blum

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=0d8720d6-97b2-405a-a97d-d4c78887c431@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=blum@kernel.org \
    --cc=bp@alien8.de \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=ritesh.list@gmail.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=yeoreum.yun@arm.com \
    /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®