|
|
a41c76 |
From 085b955a75c49585d94fd5a19d6ac37833bb05cb Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <085b955a75c49585d94fd5a19d6ac37833bb05cb@dist-git>
|
|
|
a41c76 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
a41c76 |
Date: Wed, 24 Jun 2020 13:16:20 +0200
|
|
|
a41c76 |
Subject: [PATCH] tools: Secure guest check on s390 in virt-host-validate
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Add checking in virt-host-validate for secure guest support
|
|
|
a41c76 |
on s390 for IBM Secure Execution.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
a41c76 |
Tested-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
|
|
|
a41c76 |
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
|
|
|
a41c76 |
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
|
|
|
a41c76 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 0254ceab82f5e1f7b505730586d8c8337ecc5920)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1848997
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1850351
|
|
|
a41c76 |
|
|
|
a41c76 |
Conflicts:
|
|
|
a41c76 |
tools/virt-host-validate-common.c
|
|
|
a41c76 |
tools/virt-host-validate-common.h
|
|
|
a41c76 |
- unrelated commit 4653a5194c1 was not backported
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
Message-Id: <744e4ceb0760fe10ab0d82de24a78c280482d90d.1592996194.git.jdenemar@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
tools/virt-host-validate-common.c | 64 ++++++++++++++++++++++++++++++-
|
|
|
a41c76 |
tools/virt-host-validate-common.h | 4 ++
|
|
|
a41c76 |
tools/virt-host-validate-qemu.c | 4 ++
|
|
|
a41c76 |
3 files changed, 70 insertions(+), 2 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
|
|
|
a41c76 |
index bce0f14917..e59469a49b 100644
|
|
|
a41c76 |
--- a/tools/virt-host-validate-common.c
|
|
|
a41c76 |
+++ b/tools/virt-host-validate-common.c
|
|
|
a41c76 |
@@ -39,7 +39,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag,
|
|
|
a41c76 |
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
|
|
a41c76 |
"vmx",
|
|
|
a41c76 |
"svm",
|
|
|
a41c76 |
- "sie");
|
|
|
a41c76 |
+ "sie",
|
|
|
a41c76 |
+ "158");
|
|
|
a41c76 |
|
|
|
a41c76 |
static bool quiet;
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -209,7 +210,8 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
|
|
|
a41c76 |
* on the architecture, so check possible prefixes */
|
|
|
a41c76 |
if (!STRPREFIX(line, "flags") &&
|
|
|
a41c76 |
!STRPREFIX(line, "Features") &&
|
|
|
a41c76 |
- !STRPREFIX(line, "features"))
|
|
|
a41c76 |
+ !STRPREFIX(line, "features") &&
|
|
|
a41c76 |
+ !STRPREFIX(line, "facilities"))
|
|
|
a41c76 |
continue;
|
|
|
a41c76 |
|
|
|
a41c76 |
/* fgets() includes the trailing newline in the output buffer,
|
|
|
a41c76 |
@@ -411,3 +413,61 @@ int virHostValidateIOMMU(const char *hvname,
|
|
|
a41c76 |
virHostMsgPass();
|
|
|
a41c76 |
return 0;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+int virHostValidateSecureGuests(const char *hvname,
|
|
|
a41c76 |
+ virHostValidateLevel level)
|
|
|
a41c76 |
+{
|
|
|
a41c76 |
+ virBitmapPtr flags;
|
|
|
a41c76 |
+ bool hasFac158 = false;
|
|
|
a41c76 |
+ virArch arch = virArchFromHost();
|
|
|
a41c76 |
+ g_autofree char *cmdline = NULL;
|
|
|
a41c76 |
+ static const char *kIBMValues[] = {"y", "Y", "on", "ON", "oN", "On", "1"};
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ flags = virHostValidateGetCPUFlags();
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158))
|
|
|
a41c76 |
+ hasFac158 = true;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ virBitmapFree(flags);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ virHostMsgCheck(hvname, "%s", _("for secure guest support"));
|
|
|
a41c76 |
+ if (ARCH_IS_S390(arch)) {
|
|
|
a41c76 |
+ if (hasFac158) {
|
|
|
a41c76 |
+ if (!virFileIsDir("/sys/firmware/uv")) {
|
|
|
a41c76 |
+ virHostMsgFail(level, "IBM Secure Execution not supported by "
|
|
|
a41c76 |
+ "the currently used kernel");
|
|
|
a41c76 |
+ return 0;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (virFileReadValueString(&cmdline, "/proc/cmdline") < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ /* we're prefix matching rather than equality matching here, because
|
|
|
a41c76 |
+ * kernel would treat even something like prot_virt='yFOO' as
|
|
|
a41c76 |
+ * enabled
|
|
|
a41c76 |
+ */
|
|
|
a41c76 |
+ if (virKernelCmdlineMatchParam(cmdline, "prot_virt", kIBMValues,
|
|
|
a41c76 |
+ G_N_ELEMENTS(kIBMValues),
|
|
|
a41c76 |
+ VIR_KERNEL_CMDLINE_FLAGS_SEARCH_FIRST |
|
|
|
a41c76 |
+ VIR_KERNEL_CMDLINE_FLAGS_CMP_PREFIX)) {
|
|
|
a41c76 |
+ virHostMsgPass();
|
|
|
a41c76 |
+ return 1;
|
|
|
a41c76 |
+ } else {
|
|
|
a41c76 |
+ virHostMsgFail(level,
|
|
|
a41c76 |
+ "IBM Secure Execution appears to be disabled "
|
|
|
a41c76 |
+ "in kernel. Add prot_virt=1 to kernel cmdline "
|
|
|
a41c76 |
+ "arguments");
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+ } else {
|
|
|
a41c76 |
+ virHostMsgFail(level, "Hardware or firmware does not provide "
|
|
|
a41c76 |
+ "support for IBM Secure Execution");
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+ } else {
|
|
|
a41c76 |
+ virHostMsgFail(level,
|
|
|
a41c76 |
+ "Unknown if this platform has Secure Guest support");
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ return 0;
|
|
|
a41c76 |
+}
|
|
|
a41c76 |
diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h
|
|
|
a41c76 |
index 1b7e93e520..1653c9c95b 100644
|
|
|
a41c76 |
--- a/tools/virt-host-validate-common.h
|
|
|
a41c76 |
+++ b/tools/virt-host-validate-common.h
|
|
|
a41c76 |
@@ -38,6 +38,7 @@ typedef enum {
|
|
|
a41c76 |
VIR_HOST_VALIDATE_CPU_FLAG_VMX = 0,
|
|
|
a41c76 |
VIR_HOST_VALIDATE_CPU_FLAG_SVM,
|
|
|
a41c76 |
VIR_HOST_VALIDATE_CPU_FLAG_SIE,
|
|
|
a41c76 |
+ VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158,
|
|
|
a41c76 |
|
|
|
a41c76 |
VIR_HOST_VALIDATE_CPU_FLAG_LAST,
|
|
|
a41c76 |
} virHostValidateCPUFlag;
|
|
|
a41c76 |
@@ -83,3 +84,6 @@ int virHostValidateCGroupControllers(const char *hvname,
|
|
|
a41c76 |
|
|
|
a41c76 |
int virHostValidateIOMMU(const char *hvname,
|
|
|
a41c76 |
virHostValidateLevel level);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+int virHostValidateSecureGuests(const char *hvname,
|
|
|
a41c76 |
+ virHostValidateLevel level);
|
|
|
a41c76 |
diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c
|
|
|
a41c76 |
index ff3c1f0231..b38b0fbd6a 100644
|
|
|
a41c76 |
--- a/tools/virt-host-validate-qemu.c
|
|
|
a41c76 |
+++ b/tools/virt-host-validate-qemu.c
|
|
|
a41c76 |
@@ -112,5 +112,9 @@ int virHostValidateQEMU(void)
|
|
|
a41c76 |
VIR_HOST_VALIDATE_WARN) < 0)
|
|
|
a41c76 |
ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
+ if (virHostValidateSecureGuests("QEMU",
|
|
|
a41c76 |
+ VIR_HOST_VALIDATE_WARN) < 0)
|
|
|
a41c76 |
+ ret = -1;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.27.0
|
|
|
a41c76 |
|