[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZVHRufhNmVTvJYWV@chao-email>
Date: Mon, 13 Nov 2023 15:35:21 +0800
From: Chao Gao <chao.gao@...el.com>
To: Xin Li <xin3.li@...el.com>
CC: <kvm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-hyperv@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>, <seanjc@...gle.com>,
<pbonzini@...hat.com>, <corbet@....net>, <kys@...rosoft.com>,
<haiyangz@...rosoft.com>, <wei.liu@...nel.org>,
<decui@...rosoft.com>, <tglx@...utronix.de>, <mingo@...hat.com>,
<bp@...en8.de>, <dave.hansen@...ux.intel.com>, <x86@...nel.org>,
<hpa@...or.com>, <vkuznets@...hat.com>, <peterz@...radead.org>,
<ravi.v.shankar@...el.com>
Subject: Re: [PATCH v1 11/23] KVM: x86: Add kvm_is_fred_enabled()
On Wed, Nov 08, 2023 at 10:29:51AM -0800, Xin Li wrote:
>Add kvm_is_fred_enabled() to get if FRED is enabled on a vCPU.
>
>Tested-by: Shan Kang <shan.kang@...el.com>
>Signed-off-by: Xin Li <xin3.li@...el.com>
>---
> arch/x86/kvm/kvm_cache_regs.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
>diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
>index 75eae9c4998a..390643e8c532 100644
>--- a/arch/x86/kvm/kvm_cache_regs.h
>+++ b/arch/x86/kvm/kvm_cache_regs.h
>@@ -187,6 +187,16 @@ static __always_inline bool kvm_is_cr4_bit_set(struct kvm_vcpu *vcpu,
> return !!kvm_read_cr4_bits(vcpu, cr4_bit);
> }
>
>+static __always_inline bool kvm_is_fred_enabled(struct kvm_vcpu *vcpu)
>+{
>+#ifdef CONFIG_X86_64
>+ return cpu_feature_enabled(X86_FEATURE_FRED) &&
>+ kvm_is_cr4_bit_set(vcpu, X86_CR4_FRED);
FRED is enabled when CR4.FRED = IA32_EFER.LMA = 1. Any reason to omit
the check about long mode?
>+#else
>+ return false;
>+#endif
>+}
>+
> static inline ulong kvm_read_cr3(struct kvm_vcpu *vcpu)
> {
> if (!kvm_register_is_available(vcpu, VCPU_EXREG_CR3))
>--
>2.42.0
>
>
Powered by blists - more mailing lists