Skip to content

Commit f106797

Browse files
bonzinisean-jc
authored andcommitted
KVM: x86: Add x86_emulate_ops.get_xcr() callback
This will be necessary in order to check whether AVX is enabled. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Chang S. Bae <chang.seok.bae@intel.com> Link: https://patch.msgid.link/20251114003633.60689-7-pbonzini@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 7e11eec commit f106797

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/x86/kvm/kvm_emulate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ struct x86_emulate_ops {
237237
bool (*is_smm)(struct x86_emulate_ctxt *ctxt);
238238
int (*leave_smm)(struct x86_emulate_ctxt *ctxt);
239239
void (*triple_fault)(struct x86_emulate_ctxt *ctxt);
240+
int (*get_xcr)(struct x86_emulate_ctxt *ctxt, u32 index, u64 *xcr);
240241
int (*set_xcr)(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr);
241242

242243
gva_t (*get_untagged_addr)(struct x86_emulate_ctxt *ctxt, gva_t addr,

arch/x86/kvm/x86.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8804,6 +8804,14 @@ static void emulator_triple_fault(struct x86_emulate_ctxt *ctxt)
88048804
kvm_make_request(KVM_REQ_TRIPLE_FAULT, emul_to_vcpu(ctxt));
88058805
}
88068806

8807+
static int emulator_get_xcr(struct x86_emulate_ctxt *ctxt, u32 index, u64 *xcr)
8808+
{
8809+
if (index != XCR_XFEATURE_ENABLED_MASK)
8810+
return 1;
8811+
*xcr = emul_to_vcpu(ctxt)->arch.xcr0;
8812+
return 0;
8813+
}
8814+
88078815
static int emulator_set_xcr(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr)
88088816
{
88098817
return __kvm_set_xcr(emul_to_vcpu(ctxt), index, xcr);
@@ -8876,6 +8884,7 @@ static const struct x86_emulate_ops emulate_ops = {
88768884
.is_smm = emulator_is_smm,
88778885
.leave_smm = emulator_leave_smm,
88788886
.triple_fault = emulator_triple_fault,
8887+
.get_xcr = emulator_get_xcr,
88798888
.set_xcr = emulator_set_xcr,
88808889
.get_untagged_addr = emulator_get_untagged_addr,
88818890
.is_canonical_addr = emulator_is_canonical_addr,

0 commit comments

Comments
 (0)