lkml.org 
[lkml]   [2022]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH V2 4/5] KVM: X86: Handle implicit supervisor access with SMAP
From
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

\
 
 \ /
  Last update: 2022-03-15 22:05    [W:0.436 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site