From b49f7c39118d77cf762b9600ae8391a7ce0fe04c Mon Sep 17 00:00:00 2001 From: mlarkin Date: Fri, 14 Apr 2017 01:02:28 +0000 Subject: [PATCH] SVM: calculate max ASID value and save for later use. This will be used in an upcoming diff to handle ASID/VPID reuse/rollover. --- sys/arch/amd64/amd64/identcpu.c | 8 +++++++- sys/arch/amd64/include/cpu.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index ad20b9ada7e..204e62b0c82 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -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; } /* diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index a66ec6e9f4c..10e7292d763 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -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 { -- 2.20.1