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]
Date:   Fri, 10 Dec 2021 10:46:18 -0600
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>,
        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>,
        "Christian Borntraeger" <borntraeger@...ux.ibm.com>,
        Janosch Frank <frankja@...ux.ibm.com>,
        David Hildenbrand <david@...hat.com>,
        "Claudio Imbrenda" <imbrenda@...ux.ibm.com>,
        Marc Zyngier <maz@...nel.org>,
        James Morse <james.morse@....com>,
        Alexandru Elisei <alexandru.elisei@....com>,
        "Suzuki K Poulose" <suzuki.poulose@....com>,
        <kvmarm@...ts.cs.columbia.edu>
Subject: [PATCH RFC 08/10] kvm: selftests: introduce ucall implementation based on halt instructions

With the shared ucall interfaces the only thing the ucall
implementation really needs to do is generate an exit to host userspace
so that the shared ucall struct can be examined. This implementation
uses a 'halt' instruction to generate such an exit, and is suitable for
use with SEV guests, and potentially other confidential guest
implementations.

Signed-off-by: Michael Roth <michael.roth@....com>
---
 .../selftests/kvm/include/x86_64/ucall.h      |  1 +
 .../testing/selftests/kvm/lib/x86_64/ucall.c  | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/tools/testing/selftests/kvm/include/x86_64/ucall.h b/tools/testing/selftests/kvm/include/x86_64/ucall.h
index 8366bdc9c04e..457fc1406746 100644
--- a/tools/testing/selftests/kvm/include/x86_64/ucall.h
+++ b/tools/testing/selftests/kvm/include/x86_64/ucall.h
@@ -12,6 +12,7 @@
 #include "ucall_common.h"
 
 extern const struct ucall_ops ucall_ops_pio;
+extern const struct ucall_ops ucall_ops_halt;
 
 extern const struct ucall_ops ucall_ops_default;
 
diff --git a/tools/testing/selftests/kvm/lib/x86_64/ucall.c b/tools/testing/selftests/kvm/lib/x86_64/ucall.c
index 157d2a102547..4dfb12881434 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/ucall.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/ucall.c
@@ -57,4 +57,27 @@ const struct ucall_ops ucall_ops_pio = {
 	.recv_cmd_shared = ucall_ops_pio_recv_cmd_shared,
 };
 
+static void ucall_ops_halt_send_cmd_shared(struct ucall *uc)
+{
+	asm volatile("hlt" : : : "memory");
+}
+
+static uint64_t ucall_ops_halt_recv_cmd_shared(struct kvm_vm *vm, uint32_t vcpu_id,
+					       struct ucall *uc)
+{
+	struct kvm_run *run = vcpu_state(vm, vcpu_id);
+
+	TEST_ASSERT(run->exit_reason == KVM_EXIT_HLT,
+		    "unexpected exit reason: %u (%s)",
+		    run->exit_reason, exit_reason_str(run->exit_reason));
+
+	return uc->cmd;
+}
+
+const struct ucall_ops ucall_ops_halt = {
+	.name = "halt",
+	.send_cmd_shared = ucall_ops_halt_send_cmd_shared,
+	.recv_cmd_shared = ucall_ops_halt_recv_cmd_shared,
+};
+
 const struct ucall_ops ucall_ops_default = ucall_ops_pio;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ