SVM: calculate max ASID value and save for later use. This will be used in
authormlarkin <mlarkin@openbsd.org>
Fri, 14 Apr 2017 01:02:28 +0000 (01:02 +0000)
committermlarkin <mlarkin@openbsd.org>
Fri, 14 Apr 2017 01:02:28 +0000 (01:02 +0000)
an upcoming diff to handle ASID/VPID reuse/rollover.

sys/arch/amd64/amd64/identcpu.c
sys/arch/amd64/include/cpu.h

index ad20b9a..204e62b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: identcpu.c,v 1.82 2017/03/28 21:36:27 mlarkin Exp $   */
+/*     $OpenBSD: identcpu.c,v 1.83 2017/04/14 01:02:28 mlarkin Exp $   */
 /*     $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $        */
 
 /*
@@ -945,6 +945,12 @@ cpu_check_vmm_cap(struct cpu_info *ci)
 
                if (!(msr & AMD_SVMDIS))
                        ci->ci_vmm_flags |= CI_VMM_SVM;
+
+               CPUID(0x8000000A, dummy, ci->ci_vmm_cap.vcc_svm.svm_max_asid,
+                   dummy, dummy);
+
+               if (ci->ci_vmm_cap.vcc_svm.svm_max_asid > 0xFFFF)
+                       ci->ci_vmm_cap.vcc_svm.svm_max_asid = 0xFFFF;
        }
 
        /*
index a66ec6e..10e7292 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cpu.h,v 1.110 2017/03/16 10:02:03 mpi Exp $   */
+/*     $OpenBSD: cpu.h,v 1.111 2017/04/14 01:02:28 mlarkin Exp $       */
 /*     $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $     */
 
 /*-
@@ -77,6 +77,7 @@ struct vmx {
  * SVM for AMD CPUs
  */
 struct svm {
+       uint32_t        svm_max_asid;
 };
 
 union vmm_cpu_cap {