lkml.org 
[lkml]   [2023]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 01/12] KVM: x86: Add a framework for enabling KVM-governed x86 features
On Fri, Feb 17, 2023 at 03:10:11PM -0800, Sean Christopherson wrote:
>+static __always_inline void kvm_governed_feature_set(struct kvm_vcpu *vcpu,
>+ unsigned int x86_feature)
>+{
>+ BUILD_BUG_ON(KVM_NR_GOVERNED_FEATURES >
>+ sizeof(vcpu->arch.governed_features.enabled) * BITS_PER_BYTE);
>+
>+ vcpu->arch.governed_features.enabled |= kvm_governed_feature_bit(x86_feature);
>+}
>+
>+static __always_inline void kvm_governed_feature_check_and_set(struct kvm_vcpu *vcpu,
>+ unsigned int x86_feature)
>+{
>+ if (guest_cpuid_has(vcpu, x86_feature))

Most callers in this series are conditional on either boot_cpu_has() or some
local variables. Can we convert them to kvm_cpu_cap_has() and incorporate them
within this function? i.e.,

if (kvm_cpu_cap_has(x86_feature) && guest_cpuid_has(vcpu, x86_feature))


The benefits of doing so are
1. callers needn't repeat

if (kvm_cpu_cap_has(x86_feature))
kvm_governed_feature_check_and_set(x86_feature)

2. this fits the idea better that guests can use a governed feature only if host
supports it _and_ QEMU exposes it to the guest.

>+ kvm_governed_feature_set(vcpu, x86_feature);
>+}
>+

\
 
 \ /
  Last update: 2023-06-30 10:04    [W:0.958 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site