[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/4] s390x/pv: Check for support on the host
From: |
Cédric Le Goater |
Subject: |
[PATCH v2 2/4] s390x/pv: Check for support on the host |
Date: |
Fri, 6 Jan 2023 08:53:28 +0100 |
From: Cédric Le Goater <clg@redhat.com>
Support for protected VMs should have been enabled on the host with
the kernel parameter 'prot_virt=1'. If the hardware supports the
feature, it is reflected under sysfs.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/s390x/pv.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 8a1c71436b..d53ef8fd38 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -14,6 +14,7 @@
#include <linux/kvm.h>
#include "qapi/error.h"
+#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "sysemu/kvm.h"
#include "qom/object_interfaces.h"
@@ -280,9 +281,29 @@ static bool s390_pv_check_cpus(Error **errp)
return true;
}
+#define S390_PV_HOST "/sys/firmware/uv/prot_virt_host"
+
+static bool s390_pv_check_host(Error **errp)
+{
+ gchar *s = NULL;
+ uint64_t pv_host = 0;
+
+ if (g_file_get_contents(S390_PV_HOST, &s, NULL, NULL)) {
+ pv_host = g_ascii_strtoull(s, NULL, 10);
+ }
+ g_free(s);
+
+ if (pv_host != 1) {
+ error_setg(errp, "Host does not support protected VMs");
+ return false;
+ }
+
+ return true;
+}
+
static bool s390_pv_guest_check(ConfidentialGuestSupport *cgs, Error **errp)
{
- return s390_pv_check_cpus(errp);
+ return s390_pv_check_cpus(errp) && s390_pv_check_host(errp);
}
int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
--
2.38.1
- [PATCH v2 0/4] s390x/pv: Improve protected VM support, Cédric Le Goater, 2023/01/06
- [PATCH v2 2/4] s390x/pv: Check for support on the host,
Cédric Le Goater <=
- [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Cédric Le Goater, 2023/01/06
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Janosch Frank, 2023/01/09
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Cédric Le Goater, 2023/01/09
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Janosch Frank, 2023/01/09
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Cédric Le Goater, 2023/01/09
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Janosch Frank, 2023/01/09
- Re: [PATCH v2 3/4] s390x/pv: Introduce a s390_pv_check() helper for runtime, Cédric Le Goater, 2023/01/09