Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2503657pxj; Mon, 10 May 2021 04:42:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx69+unnNiRvN6wd9CFTZgjKviV65ChQ3oW0j11Sam6vrUqJsyJtwNHAEZSAQNUjMW0m40d X-Received: by 2002:a17:906:82cb:: with SMTP id a11mr25461045ejy.213.1620646946469; Mon, 10 May 2021 04:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620646946; cv=none; d=google.com; s=arc-20160816; b=OL0IlVL7aGhyvaBh/fOT2NXe4McQKyROLvgOzWYRfzXtO6+VJTAA82jkZUlpZfOO3t U7L0svFrkPfKVNBJusxdyjtihTpsuqhrDHvndPL0aFiABum4gUIXdoA+nyj+4/YtxiVZ 4DBMY14HEYc7Cw/fgN369IgGrGudgvZRmKpI395pMVgkwF6MMknmm26dIZetBzDBiwwJ DUJnUwZ6smGXXICakYRGLfjWO5j+pU288kB5ciNOSZ0jsCjTEdoySS+jAvfmPWAOtG4v KFpGbd344i2XrgC2UbUc0ZmbyZd5US2zWsty128wLL7wZ/g26NGsg2XWS57E/5fYC1gd uFPw== 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=uJ3txCIFQaL80NFSZ9PvvKn1hdzAemfpbghh/7ZymHY=; b=IcA472q5OZorBlido0/Z+08hcCAauCOLj3HjuqDLQKbbchruPCgM5ThxjrP0OlvHRp +XbZs8wGAdpcTYo/OyKeAmuF/3Beg2eqVgKjJN6w/uP5Abj77SibNfWcWI0hebAN/bjC W0jLs2V7mxhDgKB6jr5oCJq+txBBoHCwGWF4qLWLtPb+VKTT6UuOzdi7n3V9SRZ7OZ7M sG/2MVd9JyI2UvFFMSG541AOgnEL/kdsox3l4NPU3qMnasSOyfWleqXNeqOhA0kV50nD 9HccgPY+KfqPsUS/mJDbUfJJMZ/bKgrj69NI26panjPnXmdjnRW+b/yQuCVaYvmKS9G6 5Rbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BEURpvZh; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn24si13928142ejc.674.2021.05.10.04.42.02; Mon, 10 May 2021 04:42:26 -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=@linuxfoundation.org header.s=korg header.b=BEURpvZh; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241146AbhEJLhk (ORCPT + 99 others); Mon, 10 May 2021 07:37:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233774AbhEJKzL (ORCPT ); Mon, 10 May 2021 06:55:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9573461C1E; Mon, 10 May 2021 10:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643345; bh=8TUX8ebQCnnosyGIob6anlDtDbTdnqT6huL51mjRUGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEURpvZh4hvc6FlqJvRt/PNbpo3oBl5daDNi19gmk1fROGMXZ0RsEor8bw0GEpBmv O85+maKxQK/2P7qmy4sgpYiXsIAoVk9IA9EeOCeKxTHL5dm0paqHN2Nvg7DcFWetg2 vHtzPZRJzQs/gdxD19L2Bm4qxx6hgsMMrlFw29Vc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, dann frazier , Marc Zyngier , Fu Wei , Sudeep Holla , Hanjun Guo , Lorenzo Pieralisi , Catalin Marinas Subject: [PATCH 5.10 232/299] ACPI: GTDT: Dont corrupt interrupt mappings on watchdow probe failure Date: Mon, 10 May 2021 12:20:29 +0200 Message-Id: <20210510102012.624630596@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Marc Zyngier commit 1ecd5b129252249b9bc03d7645a7bda512747277 upstream. When failing the driver probe because of invalid firmware properties, the GTDT driver unmaps the interrupt that it mapped earlier. However, it never checks whether the mapping of the interrupt actially succeeded. Even more, should the firmware report an illegal interrupt number that overlaps with the GIC SGI range, this can result in an IPI being unmapped, and subsequent fireworks (as reported by Dann Frazier). Rework the driver to have a slightly saner behaviour and actually check whether the interrupt has been mapped before unmapping things. Reported-by: dann frazier Fixes: ca9ae5ec4ef0 ("acpi/arm64: Add SBSA Generic Watchdog support in GTDT driver") Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/YH87dtTfwYgavusz@xps13.dannf Cc: Cc: Fu Wei Reviewed-by: Sudeep Holla Tested-by: dann frazier Tested-by: Hanjun Guo Reviewed-by: Hanjun Guo Reviewed-by: Lorenzo Pieralisi Link: https://lore.kernel.org/r/20210421164317.1718831-2-maz@kernel.org Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/arm64/gtdt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/acpi/arm64/gtdt.c +++ b/drivers/acpi/arm64/gtdt.c @@ -329,7 +329,7 @@ static int __init gtdt_import_sbsa_gwdt( int index) { struct platform_device *pdev; - int irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags); + int irq; /* * According to SBSA specification the size of refresh and control @@ -338,7 +338,7 @@ static int __init gtdt_import_sbsa_gwdt( struct resource res[] = { DEFINE_RES_MEM(wd->control_frame_address, SZ_4K), DEFINE_RES_MEM(wd->refresh_frame_address, SZ_4K), - DEFINE_RES_IRQ(irq), + {}, }; int nr_res = ARRAY_SIZE(res); @@ -348,10 +348,11 @@ static int __init gtdt_import_sbsa_gwdt( if (!(wd->refresh_frame_address && wd->control_frame_address)) { pr_err(FW_BUG "failed to get the Watchdog base address.\n"); - acpi_unregister_gsi(wd->timer_interrupt); return -EINVAL; } + irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags); + res[2] = (struct resource)DEFINE_RES_IRQ(irq); if (irq <= 0) { pr_warn("failed to map the Watchdog interrupt.\n"); nr_res--; @@ -364,7 +365,8 @@ static int __init gtdt_import_sbsa_gwdt( */ pdev = platform_device_register_simple("sbsa-gwdt", index, res, nr_res); if (IS_ERR(pdev)) { - acpi_unregister_gsi(wd->timer_interrupt); + if (irq > 0) + acpi_unregister_gsi(wd->timer_interrupt); return PTR_ERR(pdev); }