vmm(4): return proper cache topology for cpuid(0x4)
authormlarkin <mlarkin@openbsd.org>
Wed, 11 Jul 2018 13:19:42 +0000 (13:19 +0000)
committermlarkin <mlarkin@openbsd.org>
Wed, 11 Jul 2018 13:19:42 +0000 (13:19 +0000)
Make the cache neighbor fields match the number of VCPUs present
(currently 1)

ok reyk

sys/arch/amd64/amd64/vmm.c
sys/arch/amd64/include/vmmvar.h

index 6dc20d5..a5f780b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmm.c,v 1.212 2018/07/11 12:55:01 mlarkin Exp $       */
+/*     $OpenBSD: vmm.c,v 1.213 2018/07/11 13:19:42 mlarkin Exp $       */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -5988,13 +5988,13 @@ vmm_handle_cpuid(struct vcpu *vcpu)
                break;
        case 0x04:      /* Deterministic cache info */
                if (*rcx == 0) {
-                       *rax = eax;
+                       *rax = eax & VMM_CPUID4_CACHE_TOPOLOGY_MASK;
                        *rbx = ebx;
                        *rcx = ecx;
                        *rdx = edx;
                } else {
                        CPUID_LEAF(*rax, *rcx, eax, ebx, ecx, edx);
-                       *rax = eax;
+                       *rax = eax & VMM_CPUID4_CACHE_TOPOLOGY_MASK;
                        *rbx = ebx;
                        *rcx = ecx;
                        *rdx = edx;
index 9e3ad94..033bb6e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmmvar.h,v 1.54 2018/07/05 05:07:03 mlarkin Exp $     */
+/*     $OpenBSD: vmmvar.h,v 1.55 2018/07/11 13:19:42 mlarkin Exp $     */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -609,6 +609,11 @@ struct vm_rwregs_params {
  */
 #define VMM_FEAT_EFLAGS_MASK ~(CPUID_RDTSCP)
 
+/*
+ * CPUID[0x4] deterministic cache info
+ */
+#define VMM_CPUID4_CACHE_TOPOLOGY_MASK 0x3FF
+
 #ifdef _KERNEL
 
 #define VMX_FAIL_LAUNCH_UNKNOWN 1