qemu-kvm.git uq/master queue
The following changes since commit 03ecd2c80a64d030a22fe67cc7a60f24e17ff211:
virtio-serial-bus: Ports are expected to implement 'have_data' callback (2011-12-21 15:00:29 -0600)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
Gleb Natapov (1):
enable architectural PMU cpuid leaf for kvm
Jan Kiszka (3):
kvm: x86: Use symbols for all xsave field
kvm: x86: Avoid runtime allocation of xsave buffer
kvm: x86: Drop redundant apic base and tpr update from kvm_get_sregs
Vasilis Liaskovitis (1):
Set numa topology for max_cpus
hw/pc.c | 8 ++++---- target-i386/cpu.h | 3 ++- target-i386/cpuid.c | 17 +++++++++++++---- target-i386/kvm.c | 34 +++++++++++++++++----------------- vl.c | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-)
PATCH 1/5 kvm: x86: Use symbols for all xsave field
From: Jan Kiszka <[email protected]>
Field 0 (FCW+FSW) and 1 (FTW+FOP) were hard-coded so far.
--- target-i386/kvm.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
target-i386/kvm.c +8 -6
@@ -759,6 +759,8 @@ static int kvm_put_fpu(CPUState *env)return kvm_vcpu_ioctl (env,KVM_SET_FPU , &fpu); } +#define XSAVE_FCW_FSW 0 +#define XSAVE_FTW_FOP 1#define XSAVE_CWD_RIP 2#define XSAVE_CWD_RDP 4#define XSAVE_MXCSR 6
@@ -786,8 +788,8 @@ static int kvm_put_xsave(CPUState *env)for (i =0 ; i <8 ; ++i) { twd |= (!env->fptags[i]) << i; } - xsave->region[0 ] = (uint32_t )(swd <<16 ) + cwd; - xsave->region[1 ] = (uint32_t )(env->fpop <<16 ) + twd; + xsave->region[XSAVE_FCW_FSW ] = (uint32_t )(swd <<16 ) + cwd; + xsave->region[XSAVE_FTW_FOP ] = (uint32_t )(env->fpop <<16 ) + twd;memcpy (&xsave->region[XSAVE_CWD_RIP ], &env->fpip,sizeof (env->fpip));memcpy (&xsave->region[XSAVE_CWD_RDP ], &env->fpdp,sizeof (env->fpdp)); memcpy(&xsave->region[XSAVE_ST_SPACE], env->fpregs,
@@ -991,10 +993,10 @@ static int kvm_get_xsave(CPUState *env)return ret; } - cwd = (uint16_t )xsave->region[0 ]; - swd = (uint16_t )(xsave->region[0 ] >>16 ); - twd = (uint16_t )xsave->region[1 ]; - env->fpop = (uint16_t )(xsave->region[1 ] >>16 ); + cwd = (uint16_t )xsave->region[XSAVE_FCW_FSW ]; + swd = (uint16_t )(xsave->region[XSAVE_FCW_FSW ] >>16 ); + twd = (uint16_t )xsave->region[XSAVE_FTW_FOP ]; + env->fpop = (uint16_t )(xsave->region[XSAVE_FTW_FOP ] >>16 ); env->fpstt = (swd >>11 ) &7 ; env->fpus = swd; env->fpuc = cwd;
Signature · 1 line
1.7.6.4
PATCH 2/5 kvm: x86: Avoid runtime allocation of xsave buffer
In reply to Marcelo TosattiFrom: Jan Kiszka <[email protected]>
Keep a per-VCPU xsave buffer for kvm_put/get_xsave instead of continuously allocating and freeing it on state sync.
--- target-i386/cpu.h | 3 ++- target-i386/kvm.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
target-i386/cpu.h +2 -1
@@ -751,7 +751,8 @@ typedef struct CPUX86State {uint32_t cpuid_svm_features;bool tsc_valid;int tsc_khz; - +void *kvm_xsave_buf; +/* in order to simplify APIC support, we leave this pointer to the user */ struct DeviceState *apic_state;
target-i386/kvm.c +7 -8
@@ -516,6 +516,10 @@ int kvm_arch_init_vcpu(CPUState *env) } } +if (kvm_has_xsave ()) { + env->kvm_xsave_buf =qemu_memalign (4096 ,sizeof (struct kvm_xsave )); + } +return 0 ; }
@@ -771,15 +775,14 @@ static int kvm_put_fpu(CPUState *env)static int kvm_put_xsave (CPUState *env) { -int i, r; -struct kvm_xsave * xsave; +struct kvm_xsave * xsave = env->kvm_xsave_buf;uint16_t cwd, swd, twd; +int i, r;if (!kvm_has_xsave ()) {return kvm_put_fpu (env); } - xsave =qemu_memalign (4096 ,sizeof (struct kvm_xsave ));memset (xsave,0 ,sizeof (struct kvm_xsave )); twd =0 ; swd = env->fpus & ~(7 <<11 );
@@ -801,7 +804,6 @@ static int kvm_put_xsave(CPUState *env)memcpy (&xsave->region[XSAVE_YMMH_SPACE ], env->ymmh_regs,sizeof env->ymmh_regs); r =kvm_vcpu_ioctl (env,KVM_SET_XSAVE , xsave); -g_free (xsave);return r; }
@@ -978,7 +980,7 @@ static int kvm_get_fpu(CPUState *env)static int kvm_get_xsave (CPUState *env) { -struct kvm_xsave * xsave; +struct kvm_xsave * xsave = env->kvm_xsave_buf;int ret, i;uint16_t cwd, swd, twd;
@@ -986,10 +988,8 @@ static int kvm_get_xsave(CPUState *env)return kvm_get_fpu (env); } - xsave =qemu_memalign (4096 ,sizeof (struct kvm_xsave )); ret =kvm_vcpu_ioctl (env,KVM_GET_XSAVE , xsave);if (ret <0 ) { -g_free (xsave);return ret; }
@@ -1013,7 +1013,6 @@ static int kvm_get_xsave(CPUState *env) env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV ];memcpy (env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE ],sizeof env->ymmh_regs); -g_free (xsave);return 0 ; }
Signature · 1 line
1.7.6.4
PATCH 3/5 kvm: x86: Drop redundant apic base and tpr update from kvm_get_sregs
In reply to Marcelo TosattiFrom: Jan Kiszka <[email protected]>
The latter was already commented out, the former is redundant as well. We always get the latest changes after return from the guest via kvm_arch_post_run.
--- target-i386/kvm.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
target-i386/kvm.c +2 -3
@@ -1082,10 +1082,9 @@ static int kvm_get_sregs(CPUState *env) env->cr[3 ] = sregs.cr3; env->cr[4 ] = sregs.cr4; -cpu_set_apic_base (env->apic_state, sregs.apic_base); - env->efer = sregs.efer; -//cpu_set_apic_tpr(env->apic_state, sregs.cr8); + +/* changes to apic base and cr8/tpr are read back via kvm_arch_post_run */ #define HFLAG_COPY_MASK \ ~( HF_CPL_MASK | HF_PE_MASK | HF_MP_MASK | HF_EM_MASK | \
Signature · 1 line
1.7.6.4
PATCH 4/5 Set numa topology for max_cpus
In reply to Marcelo TosattiFrom: Vasilis Liaskovitis <[email protected]>
qemu-kvm passes numa/SRAT topology information for smp_cpus to SeaBIOS. However SeaBIOS always expects to setup max_cpus number of SRAT cpu entries (MaxCountCPUs variable in build_srat function of Seabios). When qemu-kvm runs with smp_cpus != max_cpus (e.g. -smp 2,maxcpus=4), Seabios will mistakenly use memory SRAT info for setting up CPU SRAT entries for the offline CPUs. Wrong SRAT memory entries are also created. This breaks NUMA in a guest. Fix by setting up SRAT info for max_cpus in qemu-kvm.
--- hw/pc.c | 8 ++++---- vl.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/pc.c +4 -4
@@ -624,9 +624,9 @@ static void *bochs_bios_init(void)* of nodes, one word for each VCPU->node and one word for each node to * hold the amount of memory. */ - numa_fw_cfg =g_malloc0 ((1 + smp_cpus + nb_numa_nodes) *8 ); + numa_fw_cfg =g_malloc0 ((1 + max_cpus + nb_numa_nodes) *8 ); numa_fw_cfg[0 ] =cpu_to_le64 (nb_numa_nodes); -for (i =0 ; i < smp_cpus; i++) { +for (i =0 ; i < max_cpus; i++) {for (j =0 ; j < nb_numa_nodes; j++) {if (node_cpumask[j] & (1 << i)) { numa_fw_cfg[i +1 ] =cpu_to_le64 (j);
@@ -635,10 +635,10 @@ static void *bochs_bios_init(void) } }for (i =0 ; i < nb_numa_nodes; i++) { - numa_fw_cfg[smp_cpus +1 + i] =cpu_to_le64 (node_mem[i]); + numa_fw_cfg[max_cpus +1 + i] =cpu_to_le64 (node_mem[i]); }fw_cfg_add_bytes (fw_cfg,FW_CFG_NUMA , (uint8_t *)numa_fw_cfg, - (1 + smp_cpus + nb_numa_nodes) *8 ); + (1 + max_cpus + nb_numa_nodes) *8 );return fw_cfg; }
vl.c +1 -1
@@ -3305,7 +3305,7 @@ int main(int argc, char **argv, char **envp)* real machines which also use this scheme. */ if (i == nb_numa_nodes) { -for (i =0 ; i < smp_cpus; i++) { +for (i =0 ; i < max_cpus; i++) { node_cpumask[i % nb_numa_nodes] |=1 << i; } }
Signature · 1 line
1.7.6.4
PATCH 5/5 enable architectural PMU cpuid leaf for kvm
In reply to Marcelo TosattiFrom: Gleb Natapov <[email protected]>
--- target-i386/cpuid.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-)
target-i386/cpuid.c +13 -4
@@ -1180,10 +1180,19 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,break ;case 0xA :/* Architectural Performance Monitoring Leaf */ - *eax =0 ; - *ebx =0 ; - *ecx =0 ; - *edx =0 ; +if (kvm_enabled ()) { +KVMState *s = env->kvm_state; + + *eax =kvm_arch_get_supported_cpuid (s,0xA , count,R_EAX ); + *ebx =kvm_arch_get_supported_cpuid (s,0xA , count,R_EBX ); + *ecx =kvm_arch_get_supported_cpuid (s,0xA , count,R_ECX ); + *edx =kvm_arch_get_supported_cpuid (s,0xA , count,R_EDX ); + }else { + *eax =0 ; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; + }break ;case 0xD :/* Processor Extended State */
Signature · 1 line
1.7.6.4
Quoted 6 lines · Marcelo Tosatti
The following changes since commit
03ecd2c80a64d030a22fe67cc7a60f24e17ff211:virtio-serial-bus: Ports are expected to implement 'have_data' callback (2011-12-21 15:00:29 -0600)are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.gituq/master
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 20 lines
Gleb Natapov (1):
enable architectural PMU cpuid leaf for kvmJan Kiszka (3):
kvm: x86: Use symbols for all xsave field
kvm: x86: Avoid runtime allocation of xsave buffer
kvm: x86: Drop redundant apic base and tpr update fromkvm_get_sregsVasilis Liaskovitis (1):
Set numa topology formax_cpushw/pc.c | 8 ++++---- target-i386/cpu.h | 3 ++- target-i386/cpuid.c | 17 +++++++++++++---- target-i386/kvm.c | 34 +++++++++++++++++----------------- vl.c | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-)