mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-14 22:34:26 +00:00
HV: instr_emul: Make vie_read/write_bytereg as non-failed function
vie_read/write_bytereg call vm_get/set_register to get/set byteregs. We have make vm_get/set_register as non-failed function in previous patch. So, this patch make the vie_read/write_bytereg as non-failed function too. Signed-off-by: Kaige Fu <kaige.fu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
59c0f355c8
commit
12726dbfc9
@ -597,11 +597,11 @@ static void vie_calc_bytereg(struct instr_emul_vie *vie,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vie_read_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie,
|
static uint8_t vie_read_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie)
|
||||||
uint8_t *rval)
|
|
||||||
{
|
{
|
||||||
|
int lhbr;
|
||||||
uint64_t val;
|
uint64_t val;
|
||||||
int error = 0, lhbr;
|
uint8_t reg_val;
|
||||||
enum cpu_reg_name reg;
|
enum cpu_reg_name reg;
|
||||||
|
|
||||||
vie_calc_bytereg(vie, ®, &lhbr);
|
vie_calc_bytereg(vie, ®, &lhbr);
|
||||||
@ -612,37 +612,36 @@ static int vie_read_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie,
|
|||||||
* base register right by 8 bits (%ah = %rax >> 8).
|
* base register right by 8 bits (%ah = %rax >> 8).
|
||||||
*/
|
*/
|
||||||
if (lhbr != 0) {
|
if (lhbr != 0) {
|
||||||
*rval = (uint8_t)(val >> 8);
|
reg_val = (uint8_t)(val >> 8);
|
||||||
} else {
|
} else {
|
||||||
*rval = (uint8_t)val;
|
reg_val = (uint8_t)val;
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
|
return reg_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vie_write_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie,
|
static void vie_write_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie,
|
||||||
uint8_t byte)
|
uint8_t byte)
|
||||||
{
|
{
|
||||||
uint64_t origval, val, mask;
|
uint64_t origval, val, mask;
|
||||||
int error = 0, lhbr;
|
|
||||||
enum cpu_reg_name reg;
|
enum cpu_reg_name reg;
|
||||||
|
int lhbr;
|
||||||
|
|
||||||
vie_calc_bytereg(vie, ®, &lhbr);
|
vie_calc_bytereg(vie, ®, &lhbr);
|
||||||
origval = vm_get_register(vcpu, reg);
|
origval = vm_get_register(vcpu, reg);
|
||||||
if (error == 0) {
|
|
||||||
val = byte;
|
val = byte;
|
||||||
mask = 0xffU;
|
mask = 0xffU;
|
||||||
if (lhbr != 0) {
|
if (lhbr != 0) {
|
||||||
/*
|
/*
|
||||||
* Shift left by 8 to store 'byte' in a legacy high
|
* Shift left by 8 to store 'byte' in a legacy high
|
||||||
* byte register.
|
* byte register.
|
||||||
*/
|
*/
|
||||||
val <<= 8;
|
val <<= 8;
|
||||||
mask <<= 8;
|
mask <<= 8;
|
||||||
}
|
|
||||||
val |= origval & ~mask;
|
|
||||||
vm_set_register(vcpu, reg, val);
|
|
||||||
}
|
}
|
||||||
return error;
|
val |= origval & ~mask;
|
||||||
|
vm_set_register(vcpu, reg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vie_update_register(struct vcpu *vcpu, enum cpu_reg_name reg,
|
static int vie_update_register(struct vcpu *vcpu, enum cpu_reg_name reg,
|
||||||
@ -744,10 +743,8 @@ static int emulate_mov(struct vcpu *vcpu, struct instr_emul_vie *vie)
|
|||||||
* REX + 88/r: mov r/m8, r8 (%ah, %ch, %dh, %bh not available)
|
* REX + 88/r: mov r/m8, r8 (%ah, %ch, %dh, %bh not available)
|
||||||
*/
|
*/
|
||||||
size = 1U; /* override for byte operation */
|
size = 1U; /* override for byte operation */
|
||||||
error = vie_read_bytereg(vcpu, vie, &byte);
|
byte = vie_read_bytereg(vcpu, vie);
|
||||||
if (error == 0) {
|
error = mmio_write(vcpu, byte);
|
||||||
error = mmio_write(vcpu, byte);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 0x89U:
|
case 0x89U:
|
||||||
/*
|
/*
|
||||||
@ -771,7 +768,7 @@ static int emulate_mov(struct vcpu *vcpu, struct instr_emul_vie *vie)
|
|||||||
size = 1U; /* override for byte operation */
|
size = 1U; /* override for byte operation */
|
||||||
error = mmio_read(vcpu, &val);
|
error = mmio_read(vcpu, &val);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
error = vie_write_bytereg(vcpu, vie, (uint8_t)val);
|
vie_write_bytereg(vcpu, vie, (uint8_t)val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x8BU:
|
case 0x8BU:
|
||||||
|
Loading…
Reference in New Issue
Block a user