[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/HVM: don't mark evtchn upcall vector as pending when vLAPIC is disabled


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 18 Nov 2022 11:31:28 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/4843PEKfZVz9As49dWM3d43kFfV2jNSzREIg8Ev5iw=; b=AeCLcKzsp2h741xRaOUz7HlHvSpGX4Vr9uxXkCYynOIIqegYdfoFtkR+sF5DPV0ZGohMxP/DSbYnicI9sChRTvUjEAU2OMtTGubLNieqXAuV6zDjx67mVVD9s6qc+xsxw9AmtOfWkKp6eYFbIEwBZ9Umi1squt/94DtdnyZngDr9LgGTCLCDGUZl88YcM3EmUdbRCdeAyrRMI/vKr3EDUww+aB8598q3Wh6/1uLrrosrj36lf5bpMtudry25Kj9HRPpktHTuO90OPJLNTka6POLesRxImGYBwrCfIGTNobXGGK/xQhodHn43Jf+L8G2gEJ9qTSfDjv8TD6Cip4XMzg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XlmrzwobKb2nRm1TyXPlhkHdclgdwdPJ2rUbxVCofkVzTb8836q0+pyuZr3ge4HrKgl0DSDINhy0HZbMQAydPCMn2/I0+ZdyGJmFKKhO6rvcxkcjIWGSMt3uP8GiA2D9uqPQwRB5N55zfw/DPxdF3XmzRlY0MrNlw9GLuvI29rjCSyPP9hm8G8rTsI4zi/G4yNHJp0EDjCoBwnW6MUP7sbSyank7ct+jLhvi5tZ3TrTZoAoAoWB/wPfWoS/WVy96J9QLbFPG+8BmBBl3fE0hjFP89tAizrZsX6/adxua0Hm+22yT2+sVIArAThquHknC0lo2zgLJYGtKAxY8lk3plg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Fri, 18 Nov 2022 10:32:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Linux'es relatively new use of HVMOP_set_evtchn_upcall_vector has
exposed a problem with the marking of the respective vector as
pending: For quite some time Linux has been checking whether any stale
ISR or IRR bits would still be set while preparing the LAPIC for use.
This check is now triggering on the upcall vector, as the registration,
at least for APs, happens before the LAPIC is actually enabled.

In software-disabled state an LAPIC would not accept any interrupt
requests and hence no IRR bit would newly become set while in this
state. As a result it is also wrong for us to mark the upcall vector as
having a pending request when the vLAPIC is in this state.

To compensate for the "enabled" check added to the assertion logic, add
logic to (conditionally) mark the upcall vector as having a request
pending at the time the LAPIC is being software-enabled by the guest.

Fixes: 7b5b8ca7dffd ("x86/upcall: inject a spurious event after setting upcall 
vector")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Don't one or both of the Viridian uses of vlapic_set_irq() need similar
guarding?

Is it actually necessary for hvmop_set_evtchn_upcall_vector() and
hvm_set_callback_via() to call hvm_assert_evtchn_irq() when
evtchn_upcall_pending is false?

--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -321,9 +321,10 @@ void hvm_assert_evtchn_irq(struct vcpu *
 
     if ( v->arch.hvm.evtchn_upcall_vector != 0 )
     {
-        uint8_t vector = v->arch.hvm.evtchn_upcall_vector;
+        struct vlapic *vlapic = vcpu_vlapic(v);
 
-        vlapic_set_irq(vcpu_vlapic(v), vector, 0);
+        if ( vlapic_enabled(vlapic) )
+           vlapic_set_irq(vlapic, v->arch.hvm.evtchn_upcall_vector, 0);
     }
     else if ( is_hvm_pv_evtchn_domain(v->domain) )
         vcpu_kick(v);
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -829,6 +829,9 @@ void vlapic_reg_write(struct vcpu *v, un
         {
             vlapic->hw.disabled &= ~VLAPIC_SW_DISABLED;
             pt_may_unmask_irq(vlapic_domain(vlapic), &vlapic->pt);
+            if ( v->arch.hvm.evtchn_upcall_vector &&
+                 vcpu_info(v, evtchn_upcall_pending) )
+                vlapic_set_irq(vlapic, v->arch.hvm.evtchn_upcall_vector, 0);
         }
         break;
 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.