linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SVM: reliably detect if SVM was disabled by BIOS
@ 2007-06-21 17:51 Joerg Roedel
  2007-06-22  9:30 ` Avi Kivity
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2007-06-21 17:51 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]


From: Joerg Roedel <joerg.roedel@amd.com>

This patch adds an implementation to the svm is_disabled function to
detect reliably if the BIOS disabled the SVM feature in the CPU. This
fixes the issues with kernel panics when loading the kvm-amd module on
machines where SVM is available but disabled.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

-- 
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: svm-detect-svm-disable.patch --]
[-- Type: text/plain, Size: 852 bytes --]

diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index fa17d6d..54aa83a 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1727,6 +1727,12 @@ static void svm_inject_page_fault(struct kvm_vcpu *vcpu,
 
 static int is_disabled(void)
 {
+	uint64_t vm_cr;
+
+	rdmsrl(MSR_VM_CR, vm_cr);
+	if (vm_cr & (1 << SVM_VM_CR_SVM_DISABLE))
+		return 1;
+
 	return 0;
 }
 
diff --git a/drivers/kvm/svm.h b/drivers/kvm/svm.h
index 5e93814..005a9c5 100644
--- a/drivers/kvm/svm.h
+++ b/drivers/kvm/svm.h
@@ -175,8 +175,11 @@ struct __attribute__ ((__packed__)) vmcb {
 #define SVM_CPUID_FUNC 0x8000000a
 
 #define MSR_EFER_SVME_MASK (1ULL << 12)
+#define MSR_VM_CR       0xc0010114ULL
 #define MSR_VM_HSAVE_PA 0xc0010117ULL
 
+#define SVM_VM_CR_SVM_DISABLE 4
+
 #define SVM_SELECTOR_S_SHIFT 4
 #define SVM_SELECTOR_DPL_SHIFT 5
 #define SVM_SELECTOR_P_SHIFT 7

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] SVM: reliably detect if SVM was disabled by BIOS
  2007-06-21 17:51 [PATCH] SVM: reliably detect if SVM was disabled by BIOS Joerg Roedel
@ 2007-06-22  9:30 ` Avi Kivity
  2007-06-22  9:35   ` Joerg Roedel
  0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2007-06-22  9:30 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: kvm-devel, linux-kernel

Joerg Roedel wrote:
> From: Joerg Roedel <joerg.roedel@amd.com>
>
> This patch adds an implementation to the svm is_disabled function to
> detect reliably if the BIOS disabled the SVM feature in the CPU. This
> fixes the issues with kernel panics when loading the kvm-amd module on
> machines where SVM is available but disabled.
>
>   

Applied; thanks.

Is this msr documented anywhere?  I assume it is implemented on all
processors with svm?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] SVM: reliably detect if SVM was disabled by BIOS
  2007-06-22  9:30 ` Avi Kivity
@ 2007-06-22  9:35   ` Joerg Roedel
  0 siblings, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2007-06-22  9:35 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel, linux-kernel

On Fri, Jun 22, 2007 at 12:30:48PM +0300, Avi Kivity wrote:
> Joerg Roedel wrote:
> > From: Joerg Roedel <joerg.roedel@amd.com>
> >
> > This patch adds an implementation to the svm is_disabled function to
> > detect reliably if the BIOS disabled the SVM feature in the CPU. This
> > fixes the issues with kernel panics when loading the kvm-amd module on
> > machines where SVM is available but disabled.
> >
> >   
> 
> Applied; thanks.
> 
> Is this msr documented anywhere?  I assume it is implemented on all
> processors with svm?

Not in the public documentation yet. But it will be documented with one of
the next documentation updates. This MSR is implemented in all SVM
capable processors.

Regards,

Joerg

-- 
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-22  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-21 17:51 [PATCH] SVM: reliably detect if SVM was disabled by BIOS Joerg Roedel
2007-06-22  9:30 ` Avi Kivity
2007-06-22  9:35   ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).