Skip to content

Commit

Permalink
i386: Compile CPUX86State xsave_buf only when support KVM or HVF
Browse files Browse the repository at this point in the history
While at it, also rename var to indicate it is not used only in KVM.

Reviewed-by: Nikita Leshchenko <nikita.leshchenko@oracle.com>
Reviewed-by: Patrick Colp <patrick.colp@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20180914003827.124570-2-liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Liran Alon authored and bonzini committed Oct 2, 2018
1 parent f8dc4c6 commit 5b8063c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion target/i386/cpu.h
Expand Up @@ -1327,7 +1327,9 @@ typedef struct CPUX86State {
bool tsc_valid;
int64_t tsc_khz;
int64_t user_tsc_khz; /* for sanity check only */
void *kvm_xsave_buf;
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
void *xsave_buf;
#endif
#if defined(CONFIG_HVF)
HVFX86EmulatorState *hvf_emul;
#endif
Expand Down
2 changes: 1 addition & 1 deletion target/i386/hvf/README.md
Expand Up @@ -2,6 +2,6 @@

These sources (and ../hvf-all.c) are adapted from Veertu Inc's vdhh (Veertu Desktop Hosted Hypervisor) (last known location: https://github.com/veertuinc/vdhh) with some minor changes, the most significant of which were:

1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw` API; many struct members have been moved around (emulated x86 state, kvm_xsave_buf) due to historical differences + QEMU needing to handle more emulation targets.
1. Adapt to our current QEMU's `CPUState` structure and `address_space_rw` API; many struct members have been moved around (emulated x86 state, xsave_buf) due to historical differences + QEMU needing to handle more emulation targets.
2. Removal of `apic_page` and hyperv-related functionality.
3. More relaxed use of `qemu_mutex_lock_iothread`.
2 changes: 1 addition & 1 deletion target/i386/hvf/hvf.c
Expand Up @@ -587,7 +587,7 @@ int hvf_init_vcpu(CPUState *cpu)
hvf_reset_vcpu(cpu);

x86cpu = X86_CPU(cpu);
x86cpu->env.kvm_xsave_buf = qemu_memalign(4096, 4096);
x86cpu->env.xsave_buf = qemu_memalign(4096, 4096);

hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_STAR, 1);
hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_LSTAR, 1);
Expand Down
4 changes: 2 additions & 2 deletions target/i386/hvf/x86hvf.c
Expand Up @@ -75,7 +75,7 @@ void hvf_put_xsave(CPUState *cpu_state)

struct X86XSaveArea *xsave;

xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
xsave = X86_CPU(cpu_state)->env.xsave_buf;

x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave);

Expand Down Expand Up @@ -163,7 +163,7 @@ void hvf_get_xsave(CPUState *cpu_state)
{
struct X86XSaveArea *xsave;

xsave = X86_CPU(cpu_state)->env.kvm_xsave_buf;
xsave = X86_CPU(cpu_state)->env.xsave_buf;

if (hv_vcpu_read_fpstate(cpu_state->hvf_fd, (void*)xsave, 4096)) {
abort();
Expand Down
6 changes: 3 additions & 3 deletions target/i386/kvm.c
Expand Up @@ -1189,7 +1189,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
}

if (has_xsave) {
env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
env->xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave));
}
cpu->kvm_msr_buf = g_malloc0(MSR_BUF_SIZE);

Expand Down Expand Up @@ -1639,7 +1639,7 @@ ASSERT_OFFSET(XSAVE_PKRU, pkru_state);
static int kvm_put_xsave(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
X86XSaveArea *xsave = env->kvm_xsave_buf;
X86XSaveArea *xsave = env->xsave_buf;

if (!has_xsave) {
return kvm_put_fpu(cpu);
Expand Down Expand Up @@ -2081,7 +2081,7 @@ static int kvm_get_fpu(X86CPU *cpu)
static int kvm_get_xsave(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
X86XSaveArea *xsave = env->kvm_xsave_buf;
X86XSaveArea *xsave = env->xsave_buf;
int ret;

if (!has_xsave) {
Expand Down

0 comments on commit 5b8063c

Please sign in to comment.