[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] Turn on dcr.dm inside XEN



# HG changeset patch
# User awilliam@xxxxxxxxxxxx
# Date 1170714219 25200
# Node ID d879bbaa3faab772fab94bab6cb8f5ee2689b3fc
# Parent  d9f7f4f9c7ff86484afb047accdad23e1482637f
[IA64] Turn on dcr.dm inside XEN

For xeno, dcr.dm is alway set to 1,
For VTI-domain,
    if guest cpl > 0, dcr.dm is set to 1,
    if guest cpl == 0, dcr.dm is set to 0,
This is because Window ld.s on tr mapped page.

Signed-off-by: Anthony Xu <anthony.xu@xxxxxxxxx>
---
 xen/arch/ia64/vmx/vmx_interrupt.c |    2 +-
 xen/arch/ia64/vmx/vmx_phy_mode.c  |    2 +-
 xen/arch/ia64/vmx/vmx_vcpu.c      |   17 +++++++++++++++++
 xen/arch/ia64/vmx/vmx_virt.c      |    4 ++--
 xen/arch/ia64/xen/domain.c        |    9 ++++-----
 xen/arch/ia64/xen/vcpu.c          |   13 +++----------
 xen/include/asm-ia64/domain.h     |    1 -
 xen/include/asm-ia64/vmx_vcpu.h   |   21 +--------------------
 xen/include/asm-ia64/vmx_vpd.h    |    9 ---------
 xen/include/asm-ia64/xenkregs.h   |    4 ++++
 10 files changed, 33 insertions(+), 49 deletions(-)

diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/vmx/vmx_interrupt.c
--- a/xen/arch/ia64/vmx/vmx_interrupt.c Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/vmx/vmx_interrupt.c Mon Feb 05 15:23:39 2007 -0700
@@ -99,7 +99,7 @@ inject_guest_interruption(VCPU *vcpu, u6
     pt_isr.ir = 0;
     VMX(vcpu,cr_isr) = pt_isr.val;
     collect_interruption(vcpu);
-
+    vmx_ia64_set_dcr(vcpu);
     vmx_vcpu_get_iva(vcpu,&viva);
     regs->cr_iip = viva + vec;
 }
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/vmx/vmx_phy_mode.c
--- a/xen/arch/ia64/vmx/vmx_phy_mode.c  Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/vmx/vmx_phy_mode.c  Mon Feb 05 15:23:39 2007 -0700
@@ -188,7 +188,7 @@ vmx_load_all_rr(VCPU *vcpu)
                        (void *)vcpu->arch.privregs,
                        (void *)vcpu->arch.vhpt.hash, pal_vaddr );
        ia64_set_pta(VMX(vcpu, mpta));
-       ia64_set_dcr(VMX(vcpu, mdcr));
+       vmx_ia64_set_dcr(vcpu);
 
        ia64_srlz_d();
        ia64_set_psr(psr);
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/vmx/vmx_vcpu.c
--- a/xen/arch/ia64/vmx/vmx_vcpu.c      Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/vmx/vmx_vcpu.c      Mon Feb 05 15:23:39 2007 -0700
@@ -77,6 +77,22 @@ struct guest_psr_bundle guest_psr_buf[10
 struct guest_psr_bundle guest_psr_buf[100];
 unsigned long guest_psr_index = 0;
 #endif
+
+
+void
+vmx_ia64_set_dcr(VCPU *v)   
+{
+    unsigned long dcr_bits = IA64_DEFAULT_DCR_BITS;
+
+    // if guest is runing on cpl > 0, set dcr.dm=1
+    // if geust is runing on cpl = 0, set dcr.dm=0
+    // because Guest OS may ld.s on tr mapped page.
+    if (!(VCPU(v, vpsr) & IA64_PSR_CPL))
+        dcr_bits &= ~IA64_DCR_DM;
+
+    ia64_set_dcr(dcr_bits);
+}
+
 
 void
 vmx_vcpu_set_psr(VCPU *vcpu, unsigned long value)
@@ -261,6 +277,7 @@ IA64FAULT vmx_vcpu_rfi(VCPU *vcpu)
     else
         vcpu_bsw0(vcpu);
     vmx_vcpu_set_psr(vcpu,psr);
+    vmx_ia64_set_dcr(vcpu);
     ifs=VCPU(vcpu,ifs);
     if(ifs>>63)
         regs->cr_ifs = ifs;
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/vmx/vmx_virt.c
--- a/xen/arch/ia64/vmx/vmx_virt.c      Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/vmx/vmx_virt.c      Mon Feb 05 15:23:39 2007 -0700
@@ -1234,7 +1234,7 @@ IA64FAULT vmx_emul_mov_to_cr(VCPU *vcpu,
 #endif  //CHECK_FAULT
     r2 = cr_igfld_mask(inst.M32.cr3,r2);
     switch (inst.M32.cr3) {
-        case 0: return vmx_vcpu_set_dcr(vcpu,r2);
+        case 0: return vcpu_set_dcr(vcpu,r2);
         case 1: return vmx_vcpu_set_itm(vcpu,r2);
         case 2: return vmx_vcpu_set_iva(vcpu,r2);
         case 8: return vmx_vcpu_set_pta(vcpu,r2);
@@ -1299,7 +1299,7 @@ IA64FAULT vmx_emul_mov_from_cr(VCPU *vcp
 
 //    from_cr_cnt[inst.M33.cr3]++;
     switch (inst.M33.cr3) {
-        case 0: return vmx_cr_get(dcr);
+        case 0: return cr_get(dcr);
         case 1: return vmx_cr_get(itm);
         case 2: return vmx_cr_get(iva);
         case 8: return vmx_cr_get(pta);
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/xen/domain.c        Mon Feb 05 15:23:39 2007 -0700
@@ -42,6 +42,7 @@
 #include <asm/vmx_vpd.h>
 #include <asm/vmx_phy_mode.h>
 #include <asm/vhpt.h>
+#include <asm/vcpu.h>
 #include <asm/tlbflush.h>
 #include <asm/regionreg.h>
 #include <asm/dom_fw.h>
@@ -204,9 +205,7 @@ void context_switch(struct vcpu *prev, s
         if (!VMX_DOMAIN(next)) {
             /* VMX domains can change the physical cr.dcr.
              * Restore default to prevent leakage. */
-            ia64_setreg(_IA64_REG_CR_DCR, (IA64_DCR_DP | IA64_DCR_DK
-                           | IA64_DCR_DX | IA64_DCR_DR | IA64_DCR_PP
-                           | IA64_DCR_DA | IA64_DCR_DD | IA64_DCR_LC));
+            ia64_setreg(_IA64_REG_CR_DCR, IA64_DEFAULT_DCR_BITS);
         }
     }
     if (VMX_DOMAIN(next))
@@ -582,7 +581,7 @@ void arch_get_info_guest(struct vcpu *v,
                er->dtrs[i].rid = v->arch.dtrs[i].rid;
        }
        er->event_callback_ip = v->arch.event_callback_ip;
-       er->dcr = v->arch.dcr;
+       er->dcr = PSCB(v,dcr);
        er->iva = v->arch.iva;
 }
 
@@ -618,7 +617,7 @@ int arch_set_info_guest(struct vcpu *v, 
                                     er->dtrs[i].rid);
                }
                v->arch.event_callback_ip = er->event_callback_ip;
-               v->arch.dcr = er->dcr;
+               PSCB(v,dcr) = er->dcr;
                v->arch.iva = er->iva;
        }
 
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/arch/ia64/xen/vcpu.c
--- a/xen/arch/ia64/xen/vcpu.c  Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/arch/ia64/xen/vcpu.c  Mon Feb 05 15:23:39 2007 -0700
@@ -501,7 +501,7 @@ BOOLEAN vcpu_get_psr_i(VCPU * vcpu)
 
 u64 vcpu_get_ipsr_int_state(VCPU * vcpu, u64 prevpsr)
 {
-       u64 dcr = PSCBX(vcpu, dcr);
+       u64 dcr = PSCB(vcpu, dcr);
        PSR psr;
 
        //printk("*** vcpu_get_ipsr_int_state (0x%016lx)...\n",prevpsr);
@@ -532,10 +532,7 @@ u64 vcpu_get_ipsr_int_state(VCPU * vcpu,
 
 IA64FAULT vcpu_get_dcr(VCPU * vcpu, u64 * pval)
 {
-//verbose("vcpu_get_dcr: called @%p\n",PSCB(vcpu,iip));
-       // Reads of cr.dcr on Xen always have the sign bit set, so
-       // a domain can differentiate whether it is running on SP or not
-       *pval = PSCBX(vcpu, dcr) | 0x8000000000000000L;
+       *pval = PSCB(vcpu, dcr);
        return IA64_NO_FAULT;
 }
 
@@ -651,11 +648,7 @@ IA64FAULT vcpu_get_iha(VCPU * vcpu, u64 
 
 IA64FAULT vcpu_set_dcr(VCPU * vcpu, u64 val)
 {
-       // Reads of cr.dcr on SP always have the sign bit set, so
-       // a domain can differentiate whether it is running on SP or not
-       // Thus, writes of DCR should ignore the sign bit
-//verbose("vcpu_set_dcr: called\n");
-       PSCBX(vcpu, dcr) = val & ~0x8000000000000000L;
+       PSCB(vcpu, dcr) = val;
        return IA64_NO_FAULT;
 }
 
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/include/asm-ia64/domain.h     Mon Feb 05 15:23:39 2007 -0700
@@ -162,7 +162,6 @@ struct arch_vcpu {
     unsigned long irr[4];          /* Interrupt request register.  */
     unsigned long insvc[4];            /* Interrupt in service.  */
     unsigned long iva;
-    unsigned long dcr;
     unsigned long domain_itm;
     unsigned long domain_itm_last;
 
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/include/asm-ia64/vmx_vcpu.h
--- a/xen/include/asm-ia64/vmx_vcpu.h   Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/include/asm-ia64/vmx_vcpu.h   Mon Feb 05 15:23:39 2007 -0700
@@ -126,17 +126,12 @@ extern void data_page_not_present(VCPU *
 extern void data_page_not_present(VCPU * vcpu, u64 vadr);
 extern void inst_page_not_present(VCPU * vcpu, u64 vadr);
 extern void data_access_rights(VCPU * vcpu, u64 vadr);
+extern void vmx_ia64_set_dcr(VCPU * v);
 
 /**************************************************************************
  VCPU control register access routines
 **************************************************************************/
 
-static inline IA64FAULT vmx_vcpu_get_dcr(VCPU * vcpu, u64 * pval)
-{
-       *pval = VCPU(vcpu, dcr);
-       return IA64_NO_FAULT;
-}
-
 static inline IA64FAULT vmx_vcpu_get_itm(VCPU * vcpu, u64 * pval)
 {
        *pval = VCPU(vcpu, itm);
@@ -230,20 +225,6 @@ static inline IA64FAULT vmx_vcpu_get_lrr
 static inline IA64FAULT vmx_vcpu_get_lrr1(VCPU * vcpu, u64 * pval)
 {
        *pval = VCPU(vcpu, lrr1);
-       return IA64_NO_FAULT;
-}
-
-static inline IA64FAULT vmx_vcpu_set_dcr(VCPU * vcpu, u64 val)
-{
-       u64 mdcr, mask;
-       VCPU(vcpu, dcr) = val;
-       /* All vDCR bits will go to mDCR, except for be/pp/dm bits */
-       mdcr = ia64_get_dcr();
-       /* Machine dcr.dm masked to handle guest ld.s on tr mapped page */
-       mask = IA64_DCR_BE | IA64_DCR_PP | IA64_DCR_DM;
-       mdcr = (mdcr & mask) | (val & (~mask));
-       ia64_set_dcr(mdcr);
-       VMX(vcpu, mdcr) = mdcr;
        return IA64_NO_FAULT;
 }
 
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/include/asm-ia64/vmx_vpd.h
--- a/xen/include/asm-ia64/vmx_vpd.h    Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/include/asm-ia64/vmx_vpd.h    Mon Feb 05 15:23:39 2007 -0700
@@ -86,16 +86,7 @@ struct arch_vmx_struct {
     unsigned long   cr_isr;    /* for emulation */
     unsigned long   cause;
     unsigned long   opcode;
-
-//    unsigned long   mrr5;
-//    unsigned long   mrr6;
-//    unsigned long   mrr7;
-    unsigned long   mdcr;
     unsigned long   mpta;
-//    unsigned long   rfi_pfs;
-//    unsigned long   rfi_iip;
-//    unsigned long   rfi_ipsr;
-//    unsigned long   rfi_ifs;
     unsigned long   flags;
     unsigned long   xen_port;
     unsigned char   xtp;
diff -r d9f7f4f9c7ff -r d879bbaa3faa xen/include/asm-ia64/xenkregs.h
--- a/xen/include/asm-ia64/xenkregs.h   Mon Feb 05 14:24:27 2007 -0700
+++ b/xen/include/asm-ia64/xenkregs.h   Mon Feb 05 15:23:39 2007 -0700
@@ -12,6 +12,10 @@
 /* Processor status register bits: */
 #define IA64_PSR_VM_BIT                46
 #define IA64_PSR_VM    (__IA64_UL(1) << IA64_PSR_VM_BIT)
+
+#define IA64_DEFAULT_DCR_BITS  (IA64_DCR_PP | IA64_DCR_LC | IA64_DCR_DM | \
+                                IA64_DCR_DP | IA64_DCR_DK | IA64_DCR_DX | \
+                                IA64_DCR_DR | IA64_DCR_DA | IA64_DCR_DD)
 
 /* Interruption Function State */
 #define IA64_IFS_V_BIT         63

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.