Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4417018pxk; Wed, 30 Sep 2020 02:19:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2/s8X1dJj6IKRFuyn/WryMOC3c7ZqAeijHIuJU2ff+1V6pw+QttrkaiOvFi8TVXwxhHzj X-Received: by 2002:a17:906:1b15:: with SMTP id o21mr1766684ejg.377.1601457585645; Wed, 30 Sep 2020 02:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601457585; cv=none; d=google.com; s=arc-20160816; b=TvifM0u5n5Bq/ZN/jyOwILOTCzdrxFtGjcyVuMnvm8fIfHawF3FlFfY2GqNClMO/Sv 1lJSWFgUSr/Eq18TQ3HeNj42vvG0aGz/JSnXefUepDB4gGn6BRC+YIR1nzuSN1+rPnGZ yjgU37wE189du2x5xDPYfeulSNyrstXF8L+KIHypvaF1g8EfZvImIaAvk9bVHYFjqY5R WjPcgsxfB85tHGKeEwjwhh0icrW2t2QZOkQCCdWQ+c/TGgSTQQleD+/iC6x6XKbhvvIN /mrousvbb086B0j1HUI6phhFLdamRkbWU2wJfF7yma1LHzEpqwzdpdLGFPvz2x7ORUhx 13PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=w36Rzrz5XUNYFQzlz0bmqYe/dXsy1jXbycdq061JRBo=; b=gD0Ksc6S3BXRwpk/WgsNT0nKw5uPZPmk37WWI6saH107mQe+JbD5J5sQzSFBU5cE/Q mtWflGRfuZFjTwFwGJKl/v4PK6Zac4tQdp5iiMBrChW3U9dpNQGhfk993qR9XiPKz8ML K6/EB66Rg58iAtdaaWRgQNWvGutmLhwULHm9EB+abRzP/L5oE1YwRa2b6kouPyG+cFbB pU058xMHTOBQSfAYiEf80HB4nmke5QJMvRWPReX7Z4wLiWEQ4exERm2BExZUeOZIZePm vXjZI8MHwGDN5HNupor+egQfNrsxy+TmjHN7ramTZuQlQOqB4ae+qxFBL8GH0RtDfQoh RlbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UBySA8yg; 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=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si720333edv.314.2020.09.30.02.19.23; Wed, 30 Sep 2020 02:19:45 -0700 (PDT) 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=@suse.com header.s=susede1 header.b=UBySA8yg; 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=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728744AbgI3JQU (ORCPT + 99 others); Wed, 30 Sep 2020 05:16:20 -0400 Received: from mx2.suse.de ([195.135.220.15]:52534 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgI3JQT (ORCPT ); Wed, 30 Sep 2020 05:16:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601457378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=w36Rzrz5XUNYFQzlz0bmqYe/dXsy1jXbycdq061JRBo=; b=UBySA8ygsGeAU+PMR59aYW7hJ7QhySOdAj1PVTvimwPEQRSMQhtaCQWvHmNOT4WOWzUuny pf8xOOcQFr2kVKfJM2IS02N8Tmx2/UZJPqinuSZYKU6bTOHcrjqYflY6p1JrAVbowGto7K GA/F875LBkdNL+wBgc42LxlDl6sW3/w= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DCA8EB05D; Wed, 30 Sep 2020 09:16:17 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org Subject: [PATCH] xen/events: don't use chip_data for legacy IRQs Date: Wed, 30 Sep 2020 11:16:14 +0200 Message-Id: <20200930091614.13660-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit c330fb1ddc0a ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.") Xen is using the chip_data pointer for storing IRQ specific data. When running as a HVM domain this can result in problems for legacy IRQs, as those might use chip_data for their own purposes. Use a local array for this purpose in case of legacy IRQs, avoiding the double use. Cc: stable@vger.kernel.org Fixes: c330fb1ddc0a ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.") Signed-off-by: Juergen Gross --- drivers/xen/events/events_base.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 90b8f56fbadb..6f02c18fa65c 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -92,6 +92,8 @@ static bool (*pirq_needs_eoi)(unsigned irq); /* Xen will never allocate port zero for any purpose. */ #define VALID_EVTCHN(chn) ((chn) != 0) +static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY]; + static struct irq_chip xen_dynamic_chip; static struct irq_chip xen_percpu_chip; static struct irq_chip xen_pirq_chip; @@ -156,7 +158,18 @@ int get_evtchn_to_irq(evtchn_port_t evtchn) /* Get info for IRQ */ struct irq_info *info_for_irq(unsigned irq) { - return irq_get_chip_data(irq); + if (irq < nr_legacy_irqs()) + return legacy_info_ptrs[irq]; + else + return irq_get_chip_data(irq); +} + +static void set_info_for_irq(unsigned int irq, struct irq_info *info) +{ + if (irq < nr_legacy_irqs()) + legacy_info_ptrs[irq] = info; + else + irq_set_chip_data(irq, info); } /* Constructors for packed IRQ information. */ @@ -377,7 +390,7 @@ static void xen_irq_init(unsigned irq) info->type = IRQT_UNBOUND; info->refcnt = -1; - irq_set_chip_data(irq, info); + set_info_for_irq(irq, info); list_add_tail(&info->list, &xen_irq_list_head); } @@ -426,14 +439,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi) static void xen_free_irq(unsigned irq) { - struct irq_info *info = irq_get_chip_data(irq); + struct irq_info *info = info_for_irq(irq); if (WARN_ON(!info)) return; list_del(&info->list); - irq_set_chip_data(irq, NULL); + set_info_for_irq(irq, NULL); WARN_ON(info->refcnt > 0); @@ -603,7 +616,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); static void __unbind_from_irq(unsigned int irq) { evtchn_port_t evtchn = evtchn_from_irq(irq); - struct irq_info *info = irq_get_chip_data(irq); + struct irq_info *info = info_for_irq(irq); if (info->refcnt > 0) { info->refcnt--; @@ -1108,7 +1121,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi, void unbind_from_irqhandler(unsigned int irq, void *dev_id) { - struct irq_info *info = irq_get_chip_data(irq); + struct irq_info *info = info_for_irq(irq); if (WARN_ON(!info)) return; @@ -1142,7 +1155,7 @@ int evtchn_make_refcounted(evtchn_port_t evtchn) if (irq == -1) return -ENOENT; - info = irq_get_chip_data(irq); + info = info_for_irq(irq); if (!info) return -ENOENT; @@ -1170,7 +1183,7 @@ int evtchn_get(evtchn_port_t evtchn) if (irq == -1) goto done; - info = irq_get_chip_data(irq); + info = info_for_irq(irq); if (!info) goto done; -- 2.26.2