x86/sev: Check the VMPL level
authorBrijesh Singh <brijesh.singh@amd.com>
Wed, 9 Feb 2022 18:10:08 +0000 (12:10 -0600)
committerBorislav Petkov <bp@suse.de>
Wed, 6 Apr 2022 11:10:34 +0000 (13:10 +0200)
commit81cc3df9a90e7817494421ecc48ede6bd5e8132b
treefd88593d7c636ce70ec6fe5dff2cc40294238e71
parent0bd6f1e526070271dbe0f626b123b4f6b01dc79c
x86/sev: Check the VMPL level

The Virtual Machine Privilege Level (VMPL) feature in the SEV-SNP
architecture allows a guest VM to divide its address space into four
levels. The level can be used to provide hardware isolated abstraction
layers within a VM. VMPL0 is the highest privilege level, and VMPL3 is
the least privilege level. Certain operations must be done by the VMPL0
software, such as:

* Validate or invalidate memory range (PVALIDATE instruction)
* Allocate VMSA page (RMPADJUST instruction when VMSA=1)

The initial SNP support requires that the guest kernel is running at
VMPL0. Add such a check to verify the guest is running at level 0 before
continuing the boot. There is no easy method to query the current VMPL
level, so use the RMPADJUST instruction to determine whether the guest
is running at the VMPL0.

  [ bp: Massage commit message. ]

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220307213356.2797205-15-brijesh.singh@amd.com
arch/x86/boot/compressed/sev.c
arch/x86/include/asm/sev-common.h
arch/x86/include/asm/sev.h