Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2108160lkv; Thu, 20 May 2021 03:36:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv8++QAJJ8TFZQ316yaBU7FicmqVmEDS1QYXKQ2Frje8WCUaM3T7Dp79lkvMIHSGJt/8tW X-Received: by 2002:a05:6602:1223:: with SMTP id z3mr4815958iot.97.1621506969019; Thu, 20 May 2021 03:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621506969; cv=none; d=google.com; s=arc-20160816; b=d0O7M+BfojSrHArAS3rkmZaMlYL6NM0I7cSE2HDJJPeSmnXT3WMdJAV+QNsEzNMxEs Utqr/mui541lEJ/rn9XXVh2NBnhoyEg/FSOApfWsBHdqh+ixeSLWrpCEcysp16lIIBA4 pWkmJ+ZcaGXqOGF2LR5b3zbPMuSPBFIcggEE7oC6xFgzL7v4dPJ4LTW7SjVAEwqD1Trg mBZnweVPH03lugQOzvfOIqlwgRGtQzt+Pbbo3+gnP5rTCkADEiYhlZ7dgU6WLazATwK5 GK9gLYpXiGlOOpgmHB6aNq3MEtQYVbbWZjzodsNI7tAPfurbJxVMbdg7GQmfEwBzsUXq ipMQ== 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=0b/Cf4hxltWgl15PXI7QUmkzpIOAcOJNN+yaqjU55g8=; b=EanyiSBPaFj3WrmLOWF3uc0D0RJUFoe795Lbz+xTw2QjP2RDgjQZb3gX/gJBSB51wE yhACIJK3Cy5Wix4SFFtANW6Hs9zc1KK89TUARcmg8FlhzckMsEg0yui81XLAjT4ppsso 0jH5VmO0eOx5Rk14L/zG52z/jr9T84DKQjMGEP31ALddcfvqZvrqItiitFOxzzPTidOd gKgGpfxHTX3A9xkSBMWtZs+jrQSVeoQDqutP9PqN1mbd3xqm1Mkx5CyF4Z/hBay3pDTQ pX4lLkpvvDRA2EnUH+JWffqoAtE+Qd6ovsR9mlQIFbX2muPZlsfRtrLdoSo5Zj4FAZfs 3T1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E8FFFIkL; 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 t4si2219896iom.3.2021.05.20.03.35.52; Thu, 20 May 2021 03:36:09 -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=E8FFFIkL; 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 S237480AbhETKel (ORCPT + 99 others); Thu, 20 May 2021 06:34:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235060AbhETKVK (ORCPT ); Thu, 20 May 2021 06:21:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D0B7619C6; Thu, 20 May 2021 09:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504072; bh=2d1CnJ5rJbw1/cXoVBw1vIIysyl6VGjNysbHa3yMiKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8FFFIkLuq5BPuRm2Z7PdG2e+t4GQpb/l3LpEtd0yKV/shldzAf9U1Omg3j+5uihr mTzDFjKwt6x5skKbfNVTWwUAl0zWEE5bnJVv1nNPNsayFPVGrcVW3uoIIuD06OMA+1 /bI+PclIQGrjslSygDLIbysVVcci3fhsQ8Y/FK7U= 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 4.14 079/323] ACPI: GTDT: Dont corrupt interrupt mappings on watchdow probe failure Date: Thu, 20 May 2021 11:19:31 +0200 Message-Id: <20210520092122.796479096@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -332,7 +332,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 @@ -341,7 +341,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); @@ -351,10 +351,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--; @@ -367,7 +368,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); }