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

[PATCH v3 1/3] xen/events: Cleanup find_virq() return codes


  • To: Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Olaf Hering <olaf@xxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 27 Aug 2025 20:36:01 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NkpL+bA00dMgKT7xrwZLxxLo891ByJ0bYLULdHYLwb0=; b=hC2Emc2p7rPrxdliq/1zLUqYyZxg2t9s7RJYNWRJe1IoAHXTsGznc8RmJ79lZDXF7reapyNJfJWdpx/ZtNfZOKvacSPoetH5CyP2PlXfQA9kQfIJcVqEpZ6R3Zh8FPO3fPei1CiqzRNCv0ZzGX+hwmBc5H5kwzwEocPI/xwK5p1ckKVmwSeTzoHCJi6wAuR1cfvDxOLqALCuDukdV9HtfN4fgoNJzoVm4Qi5xWXg2x3Y2SYlR6sJgWb/vLsFwGryI7XILHDqC2DT3Q4lF1TTWC5G8rWsJ8fSPjUYbXwnLWlptY1BwZbz4LY6S32j/knvAKL0BOTbhIt3TKMtocH1Rw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OLaKtVP7XF4mQE29CjvSkeTwZTRV00N2FPeSN4Zk1LWqsyWT9Z6APFEjf2dtPI+TWSLjaMa8mqMEZbUZJn1o+OQTQETviTK/thuqV4Ya07nM5Yp01ifjlK0j47z6KUdEjmfex7ntZk3ztuyPt+3l8YNs6Vr/54FSWK3mghf37A3vwiU48dbBwDWqYqIfewuyJfzO3B7ZqCsKE7Sa+oV+zXjE/nizpVnhRu/A/plnPedmvoOabMAkGdR9Jqqi9/WHsfy7H9PYSe9HD41G3ksiRGxc3/XWapFJuvM3YgObsA/6C/70zh7+oOEwYKM2g+pbssGMRlyIzeniIEOiY+827w==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, <stable@xxxxxxxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 28 Aug 2025 00:34:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

rc is overwritten by the evtchn_status hypercall in each iteration, so
the return value will be whatever the last iteration is.  This could
incorrectly return success even if the event channel was not found.
Change to an explicit -ENOENT for an un-found virq and return 0 on a
successful match.

Fixes: 62cc5fc7b2e0 ("xen/pv-on-hvm kexec: rebind virqs to existing 
eventchannel ports")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
v3:
Reduce rc's scope
Add R-b: Jan
Mention false success in commit message
Add Fixes
Cc: stable
Add R-b: Juergen

v2:
New
---
 drivers/xen/events/events_base.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 41309d38f78c..374231d84e4f 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1318,10 +1318,11 @@ static int find_virq(unsigned int virq, unsigned int 
cpu, evtchn_port_t *evtchn)
 {
        struct evtchn_status status;
        evtchn_port_t port;
-       int rc = -ENOENT;
 
        memset(&status, 0, sizeof(status));
        for (port = 0; port < xen_evtchn_max_channels(); port++) {
+               int rc;
+
                status.dom = DOMID_SELF;
                status.port = port;
                rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status);
@@ -1331,10 +1332,10 @@ static int find_virq(unsigned int virq, unsigned int 
cpu, evtchn_port_t *evtchn)
                        continue;
                if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) {
                        *evtchn = port;
-                       break;
+                       return 0;
                }
        }
-       return rc;
+       return -ENOENT;
 }
 
 /**
-- 
2.34.1




 


Rackspace

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