x86/sev: Prepare for using the RMPREAD instruction to access the RMP
authorTom Lendacky <thomas.lendacky@amd.com>
Mon, 2 Dec 2024 20:50:46 +0000 (14:50 -0600)
committerBorislav Petkov (AMD) <bp@alien8.de>
Fri, 13 Dec 2024 21:46:14 +0000 (22:46 +0100)
commit3e43c60eb3e3779e88635d45400f7387ec732c07
tree694f7d07fd093c6a89b3097cedb624238a6f3eb3
parentfac04efc5c793dccbd07e2d59af9f90b7fc0dca4
x86/sev: Prepare for using the RMPREAD instruction to access the RMP

The RMPREAD instruction returns an architecture defined format of an RMP
entry. This is the preferred method for examining RMP entries.

In preparation for using the RMPREAD instruction, convert the existing code
that directly accesses the RMP to map the raw RMP information into the
architecture defined format.

RMPREAD output returns a status bit for the 2MB region status. If the input
page address is 2MB aligned and any other pages within the 2MB region are
assigned, then 2MB region status will be set to 1. Otherwise, the 2MB region
status will be set to 0.

For systems that do not support RMPREAD, calculating this value would require
looping over all of the RMP table entries within that range until one is found
with the assigned bit set. Since this bit is not defined in the current
format, and so not used today, do not incur the overhead associated with
calculating it.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Link: https://lore.kernel.org/r/da49d5af1eb7f9039f35f14a32ca091efb2dd818.1733172653.git.thomas.lendacky@amd.com
arch/x86/virt/svm/sev.c