Skip to content

Commit f19d1f3

Browse files
justdoitqdpaulusmack
authored andcommitted
KVM: PPC: Fix a mmio_host_swabbed uninitialized usage issue
When KVM emulates VMX store, it will invoke kvmppc_get_vmx_data() to retrieve VMX reg val. kvmppc_get_vmx_data() will check mmio_host_swabbed to decide which double word of vr[] to be used. But the mmio_host_swabbed can be uninitialized during VMX store procedure: kvmppc_emulate_loadstore \- kvmppc_handle_store128_by2x64 \- kvmppc_get_vmx_data So vcpu->arch.mmio_host_swabbed is not meant to be used at all for emulation of store instructions, and this patch makes that true for VMX stores. This patch also initializes mmio_host_swabbed to avoid possible future problems. Signed-off-by: Simon Guo <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 173c520 commit f19d1f3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

arch/powerpc/kvm/emulate_loadstore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
111111
vcpu->arch.mmio_sp64_extend = 0;
112112
vcpu->arch.mmio_sign_extend = 0;
113113
vcpu->arch.mmio_vmx_copy_nums = 0;
114+
vcpu->arch.mmio_host_swabbed = 0;
114115

115116
switch (get_op(inst)) {
116117
case 31:

arch/powerpc/kvm/powerpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ static inline int kvmppc_get_vmx_data(struct kvm_vcpu *vcpu, int rs, u64 *val)
13741374
if (di > 1)
13751375
return -1;
13761376

1377-
if (vcpu->arch.mmio_host_swabbed)
1377+
if (kvmppc_need_byteswap(vcpu))
13781378
di = 1 - di;
13791379

13801380
w0 = vrs.u[di * 2];

0 commit comments

Comments
 (0)