summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-06-14 20:06:49 +0000
committerSean Christopherson <seanjc@google.com>2022-07-13 18:14:17 -0700
commit1940af0b8179ae2c2bd287fbd3edaab59df5fb55 (patch)
tree1211a08f96cd5575da297add75702b474cd1857b /tools/testing/selftests/kvm/x86_64/emulator_error_test.c
parent7af7161d87383f84caec1e8aaf6366c31ce845ec (diff)
KVM: selftests: Add and use helper to set vCPU's CPUID maxphyaddr
Add a helper to set a vCPU's guest.MAXPHYADDR, and use it in the test that verifies the emulator returns an error on an unknown instruction when KVM emulates in response to an EPT violation with a GPA that is legal in hardware but illegal with respect to the guest's MAXPHYADDR. Add a helper even though there's only a single user at this time. Before its removal, mmu_role_test also stuffed guest.MAXPHYADDR, and the helper provides a small amount of clarity. More importantly, this eliminates a set_cpuid() user and an instance of modifying kvm_get_supported_cpuid()'s static "cpuid". Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220614200707.3315957-25-seanjc@google.com
Diffstat (limited to 'tools/testing/selftests/kvm/x86_64/emulator_error_test.c')
-rw-r--r--tools/testing/selftests/kvm/x86_64/emulator_error_test.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/emulator_error_test.c b/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
index d8dbed419638..236e11755ba6 100644
--- a/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
+++ b/tools/testing/selftests/kvm/x86_64/emulator_error_test.c
@@ -150,8 +150,6 @@ static uint64_t process_ucall(struct kvm_vcpu *vcpu)
int main(int argc, char *argv[])
{
- struct kvm_cpuid_entry2 *entry;
- struct kvm_cpuid2 *cpuid;
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
uint64_t gpa, pte;
@@ -165,13 +163,7 @@ int main(int argc, char *argv[])
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
- cpuid = kvm_get_supported_cpuid();
-
- entry = kvm_get_supported_cpuid_index(0x80000008, 0);
- entry->eax = (entry->eax & 0xffffff00) | MAXPHYADDR;
- set_cpuid(cpuid, entry);
-
- vcpu_init_cpuid(vcpu, cpuid);
+ vcpu_set_cpuid_maxphyaddr(vcpu, MAXPHYADDR);
rc = kvm_check_cap(KVM_CAP_EXIT_ON_EMULATION_FAILURE);
TEST_ASSERT(rc, "KVM_CAP_EXIT_ON_EMULATION_FAILURE is unavailable");