From: Peter Zijlstra <peterz@infradead.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
Nikunj A Dadhania <nikunj@amd.com>,
kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Randy Dunlap <rdunlap@infradead.org>,
Tom Lendacky <thomas.lendacky@amd.com>,
Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH] KVM: SVM: Add exception to disable objtool warning for kvm-amd.o
Date: Thu, 10 Aug 2023 23:14:08 +0200 [thread overview]
Message-ID: <20230810211408.GI212435@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <fdf4d17a-e134-6e03-87d0-2c018c13a891@redhat.com>
On Thu, Aug 10, 2023 at 04:17:41PM +0200, Paolo Bonzini wrote:
> On 8/5/23 02:55, Peter Zijlstra wrote:
> > > + * Clobbering BP here is mostly ok since GIF will block NMIs and with
> > > + * the exception of #MC and the kvm_rebooting _ASM_EXTABLE()s below
> > > + * nothing untoward will happen until BP is restored.
> > > + *
> > > + * The kvm_rebooting exceptions should not want to unwind stack, and
> > > + * while #MV might want to unwind stack, it is ultimately fatal.
> > > + */
> > Aside from me not being able to type #MC, I did realize that the
> > kvm_reboot exception will go outside noinstr code and can hit
> > tracing/instrumentation and do unwinds from there.
>
> Asynchronously disabling SVM requires an IPI, so kvm_rebooting cannot change
> within CLGI/STGI. We can check it after CLGI instead of waiting for a #GP:
Seems fair; thanks!
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 956726d867aa..e3755f5eaf81 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4074,7 +4074,10 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct
> kvm_vcpu *vcpu)
> if (!static_cpu_has(X86_FEATURE_V_SPEC_CTRL))
> x86_spec_ctrl_set_guest(svm->virt_spec_ctrl);
>
> - svm_vcpu_enter_exit(vcpu, spec_ctrl_intercepted);
> + if (unlikely(kvm_rebooting))
> + svm->vmcb->control.exit_code = SVM_EXIT_PAUSE;
> + else
> + svm_vcpu_enter_exit(vcpu, spec_ctrl_intercepted);
>
> if (!static_cpu_has(X86_FEATURE_V_SPEC_CTRL))
> x86_spec_ctrl_restore_host(svm->virt_spec_ctrl);
> diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S
> index 8e8295e774f0..34641b3a6823 100644
> --- a/arch/x86/kvm/svm/vmenter.S
> +++ b/arch/x86/kvm/svm/vmenter.S
> @@ -270,23 +270,12 @@ SYM_FUNC_START(__svm_vcpu_run)
> RESTORE_GUEST_SPEC_CTRL_BODY
> RESTORE_HOST_SPEC_CTRL_BODY
>
> -10: cmpb $0, kvm_rebooting
> - jne 2b
> - ud2
> -30: cmpb $0, kvm_rebooting
> - jne 4b
> - ud2
> -50: cmpb $0, kvm_rebooting
> - jne 6b
> - ud2
> -70: cmpb $0, kvm_rebooting
> - jne 8b
> - ud2
> +10: ud2
>
> _ASM_EXTABLE(1b, 10b)
> - _ASM_EXTABLE(3b, 30b)
> - _ASM_EXTABLE(5b, 50b)
> - _ASM_EXTABLE(7b, 70b)
> + _ASM_EXTABLE(3b, 10b)
> + _ASM_EXTABLE(5b, 10b)
> + _ASM_EXTABLE(7b, 10b)
>
> SYM_FUNC_END(__svm_vcpu_run)
>
>
> Paolo
>
next prev parent reply other threads:[~2023-08-10 21:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 9:11 [PATCH] KVM: SVM: Add exception to disable objtool warning for kvm-amd.o Nikunj A Dadhania
2023-08-02 14:02 ` Sean Christopherson
2023-08-03 6:25 ` Nikunj A. Dadhania
2023-08-03 12:06 ` Peter Zijlstra
2023-08-03 18:06 ` Paolo Bonzini
2023-08-03 19:07 ` Peter Zijlstra
2023-08-04 3:25 ` Nikunj A. Dadhania
2023-08-04 10:20 ` Paolo Bonzini
2023-08-04 20:48 ` Peter Zijlstra
2023-08-04 23:19 ` Josh Poimboeuf
2023-08-05 0:55 ` Peter Zijlstra
2023-08-10 14:17 ` Paolo Bonzini
2023-08-10 21:14 ` Peter Zijlstra [this message]
2023-08-04 11:14 ` Peter Zijlstra
2023-08-04 12:40 ` Nikunj A. Dadhania
2023-08-04 20:42 ` Peter Zijlstra
2023-08-12 0:51 ` kernel test robot
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=20230810211408.GI212435@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jpoimboe@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=ravi.bangoria@amd.com \
--cc=rdunlap@infradead.org \
--cc=seanjc@google.com \
--cc=thomas.lendacky@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.