WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86: Always respect guest setting CR4.TSD

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: Always respect guest setting CR4.TSD
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Nov 2009 03:30:25 -0800
Delivery-date: Thu, 26 Nov 2009 03:34:51 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1259234690 0
# Node ID 8a0f156487b0c90a75474a38dd238c3e7b7aa630
# Parent  44ea369eefc13145c082fd0e48d15e502b7cd5b9
x86: Always respect guest setting CR4.TSD

Also fix guest reads of CR4.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/time.c  |    2 +-
 xen/arch/x86/traps.c |   22 ++++++++++++----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff -r 44ea369eefc1 -r 8a0f156487b0 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Thu Nov 26 11:02:30 2009 +0000
+++ b/xen/arch/x86/time.c       Thu Nov 26 11:24:50 2009 +0000
@@ -1640,7 +1640,7 @@ void pv_soft_rdtsc(struct vcpu *v, struc
 
     if ( rdtscp )
          regs->ecx =
-             (d->arch.tsc_mode == TSC_MODE_PVRDTSCP) ?  d->arch.incarnation : 
0;
+             (d->arch.tsc_mode == TSC_MODE_PVRDTSCP) ? d->arch.incarnation : 0;
 }
 
 static int host_tsc_is_safe(void)
diff -r 44ea369eefc1 -r 8a0f156487b0 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Thu Nov 26 11:02:30 2009 +0000
+++ b/xen/arch/x86/traps.c      Thu Nov 26 11:24:50 2009 +0000
@@ -2034,9 +2034,7 @@ static int emulate_privileged_op(struct 
      * are executable only from guest kernel mode (virtual ring 0).
      */
     opcode = insn_fetch(u8, code_base, eip, code_limit);
-    if ( !guest_kernel_mode(v, regs) &&
-         (opcode != 0x1) && /* always emulate rdtscp */
-         !((opcode == 0x31) && v->domain->arch.vtsc) )
+    if ( !guest_kernel_mode(v, regs) && (opcode != 0x1) && (opcode != 0x31) )
         goto fail;
 
     if ( lock && (opcode & ~3) != 0x20 )
@@ -2044,6 +2042,9 @@ static int emulate_privileged_op(struct 
     switch ( opcode )
     {
     case 0x1: /* RDTSCP */
+        if ( (v->arch.guest_context.ctrlreg[4] & X86_CR4_TSD) &&
+             !guest_kernel_mode(v, regs) )
+            goto fail;
         if ( insn_fetch(u8, code_base, eip, code_limit) != 0xf9 )
             goto fail;
         pv_soft_rdtsc(v, regs, 1);
@@ -2093,12 +2094,7 @@ static int emulate_privileged_op(struct 
             break;
 
         case 4: /* Read CR4 */
-            /*
-             * Guests can read CR4 to see what features Xen has enabled. We
-             * therefore lie about PGE and PSE as they are unavailable to
-             * guests.
-             */
-            *reg = read_cr4() & ~(X86_CR4_PGE|X86_CR4_PSE);
+            *reg = v->arch.guest_context.ctrlreg[4];
             break;
 
         default:
@@ -2297,7 +2293,13 @@ static int emulate_privileged_op(struct 
     }
 
     case 0x31: /* RDTSC */
-        pv_soft_rdtsc(v, regs, 0);
+        if ( (v->arch.guest_context.ctrlreg[4] & X86_CR4_TSD) &&
+             !guest_kernel_mode(v, regs) )
+            goto fail;
+        if ( v->domain->arch.vtsc )
+            pv_soft_rdtsc(v, regs, 0);
+        else
+            rdtsc(regs->eax, regs->edx);
         break;
 
     case 0x32: /* RDMSR */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: Always respect guest setting CR4.TSD, Xen patchbot-unstable <=