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 <wei.guo.simon@gmail.com> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
		
							parent
							
								
									173c520a04
								
							
						
					
					
						commit
						f19d1f367a
					
				| @ -111,6 +111,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) | ||||
| 	vcpu->arch.mmio_sp64_extend = 0; | ||||
| 	vcpu->arch.mmio_sign_extend = 0; | ||||
| 	vcpu->arch.mmio_vmx_copy_nums = 0; | ||||
| 	vcpu->arch.mmio_host_swabbed = 0; | ||||
| 
 | ||||
| 	switch (get_op(inst)) { | ||||
| 	case 31: | ||||
|  | ||||
| @ -1374,7 +1374,7 @@ static inline int kvmppc_get_vmx_data(struct kvm_vcpu *vcpu, int rs, u64 *val) | ||||
| 	if (di > 1) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	if (vcpu->arch.mmio_host_swabbed) | ||||
| 	if (kvmppc_need_byteswap(vcpu)) | ||||
| 		di = 1 - di; | ||||
| 
 | ||||
| 	w0 = vrs.u[di * 2]; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user