Re: [PATCH v4 1/9] KVM: x86: Intercept CR4.LAM_SUP when LAM feature is enabled in guest

Robert Hoo
2023-02-09T12:48:55Z

On Thu, 2023-02-09 at 17:21 +0800, Chao Gao wrote:
> The subject doesn't match what the patch does; intercepting
> CR4.LAM_SUP isn't done by this patch. How about:
>
> Virtualize CR4.LAM_SUP

All right, although I think this patch is all about intercepting
CR4.LAM_SUP. Additional handling on CR4 bits intercepting in
kvm/vmx_set_cr4() isn't always necessary.

>
> and in the changelog,

Do you mean in cover letter? or in this patch's description here?

> explain a bit why CR4.LAM_SUP isn't
> pass-thru'd and why no change to kvm/vmx_set_cr4() is needed.

OK.

Existing kvm/vmx_set_cr4() can handle CR4.LAM_SUP well, no additional
code need to be added.
If we take a look at kvm/vmx_set_cr4() body, besides the ultimate goal
of
vmcs_writel(CR4_READ_SHADOW, cr4);
vmcs_writel(GUEST_CR4, hw_cr4);

other hunks are about constructing/adjust cr4/hw_cr4. Those are for the
CR4 bits that has dependency on other features/system status (e.g.
paging), while CR4.LAM_SUP doesn't.

>
> On Thu, Feb 09, 2023 at 10:40:14AM +0800, Robert Hoo wrote:
> > Remove CR4.LAM_SUP (bit 28) from default CR4_RESERVED_BITS, while
> > reserve
>
> s/(bit 28)//
>
> > it in __cr4_reserved_bits() by feature testing.
> >
> > Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
> > Reviewed-by: Jingqi Liu <jingqi.liu@intel.com>