# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1183392632 21600
# Node ID 962f222238173dabe01ea44c1f80e585ff0840f4
# Parent c7e16caf4e630d8c84d2f630e5ef481756a589a2
[IA64] Domain debugger for VTi: virtualize ibr and dbr.
Misc cleanup.
Signed-off-by: Tristan Gingold <tgingold@xxxxxxx>
---
xen/arch/ia64/vmx/vmmu.c | 3 -
xen/arch/ia64/vmx/vmx_ivt.S | 2 -
xen/arch/ia64/vmx/vmx_process.c | 39 +++++++++++++++++++-----
xen/arch/ia64/vmx/vmx_utility.c | 13 ++++----
xen/arch/ia64/vmx/vmx_vcpu.c | 3 -
xen/arch/ia64/vmx/vmx_virt.c | 45 ++++++++++++++++++++--------
xen/arch/ia64/xen/vcpu.c | 12 ++++---
xen/include/asm-ia64/linux-xen/asm/ptrace.h | 1
xen/include/asm-ia64/vmx.h | 2 +
xen/include/asm-ia64/vmx_vcpu.h | 32 +++++++------------
10 files changed, 98 insertions(+), 54 deletions(-)
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmmu.c
--- a/xen/arch/ia64/vmx/vmmu.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmmu.c Mon Jul 02 10:10:32 2007 -0600
@@ -540,8 +540,7 @@ IA64FAULT vmx_vcpu_ptc_e(VCPU *vcpu, u64
IA64FAULT vmx_vcpu_ptc_g(VCPU *vcpu, u64 va, u64 ps)
{
- vmx_vcpu_ptc_ga(vcpu, va, ps);
- return IA64_ILLOP_FAULT;
+ return vmx_vcpu_ptc_ga(vcpu, va, ps);
}
/*
IA64FAULT vmx_vcpu_ptc_ga(VCPU *vcpu, u64 va, u64 ps)
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmx_ivt.S
--- a/xen/arch/ia64/vmx/vmx_ivt.S Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmx_ivt.S Mon Jul 02 10:10:32 2007 -0600
@@ -1001,7 +1001,7 @@ END(vmx_speculation_vector)
// 0x5900 Entry 29 (size 16 bundles) Debug (16,28,56)
ENTRY(vmx_debug_vector)
VMX_DBG_FAULT(29)
- VMX_FAULT(29)
+ VMX_REFLECT(29)
END(vmx_debug_vector)
.org vmx_ia64_ivt+0x5a00
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmx_process.c
--- a/xen/arch/ia64/vmx/vmx_process.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmx_process.c Mon Jul 02 10:10:32 2007 -0600
@@ -86,19 +86,20 @@ void vmx_reflect_interruption(u64 ifa, u
u64 vpsr = VCPU(vcpu, vpsr);
vector = vec2off[vec];
- if(!(vpsr&IA64_PSR_IC)&&(vector!=IA64_DATA_NESTED_TLB_VECTOR)){
- panic_domain(regs, "Guest nested fault vector=%lx!\n", vector);
- }
switch (vec) {
-
+ case 5: // IA64_DATA_NESTED_TLB_VECTOR
+ break;
case 22: // IA64_INST_ACCESS_RIGHTS_VECTOR
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
if (vhpt_access_rights_fixup(vcpu, ifa, 0))
return;
break;
case 25: // IA64_DISABLED_FPREG_VECTOR
-
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
if (FP_PSR(vcpu) & IA64_PSR_DFH) {
FP_PSR(vcpu) = IA64_PSR_MFH;
if (__ia64_per_cpu_var(fp_owner) != vcpu)
@@ -110,8 +111,10 @@ void vmx_reflect_interruption(u64 ifa, u
}
break;
-
+
case 32: // IA64_FP_FAULT_VECTOR
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
// handle fpswa emulation
// fp fault
status = handle_fpu_swa(1, regs, isr);
@@ -123,6 +126,8 @@ void vmx_reflect_interruption(u64 ifa, u
break;
case 33: // IA64_FP_TRAP_VECTOR
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
//fp trap
status = handle_fpu_swa(0, regs, isr);
if (!status)
@@ -132,7 +137,23 @@ void vmx_reflect_interruption(u64 ifa, u
return;
}
break;
-
+
+ case 29: // IA64_DEBUG_VECTOR
+ case 35: // IA64_TAKEN_BRANCH_TRAP_VECTOR
+ case 36: // IA64_SINGLE_STEP_TRAP_VECTOR
+ if (vmx_guest_kernel_mode(regs)
+ && current->domain->debugger_attached) {
+ domain_pause_for_debugger();
+ return;
+ }
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
+ break;
+
+ default:
+ if (!(vpsr & IA64_PSR_IC))
+ goto nested_fault;
+ break;
}
VCPU(vcpu,isr)=isr;
VCPU(vcpu,iipa) = regs->cr_iip;
@@ -142,6 +163,10 @@ void vmx_reflect_interruption(u64 ifa, u
set_ifa_itir_iha(vcpu,ifa,1,1,1);
}
inject_guest_interruption(vcpu, vector);
+ return;
+
+ nested_fault:
+ panic_domain(regs, "Guest nested fault vector=%lx!\n", vector);
}
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmx_utility.c
--- a/xen/arch/ia64/vmx/vmx_utility.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmx_utility.c Mon Jul 02 10:10:32 2007 -0600
@@ -26,7 +26,7 @@
#include <asm/processor.h>
#include <asm/vmx_mm_def.h>
-
+#ifdef CHECK_FAULT
/*
* Return:
* 0: Not reserved indirect registers
@@ -71,6 +71,7 @@ is_reserved_indirect_register (
return 0;
}
+#endif
/*
* Return:
@@ -207,7 +208,7 @@ check_psr_rsv_fields (u64 value)
}
-
+#ifdef CHECK_FAULT
/*
* Return:
* 1: CR reserved fields are not zero
@@ -310,9 +311,9 @@ check_cr_rsv_fields (int index, u64 valu
panic ("Unsupported CR");
return 0;
}
-
-
-
+#endif
+
+#if 0
/*
* Return:
* 0: Indirect Reg reserved fields are not zero
@@ -361,7 +362,7 @@ check_indirect_reg_rsv_fields ( int type
return 1;
}
-
+#endif
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmx_vcpu.c
--- a/xen/arch/ia64/vmx/vmx_vcpu.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmx_vcpu.c Mon Jul 02 10:10:32 2007 -0600
@@ -96,8 +96,7 @@ vmx_vcpu_set_psr(VCPU *vcpu, unsigned lo
*/
VCPU(vcpu,vpsr) = value &
(~ (IA64_PSR_ID |IA64_PSR_DA | IA64_PSR_DD |
- IA64_PSR_SS | IA64_PSR_ED | IA64_PSR_IA
- ));
+ IA64_PSR_ED | IA64_PSR_IA));
if ( !old_psr.i && (value & IA64_PSR_I) ) {
// vpsr.i 0->1
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/vmx/vmx_virt.c
--- a/xen/arch/ia64/vmx/vmx_virt.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/vmx/vmx_virt.c Mon Jul 02 10:10:32 2007 -0600
@@ -178,8 +178,8 @@ static IA64FAULT vmx_emul_mov_to_psr(VCP
{
u64 val;
- if(vcpu_get_gr_nat(vcpu, inst.M35.r2, &val) != IA64_NO_FAULT)
- panic_domain(vcpu_regs(vcpu),"get_psr nat bit fault\n");
+ if (vcpu_get_gr_nat(vcpu, inst.M35.r2, &val) != IA64_NO_FAULT)
+ panic_domain(vcpu_regs(vcpu),"get_psr nat bit fault\n");
return vmx_vcpu_set_psr_l(vcpu, val);
}
@@ -914,7 +914,6 @@ static IA64FAULT vmx_emul_mov_to_ibr(VCP
static IA64FAULT vmx_emul_mov_to_ibr(VCPU *vcpu, INST64 inst)
{
u64 r3,r2;
- return IA64_NO_FAULT;
#ifdef CHECK_FAULT
IA64_PSR vpsr;
vpsr.val=vmx_vcpu_get_psr(vcpu);
@@ -932,7 +931,7 @@ static IA64FAULT vmx_emul_mov_to_ibr(VCP
return IA64_FAULT;
#endif //CHECK_FAULT
}
- return (vmx_vcpu_set_ibr(vcpu,r3,r2));
+ return vmx_vcpu_set_ibr(vcpu,r3,r2);
}
static IA64FAULT vmx_emul_mov_to_pmc(VCPU *vcpu, INST64 inst)
@@ -1062,6 +1061,7 @@ static IA64FAULT vmx_emul_mov_from_dbr(V
static IA64FAULT vmx_emul_mov_from_dbr(VCPU *vcpu, INST64 inst)
{
u64 r3,r1;
+ IA64FAULT res;
#ifdef CHECK_FAULT
if(check_target_register(vcpu, inst.M43.r1)){
set_illegal_op_isr(vcpu);
@@ -1092,13 +1092,16 @@ static IA64FAULT vmx_emul_mov_from_dbr(V
return IA64_FAULT;
}
#endif //CHECK_FAULT
- r1 = vmx_vcpu_get_dbr(vcpu, r3);
+ res = vmx_vcpu_get_ibr(vcpu, r3, &r1);
+ if (res != IA64_NO_FAULT)
+ return res;
return vcpu_set_gr(vcpu, inst.M43.r1, r1,0);
}
static IA64FAULT vmx_emul_mov_from_ibr(VCPU *vcpu, INST64 inst)
{
u64 r3,r1;
+ IA64FAULT res;
#ifdef CHECK_FAULT
if(check_target_register(vcpu, inst.M43.r1)){
set_illegal_op_isr(vcpu);
@@ -1129,7 +1132,9 @@ static IA64FAULT vmx_emul_mov_from_ibr(V
return IA64_FAULT;
}
#endif //CHECK_FAULT
- r1 = vmx_vcpu_get_ibr(vcpu, r3);
+ res = vmx_vcpu_get_dbr(vcpu, r3, &r1);
+ if (res != IA64_NO_FAULT)
+ return res;
return vcpu_set_gr(vcpu, inst.M43.r1, r1,0);
}
@@ -1562,21 +1567,37 @@ if ( (cause == 0xff && opcode == 0x1e000
break;
case EVENT_VMSW:
printk ("Unimplemented instruction %ld\n", cause);
- status=IA64_FAULT;
+ status=IA64_FAULT;
break;
default:
- panic_domain(regs,"unknown cause %ld, iip: %lx, ipsr: %lx\n",
cause,regs->cr_iip,regs->cr_ipsr);
+ panic_domain(regs,"unknown cause %ld, iip: %lx, ipsr: %lx\n",
+ cause,regs->cr_iip,regs->cr_ipsr);
break;
};
#if 0
- if (status == IA64_FAULT)
+ if (status != IA64_NO_FAULT)
panic("Emulation failed with cause %d:\n", cause);
#endif
- if ( status == IA64_NO_FAULT && cause !=EVENT_RFI ) {
- vcpu_increment_iip(vcpu);
- }
+ switch (status) {
+ case IA64_RSVDREG_FAULT:
+ set_rsv_reg_field_isr(vcpu);
+ rsv_reg_field(vcpu);
+ break;
+ case IA64_ILLOP_FAULT:
+ set_illegal_op_isr(vcpu);
+ illegal_op(vcpu);
+ break;
+ case IA64_FAULT:
+ /* Registers aleady set. */
+ break;
+ case IA64_NO_FAULT:
+ if ( cause != EVENT_RFI )
+ vcpu_increment_iip(vcpu);
+ break;
+ }
+
recover_if_physical_mode(vcpu);
return;
diff -r c7e16caf4e63 -r 962f22223817 xen/arch/ia64/xen/vcpu.c
--- a/xen/arch/ia64/xen/vcpu.c Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/arch/ia64/xen/vcpu.c Mon Jul 02 10:10:32 2007 -0600
@@ -1780,8 +1780,10 @@ IA64FAULT vcpu_set_dbr(VCPU * vcpu, u64
if (val >= HYPERVISOR_VIRT_START && val <= HYPERVISOR_VIRT_END)
return IA64_ILLOP_FAULT;
} else {
- /* Mask PL0. */
- val &= ~(1UL << 56);
+ if (!VMX_DOMAIN(vcpu)) {
+ /* Mask PL0. */
+ val &= ~(1UL << 56);
+ }
}
if (val != 0)
vcpu->arch.dbg_used |= (1 << reg);
@@ -1802,8 +1804,10 @@ IA64FAULT vcpu_set_ibr(VCPU * vcpu, u64
if (val >= HYPERVISOR_VIRT_START && val <= HYPERVISOR_VIRT_END)
return IA64_ILLOP_FAULT;
} else {
- /* Mask PL0. */
- val &= ~(1UL << 56);
+ if (!VMX_DOMAIN(vcpu)) {
+ /* Mask PL0. */
+ val &= ~(1UL << 56);
+ }
}
if (val != 0)
vcpu->arch.dbg_used |= (1 << (reg + IA64_NUM_DBG_REGS));
diff -r c7e16caf4e63 -r 962f22223817 xen/include/asm-ia64/linux-xen/asm/ptrace.h
--- a/xen/include/asm-ia64/linux-xen/asm/ptrace.h Mon Jul 02 09:54:53
2007 -0600
+++ b/xen/include/asm-ia64/linux-xen/asm/ptrace.h Mon Jul 02 10:10:32
2007 -0600
@@ -278,6 +278,7 @@ struct switch_stack {
#ifdef XEN
# define guest_mode(regs) (ia64_psr(regs)->cpl != 0)
# define guest_kernel_mode(regs) (ia64_psr(regs)->cpl ==
CONFIG_CPL0_EMUL)
+# define vmx_guest_kernel_mode(regs) (ia64_psr(regs)->cpl == 0)
#else
# define user_mode(regs) (((struct ia64_psr *)
&(regs)->cr_ipsr)->cpl != 0)
#endif
diff -r c7e16caf4e63 -r 962f22223817 xen/include/asm-ia64/vmx.h
--- a/xen/include/asm-ia64/vmx.h Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/include/asm-ia64/vmx.h Mon Jul 02 10:10:32 2007 -0600
@@ -50,6 +50,8 @@ extern void inject_guest_interruption(st
extern void inject_guest_interruption(struct vcpu *vcpu, u64 vec);
extern void set_illegal_op_isr (struct vcpu *vcpu);
extern void illegal_op (struct vcpu *vcpu);
+extern void set_rsv_reg_field_isr (struct vcpu *vcpu);
+extern void rsv_reg_field (struct vcpu *vcpu);
extern void vmx_relinquish_guest_resources(struct domain *d);
extern void vmx_relinquish_vcpu_resources(struct vcpu *v);
extern void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err);
diff -r c7e16caf4e63 -r 962f22223817 xen/include/asm-ia64/vmx_vcpu.h
--- a/xen/include/asm-ia64/vmx_vcpu.h Mon Jul 02 09:54:53 2007 -0600
+++ b/xen/include/asm-ia64/vmx_vcpu.h Mon Jul 02 10:10:32 2007 -0600
@@ -313,30 +313,22 @@ static inline u64 vmx_vcpu_get_cpuid(VCP
static inline IA64FAULT vmx_vcpu_set_dbr(VCPU * vcpu, u64 reg, u64 val)
{
- // TODO: unimplemented DBRs return a reserved register fault
- // TODO: Should set Logical CPU state, not just physical
- ia64_set_dbr(reg, val);
- return IA64_NO_FAULT;
+ return vcpu_set_dbr(vcpu, reg, val);
}
static inline IA64FAULT vmx_vcpu_set_ibr(VCPU * vcpu, u64 reg, u64 val)
{
- // TODO: unimplemented IBRs return a reserved register fault
- // TODO: Should set Logical CPU state, not just physical
- ia64_set_ibr(reg, val);
- return IA64_NO_FAULT;
-}
-
-static inline u64 vmx_vcpu_get_dbr(VCPU * vcpu, u64 reg)
-{
- // TODO: unimplemented DBRs return a reserved register fault
- return ((u64)ia64_get_dbr(reg));
-}
-
-static inline u64 vmx_vcpu_get_ibr(VCPU * vcpu, u64 reg)
-{
- // TODO: unimplemented IBRs return a reserved register fault
- return ((u64)ia64_get_ibr(reg));
+ return vcpu_set_ibr(vcpu, reg, val);
+}
+
+static inline IA64FAULT vmx_vcpu_get_dbr(VCPU * vcpu, u64 reg, u64 *pval)
+{
+ return vcpu_get_dbr(vcpu, reg, pval);
+}
+
+static inline IA64FAULT vmx_vcpu_get_ibr(VCPU * vcpu, u64 reg, u64 *pval)
+{
+ return vcpu_get_ibr(vcpu, reg, pval);
}
/**************************************************************************
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|