|
|
fbe740 |
From 962f3c23ce6f477cfb24f5fa66a9f296ce953759 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <962f3c23ce6f477cfb24f5fa66a9f296ce953759@dist-git>
|
|
|
fbe740 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
fbe740 |
Date: Wed, 24 Jun 2020 13:16:21 +0200
|
|
|
fbe740 |
Subject: [PATCH] tools: Secure guest check for AMD in virt-host-validate
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
Add checking in virt-host-validate for secure guest support
|
|
|
fbe740 |
on x86 for AMD Secure Encrypted Virtualization.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
fbe740 |
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
|
|
|
fbe740 |
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
|
|
|
fbe740 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 4b561d49ad5d6cc45766714253adb798bb99b6e8)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1848997
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1850351
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Message-Id: <638121e5c2692557b1b2d716371d324d61273282.1592996194.git.jdenemar@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
tools/virt-host-validate-common.c | 30 +++++++++++++++++++++++++++++-
|
|
|
fbe740 |
tools/virt-host-validate-common.h | 1 +
|
|
|
fbe740 |
2 files changed, 30 insertions(+), 1 deletion(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
|
|
|
fbe740 |
index e59469a49b..82e6092c01 100644
|
|
|
fbe740 |
--- a/tools/virt-host-validate-common.c
|
|
|
fbe740 |
+++ b/tools/virt-host-validate-common.c
|
|
|
fbe740 |
@@ -40,7 +40,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag,
|
|
|
fbe740 |
"vmx",
|
|
|
fbe740 |
"svm",
|
|
|
fbe740 |
"sie",
|
|
|
fbe740 |
- "158");
|
|
|
fbe740 |
+ "158",
|
|
|
fbe740 |
+ "sev");
|
|
|
fbe740 |
|
|
|
fbe740 |
static bool quiet;
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -420,14 +421,18 @@ int virHostValidateSecureGuests(const char *hvname,
|
|
|
fbe740 |
{
|
|
|
fbe740 |
virBitmapPtr flags;
|
|
|
fbe740 |
bool hasFac158 = false;
|
|
|
fbe740 |
+ bool hasAMDSev = false;
|
|
|
fbe740 |
virArch arch = virArchFromHost();
|
|
|
fbe740 |
g_autofree char *cmdline = NULL;
|
|
|
fbe740 |
static const char *kIBMValues[] = {"y", "Y", "on", "ON", "oN", "On", "1"};
|
|
|
fbe740 |
+ g_autofree char *mod_value = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
flags = virHostValidateGetCPUFlags();
|
|
|
fbe740 |
|
|
|
fbe740 |
if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158))
|
|
|
fbe740 |
hasFac158 = true;
|
|
|
fbe740 |
+ else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SEV))
|
|
|
fbe740 |
+ hasAMDSev = true;
|
|
|
fbe740 |
|
|
|
fbe740 |
virBitmapFree(flags);
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -463,6 +468,29 @@ int virHostValidateSecureGuests(const char *hvname,
|
|
|
fbe740 |
virHostMsgFail(level, "Hardware or firmware does not provide "
|
|
|
fbe740 |
"support for IBM Secure Execution");
|
|
|
fbe740 |
}
|
|
|
fbe740 |
+ } else if (hasAMDSev) {
|
|
|
fbe740 |
+ if (virFileReadValueString(&mod_value, "/sys/module/kvm_amd/parameters/sev") < 0) {
|
|
|
fbe740 |
+ virHostMsgFail(level, "AMD Secure Encrypted Virtualization not "
|
|
|
fbe740 |
+ "supported by the currently used kernel");
|
|
|
fbe740 |
+ return 0;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (mod_value[0] != '1') {
|
|
|
fbe740 |
+ virHostMsgFail(level,
|
|
|
fbe740 |
+ "AMD Secure Encrypted Virtualization appears to be "
|
|
|
fbe740 |
+ "disabled in kernel. Add kvm_amd.sev=1 "
|
|
|
fbe740 |
+ "to the kernel cmdline arguments");
|
|
|
fbe740 |
+ return 0;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (virFileExists("/dev/sev")) {
|
|
|
fbe740 |
+ virHostMsgPass();
|
|
|
fbe740 |
+ return 1;
|
|
|
fbe740 |
+ } else {
|
|
|
fbe740 |
+ virHostMsgFail(level,
|
|
|
fbe740 |
+ "AMD Secure Encrypted Virtualization appears to be "
|
|
|
fbe740 |
+ "disabled in firemare.");
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
} else {
|
|
|
fbe740 |
virHostMsgFail(level,
|
|
|
fbe740 |
"Unknown if this platform has Secure Guest support");
|
|
|
fbe740 |
diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h
|
|
|
fbe740 |
index 1653c9c95b..014331c0e0 100644
|
|
|
fbe740 |
--- a/tools/virt-host-validate-common.h
|
|
|
fbe740 |
+++ b/tools/virt-host-validate-common.h
|
|
|
fbe740 |
@@ -39,6 +39,7 @@ typedef enum {
|
|
|
fbe740 |
VIR_HOST_VALIDATE_CPU_FLAG_SVM,
|
|
|
fbe740 |
VIR_HOST_VALIDATE_CPU_FLAG_SIE,
|
|
|
fbe740 |
VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158,
|
|
|
fbe740 |
+ VIR_HOST_VALIDATE_CPU_FLAG_SEV,
|
|
|
fbe740 |
|
|
|
fbe740 |
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
|
|
fbe740 |
} virHostValidateCPUFlag;
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.27.0
|
|
|
fbe740 |
|