public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Joerg Roedel" <joerg.roedel-5C7GfCeVMHo@public.gmane.org>
To: "Avi Kivity" <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH] Fix possible FPU information on SVM
Date: Thu, 7 Jun 2007 16:01:45 +0200	[thread overview]
Message-ID: <20070607140145.GD24291@amd.com> (raw)

[-- 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

             reply	other threads:[~2007-06-07 14:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-07 14:01 Joerg Roedel [this message]
     [not found] ` <20070607140145.GD24291-5C7GfCeVMHo@public.gmane.org>
2007-06-07 14:08   ` [PATCH] Fix possible FPU information on SVM 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070607140145.GD24291@amd.com \
    --to=joerg.roedel-5c7gfcevmho@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox