From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: kvm <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Paul Durrant <paul@xen.org>
Subject: Re: [PATCH v4] KVM: x86/xen: Inject vCPU upcall vector when local APIC is enabled
Date: Tue, 6 Feb 2024 11:19:50 -0800 [thread overview]
Message-ID: <ZcKGVoaituZPkNTU@google.com> (raw)
In-Reply-To: <6150a0a8c3d911c6c2ada23c0b9c8b35991bd235.camel@infradead.org>
On Tue, Jan 16, 2024, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> Linux guests since commit b1c3497e604d ("x86/xen: Add support for
> HVMOP_set_evtchn_upcall_vector") in v6.0 onwards will use the per-vCPU
> upcall vector when it's advertised in the Xen CPUID leaves.
>
> This upcall is injected through the guest's local APIC as an MSI, unlike
> the older system vector which was merely injected by the hypervisor any
> time the CPU was able to receive an interrupt and the upcall_pending
> flags is set in its vcpu_info.
>
> Effectively, that makes the per-CPU upcall edge triggered instead of
> level triggered, which results in the upcall being lost if the MSI is
> delivered when the local APIC is *disabled*.
>
> Xen checks the vcpu_info->evtchn_upcall_pending flag when the local APIC
> for a vCPU is software enabled (in fact, on any write to the SPIV
> register which doesn't disable the APIC). Do the same in KVM since KVM
> doesn't provide a way for userspace to intervene and trap accesses to
> the SPIV register of a local APIC emulated by KVM.
>
> Astute reviewers may note that kvm_xen_inject_vcpu_vector() function has
> a WARN_ON_ONCE() in the case where kvm_irq_delivery_to_apic_fast() fails
> and returns false. In the case where the MSI is not delivered due to the
> local APIC being disabled, kvm_irq_delivery_to_apic_fast() still returns
> true but the value in *r is zero. So the WARN_ON_ONCE() remains correct,
> as that case should still never happen.
>
> Fixes: fde0451be8fb3 ("KVM: x86/xen: Support per-vCPU event channel upcall via local APIC")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> Reviewed-by: Paul Durrant <paul@xen.org>
> Cc: stable@vger.kernel.org
> ---
> v4: Reword commit message,
> rename kvm_xen_enable_lapic() → kvm_xen_sw_enable_lapic().
> v3: Repost, add Cc:stable.
> v2: Add Fixes: tag.
>
> arch/x86/kvm/lapic.c | 5 ++++-
> arch/x86/kvm/xen.c | 2 +-
> arch/x86/kvm/xen.h | 18 ++++++++++++++++++
> 3 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 3242f3da2457..75bc7d3f0022 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -41,6 +41,7 @@
> #include "ioapic.h"
> #include "trace.h"
> #include "x86.h"
> +#include "xen.h"
> #include "cpuid.h"
> #include "hyperv.h"
> #include "smm.h"
Patch is corrupt.
git am /home/seanjc/patches/v4_20240116_dwmw2_kvm_x86_xen_inject_vcpu_upcall_vector_when_local_apic_is_enabled.mbx
Applying: KVM: x86/xen: Inject vCPU upcall vector when local APIC is enabled
error: corrupt patch at line 17
cat ~/patches/v4_20240116_dwmw2_kvm_x86_xen_inject_vcpu_upcall_vector_when_local_apic_is_enabled.mbx | patch -p 1 --merge
patching file arch/x86/kvm/lapic.c
patch: **** malformed patch at line 59: #include "ioapic.h"
Based on what I see in a web view, I suspect something on your end is converting
whitespace to fancy unicode equivalents.
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 3242f3da2457..75bc7d3f0022 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -41,6 +41,7 @@
=C2=A0#include "ioapic.h"
=C2=A0#include "trace.h"
=C2=A0#include "x86.h"
+#include "xen.h"
=C2=A0#include "cpuid.h"
=C2=A0#include "hyperv.h"
=C2=A0#include "smm.h"
next prev parent reply other threads:[~2024-02-06 19:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 19:00 [PATCH v4] KVM: x86/xen: Inject vCPU upcall vector when local APIC is enabled David Woodhouse
2024-02-06 19:19 ` Sean Christopherson [this message]
2024-02-06 19:26 ` David Woodhouse
2024-02-06 19:49 ` Sean Christopherson
2024-02-06 19:55 ` David Woodhouse
2024-02-14 16:32 ` Michal Luczaj
2024-02-17 11:25 ` David Woodhouse
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=ZcKGVoaituZPkNTU@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--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