HV: instr_emul: convert cpl to uint8_t
CPL is represented by a plain int but calculated from shifts and bit-wise operations. Convert it the uint8_t for consistency. Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
ab156c9633
commit
479dacc219
|
@ -1527,13 +1527,13 @@ vmm_emulate_instruction(struct vcpu *vcpu, uint64_t gpa, struct vie *vie,
|
|||
}
|
||||
|
||||
int
|
||||
vie_alignment_check(int cpl, uint8_t size, uint64_t cr0, uint64_t rf, uint64_t gla)
|
||||
vie_alignment_check(uint8_t cpl, uint8_t size, uint64_t cr0, uint64_t rf, uint64_t gla)
|
||||
{
|
||||
ASSERT(size == 1U || size == 2U || size == 4U || size == 8U,
|
||||
"%s: invalid size %hhu", __func__, size);
|
||||
ASSERT(cpl >= 0 && cpl <= 3, "%s: invalid cpl %d", __func__, cpl);
|
||||
ASSERT(cpl <= 3U, "%s: invalid cpl %d", __func__, cpl);
|
||||
|
||||
if (cpl != 3 || (cr0 & CR0_AM) == 0 || (rf & PSL_AC) == 0)
|
||||
if (cpl != 3U || (cr0 & CR0_AM) == 0 || (rf & PSL_AC) == 0)
|
||||
return 0;
|
||||
|
||||
return ((gla & (size - 1U)) != 0UL) ? 1 : 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ int vie_update_register(struct vcpu *vcpu, enum cpu_reg_name reg,
|
|||
/*
|
||||
* Returns 1 if an alignment check exception should be injected and 0 otherwise.
|
||||
*/
|
||||
int vie_alignment_check(int cpl, uint8_t operand_size, uint64_t cr0,
|
||||
int vie_alignment_check(uint8_t cpl, uint8_t operand_size, uint64_t cr0,
|
||||
uint64_t rflags, uint64_t gla);
|
||||
|
||||
/* Returns 1 if the 'gla' is not canonical and 0 otherwise. */
|
||||
|
|
|
@ -261,11 +261,11 @@ static uint32_t get_vmcs_field(enum cpu_reg_name ident)
|
|||
static void get_guest_paging_info(struct vcpu *vcpu, struct emul_cnx *emul_cnx,
|
||||
uint32_t csar)
|
||||
{
|
||||
uint32_t cpl;
|
||||
uint8_t cpl;
|
||||
|
||||
ASSERT(emul_cnx != NULL && vcpu != NULL, "Error in input arguments");
|
||||
|
||||
cpl = (csar >> 5) & 3U;
|
||||
cpl = (uint8_t)((csar >> 5) & 3U);
|
||||
emul_cnx->paging.cr3 =
|
||||
vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].cr3;
|
||||
emul_cnx->paging.cpl = cpl;
|
||||
|
|
|
@ -173,7 +173,7 @@ struct seg_desc {
|
|||
|
||||
struct vm_guest_paging {
|
||||
uint64_t cr3;
|
||||
int cpl;
|
||||
uint8_t cpl;
|
||||
enum vm_cpu_mode cpu_mode;
|
||||
enum vm_paging_mode paging_mode;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue