• Jing Liu's avatar
    kvm: x86: Enable dynamic xfeatures at KVM_SET_CPUID2 · 5ab2f45b
    Jing Liu authored
    KVM can request fpstate expansion in two approaches:
    
      1) When intercepting guest updates to XCR0 and XFD MSR;
    
      2) Before vcpu runs (e.g. at KVM_SET_CPUID2);
    
    The first option doesn't waste memory for legacy guest if it doesn't
    support XFD. However doing so introduces more complexity and also
    imposes an order requirement in the restoring path, i.e. XCR0/XFD
    must be restored before XSTATE.
    
    Given that the agreement is to do the static approach. This is
    considered a better tradeoff though it does waste 8K memory for
    legacy guest if its CPUID includes dynamically-enabled xfeatures.
    
    Successful fpstate expansion requires userspace VMM to acquire
    guest xstate permissions before calling KVM_SET_CPUID2.
    
    Also take the chance to adjust the indent in kvm_set_cpuid().
    Signed-off-by: default avatarJing Liu <jing2.liu@intel.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarKevin Tian <kevin.tian@intel.com>
    Signed-off-by: default avatarYang Zhong <yang.zhong@intel.com>
    Message-Id: <20220105123532.12586-9-yang.zhong@intel.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    5ab2f45b
cpuid.c 34.9 KB