public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix possible FPU information on SVM
@ 2007-06-07 14:01 Joerg Roedel
       [not found] ` <20070607140145.GD24291-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2007-06-07 14:01 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel

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

From: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>

On AMD K8 processors the fxsave/fxrstor instructions do not save and
restore the x87 error pointers FIP/FOP and FDP except the ES bit in the
status word is set. This could lead to information leakage from host to
guest and vice versa. This patch fixes this by setting the error
pointers to defined values on FPU state switch in KVM.

Signed-off-by: Joerg Roedel <joerg.roedel-5C7GfCeVMHo@public.gmane.org>

-- 
           |           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: kvm-fpu.patch --]
[-- Type: text/plain, Size: 1063 bytes --]

diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index ed33f59..f2d5ab0 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1474,6 +1474,18 @@ static void load_db_regs(unsigned long *db_regs)
 	asm volatile ("mov %0, %%dr3" : : "r"(db_regs[3]));
 }
 
+/* pass data that is likly in L1 here */
+static inline void fx_clear_error_pointers(void *data)
+{
+	/*
+	 * AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception is
+	 * pending. So this function is used to set these registers to defined
+	 * values.
+	 */
+	asm volatile ("emms\n"
+		      "fildl %[addr]\n" :: [addr] "m" (data));
+}
+
 static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
 	u16 fs_selector;
@@ -1510,6 +1522,7 @@ again:
 
 	if (vcpu->fpu_active) {
 		fx_save(vcpu->host_fx_image);
+		fx_clear_error_pointers(vcpu->svm->vmcb);
 		fx_restore(vcpu->guest_fx_image);
 	}
 
@@ -1624,6 +1637,7 @@ again:
 
 	if (vcpu->fpu_active) {
 		fx_save(vcpu->guest_fx_image);
+		fx_clear_error_pointers(vcpu->svm->vmcb);
 		fx_restore(vcpu->host_fx_image);
 	}
 

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-07 14:01 [PATCH] Fix possible FPU information on SVM Joerg Roedel
     [not found] ` <20070607140145.GD24291-5C7GfCeVMHo@public.gmane.org>
2007-06-07 14:08   ` Avi Kivity
     [not found]     ` <46681170.2080700-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-07 14:42       ` Joerg Roedel
     [not found]         ` <20070607144251.GF24291-5C7GfCeVMHo@public.gmane.org>
2007-06-07 14:51           ` Avi Kivity
     [not found]             ` <46681B75.6020709-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-07 17:22               ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox