Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1046801pxu; Thu, 17 Dec 2020 00:20:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3VM7+XBYzbV7qsnqjeOimf6dEkjBN1ElEzMchM+7C1mg7NKWt20WrU3WKhFpESTSyqkcM X-Received: by 2002:a17:906:254b:: with SMTP id j11mr34593445ejb.326.1608193251192; Thu, 17 Dec 2020 00:20:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608193251; cv=none; d=google.com; s=arc-20160816; b=TKNHI76FR7RxVpShZQ1njRfAuhg6nQtO131NUJh70JmFkPlgfiJHGPbFVCSvwNOEqY KMp+pMIN3D6VvgvrZY3sBekbcgvbBIY7tAtpp9YvOr4UHQARjtY4cHCT3gBy+S4uLiss p5H+BnmFdevriW2vHBxemttrJxuqTEF4LzBt0Wx/AllWIXeCxi/DQfuFEPh/+GDwAOUS ay4DqtOpbJwR04cauRhhaFo7A7sFEDHtEJcV4gw9aPboR6h7JKaTHfJyRY7lWxuMTWSN YLunXEOTDOpEGeOdL5FzRQDfT7fSqcnOeYoWiHlx9f4I2XPggEnhMC8NaPLCKdQNWdZ5 N81Q== 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=M/hg1+/n65xzAqzOAtMxz0yiV3n+lwdo6ngwya5vN50=; b=wSCmGVNxDVHMWijzKZHx+AU2gSQdvgMqMzZbvwUWWtL0loJd7NOOjSP/acAsR///wn Fp4bsAsVGyoBQn2O2NXwg94EP/7580dzfk0sw654oGoAAElQ4Hthj+yjZouXO49ye1CB i4jmzsy2HED89/H3w5Z0MyA7yI7BtU5jTkg2gcocCCPSBeaieYxSzshUJHZhQSICm50w ACdqfgk6gJu1DmuMZuUG0kYwROJRySWAQBACi7mgvYTXhxlph7iHnw9AR92UEN2nW4sm zUZzcoXAvh6T43EUeqDpcrcuSnQJxeNTvfZgVHFIj8otjC0nqMV9fdkjPpE8H6lckwPL C+uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=MEihbd4n; 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 j15si4070231edv.474.2020.12.17.00.20.28; Thu, 17 Dec 2020 00:20:51 -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=MEihbd4n; 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 S1727559AbgLQITK (ORCPT + 99 others); Thu, 17 Dec 2020 03:19:10 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:50398 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgLQITJ (ORCPT ); Thu, 17 Dec 2020 03:19:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1608193149; x=1639729149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=M/hg1+/n65xzAqzOAtMxz0yiV3n+lwdo6ngwya5vN50=; b=MEihbd4nhmHesHeymToy8qlKKmpluxJPNOWY6ZZCG6Udbl9TKnc+62A/ DtN4gjb5JV/911UAxUAw+BWLk7eFpSufgx+OoHQ/MWcKA9wnzkX6Lzpkr py8zbguN57Rzoh0hUfyNvCMNp91YpzplxHdTp2y2CK1O0de9YJM98Zo68 g=; X-IronPort-AV: E=Sophos;i="5.78,426,1599523200"; d="scan'208";a="69927765" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 17 Dec 2020 08:18:11 +0000 Received: from EX13D31EUA004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id DAB48240B25; Thu, 17 Dec 2020 08:18:09 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.162.144) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 17 Dec 2020 08:18:04 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , Author Redacted Subject: [PATCH 2/5] xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path() Date: Thu, 17 Dec 2020 09:17:24 +0100 Message-ID: <20201217081727.8253-3-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217081727.8253-1-sjpark@amazon.com> References: <20201217081727.8253-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.144] X-ClientProxiedBy: EX13D30UWC002.ant.amazon.com (10.43.162.235) 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 Signed-off-by: Author Redacted 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