Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3208204pxb; Mon, 9 Nov 2020 05:37:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbat9T21x9ZM2s2+rzxf6slJtY79NLhTeMdeGh2ScyuyB9KHzXohcqeQihRcll+BZzyoac X-Received: by 2002:a50:bc02:: with SMTP id j2mr16049032edh.317.1604929072436; Mon, 09 Nov 2020 05:37:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929072; cv=none; d=google.com; s=arc-20160816; b=nrzLvBD/ureLH1Gc7HdF//7nLdkgIdkxqQC5gMKowu8ADYlfu5bhIiwf2Fcbu56TyS 7owXc/+YPgTfuvDt2qE9e0Nt/wUkyUP/0QXQsWN1XoE4MBuGtf+HgtpGDAGB1G3W8woJ Bow4n2pSjXoF6fBgzC8IGcpEAwyA/688/x9y7V9gHgRSr+B2MWUwgrNwJupCX6naRbQy 7eCsUtNONGm6nkpMII+EkqmufS3R4eH2U2fPPWuW2KbqHScu1opDoC3rFS6oFWPCU0sb 5HcU+MPITjPEw2DfpVT0ClDhBcCt4R+VpakjTFFDZYeXL9L1YE6+aRnnqpcLTA7M709U UWIQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=09Fjy3DIdiIWlWpwtC6nzJO4+GUl701i5ouM+n3ubnk=; b=Qmhit8CFr6H/D00lWcw7mXJLZG05wx3+rLPy/xe8js8/u80Lb+PDZk9HGaybTOngAS HKdyFxfu/im2pmQ/l8vSdP06kSYzrDk2k0MIXfQlNyWvd6ZJ0FixNHWMx6IEXr7XI9kK Em8u8nM8m7dZmZvxUHHvFeo8xcTJeWSwIegRsHIFpaa53hBz0TnT+6xkV1ZIVMZmiLQk 8nXUZRV5tjcm17jbFn3gCaQMSSLQCInMeHWhzsVBzEElIsIffeqqeEkZCfg6Ol6d8MeF XAbaGHcqR7PR/2Mr8lt5mMytMJFWNu0D66CiLNXhyTzEzo6uySexhwV0py+J6jOLRxXI yRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hPV0TLQM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si6991785edq.576.2020.11.09.05.37.29; Mon, 09 Nov 2020 05:37:52 -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=@kernel.org header.s=default header.b=hPV0TLQM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731828AbgKINdl (ORCPT + 99 others); Mon, 9 Nov 2020 08:33:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:59042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731055AbgKINGX (ORCPT ); Mon, 9 Nov 2020 08:06:23 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D979216C4; Mon, 9 Nov 2020 13:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927178; bh=HHnj1utKXUgABVCCmuo7SJDoE6X7E/TgAIv24PHlGfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPV0TLQM/GiQVq86YV4IbLOlhvgw8zFrAkvwZjzas/wcUt8JwjbzImW+IvNIOxFiz 5KGSM3pB+jEn05qJioJFXKKjjm8TM5q2VBSrKYkuU0Xa0hOvLlNlmRjyL/zn6L0RN0 UP+rUv2UMcK8FXPQ+IX8R3PVYmV1XYZ5o9TsVQSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Stefan Bader , Boris Ostrovsky , Ben Hutchings Subject: [PATCH 4.14 02/48] xen/events: dont use chip_data for legacy IRQs Date: Mon, 9 Nov 2020 13:55:11 +0100 Message-Id: <20201109125016.859402737@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125016.734107741@linuxfoundation.org> References: <20201109125016.734107741@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 0891fb39ba67bd7ae023ea0d367297ffff010781 upstream. 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 Tested-by: Stefan Bader Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/r/20200930091614.13660-1-jgross@suse.com Signed-off-by: Juergen Gross [bwh: Backported to 4.9: adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_base.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -90,6 +90,8 @@ static bool (*pirq_needs_eoi)(unsigned i /* 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; @@ -154,7 +156,18 @@ int get_evtchn_to_irq(unsigned 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. */ @@ -375,7 +388,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); } @@ -424,14 +437,14 @@ static int __must_check xen_allocate_irq 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); @@ -601,7 +614,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); static void __unbind_from_irq(unsigned int irq) { int 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--; @@ -1105,7 +1118,7 @@ int bind_ipi_to_irqhandler(enum ipi_vect 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; @@ -1139,7 +1152,7 @@ int evtchn_make_refcounted(unsigned int if (irq == -1) return -ENOENT; - info = irq_get_chip_data(irq); + info = info_for_irq(irq); if (!info) return -ENOENT; @@ -1167,7 +1180,7 @@ int evtchn_get(unsigned int evtchn) if (irq == -1) goto done; - info = irq_get_chip_data(irq); + info = info_for_irq(irq); if (!info) goto done;