[PATCH RFC 07/10] kvm: selftests: add ucall_shared ops for PIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux