KVM: selftests: Move HYPERV_LINUX_OS_ID definition to a common header
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 1 Nov 2022 14:54:09 +0000 (15:54 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 18 Nov 2022 17:59:21 +0000 (12:59 -0500)
HYPERV_LINUX_OS_ID needs to be written to HV_X64_MSR_GUEST_OS_ID by
each Hyper-V specific selftest.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20221101145426.251680-32-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/include/x86_64/hyperv.h
tools/testing/selftests/kvm/x86_64/hyperv_features.c

index b669107..f0a8a93 100644 (file)
 /* hypercall options */
 #define HV_HYPERCALL_FAST_BIT          BIT(16)
 
+/* Proper HV_X64_MSR_GUEST_OS_ID value */
+#define HYPERV_LINUX_OS_ID ((u64)0x8100 << 48)
+
 #endif /* !SELFTEST_KVM_HYPERV_H */
index 2b6d455..6558cc6 100644 (file)
@@ -13,8 +13,6 @@
 #include "processor.h"
 #include "hyperv.h"
 
-#define LINUX_OS_ID ((u64)0x8100 << 48)
-
 static inline uint8_t hypercall(u64 control, vm_vaddr_t input_address,
                                vm_vaddr_t output_address, uint64_t *hv_status)
 {
@@ -72,7 +70,7 @@ static void guest_hcall(vm_vaddr_t pgs_gpa, struct hcall_data *hcall)
 
        GUEST_ASSERT(hcall->control);
 
-       wrmsr(HV_X64_MSR_GUEST_OS_ID, LINUX_OS_ID);
+       wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_LINUX_OS_ID);
        wrmsr(HV_X64_MSR_HYPERCALL, pgs_gpa);
 
        if (!(hcall->control & HV_HYPERCALL_FAST_BIT)) {
@@ -170,7 +168,7 @@ static void guest_test_msrs_access(void)
                         */
                        msr->idx = HV_X64_MSR_GUEST_OS_ID;
                        msr->write = 1;
-                       msr->write_val = LINUX_OS_ID;
+                       msr->write_val = HYPERV_LINUX_OS_ID;
                        msr->available = 1;
                        break;
                case 3: