From owner-svn-src-projects@FreeBSD.ORG Sat Oct 11 03:09:35 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 77C14D00; Sat, 11 Oct 2014 03:09:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6439A96F; Sat, 11 Oct 2014 03:09:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9B39ZTF075847; Sat, 11 Oct 2014 03:09:35 GMT (envelope-from neel@FreeBSD.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9B39YvR075845; Sat, 11 Oct 2014 03:09:34 GMT (envelope-from neel@FreeBSD.org) Message-Id: <201410110309.s9B39YvR075845@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: neel set sender to neel@FreeBSD.org using -f From: Neel Natu Date: Sat, 11 Oct 2014 03:09:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r272926 - in projects/bhyve_svm/sys: amd64/vmm/amd x86/include X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Oct 2014 03:09:35 -0000 Author: neel Date: Sat Oct 11 03:09:34 2014 New Revision: 272926 URL: https://svnweb.freebsd.org/changeset/base/272926 Log: Use a consistent style for messages emitted when the module is loaded. Modified: projects/bhyve_svm/sys/amd64/vmm/amd/svm.c projects/bhyve_svm/sys/x86/include/specialreg.h Modified: projects/bhyve_svm/sys/amd64/vmm/amd/svm.c ============================================================================== --- projects/bhyve_svm/sys/amd64/vmm/amd/svm.c Sat Oct 11 02:02:58 2014 (r272925) +++ projects/bhyve_svm/sys/amd64/vmm/amd/svm.c Sat Oct 11 03:09:34 2014 (r272926) @@ -174,10 +174,10 @@ svm_cleanup(void) } /* - * Check for required BHyVe SVM features in a CPU. + * Verify that all the features required by bhyve are available. */ static int -svm_cpuid_features(void) +check_svm_features(void) { u_int regs[4]; @@ -185,11 +185,13 @@ svm_cpuid_features(void) do_cpuid(0x8000000A, regs); svm_feature = regs[3]; - printf("SVM rev: 0x%x NASID:0x%x\n", regs[0] & 0xFF, regs[1]); + printf("SVM: Revision %d\n", regs[0] & 0xFF); + printf("SVM: NumASID %u\n", regs[1]); + nasid = regs[1]; KASSERT(nasid > 1, ("Insufficient ASIDs for guests: %#x", nasid)); - printf("SVM Features:0x%b\n", svm_feature, + printf("SVM: Features 0x%b\n", svm_feature, "\020" "\001NP" /* Nested paging */ "\002LbrVirt" /* LBR virtualization */ @@ -199,32 +201,27 @@ svm_cpuid_features(void) "\006VmcbClean" /* VMCB clean bits */ "\007FlushByAsid" /* Flush by ASID */ "\010DecodeAssist" /* Decode assist */ - "\011" - "\012" + "\011" + "\012" "\013PauseFilter" - "\014" + "\014" "\015PauseFilterThreshold" "\016AVIC" ); - /* SVM Lock */ - if (!(svm_feature & AMD_CPUID_SVM_SVML)) { - printf("SVM is disabled by BIOS, please enable in BIOS.\n"); + /* bhyve requires the Nested Paging feature */ + if (!(svm_feature & AMD_CPUID_SVM_NP)) { + printf("SVM: Nested Paging feature not available.\n"); return (ENXIO); } - /* - * bhyve need RVI to work. - */ - if (!(svm_feature & AMD_CPUID_SVM_NP)) { - printf("Missing Nested paging or RVI SVM support in processor.\n"); - return (EIO); + /* bhyve requires the NRIP Save feature */ + if (!(svm_feature & AMD_CPUID_SVM_NRIP_SAVE)) { + printf("SVM: NRIP Save feature not available.\n"); + return (ENXIO); } - if (svm_feature & AMD_CPUID_SVM_NRIP_SAVE) - return (0); - - return (EIO); + return (0); } static __inline int @@ -260,27 +257,26 @@ svm_enable(void *arg __unused) } /* - * Check if a processor support SVM. + * Verify that SVM is enabled and the processor has all the required features. */ static int is_svm_enabled(void) { uint64_t msr; - /* Section 15.4 Enabling SVM from APM2. */ + /* Section 15.4 Enabling SVM from APM2. */ if ((amd_feature2 & AMDID2_SVM) == 0) { - printf("SVM is not supported on this processor.\n"); + printf("SVM: not available.\n"); return (ENXIO); } msr = rdmsr(MSR_VM_CR); - /* Make sure SVM is not disabled by BIOS. */ - if ((msr & VM_CR_SVMDIS) == 0) { - return svm_cpuid_features(); + if ((msr & VM_CR_SVMDIS) != 0) { + printf("SVM: disabled by BIOS.\n"); + return (ENXIO); } - printf("SVM disabled by Key, consult TPM/BIOS manual.\n"); - return (ENXIO); + return (check_svm_features()); } /* Modified: projects/bhyve_svm/sys/x86/include/specialreg.h ============================================================================== --- projects/bhyve_svm/sys/x86/include/specialreg.h Sat Oct 11 02:02:58 2014 (r272925) +++ projects/bhyve_svm/sys/x86/include/specialreg.h Sat Oct 11 03:09:34 2014 (r272926) @@ -786,10 +786,10 @@ #define MSR_TOP_MEM2 0xc001001d /* boundary for ram above 4G */ #define MSR_K8_UCODE_UPDATE 0xc0010020 /* update microcode */ #define MSR_MC0_CTL_MASK 0xc0010044 -#define MSR_VM_CR 0xC0010114 /* SVM: feature control */ -#define MSR_VM_HSAVE_PA 0xC0010117 /* SVM: host save area address */ +#define MSR_VM_CR 0xc0010114 /* SVM: feature control */ +#define MSR_VM_HSAVE_PA 0xc0010117 /* SVM: host save area address */ -/* AMD VM_CR related */ +/* MSR_VM_CR related */ #define VM_CR_SVMDIS 0x10 /* SVM: disabled by BIOS */ /* VIA ACE crypto featureset: for via_feature_rng */