x86/sev: Perform PVALIDATE using the SVSM when not at VMPL0
authorTom Lendacky <thomas.lendacky@amd.com>
Wed, 5 Jun 2024 15:18:47 +0000 (10:18 -0500)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 17 Jun 2024 18:37:54 +0000 (20:37 +0200)
commitfcd042e86422442f999feae96f34a408555be248
treedd9ea09a47977250aa1df3800c3ecd7924d1283b
parent34ff659017359116dd58b1e008d99d21b96b3569
x86/sev: Perform PVALIDATE using the SVSM when not at VMPL0

The PVALIDATE instruction can only be performed at VMPL0. If an SVSM is
present, it will be running at VMPL0 while the guest itself is then
running at VMPL1 or a lower privilege level.

In that case, use the SVSM_CORE_PVALIDATE call to perform memory
validation instead of issuing the PVALIDATE instruction directly.

The validation of a single 4K page is now explicitly identified as such
in the function name, pvalidate_4k_page(). The pvalidate_pages()
function is used for validating 1 or more pages at either 4K or 2M in
size. Each function, however, determines whether it can issue the
PVALIDATE directly or whether the SVSM needs to be invoked.

  [ bp: Touchups. ]
  [ Tom: fold in a fix for Coconut SVSM:
    https://lore.kernel.org/r/234bb23c-d295-76e5-a690-7ea68dc1118b@amd.com  ]

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/4c4017d8b94512d565de9ccb555b1a9f8983c69c.1717600736.git.thomas.lendacky@amd.com
arch/x86/boot/compressed/sev.c
arch/x86/include/asm/sev.h
arch/x86/kernel/sev-shared.c
arch/x86/kernel/sev.c