提交 03033fda 编写于 作者: S Sean Christopherson 提交者: Zheng Zengkai

KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode

stable inclusion
from stable-5.10.43
commit b3ee3f50ab1bf7b60ba4a8346dca05ba3412fead
bugzilla: 109284
CVE: NA

--------------------------------

commit 0884335a 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: 7ff76d58 ("KVM: SVM: enhance MOV CR intercept handler")
Fixes: cae3797a ("KVM: SVM: enhance mov DR intercept handler")
Cc: stable@vger.kernel.org
Signed-off-by: NSean Christopherson <seanjc@google.com>
Message-Id: <20210422022128.3464144-4-seanjc@google.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NSudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 3ea08020
...@@ -2362,7 +2362,7 @@ static int cr_interception(struct vcpu_svm *svm) ...@@ -2362,7 +2362,7 @@ static int cr_interception(struct vcpu_svm *svm)
err = 0; err = 0;
if (cr >= 16) { /* mov to cr */ if (cr >= 16) { /* mov to cr */
cr -= 16; cr -= 16;
val = kvm_register_read(&svm->vcpu, reg); val = kvm_register_readl(&svm->vcpu, reg);
trace_kvm_cr_write(cr, val); trace_kvm_cr_write(cr, val);
switch (cr) { switch (cr) {
case 0: case 0:
...@@ -2408,7 +2408,7 @@ static int cr_interception(struct vcpu_svm *svm) ...@@ -2408,7 +2408,7 @@ static int cr_interception(struct vcpu_svm *svm)
kvm_queue_exception(&svm->vcpu, UD_VECTOR); kvm_queue_exception(&svm->vcpu, UD_VECTOR);
return 1; return 1;
} }
kvm_register_write(&svm->vcpu, reg, val); kvm_register_writel(&svm->vcpu, reg, val);
trace_kvm_cr_read(cr, val); trace_kvm_cr_read(cr, val);
} }
return kvm_complete_insn_gp(&svm->vcpu, err); return kvm_complete_insn_gp(&svm->vcpu, err);
...@@ -2439,13 +2439,13 @@ static int dr_interception(struct vcpu_svm *svm) ...@@ -2439,13 +2439,13 @@ static int dr_interception(struct vcpu_svm *svm)
if (dr >= 16) { /* mov to DRn */ if (dr >= 16) { /* mov to DRn */
if (!kvm_require_dr(&svm->vcpu, dr - 16)) if (!kvm_require_dr(&svm->vcpu, dr - 16))
return 1; return 1;
val = kvm_register_read(&svm->vcpu, reg); val = kvm_register_readl(&svm->vcpu, reg);
kvm_set_dr(&svm->vcpu, dr - 16, val); kvm_set_dr(&svm->vcpu, dr - 16, val);
} else { } else {
if (!kvm_require_dr(&svm->vcpu, dr)) if (!kvm_require_dr(&svm->vcpu, dr))
return 1; return 1;
kvm_get_dr(&svm->vcpu, dr, &val); kvm_get_dr(&svm->vcpu, dr, &val);
kvm_register_write(&svm->vcpu, reg, val); kvm_register_writel(&svm->vcpu, reg, val);
} }
return kvm_skip_emulated_instruction(&svm->vcpu); return kvm_skip_emulated_instruction(&svm->vcpu);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册