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

Robert Hoo
2023-02-14T06:11:26Z

On Tue, 2023-02-14 at 09:27 +0800, Binbin Wu wrote:
> This patch removes CR4.LAM_SUP from cr4_reserved_bits to allows the
> setting of X86_CR4_LAM_SUP by guest

Yes

> if the hardware platform supports
> the feature.

More precisely, if guest_cpuid_has() LAM feature. QEMU could turn
feature off even if underlying host/KVM tells supporting it.
>
> The interception of CR4 is decided by CR4 guest/host mask and CR4
> read
> shadow.
>
My interpretation is that "intercept CR4.x bit" is the opposite of
"guest own CR4.x bit".
Both of them are implemented via CR4 guest/host mask and CR4 shadow,
whose combination decides corresponding CR4.x bit access causes VM exit
or not.
When we changes some bits in CR4_RESERVED_BITS and
__cr4_reserved_bits(), we changes vcpu->arch.cr4_guest_owned_bits which
eventually forms the effective vmcs_writel(CR4_GUEST_HOST_MASK).