Re: [PATCH v4 8/9] KVM: x86: emulation: Apply LAM when emulating data access

Robert Hoo
2023-02-14T05:38:25Z

On Mon, 2023-02-13 at 11:53 +0800, Chao Gao wrote:
> On Thu, Feb 09, 2023 at 10:40:21AM +0800, Robert Hoo wrote:
> > When in KVM emulation, calculated a LA for data access, apply LAM
> > if
> > guest is at that moment LAM active, so that the following canonical
> > check
> > can pass.
>
> This sounds weird. Passing the canonical checking isn't the goal.
> Emulating
> the behavior of a LAM-capable processor on memory accesses is.
>
Emm, how about describe like this:
In KVM emulation, apply LAM rule for linear address calculated, (data
access only), i.e. clear possible meta data in LA, before doing
canonical check.

> > +#ifdef CONFIG_X86_64
> > +static inline bool is_lam_active(struct kvm_vcpu *vcpu)
>
> Drop this function because kvm_untagged_addr() already does these
> checks
> (and taking user/supervisor pointers into consideration).
>
OK