* [PATCH] fixup! x86/sev: Share implementation of MSR-based page state change
[not found] <20250512190834.332684-23-ardb%2Bgit%40google.com>
@ 2025-05-13 14:17 ` Ard Biesheuvel
2025-05-14 7:50 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2025-05-13 14:17 UTC (permalink / raw)
To: linux-kernel
Cc: x86, Ard Biesheuvel, Borislav Petkov, Ingo Molnar, Tom Lendacky
From: Ard Biesheuvel <ardb@kernel.org>
This is a fixup for the mentioned patch in principle but it applies to
the end of the v3 series so all subsequent conflicts have already been
resolved.
Without it, PVALIDATE will be passed the PA instead of the VA, which
will break if the early page state API is used after the 1:1 mapping is
unmapped.
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
---
arch/x86/boot/compressed/sev.c | 6 +++---
arch/x86/boot/startup/sev-shared.c | 8 ++++----
arch/x86/boot/startup/sev-startup.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index 79309944cb19..f1600b57ff0d 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -55,7 +55,7 @@ void snp_set_page_private(unsigned long paddr)
return;
msr = sev_es_rd_ghcb_msr();
- __page_state_change(paddr, SNP_PAGE_STATE_PRIVATE,
+ __page_state_change(paddr, paddr, SNP_PAGE_STATE_PRIVATE,
(struct svsm_ca *)boot_svsm_caa_pa,
boot_svsm_caa_pa);
sev_es_wr_ghcb_msr(msr);
@@ -69,7 +69,7 @@ void snp_set_page_shared(unsigned long paddr)
return;
msr = sev_es_rd_ghcb_msr();
- __page_state_change(paddr, SNP_PAGE_STATE_SHARED,
+ __page_state_change(paddr, paddr, SNP_PAGE_STATE_SHARED,
(struct svsm_ca *)boot_svsm_caa_pa,
boot_svsm_caa_pa);
sev_es_wr_ghcb_msr(msr);
@@ -100,7 +100,7 @@ void snp_accept_memory(phys_addr_t start, phys_addr_t end)
u64 msr = sev_es_rd_ghcb_msr();
for (phys_addr_t pa = start; pa < end; pa += PAGE_SIZE)
- __page_state_change(pa, SNP_PAGE_STATE_PRIVATE,
+ __page_state_change(pa, pa, SNP_PAGE_STATE_PRIVATE,
(struct svsm_ca *)boot_svsm_caa_pa,
boot_svsm_caa_pa);
sev_es_wr_ghcb_msr(msr);
diff --git a/arch/x86/boot/startup/sev-shared.c b/arch/x86/boot/startup/sev-shared.c
index 77b34ab6c7d8..5ab171120448 100644
--- a/arch/x86/boot/startup/sev-shared.c
+++ b/arch/x86/boot/startup/sev-shared.c
@@ -590,8 +590,8 @@ static void pvalidate_4k_page(unsigned long vaddr, unsigned long paddr,
}
}
-static void __page_state_change(unsigned long paddr, enum psc_op op,
- struct svsm_ca *caa, u64 caa_pa)
+static void __page_state_change(unsigned long vaddr, unsigned long paddr,
+ enum psc_op op, struct svsm_ca *caa, u64 caa_pa)
{
u64 val;
@@ -600,7 +600,7 @@ static void __page_state_change(unsigned long paddr, enum psc_op op,
* state change in the RMP table.
*/
if (op == SNP_PAGE_STATE_SHARED)
- pvalidate_4k_page(paddr, paddr, false, caa, caa_pa);
+ pvalidate_4k_page(vaddr, paddr, false, caa, caa_pa);
/* Issue VMGEXIT to change the page state in RMP table. */
sev_es_wr_ghcb_msr(GHCB_MSR_PSC_REQ_GFN(paddr >> PAGE_SHIFT, op));
@@ -616,7 +616,7 @@ static void __page_state_change(unsigned long paddr, enum psc_op op,
* consistent with the RMP entry.
*/
if (op == SNP_PAGE_STATE_PRIVATE)
- pvalidate_4k_page(paddr, paddr, true, caa, caa_pa);
+ pvalidate_4k_page(vaddr, paddr, true, caa, caa_pa);
}
/*
diff --git a/arch/x86/boot/startup/sev-startup.c b/arch/x86/boot/startup/sev-startup.c
index 21424157819c..023a157e8563 100644
--- a/arch/x86/boot/startup/sev-startup.c
+++ b/arch/x86/boot/startup/sev-startup.c
@@ -57,7 +57,7 @@ early_set_pages_state(unsigned long vaddr, unsigned long paddr,
paddr_end = paddr + (npages << PAGE_SHIFT);
while (paddr < paddr_end) {
- __page_state_change(paddr, op, caa, caa_pa);
+ __page_state_change(vaddr, paddr, op, caa, caa_pa);
vaddr += PAGE_SIZE;
paddr += PAGE_SIZE;
--
2.49.0.1045.g170613ef41-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fixup! x86/sev: Share implementation of MSR-based page state change
2025-05-13 14:17 ` [PATCH] fixup! x86/sev: Share implementation of MSR-based page state change Ard Biesheuvel
@ 2025-05-14 7:50 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2025-05-14 7:50 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-kernel, x86, Ard Biesheuvel, Borislav Petkov, Tom Lendacky
* Ard Biesheuvel <ardb+git@google.com> wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> This is a fixup for the mentioned patch in principle but it applies to
> the end of the v3 series so all subsequent conflicts have already been
> resolved.
>
> Without it, PVALIDATE will be passed the PA instead of the VA, which
> will break if the early page state API is used after the 1:1 mapping is
> unmapped.
>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> arch/x86/boot/compressed/sev.c | 6 +++---
> arch/x86/boot/startup/sev-shared.c | 8 ++++----
> arch/x86/boot/startup/sev-startup.c | 2 +-
> 3 files changed, 8 insertions(+), 8 deletions(-)
Thanks!
I folded this fix back into the originating patch and rolled forward
the changes and resolved the conflicts, the updated series can be found
at:
git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git WIP.x86/boot
Thanks,
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-14 7:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250512190834.332684-23-ardb%2Bgit%40google.com>
2025-05-13 14:17 ` [PATCH] fixup! x86/sev: Share implementation of MSR-based page state change Ard Biesheuvel
2025-05-14 7:50 ` Ingo Molnar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.