lkml.org 
[lkml]   [2024]   [Feb]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 02/16] KVM: x86: Remove separate "bit" defines for page fault error code masks
On Thu, Feb 29, 2024 at 7:40 PM Sean Christopherson <seanjc@google.com> wrote:
> Long story short, I think we should get to the below (I'll post a separate series,
> assuming I'm not missing something).
>
> unsigned long rflags = static_call(kvm_x86_get_rflags)(vcpu);
> unsigned int pfec = access & (PFERR_PRESENT_MASK |
> PFERR_WRITE_MASK |
> PFERR_USER_MASK |
> PFERR_FETCH_MASK);
>
> /*
> * For explicit supervisor accesses, SMAP is disabled if EFLAGS.AC = 1.
> * For implicit supervisor accesses, SMAP cannot be overridden.
> *
> * SMAP works on supervisor accesses only, and not_smap can
> * be set or not set when user access with neither has any bearing
> * on the result.
> *
> * We put the SMAP checking bit in place of the PFERR_RSVD_MASK bit;
> * this bit will always be zero in pfec, but it will be one in index
> * if SMAP checks are being disabled.
> */
> 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_MASK : 0)) >> 1;
> u32 errcode = PFERR_PRESENT_MASK;
> bool fault;

Sounds good. The whole series is

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

apart from the small nits that were pointed out here and there.

Paolo


\
 
 \ /
  Last update: 2024-02-29 22:08    [W:0.240 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site