Skip to content

Commit 6559b4a

Browse files
yangzhonbonzini
authored andcommitted
selftest: kvm: Move struct kvm_x86_state to header
Those changes can avoid dereferencing pointer compile issue when amx_test.c reference state->xsave. Move struct kvm_x86_state definition to processor.h. Signed-off-by: Yang Zhong <yang.zhong@intel.com> Message-Id: <20211223145322.2914028-3-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 551447c commit 6559b4a

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

tools/testing/selftests/kvm/include/x86_64/processor.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ struct desc_ptr {
9494
uint64_t address;
9595
} __attribute__((packed));
9696

97+
struct kvm_x86_state {
98+
struct kvm_xsave *xsave;
99+
struct kvm_vcpu_events events;
100+
struct kvm_mp_state mp_state;
101+
struct kvm_regs regs;
102+
struct kvm_xcrs xcrs;
103+
struct kvm_sregs sregs;
104+
struct kvm_debugregs debugregs;
105+
union {
106+
struct kvm_nested_state nested;
107+
char nested_[16384];
108+
};
109+
struct kvm_msrs msrs;
110+
};
111+
97112
static inline uint64_t get_desc64_base(const struct desc64 *desc)
98113
{
99114
return ((uint64_t)desc->base3 << 32) |
@@ -350,7 +365,6 @@ static inline unsigned long get_xmm(int n)
350365

351366
bool is_intel_cpu(void);
352367

353-
struct kvm_x86_state;
354368
struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid);
355369
void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid,
356370
struct kvm_x86_state *state);

tools/testing/selftests/kvm/lib/x86_64/processor.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,21 +1056,6 @@ void vcpu_dump(FILE *stream, struct kvm_vm *vm, uint32_t vcpuid, uint8_t indent)
10561056
sregs_dump(stream, &sregs, indent + 4);
10571057
}
10581058

1059-
struct kvm_x86_state {
1060-
struct kvm_xsave *xsave;
1061-
struct kvm_vcpu_events events;
1062-
struct kvm_mp_state mp_state;
1063-
struct kvm_regs regs;
1064-
struct kvm_xcrs xcrs;
1065-
struct kvm_sregs sregs;
1066-
struct kvm_debugregs debugregs;
1067-
union {
1068-
struct kvm_nested_state nested;
1069-
char nested_[16384];
1070-
};
1071-
struct kvm_msrs msrs;
1072-
};
1073-
10741059
static int kvm_get_num_msrs_fd(int kvm_fd)
10751060
{
10761061
struct kvm_msr_list nmsrs;

0 commit comments

Comments
 (0)