From: Paolo Bonzini <pbonzini@redhat.com>
To: Qian Cai <cai@lca.pw>, Marco Elver <elver@google.com>
Cc: "paul E. McKenney" <paulmck@kernel.org>,
kasan-dev <kasan-dev@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>,
kvm@vger.kernel.org
Subject: Re: KCSAN + KVM = host reset
Date: Fri, 10 Apr 2020 18:04:54 +0200 [thread overview]
Message-ID: <1d6db024-82d1-5530-2e78-478ee333173e@redhat.com> (raw)
In-Reply-To: <B798749E-F2F0-4A14-AFE3-F386AB632AEB@lca.pw>
On 10/04/20 17:50, Qian Cai wrote:
> This works,
>
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3278,7 +3278,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
>
> bool __svm_vcpu_run(unsigned long vmcb_pa, unsigned long *regs);
>
> -static void svm_vcpu_run(struct kvm_vcpu *vcpu)
> +static __no_kcsan void svm_vcpu_run(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> Does anyone has any idea why svm_vcpu_run() would be a problem for KCSAN_INTERRUPT_WATCHER=y?
All of svm_vcpu_run() has interrupts disabled anyway, but perhaps KCSAN
checks the interrupt flag? That could be a problem because
svm_vcpu_run() disables the interrupts with GIF not IF (and in fact
IF=1).
You can try this patch which moves the problematic section inside
the assembly language trampoline:
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 27f4684a4c20..6ffa07d42e5e 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3337,8 +3337,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
*/
x86_spec_ctrl_set_guest(svm->spec_ctrl, svm->virt_spec_ctrl);
- local_irq_enable();
-
__svm_vcpu_run(svm->vmcb_pa, (unsigned long *)&svm->vcpu.arch.regs);
/* Eliminate branch target predictions from guest mode */
@@ -3373,8 +3368,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
reload_tss(vcpu);
- local_irq_disable();
-
x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl);
vcpu->arch.cr2 = svm->vmcb->save.cr2;
diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S
index fa1af90067e9..a2608ede0975 100644
--- a/arch/x86/kvm/svm/vmenter.S
+++ b/arch/x86/kvm/svm/vmenter.S
@@ -78,6 +78,7 @@ SYM_FUNC_START(__svm_vcpu_run)
pop %_ASM_AX
/* Enter guest mode */
+ sti
1: vmload %_ASM_AX
jmp 3f
2: cmpb $0, kvm_rebooting
@@ -99,6 +100,8 @@ SYM_FUNC_START(__svm_vcpu_run)
ud2
_ASM_EXTABLE(5b, 6b)
7:
+ cli
+
/* "POP" @regs to RAX. */
pop %_ASM_AX
Paolo
next prev parent reply other threads:[~2020-04-10 16:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 20:59 Qian Cai
2020-04-08 21:25 ` Paolo Bonzini
2020-04-08 21:29 ` Qian Cai
2020-04-09 7:03 ` Marco Elver
2020-04-09 15:10 ` Qian Cai
2020-04-09 15:22 ` Marco Elver
2020-04-09 15:30 ` Qian Cai
2020-04-09 16:03 ` Marco Elver
2020-04-09 21:28 ` Qian Cai
2020-04-09 23:00 ` Qian Cai
2020-04-10 9:47 ` Marco Elver
2020-04-10 11:25 ` Qian Cai
2020-04-10 11:35 ` Marco Elver
2020-04-10 15:50 ` Qian Cai
2020-04-10 16:04 ` Paolo Bonzini [this message]
2020-04-10 16:06 ` Sean Christopherson
2020-04-10 19:57 ` Qian Cai
2020-04-13 8:35 ` Marco Elver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1d6db024-82d1-5530-2e78-478ee333173e@redhat.com \
--to=pbonzini@redhat.com \
--cc=cai@lca.pw \
--cc=elver@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®