lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211005234459.430873-11-michael.roth@amd.com>
Date:   Tue,  5 Oct 2021 18:44:53 -0500
From:   Michael Roth <michael.roth@....com>
To:     linux-kselftest@...r.kernel.org
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org, x86@...nel.org,
        Nathan Tempelman <natet@...gle.com>,
        Marc Orr <marcorr@...gle.com>,
        Steve Rutherford <srutherford@...gle.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Mingwei Zhang <mizhang@...gle.com>,
        Brijesh Singh <brijesh.singh@....com>,
        Tom Lendacky <thomas.lendacky@....com>,
        Varad Gautam <varad.gautam@...e.com>,
        Shuah Khan <shuah@...nel.org>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        David Woodhouse <dwmw@...zon.co.uk>,
        Ricardo Koller <ricarkol@...gle.com>,
        Jim Mattson <jmattson@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Joerg Roedel <joro@...tes.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>
Subject: [RFC 10/16] KVM: selftests: add support for creating SEV-ES guests

Only a couple KVM_SEV_* ioctls need to be handled differently for
SEV-ES. Do so when the specified policy indicates SEV-ES support.

Signed-off-by: Michael Roth <michael.roth@....com>
---
 tools/testing/selftests/kvm/lib/x86_64/sev.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/lib/x86_64/sev.c b/tools/testing/selftests/kvm/lib/x86_64/sev.c
index adda3b396566..d01b0f637ced 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/sev.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/sev.c
@@ -238,13 +238,17 @@ struct sev_vm *sev_vm_create(uint32_t policy, uint64_t npages)
 		return NULL;
 	sev->sev_policy = policy;
 
-	kvm_sev_ioctl(sev, KVM_SEV_INIT, NULL);
+	if (sev->sev_policy & SEV_POLICY_ES)
+		kvm_sev_ioctl(sev, KVM_SEV_ES_INIT, NULL);
+	else
+		kvm_sev_ioctl(sev, KVM_SEV_INIT, NULL);
 
 	vm_set_memory_encryption(vm, true, true, sev->enc_bit);
 	vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, 0, 0, npages, 0);
 	sev_register_user_range(sev, addr_gpa2hva(vm, 0), npages * vm_get_page_size(vm));
 
-	pr_info("SEV guest created, policy: 0x%x, size: %lu KB\n",
+	pr_info("%s guest created, policy: 0x%x, size: %lu KB\n",
+		(sev->sev_policy & SEV_POLICY_ES) ? "SEV-ES" : "SEV",
 		sev->sev_policy, npages * vm_get_page_size(vm) / 1024);
 
 	return sev;
@@ -269,6 +273,9 @@ void sev_vm_launch(struct sev_vm *sev)
 		    "Unexpected guest state: %d", ksev_status.state);
 
 	sev_encrypt(sev);
+
+	if (sev->sev_policy & SEV_POLICY_ES)
+		kvm_sev_ioctl(sev, KVM_SEV_LAUNCH_UPDATE_VMSA, NULL);
 }
 
 void sev_vm_measure(struct sev_vm *sev, uint8_t *measurement)
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ