Mukesh Rathor
2013-Jan-12 01:35 UTC
[RFC PATCH 4/16]: PVH xen: add params to read_segment_register
In this patch, we change read_segment_register to take vcpu and regs parameters for PVH (in upcoming patches). No functionality change. also, make emulate_privileged_op() public for later. Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com> diff -r 93d95f6dd693 -r 0339f85f6068 xen/arch/x86/domain.c --- a/xen/arch/x86/domain.c Fri Jan 11 16:22:57 2013 -0800 +++ b/xen/arch/x86/domain.c Fri Jan 11 16:24:00 2013 -0800 @@ -1370,10 +1370,10 @@ static void save_segments(struct vcpu *v struct cpu_user_regs *regs = &v->arch.user_regs; unsigned int dirty_segment_mask = 0; - regs->ds = read_segment_register(ds); - regs->es = read_segment_register(es); - regs->fs = read_segment_register(fs); - regs->gs = read_segment_register(gs); + regs->ds = read_segment_register(v, regs, ds); + regs->es = read_segment_register(v, regs, es); + regs->fs = read_segment_register(v, regs, fs); + regs->gs = read_segment_register(v, regs, gs); if ( regs->ds ) dirty_segment_mask |= DIRTY_DS; diff -r 93d95f6dd693 -r 0339f85f6068 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Fri Jan 11 16:22:57 2013 -0800 +++ b/xen/arch/x86/traps.c Fri Jan 11 16:24:00 2013 -0800 @@ -1818,7 +1818,7 @@ static inline uint64_t guest_misc_enable } \ (eip) += sizeof(_x); _x; }) -#define read_sreg(regs, sr) read_segment_register(sr) +#define read_sreg(vcpu, regs, sr) read_segment_register(vcpu, regs, sr) static int is_cpufreq_controller(struct domain *d) { @@ -1828,7 +1828,7 @@ static int is_cpufreq_controller(struct #include "x86_64/mmconfig.h" -static int emulate_privileged_op(struct cpu_user_regs *regs) +int emulate_privileged_op(struct cpu_user_regs *regs) { struct vcpu *v = current; unsigned long *reg, eip = regs->eip; @@ -1864,7 +1864,7 @@ static int emulate_privileged_op(struct goto fail; /* emulating only opcodes not allowing SS to be default */ - data_sel = read_sreg(regs, ds); + data_sel = read_sreg(v, regs, ds); /* Legacy prefixes. */ for ( i = 0; i < 8; i++, rex == opcode || (rex = 0) ) @@ -1882,17 +1882,17 @@ static int emulate_privileged_op(struct data_sel = regs->cs; continue; case 0x3e: /* DS override */ - data_sel = read_sreg(regs, ds); + data_sel = read_sreg(v, regs, ds); continue; case 0x26: /* ES override */ - data_sel = read_sreg(regs, es); + data_sel = read_sreg(v, regs, es); continue; case 0x64: /* FS override */ - data_sel = read_sreg(regs, fs); + data_sel = read_sreg(v, regs, fs); lm_ovr = lm_seg_fs; continue; case 0x65: /* GS override */ - data_sel = read_sreg(regs, gs); + data_sel = read_sreg(v, regs, gs); lm_ovr = lm_seg_gs; continue; case 0x36: /* SS override */ @@ -1939,7 +1939,7 @@ static int emulate_privileged_op(struct if ( !(opcode & 2) ) { - data_sel = read_sreg(regs, es); + data_sel = read_sreg(v, regs, es); lm_ovr = lm_seg_none; } @@ -2668,22 +2668,22 @@ static void emulate_gate_op(struct cpu_u ASSERT(opnd_sel); continue; case 0x3e: /* DS override */ - opnd_sel = read_sreg(regs, ds); + opnd_sel = read_sreg(v, regs, ds); if ( !opnd_sel ) opnd_sel = dpl; continue; case 0x26: /* ES override */ - opnd_sel = read_sreg(regs, es); + opnd_sel = read_sreg(v, regs, es); if ( !opnd_sel ) opnd_sel = dpl; continue; case 0x64: /* FS override */ - opnd_sel = read_sreg(regs, fs); + opnd_sel = read_sreg(v, regs, fs); if ( !opnd_sel ) opnd_sel = dpl; continue; case 0x65: /* GS override */ - opnd_sel = read_sreg(regs, gs); + opnd_sel = read_sreg(v, regs, gs); if ( !opnd_sel ) opnd_sel = dpl; continue; @@ -2736,7 +2736,7 @@ static void emulate_gate_op(struct cpu_u switch ( modrm & 7 ) { default: - opnd_sel = read_sreg(regs, ds); + opnd_sel = read_sreg(v, regs, ds); break; case 4: case 5: opnd_sel = regs->ss; @@ -2764,7 +2764,7 @@ static void emulate_gate_op(struct cpu_u break; } if ( !opnd_sel ) - opnd_sel = read_sreg(regs, ds); + opnd_sel = read_sreg(v, regs, ds); switch ( modrm & 7 ) { case 0: case 2: case 4: diff -r 93d95f6dd693 -r 0339f85f6068 xen/arch/x86/x86_64/traps.c --- a/xen/arch/x86/x86_64/traps.c Fri Jan 11 16:22:57 2013 -0800 +++ b/xen/arch/x86/x86_64/traps.c Fri Jan 11 16:24:00 2013 -0800 @@ -127,10 +127,10 @@ void show_registers(struct cpu_user_regs fault_crs[0] = read_cr0(); fault_crs[3] = read_cr3(); fault_crs[4] = read_cr4(); - fault_regs.ds = read_segment_register(ds); - fault_regs.es = read_segment_register(es); - fault_regs.fs = read_segment_register(fs); - fault_regs.gs = read_segment_register(gs); + fault_regs.ds = read_segment_register(v, regs, ds); + fault_regs.es = read_segment_register(v, regs, es); + fault_regs.fs = read_segment_register(v, regs, fs); + fault_regs.gs = read_segment_register(v, regs, gs); } print_xen_info(); diff -r 93d95f6dd693 -r 0339f85f6068 xen/include/asm-x86/system.h --- a/xen/include/asm-x86/system.h Fri Jan 11 16:22:57 2013 -0800 +++ b/xen/include/asm-x86/system.h Fri Jan 11 16:24:00 2013 -0800 @@ -4,7 +4,7 @@ #include <xen/lib.h> #include <asm/bitops.h> -#define read_segment_register(name) \ +#define read_segment_register(vcpu, regs, name) \ ({ u16 __sel; \ asm volatile ( "movw %%" STR(name) ",%0" : "=r" (__sel) ); \ __sel; \ diff -r 93d95f6dd693 -r 0339f85f6068 xen/include/asm-x86/traps.h --- a/xen/include/asm-x86/traps.h Fri Jan 11 16:22:57 2013 -0800 +++ b/xen/include/asm-x86/traps.h Fri Jan 11 16:24:00 2013 -0800 @@ -48,5 +48,6 @@ extern int guest_has_trap_callback(struc */ extern int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr); +int emulate_privileged_op(struct cpu_user_regs *regs); #endif /* ASM_TRAP_H */