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