mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
tools: Secure guest check for AMD in virt-host-validate
Add checking in virt-host-validate for secure guest support on x86 for AMD Secure Encrypted Virtualization. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
0254ceab82
commit
4b561d49ad
@ -41,7 +41,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag,
|
|||||||
"vmx",
|
"vmx",
|
||||||
"svm",
|
"svm",
|
||||||
"sie",
|
"sie",
|
||||||
"158");
|
"158",
|
||||||
|
"sev");
|
||||||
|
|
||||||
static bool quiet;
|
static bool quiet;
|
||||||
|
|
||||||
@ -448,14 +449,18 @@ int virHostValidateSecureGuests(const char *hvname,
|
|||||||
{
|
{
|
||||||
virBitmapPtr flags;
|
virBitmapPtr flags;
|
||||||
bool hasFac158 = false;
|
bool hasFac158 = false;
|
||||||
|
bool hasAMDSev = false;
|
||||||
virArch arch = virArchFromHost();
|
virArch arch = virArchFromHost();
|
||||||
g_autofree char *cmdline = NULL;
|
g_autofree char *cmdline = NULL;
|
||||||
static const char *kIBMValues[] = {"y", "Y", "on", "ON", "oN", "On", "1"};
|
static const char *kIBMValues[] = {"y", "Y", "on", "ON", "oN", "On", "1"};
|
||||||
|
g_autofree char *mod_value = NULL;
|
||||||
|
|
||||||
flags = virHostValidateGetCPUFlags();
|
flags = virHostValidateGetCPUFlags();
|
||||||
|
|
||||||
if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158))
|
if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158))
|
||||||
hasFac158 = true;
|
hasFac158 = true;
|
||||||
|
else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SEV))
|
||||||
|
hasAMDSev = true;
|
||||||
|
|
||||||
virBitmapFree(flags);
|
virBitmapFree(flags);
|
||||||
|
|
||||||
@ -491,6 +496,29 @@ int virHostValidateSecureGuests(const char *hvname,
|
|||||||
virHostMsgFail(level, "Hardware or firmware does not provide "
|
virHostMsgFail(level, "Hardware or firmware does not provide "
|
||||||
"support for IBM Secure Execution");
|
"support for IBM Secure Execution");
|
||||||
}
|
}
|
||||||
|
} else if (hasAMDSev) {
|
||||||
|
if (virFileReadValueString(&mod_value, "/sys/module/kvm_amd/parameters/sev") < 0) {
|
||||||
|
virHostMsgFail(level, "AMD Secure Encrypted Virtualization not "
|
||||||
|
"supported by the currently used kernel");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mod_value[0] != '1') {
|
||||||
|
virHostMsgFail(level,
|
||||||
|
"AMD Secure Encrypted Virtualization appears to be "
|
||||||
|
"disabled in kernel. Add kvm_amd.sev=1 "
|
||||||
|
"to the kernel cmdline arguments");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virFileExists("/dev/sev")) {
|
||||||
|
virHostMsgPass();
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
virHostMsgFail(level,
|
||||||
|
"AMD Secure Encrypted Virtualization appears to be "
|
||||||
|
"disabled in firemare.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
virHostMsgFail(level,
|
virHostMsgFail(level,
|
||||||
"Unknown if this platform has Secure Guest support");
|
"Unknown if this platform has Secure Guest support");
|
||||||
|
@ -38,6 +38,7 @@ typedef enum {
|
|||||||
VIR_HOST_VALIDATE_CPU_FLAG_SVM,
|
VIR_HOST_VALIDATE_CPU_FLAG_SVM,
|
||||||
VIR_HOST_VALIDATE_CPU_FLAG_SIE,
|
VIR_HOST_VALIDATE_CPU_FLAG_SIE,
|
||||||
VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158,
|
VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158,
|
||||||
|
VIR_HOST_VALIDATE_CPU_FLAG_SEV,
|
||||||
|
|
||||||
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
||||||
} virHostValidateCPUFlag;
|
} virHostValidateCPUFlag;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user