Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1214611pxu; Thu, 17 Dec 2020 05:08:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZZqMEBx4xzYNg/7vqLIi9dNqX+rF23sO88a3CABD0Mcw98SOtmyRdPogn5eRp0jZEtvMn X-Received: by 2002:a17:907:1010:: with SMTP id ox16mr35640165ejb.439.1608210492153; Thu, 17 Dec 2020 05:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608210492; cv=none; d=google.com; s=arc-20160816; b=AaFWo11vh+O3p5H3M6iS6ajdZ8HqcC0AfhNgRi0JRHwTLVOTZ05eRCYDGXpL+8EraO F+CicAq4E4YP93jZSeprq7fazbVRZCiHEVzwyVIE9ebEH6XLSswrcEJHpnDJumwnLUPi O8h//mbP8VLGdhihDnWp/kZt8nQjMfwB6+qiiNSZATIWLljUQftd885yVKLOy9IyWMUi DHZIC3GGDUo2h5m9OJSM8gefDJQ8oocs8R5gIOtkoR7tXLuzV3z1TgexMmnviWpoif5j YEXtELQKIj0OKFWKRStvGRvUL0RC825neIVImM/fBYC/S3jD9EX2+wW9KrR8PT8vh38D Iz1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Bp5lG1N2F0li/XNgW/Hi6qhK65lg9Y+nHKtPdOmFFnk=; b=k5rFGIIF+H+9EMr8PzxlFSFBR/VAOs2muJB2RV3IsVqIJbyB0LoesnW/mXv5jmDoL6 aOTq1w2942Bkym7arogoHgSqhvKyppieVVYQAyGXsmZS4/wJtv6Uo5Wo8B66iTNJSnd0 9GFV8hUXBanJrGed+XuAGgkv0tEFKY3ge22QZepKDvfaCECj8Iefen8KC7Lv5stDX97f VFiO9HRRoPfzU12bK+efM6adFg4vh49Belq47+SXuz27DIQyhf6pc/1X496KH1Ov1sIE b5nFqrt+aqdxRm/0MCNVgoyx+sAkvlteAV9L547g+hE71fiR0OdS1xAQegCsFK6pFVYA ROPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=p1cAuHzD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq10si2792259ejc.616.2020.12.17.05.07.49; Thu, 17 Dec 2020 05:08:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=p1cAuHzD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbgLQNGP (ORCPT + 99 others); Thu, 17 Dec 2020 08:06:15 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:6252 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726773AbgLQNGP (ORCPT ); Thu, 17 Dec 2020 08:06:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1608210374; x=1639746374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Bp5lG1N2F0li/XNgW/Hi6qhK65lg9Y+nHKtPdOmFFnk=; b=p1cAuHzD6R1M1qzDRpUadkkotBymgt42LJDe4RO5eSr5/ZyQkjkWwrJS cTigbsdiPrqidZ1jHGrwVnyZfw+WvnsJZxIZ5KOTkV2gVqEu4PmAwGtUq aZFS01011uZyid39yzFonmVYIlgx3JbYeEmyEtqPdDWtErMsGp+sK1qXe E=; X-IronPort-AV: E=Sophos;i="5.78,428,1599523200"; d="scan'208";a="69971891" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 17 Dec 2020 13:05:32 +0000 Received: from EX13D31EUA004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id 37DF2A1EF2; Thu, 17 Dec 2020 13:05:30 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.66) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 17 Dec 2020 13:05:26 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , Subject: [PATCH v2 2/5] xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path() Date: Thu, 17 Dec 2020 14:04:58 +0100 Message-ID: <20201217130501.12702-3-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217130501.12702-1-sjpark@amazon.com> References: <20201217130501.12702-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.66] X-ClientProxiedBy: EX13D39UWA002.ant.amazon.com (10.43.160.20) To EX13D31EUA004.ant.amazon.com (10.43.165.161) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park Some code does not directly make 'xenbus_watch' object and call 'register_xenbus_watch()' but use 'xenbus_watch_path()' instead. This commit adds support of 'will_handle' callback in the 'xenbus_watch_path()' and it's wrapper, 'xenbus_watch_pathfmt()'. This is part of XSA-349 This is upstream commit 2e85d32b1c865bec703ce0c962221a5e955c52c2 Cc: stable@vger.kernel.org Signed-off-by: SeongJae Park Reported-by: Michael Kurth Reported-by: Pawel Wieczorkiewicz Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross --- drivers/block/xen-blkback/xenbus.c | 3 ++- drivers/net/xen-netback/xenbus.c | 2 +- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 9 +++++++-- drivers/xen/xenbus/xenbus_probe.c | 2 +- include/xen/xenbus.h | 6 +++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index 0ec257e69e95..823f3480ebd1 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -553,7 +553,8 @@ static int xen_blkbk_probe(struct xenbus_device *dev, /* setup back pointer */ be->blkif->be = be; - err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed, + err = xenbus_watch_pathfmt(dev, &be->backend_watch, NULL, + backend_changed, "%s/%s", dev->nodename, "physical-device"); if (err) goto fail; diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 23f03af0a2d4..21c8e2720b40 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -849,7 +849,7 @@ static void connect(struct backend_info *be) xenvif_carrier_on(be->vif); unregister_hotplug_status_watch(be); - err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, + err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, hotplug_status_changed, "%s/%s", dev->nodename, "hotplug-status"); if (!err) diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index 48196347f2f9..12497a2140c2 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c @@ -691,7 +691,7 @@ static int xen_pcibk_xenbus_probe(struct xenbus_device *dev, /* watch the backend node for backend configuration information */ err = xenbus_watch_path(dev, dev->nodename, &pdev->be_watch, - xen_pcibk_be_watch); + NULL, xen_pcibk_be_watch); if (err) goto out; diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index d02d25f784c9..8bbd887ca422 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -114,19 +114,22 @@ EXPORT_SYMBOL_GPL(xenbus_strstate); */ int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char **, unsigned int), void (*callback)(struct xenbus_watch *, const char **, unsigned int)) { int err; watch->node = path; - watch->will_handle = NULL; + watch->will_handle = will_handle; watch->callback = callback; err = register_xenbus_watch(watch); if (err) { watch->node = NULL; + watch->will_handle = NULL; watch->callback = NULL; xenbus_dev_fatal(dev, err, "adding watch on %s", path); } @@ -153,6 +156,8 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path); */ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char **, unsigned int), void (*callback)(struct xenbus_watch *, const char **, unsigned int), const char *pathfmt, ...) @@ -169,7 +174,7 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, xenbus_dev_fatal(dev, -ENOMEM, "allocating path for watch"); return -ENOMEM; } - err = xenbus_watch_path(dev, path, watch, callback); + err = xenbus_watch_path(dev, path, watch, will_handle, callback); if (err) kfree(path); diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index c2d447687e33..c560c1b8489a 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -137,7 +137,7 @@ static int watch_otherend(struct xenbus_device *dev) container_of(dev->dev.bus, struct xen_bus_type, bus); return xenbus_watch_pathfmt(dev, &dev->otherend_watch, - bus->otherend_changed, + NULL, bus->otherend_changed, "%s/%s", dev->otherend, "state"); } diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 11697aa023b5..1772507dc2c9 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -201,10 +201,14 @@ void xenbus_suspend_cancel(void); int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char **, unsigned int), void (*callback)(struct xenbus_watch *, const char **, unsigned int)); -__printf(4, 5) +__printf(5, 6) int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char **, unsigned int), void (*callback)(struct xenbus_watch *, const char **, unsigned int), const char *pathfmt, ...); -- 2.17.1