[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211210164620.11636-8-michael.roth@amd.com>
Date: Fri, 10 Dec 2021 10:46:17 -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 07/10] kvm: selftests: add ucall_shared ops for PIO
While the PIO-based ucall implementation won't actually be ideal for
SEV guests due to the requirements/constraints on how the guest code
would needed to handle resulting #VC exceptions generated by PIO
instructions, it does provide a simple way to write/convert tests
using the new ucall_shared() interfaces so that they can be more easily
transitioned to handle running as confidential guests in the future
by selecting a different ucall_ops implementation.
Signed-off-by: Michael Roth <michael.roth@....com>
---
tools/testing/selftests/kvm/lib/x86_64/ucall.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/testing/selftests/kvm/lib/x86_64/ucall.c b/tools/testing/selftests/kvm/lib/x86_64/ucall.c
index f5d9aba0d803..157d2a102547 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/ucall.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/ucall.c
@@ -38,10 +38,23 @@ static uint64_t ucall_ops_pio_recv_cmd(struct kvm_vm *vm, uint32_t vcpu_id,
return ucall.cmd;
}
+static uint64_t ucall_ops_pio_recv_cmd_shared(struct kvm_vm *vm, uint32_t vcpu_id,
+ struct ucall *uc)
+{
+ struct kvm_run *run = vcpu_state(vm, vcpu_id);
+
+ if (run->exit_reason == KVM_EXIT_IO && run->io.port == UCALL_PIO_PORT)
+ vcpu_run_complete_io(vm, vcpu_id);
+
+ return uc->cmd;
+}
+
const struct ucall_ops ucall_ops_pio = {
.name = "PIO",
.send_cmd = ucall_ops_pio_send_cmd,
.recv_cmd = ucall_ops_pio_recv_cmd,
+ .send_cmd_shared = ucall_ops_pio_send_cmd,
+ .recv_cmd_shared = ucall_ops_pio_recv_cmd_shared,
};
const struct ucall_ops ucall_ops_default = ucall_ops_pio;
--
2.25.1
Powered by blists - more mailing lists