x86: consolidate frame state manipulation functions

Rather than doing this in multiple places, have a single central
function (decode_register()) to be used by all other code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
This commit is contained in:
Jan Beulich committed 2012-10-04 09:05:24 +02:00
1 parent f06fabda84
commit ceedb8abf0
4 files changed
+7 -75

No files matched your search

+2 -2
View File
@@ -1585,7 +1585,7 @@ int hvm_mov_to_cr(unsigned int cr, unsigned int gpr)
struct vcpu *curr = current;
unsigned long val, *reg;
if ( (reg = get_x86_gpr(guest_cpu_user_regs(), gpr)) == NULL )
if ( (reg = decode_register(gpr, guest_cpu_user_regs(), 0)) == NULL )
{
gdprintk(XENLOG_ERR, "invalid gpr: %u\n", gpr);
goto exit_and_crash;
@@ -1627,7 +1627,7 @@ int hvm_mov_from_cr(unsigned int cr, unsigned int gpr)
struct vcpu *curr = current;
unsigned long val = 0, *reg;
if ( (reg = get_x86_gpr(guest_cpu_user_regs(), gpr)) == NULL )
if ( (reg = decode_register(gpr, guest_cpu_user_regs(), 0)) == NULL )
{
gdprintk(XENLOG_ERR, "invalid gpr: %u\n", gpr);
goto exit_and_crash;
+5 -43
View File
@@ -223,56 +223,18 @@ void __set_vvmcs(void *vvmcs, u32 vmcs_encoding, u64 val)
static unsigned long reg_read(struct cpu_user_regs *regs,
enum vmx_regs_enc index)
{
unsigned long value = 0;
unsigned long *pval = decode_register(index, regs, 0);
switch ( index ) {
CASE_GET_REG(RAX, eax);
CASE_GET_REG(RCX, ecx);
CASE_GET_REG(RDX, edx);
CASE_GET_REG(RBX, ebx);
CASE_GET_REG(RBP, ebp);
CASE_GET_REG(RSI, esi);
CASE_GET_REG(RDI, edi);
CASE_GET_REG(RSP, esp);
CASE_GET_REG(R8, r8);
CASE_GET_REG(R9, r9);
CASE_GET_REG(R10, r10);
CASE_GET_REG(R11, r11);
CASE_GET_REG(R12, r12);
CASE_GET_REG(R13, r13);
CASE_GET_REG(R14, r14);
CASE_GET_REG(R15, r15);
default:
break;
}
return value;
return *pval;
}
static void reg_write(struct cpu_user_regs *regs,
enum vmx_regs_enc index,
unsigned long value)
{
switch ( index ) {
CASE_SET_REG(RAX, eax);
CASE_SET_REG(RCX, ecx);
CASE_SET_REG(RDX, edx);
CASE_SET_REG(RBX, ebx);
CASE_SET_REG(RBP, ebp);
CASE_SET_REG(RSI, esi);
CASE_SET_REG(RDI, edi);
CASE_SET_REG(RSP, esp);
CASE_SET_REG(R8, r8);
CASE_SET_REG(R9, r9);
CASE_SET_REG(R10, r10);
CASE_SET_REG(R11, r11);
CASE_SET_REG(R12, r12);
CASE_SET_REG(R13, r13);
CASE_SET_REG(R14, r14);
CASE_SET_REG(R15, r15);
default:
break;
}
unsigned long *pval = decode_register(index, regs, 0);
*pval = value;
}
static inline u32 __n2_exec_control(struct vcpu *v)
-28
View File
@@ -367,34 +367,6 @@ void vcpu_show_execution_state(struct vcpu *v)
vcpu_unpause(v);
}
unsigned long *get_x86_gpr(struct cpu_user_regs *regs, unsigned int modrm_reg)
{
void *p;
switch ( modrm_reg )
{
case 0: p = &regs->eax; break;
case 1: p = &regs->ecx; break;
case 2: p = &regs->edx; break;
case 3: p = &regs->ebx; break;
case 4: p = &regs->esp; break;
case 5: p = &regs->ebp; break;
case 6: p = &regs->esi; break;
case 7: p = &regs->edi; break;
case 8: p = &regs->r8; break;
case 9: p = &regs->r9; break;
case 10: p = &regs->r10; break;
case 11: p = &regs->r11; break;
case 12: p = &regs->r12; break;
case 13: p = &regs->r13; break;
case 14: p = &regs->r14; break;
case 15: p = &regs->r15; break;
default: p = NULL; break;
}
return p;
}
static char *trapstr(int trapnr)
{
static char *strings[] = {
-2
View File
@@ -552,8 +552,6 @@ void microcode_set_module(unsigned int);
int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len);
int microcode_resume_cpu(int cpu);
unsigned long *get_x86_gpr(struct cpu_user_regs *regs, unsigned int modrm_reg);
#endif /* !__ASSEMBLY__ */
#endif /* __ASM_X86_PROCESSOR_H */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.