From: Maxim Levitsky <mlevitsk@redhat.com>
To: kvm@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Joerg Roedel <joro@8bytes.org>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Borislav Petkov <bp@alien8.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@redhat.com>, Jim Mattson <jmattson@google.com>,
Wanpeng Li <wanpengli@tencent.com>
Subject: Re: [PATCH] KVM: x86: inhibit APICv when KVM_GUESTDBG_BLOCKIRQ active
Date: Wed, 03 Nov 2021 11:31:55 +0200 [thread overview]
Message-ID: <c6477e5bfb67f2a939a8f62cb22e48c14587a75c.camel@redhat.com> (raw)
In-Reply-To: <20211103092912.425128-1-mlevitsk@redhat.com>
On Wed, 2021-11-03 at 11:29 +0200, Maxim Levitsky wrote:
> KVM_GUESTDBG_BLOCKIRQ relies on interrupts being injected using
> standard kvm's inject_pending_event, and not via APICv/AVIC.
>
> Since this is a debug feature, just inhibit it while it
> is in use.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
> arch/x86/include/asm/kvm_host.h | 1 +
> arch/x86/kvm/svm/avic.c | 3 ++-
> arch/x86/kvm/vmx/vmx.c | 3 ++-
> arch/x86/kvm/x86.c | 3 +++
> 4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 88fce6ab4bbd7..8f6e15b95a4d8 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1034,6 +1034,7 @@ struct kvm_x86_msr_filter {
> #define APICV_INHIBIT_REASON_IRQWIN 3
> #define APICV_INHIBIT_REASON_PIT_REINJ 4
> #define APICV_INHIBIT_REASON_X2APIC 5
> +#define APICV_INHIBIT_REASON_BLOCKIRQ 6
>
> struct kvm_arch {
> unsigned long n_used_mmu_pages;
> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
> index 8052d92069e01..affc0ea98d302 100644
> --- a/arch/x86/kvm/svm/avic.c
> +++ b/arch/x86/kvm/svm/avic.c
> @@ -904,7 +904,8 @@ bool svm_check_apicv_inhibit_reasons(ulong bit)
> BIT(APICV_INHIBIT_REASON_NESTED) |
> BIT(APICV_INHIBIT_REASON_IRQWIN) |
> BIT(APICV_INHIBIT_REASON_PIT_REINJ) |
> - BIT(APICV_INHIBIT_REASON_X2APIC);
> + BIT(APICV_INHIBIT_REASON_X2APIC) |
> + BIT(APICV_INHIBIT_REASON_BLOCKIRQ);
>
> return supported & BIT(bit);
> }
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 71f54d85f104c..e4fc9ff7cd944 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7565,7 +7565,8 @@ static void hardware_unsetup(void)
> static bool vmx_check_apicv_inhibit_reasons(ulong bit)
> {
> ulong supported = BIT(APICV_INHIBIT_REASON_DISABLE) |
> - BIT(APICV_INHIBIT_REASON_HYPERV);
> + BIT(APICV_INHIBIT_REASON_HYPERV) |
> + BIT(APICV_INHIBIT_REASON_BLOCKIRQ);
>
> return supported & BIT(bit);
> }
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ac83d873d65b0..eb3b8d2375713 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -10747,6 +10747,9 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
> if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
> vcpu->arch.singlestep_rip = kvm_get_linear_rip(vcpu);
>
> + kvm_request_apicv_update(vcpu->kvm,
> + !(vcpu->guest_debug & KVM_GUESTDBG_BLOCKIRQ),
> + APICV_INHIBIT_REASON_BLOCKIRQ);
I need more coffee, bad indention here :)
Could you test if this patch works for you?
I managed to reproduce this issue on AVIC, by patching out the x2apic inhibit,
and then this patch fixed the issue for me.
Best regards,
Maxim Levitsky
> /*
> * Trigger an rflags update that will inject or remove the trace
> * flags.
next prev parent reply other threads:[~2021-11-03 9:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 12:29 [PATCH v3 0/6] KVM: my debug patch queue Maxim Levitsky
2021-08-11 12:29 ` [PATCH v3 1/6] KVM: SVM: split svm_handle_invalid_exit Maxim Levitsky
2021-08-11 12:29 ` [PATCH v3 2/6] KVM: x86: add force_intercept_exceptions_mask Maxim Levitsky
2021-09-02 16:56 ` Sean Christopherson
2022-02-08 14:34 ` Maxim Levitsky
2022-03-08 23:37 ` Sean Christopherson
2022-03-09 12:31 ` Maxim Levitsky
2022-03-09 14:03 ` Paolo Bonzini
2022-03-09 15:40 ` Sean Christopherson
2021-08-11 12:29 ` [PATCH v3 3/6] KVM: SVM: implement force_intercept_exceptions_mask Maxim Levitsky
2021-08-11 14:26 ` Maxim Levitsky
2021-09-02 17:34 ` Sean Christopherson
2022-02-08 14:35 ` Maxim Levitsky
2021-08-11 12:29 ` [PATCH v3 4/6] scripts/gdb: rework lx-symbols gdb script Maxim Levitsky
2021-08-11 12:29 ` [PATCH v3 5/6] KVM: x86: implement KVM_GUESTDBG_BLOCKIRQ Maxim Levitsky
2021-08-11 12:29 ` [PATCH v3 6/6] KVM: selftests: test KVM_GUESTDBG_BLOCKIRQ Maxim Levitsky
2021-09-06 11:20 ` Paolo Bonzini
2021-09-06 21:03 ` Maxim Levitsky
2021-11-01 15:43 ` Vitaly Kuznetsov
2021-11-01 16:19 ` Maxim Levitsky
2021-11-01 23:21 ` Sean Christopherson
2021-11-02 10:46 ` Vitaly Kuznetsov
2021-11-02 15:53 ` Sean Christopherson
2021-11-02 16:18 ` Vitaly Kuznetsov
2021-11-02 18:45 ` Sean Christopherson
2021-11-03 9:04 ` Maxim Levitsky
2021-11-03 9:29 ` [PATCH] KVM: x86: inhibit APICv when KVM_GUESTDBG_BLOCKIRQ active Maxim Levitsky
2021-11-03 9:31 ` Maxim Levitsky [this message]
2021-08-11 13:10 ` [PATCH v3 0/6] KVM: my debug patch queue Paolo Bonzini
2021-08-11 13:22 ` Maxim Levitsky
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=c6477e5bfb67f2a939a8f62cb22e48c14587a75c.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@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®