Re: [PATCH V2 4/5] KVM: X86: Handle implicit supervisor access with SMAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/11/22 08:03, Lai Jiangshan wrote:
-	unsigned long not_smap = (cpl - 3) & (rflags & X86_EFLAGS_AC);
-	int index = (pfec >> 1) +
-		    (not_smap >> (X86_EFLAGS_AC_BIT - PFERR_RSVD_BIT + 1));
+	bool explicit_access = !(access & PFERR_IMPLICIT_ACCESS);
+	bool not_smap = (rflags & X86_EFLAGS_AC) && explicit_access;
+	int index = (pfec + (!!not_smap << PFERR_RSVD_BIT)) >> 1;

Also possible:

        u64 implicit_access = access & PFERR_IMPLICIT_ACCESS;
        bool not_smap = ((rflags & X86_EFLAGS_AC) | implicit_access) == X86_EFLAGS_AC;
        int index = (pfec + (not_smap << PFERR_RSVD_BIT)) >> 1;

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux