On 8/5/2026 6:15 PM, Sohil Mehta wrote: > > +bool vmx_is_lass_violation(struct kvm_vcpu *vcpu, gva_t gva, > + unsigned int size, unsigned int flags) > +{ > + const bool is_supervisor_address = !!(gva & BIT_ULL(63)); > + const bool implicit_supervisor = !!(flags & X86EMUL_F_IMPLICIT); > + const bool fetch = !!(flags & X86EMUL_F_FETCH); > + > + if (!kvm_is_cr4_bit_set(vcpu, X86_CR4_LASS) || !is_long_mode(vcpu)) > + return false; > + > + /* > + * INVLPG isn't subject to LASS, e.g. to allow invalidating userspace > + * addresses without toggling RFLAGS.AC. Branch targets aren't subject > + * to LASS in order to simplify far control transfers (the subsequent > + * fetch will enforce LASS as appropriate). > + */ > + if (flags & (X86EMUL_F_BRANCH | X86EMUL_F_INVLPG)) > + return false; > + > + if (!implicit_supervisor && vmx_get_cpl(vcpu) == 3) > + return is_supervisor_address; > + > + /* > + * LASS enforcement for supervisor-mode data accesses depends on SMAP > + * being enabled, and like SMAP ignores explicit accesses if RFLAGS.AC=1. > + */ > + if (!fetch) { > + if (!kvm_is_cr4_bit_set(vcpu, X86_CR4_SMAP)) > + return false; > + > + if (!implicit_supervisor && (kvm_get_rflags(vcpu) & X86_EFLAGS_AC)) > + return false; > + } > + > + /* > + * The entire access must be in the appropriate address space. Note, > + * if LAM is supported, @gva has already been untagged, so barring a > + * massive architecture change to expand the canonical address range, > + * it's impossible for a user access to straddle user and supervisor > + * address spaces. > + */ > + if (size && !((gva + size - 1) & BIT_ULL(63))) > + return true; > + > + return !is_supervisor_address; > +} This looks like an essential piece for the check introduced in the series. I could follow the logic, and it looks sane to me. If allowed, Reviewed-by: Chang S. Bae The code also looks to be written according to Sean's comment in: https://lore.kernel.org/kvm/ZNwOYdy3AC12MI52@google.com Yes, this could be a matter of taste as taking and going to maintain the code. But as a reader looking at this, the logic was not that easy to capture at a high level. So what the the bottom half code does seems to be something like: if in user mode, violated if gva is a supervisor address if in supervisor mode, if LASS enforcement is applicable, violated if either gva or its access end is an user address Maybe the high-level logic could be highlighted first. Attached a diff to help figuring out that option just in case. Feel free to ignore if it doesn't matter that much. Thanks, Chang