From: Daniel P. Berrangé Date: Fri, 2 Aug 2024 15:07:46 +0000 (+0100) Subject: Add support for detecting protected virtualization on s390x X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=d1cedcffeeff58f33aa467d62c0347ce7073aa4e;p=virt-what.git Add support for detecting protected virtualization on s390x Signed-off-by: Daniel P. Berrangé (cherry picked from commit 037689fbe95e403b050c1eb736ebc8fdc2e601a5) --- diff --git a/virt-what-cvm.c b/virt-what-cvm.c index 0daa6ac..320df47 100644 --- a/virt-what-cvm.c +++ b/virt-what-cvm.c @@ -295,7 +295,26 @@ cpu_sig (void) cpu_sig_intel (); } -#else /* !x86_64 */ +#elif defined(__s390x__) + +#define SYSFS_PROT_VIRT "/sys/firmware/uv/prot_virt_guest" + +static void +cpu_sig (void) +{ + int fd = open("/sys/firmware/uv/prot_virt_guest", O_RDONLY); + char c; + if (fd < 0) + return; + + if (read(fd, &c, 1) == 1 && c == '1') + puts("s390-protvirt"); + + close(fd); +} + + +#else /* ! x86_64 && ! s390x */ static void cpu_sig (void) diff --git a/virt-what-cvm.pod b/virt-what-cvm.pod index 70213ab..00e21cb 100644 --- a/virt-what-cvm.pod +++ b/virt-what-cvm.pod @@ -60,6 +60,11 @@ paired with B. Status: tested on Microsoft Azure SEV-SNP & TDX CVM +=item B + +This is a confidential guest running on s390x with the +Protected Virtualization (Secure Execution) technology + =back =head1 EXIT STATUS