Skip to content

Commit 0884335

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode
Drop bits 63:32 on loads/stores to/from DRs and CRs when the vCPU is not in 64-bit mode. The APM states bits 63:32 are dropped for both DRs and CRs: In 64-bit mode, the operand size is fixed at 64 bits without the need for a REX prefix. In non-64-bit mode, the operand size is fixed at 32 bits and the upper 32 bits of the destination are forced to 0. Fixes: 7ff76d5 ("KVM: SVM: enhance MOV CR intercept handler") Fixes: cae3797 ("KVM: SVM: enhance mov DR intercept handler") Cc: [email protected] Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 886bbcc commit 0884335

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,7 @@ static int cr_interception(struct kvm_vcpu *vcpu)
24512451
err = 0;
24522452
if (cr >= 16) { /* mov to cr */
24532453
cr -= 16;
2454-
val = kvm_register_read(vcpu, reg);
2454+
val = kvm_register_readl(vcpu, reg);
24552455
trace_kvm_cr_write(cr, val);
24562456
switch (cr) {
24572457
case 0:
@@ -2497,7 +2497,7 @@ static int cr_interception(struct kvm_vcpu *vcpu)
24972497
kvm_queue_exception(vcpu, UD_VECTOR);
24982498
return 1;
24992499
}
2500-
kvm_register_write(vcpu, reg, val);
2500+
kvm_register_writel(vcpu, reg, val);
25012501
trace_kvm_cr_read(cr, val);
25022502
}
25032503
return kvm_complete_insn_gp(vcpu, err);
@@ -2563,11 +2563,11 @@ static int dr_interception(struct kvm_vcpu *vcpu)
25632563
dr = svm->vmcb->control.exit_code - SVM_EXIT_READ_DR0;
25642564
if (dr >= 16) { /* mov to DRn */
25652565
dr -= 16;
2566-
val = kvm_register_read(vcpu, reg);
2566+
val = kvm_register_readl(vcpu, reg);
25672567
err = kvm_set_dr(vcpu, dr, val);
25682568
} else {
25692569
kvm_get_dr(vcpu, dr, &val);
2570-
kvm_register_write(vcpu, reg, val);
2570+
kvm_register_writel(vcpu, reg, val);
25712571
}
25722572

25732573
return kvm_complete_insn_gp(vcpu, err);

0 commit comments

Comments
 (0)