Re: [PATCH v10 7/9] KVM: VMX: Implement and wire get_untagged_addr() for LAM

From: Sean Christopherson
Date: Wed Aug 16 2023 - 18:02:45 EST


On Wed, Jul 19, 2023, Binbin Wu wrote:
> + return (sign_extend64(gva, lam_bit) & ~BIT_ULL(63)) | (gva & BIT_ULL(63));

Almost forgot. Please add a comment explaning how LAM untags the address,
specifically the whole bit 63 preservation. The logic is actually straightforward,
but the above looks way more complex than it actually is. This?

/*
* Untag the address by sign-extending the LAM bit, but NOT to bit 63.
* Bit 63 is retained from the raw virtual address so that untagging
* doesn't change a user access to a supervisor access, and vice versa.
*/