Skip to content

Commit f36db73

Browse files
sean-jcSomasundaram Krishnasamy
authored andcommitted
KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode
commit 0884335 upstream. 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]> [sudip: manual backport to old file] Signed-off-by: Sudip Mukherjee <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 0b5f20dc30db7138a11a76453f466eb3e51ddcef)
1 parent 00c30d4 commit f36db73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kvm/svm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,7 +4037,7 @@ static int cr_interception(struct vcpu_svm *svm)
40374037
err = 0;
40384038
if (cr >= 16) { /* mov to cr */
40394039
cr -= 16;
4040-
val = kvm_register_read(&svm->vcpu, reg);
4040+
val = kvm_register_readl(&svm->vcpu, reg);
40414041
switch (cr) {
40424042
case 0:
40434043
if (!check_selective_cr0_intercepted(svm, val))
@@ -4082,7 +4082,7 @@ static int cr_interception(struct vcpu_svm *svm)
40824082
kvm_queue_exception(&svm->vcpu, UD_VECTOR);
40834083
return 1;
40844084
}
4085-
kvm_register_write(&svm->vcpu, reg, val);
4085+
kvm_register_writel(&svm->vcpu, reg, val);
40864086
}
40874087
return kvm_complete_insn_gp(&svm->vcpu, err);
40884088
}
@@ -4112,13 +4112,13 @@ static int dr_interception(struct vcpu_svm *svm)
41124112
if (dr >= 16) { /* mov to DRn */
41134113
if (!kvm_require_dr(&svm->vcpu, dr - 16))
41144114
return 1;
4115-
val = kvm_register_read(&svm->vcpu, reg);
4115+
val = kvm_register_readl(&svm->vcpu, reg);
41164116
kvm_set_dr(&svm->vcpu, dr - 16, val);
41174117
} else {
41184118
if (!kvm_require_dr(&svm->vcpu, dr))
41194119
return 1;
41204120
kvm_get_dr(&svm->vcpu, dr, &val);
4121-
kvm_register_write(&svm->vcpu, reg, val);
4121+
kvm_register_writel(&svm->vcpu, reg, val);
41224122
}
41234123

41244124
return kvm_skip_emulated_instruction(&svm->vcpu);

0 commit comments

Comments
 (0)