From nobody Thu May 2 15:30:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1601457405; cv=none; d=zohomail.com; s=zohoarc; b=bTOlVwmxAd8R7OJMDlrl/7geIKoczx/VsOwb3pjTwuBi7Xe1N/qyjlRE4XNrS+hnp8owhreYM8mvV9ZqXPKyg+Yz7Xg9RhhhZhtMrI6aZvnXg8ZSWLGoR56bJigteYp3vPfASpWGaLqgvOdXG9To3TJaHmFi3us4Brr/thLVlHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601457405; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=w36Rzrz5XUNYFQzlz0bmqYe/dXsy1jXbycdq061JRBo=; b=A2bA/DMM7QAocFih0rgoJBZ+5pRhm4IoE92Tp33mEKBFmr20msx7VyxJlXspb5+BTJaEZNaettGeN62zZFJDpXNIPDAWmxqcDxrXOCN4OCQ3fxH11w+9HaPrZed6CQQNgYrHrJ22hz8tQFAO9gWaRZ7sxr5SwrXnJOnc3iMLuFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601457405242491.52074579515374; Wed, 30 Sep 2020 02:16:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510.1653 (Exim 4.92) (envelope-from ) id 1kNYDk-0000Lq-LZ; Wed, 30 Sep 2020 09:16:20 +0000 Received: by outflank-mailman (output) from mailman id 510.1653; Wed, 30 Sep 2020 09:16:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNYDk-0000Lj-Hl; Wed, 30 Sep 2020 09:16:20 +0000 Received: by outflank-mailman (input) for mailman id 510; Wed, 30 Sep 2020 09:16:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNYDj-0000Le-K8 for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 09:16:19 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c2c67d14-66c7-47e2-95f5-5dcce39531d3; Wed, 30 Sep 2020 09:16:18 +0000 (UTC) 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) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNYDj-0000Le-K8 for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 09:16:19 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c2c67d14-66c7-47e2-95f5-5dcce39531d3; Wed, 30 Sep 2020 09:16:18 +0000 (UTC) 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) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c2c67d14-66c7-47e2-95f5-5dcce39531d3 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= 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: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Since commit c330fb1ddc0a ("XEN uses irqdesc::irq_data_common::handler_data= to store a per interrupt XEN data pointer which contains XEN specific info= rmation.") 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 st= ore a per interrupt XEN data pointer which contains XEN specific informatio= n.") Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Tested-by: Stefan Bader --- 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_b= ase.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) !=3D 0) =20 +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] =3D info; + else + irq_set_chip_data(irq, info); } =20 /* Constructors for packed IRQ information. */ @@ -377,7 +390,7 @@ static void xen_irq_init(unsigned irq) info->type =3D IRQT_UNBOUND; info->refcnt =3D -1; =20 - irq_set_chip_data(irq, info); + set_info_for_irq(irq, info); =20 list_add_tail(&info->list, &xen_irq_list_head); } @@ -426,14 +439,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned= gsi) =20 static void xen_free_irq(unsigned irq) { - struct irq_info *info =3D irq_get_chip_data(irq); + struct irq_info *info =3D info_for_irq(irq); =20 if (WARN_ON(!info)) return; =20 list_del(&info->list); =20 - irq_set_chip_data(irq, NULL); + set_info_for_irq(irq, NULL); =20 WARN_ON(info->refcnt > 0); =20 @@ -603,7 +616,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); static void __unbind_from_irq(unsigned int irq) { evtchn_port_t evtchn =3D evtchn_from_irq(irq); - struct irq_info *info =3D irq_get_chip_data(irq); + struct irq_info *info =3D info_for_irq(irq); =20 if (info->refcnt > 0) { info->refcnt--; @@ -1108,7 +1121,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi, =20 void unbind_from_irqhandler(unsigned int irq, void *dev_id) { - struct irq_info *info =3D irq_get_chip_data(irq); + struct irq_info *info =3D info_for_irq(irq); =20 if (WARN_ON(!info)) return; @@ -1142,7 +1155,7 @@ int evtchn_make_refcounted(evtchn_port_t evtchn) if (irq =3D=3D -1) return -ENOENT; =20 - info =3D irq_get_chip_data(irq); + info =3D info_for_irq(irq); =20 if (!info) return -ENOENT; @@ -1170,7 +1183,7 @@ int evtchn_get(evtchn_port_t evtchn) if (irq =3D=3D -1) goto done; =20 - info =3D irq_get_chip_data(irq); + info =3D info_for_irq(irq); =20 if (!info) goto done; --=20 2.26.2