1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2022, Google LLC.
5 * Test for KVM_CAP_EXIT_ON_EMULATION_FAILURE.
7 #include "flds_emulation.h"
9 #include "ucall_common.h"
11 #define MMIO_GPA 0x700000000
12 #define MMIO_GVA MMIO_GPA
14 static void guest_code(void)
16 /* Execute flds with an MMIO address to force KVM to emulate it. */
21 int main(int argc, char *argv[])
23 struct kvm_vcpu *vcpu;
26 TEST_REQUIRE(kvm_has_cap(KVM_CAP_EXIT_ON_EMULATION_FAILURE));
28 vm = vm_create_with_one_vcpu(&vcpu, guest_code);
29 vm_enable_cap(vm, KVM_CAP_EXIT_ON_EMULATION_FAILURE, 1);
30 virt_map(vm, MMIO_GVA, MMIO_GPA, 1);
33 handle_flds_emulation_failure_exit(vcpu);
35 TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_DONE);