Skip to content

Commit 96e99e3

Browse files
fyin1lijinxia
authored andcommitted
hv: use more reliable method to get guest DPL.
The DPL from SS access right field is always correct according to SDM. We use it instead of using CS selector. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 63fe48c commit 96e99e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hypervisor/arch/x86/guest/guest.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,16 @@ int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
284284
pw_info.level = pm;
285285
pw_info.is_write_access = ((*err_code & PAGE_FAULT_WR_FLAG) != 0U);
286286
pw_info.is_inst_fetch = ((*err_code & PAGE_FAULT_ID_FLAG) != 0U);
287-
pw_info.is_user_mode = ((exec_vmread16(VMX_GUEST_CS_SEL) & 0x3U) == 3U);
287+
288+
/* SDM vol3 27.3.2
289+
* If the segment register was unusable, the base, select and some
290+
* bits of access rights are undefined. With the exception of
291+
* DPL of SS
292+
* and others.
293+
* So we use DPL of SS access rights field for guest DPL.
294+
*/
295+
pw_info.is_user_mode =
296+
(((exec_vmread32(VMX_GUEST_SS_ATTR)>>5) & 0x3U) == 3U);
288297
pw_info.pse = true;
289298
pw_info.nxe = ((vcpu_get_efer(vcpu) & MSR_IA32_EFER_NXE_BIT) != 0UL);
290299
pw_info.wp = ((vcpu_get_cr0(vcpu) & CR0_WP) != 0UL);

0 commit comments

Comments
 (0)