From patchwork Fri May 1 16:19:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 186036 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp793783ilf; Fri, 1 May 2020 09:19:58 -0700 (PDT) X-Received: by 2002:a5d:6b89:: with SMTP id n9mr4922443wrx.356.1588349998679; Fri, 01 May 2020 09:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588349998; cv=none; d=google.com; s=arc-20160816; b=evbyZhESf0vZfvVFYOTmKFB7XBuIsBJPjh2A88lrcwqXqkN1rVcbcUUTqjbfATx21G 8kMIrDwlFpEtvwvq3Mz+ckQTNq6vCrkfAsDzzdAg85bRjWjU4lbs1hqhzA4yXpeHikw0 SN/iRFtRjZFTVPY7B/2wsWFJ+M8GCOAo10SVjJQ8ItmNZzhS83WEkvrTzRjVJa3UOKBl VkNw8VEUTzUAGr4KzwZLD62seU9z7F7tEAyVcn49W8njRe2f0N9QBxyofsc64nJnMYJe Hci8PNOhE3kYh77Jy2ArOnQK6PSjP2ZdE88XpxMwdE0fLU1z2N0H56ie0ZMlQ6HtWtzk xMcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Xq8gwi8GSwXFvqdFVywCJSsl3feyfQ65SGiht+YKk6g=; b=tu8cwHEW+LG7uVPFzwgoszxhhgoCsJnSty59Zkr0NcctUTljZCoWnVZuA8tHJkI2fa 6yaO7xymqGeLvWk2yF8eL2FFJ6XJB6QQpdTDNcfoa/fDEkIS027l/lrZmuy7Wau7r7r4 fiOrcRNEC9l+onjsh3wuriPHlKKPtBKBKknWPv8u5xUHuddDi0SKo5OYdoFpoXOdg9Bh C5EUrnYET8EQr+FuGWYxWhSrm9k153g45R0/qOAO1UVa8ebo4OrKu/tfEIl9e6n5Icsc OqctUzHCM21ylEZtzKy50ZE/Yj1Nh4COypKt6JpckE4sp56J57ucDw+LPvC+hoTKICq3 Bg0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zPXHbASQ; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b11sor645492wru.29.2020.05.01.09.19.58 for (Google Transport Security); Fri, 01 May 2020 09:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zPXHbASQ; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Xq8gwi8GSwXFvqdFVywCJSsl3feyfQ65SGiht+YKk6g=; b=zPXHbASQoqBg1Npt8Xzk7yRKEqfpEuY7QvZ+IoFuU4VN/odUmoWdUy5Cz+U0MfOaUE 57aux5SMXGvxyPCXn3FSARElWT+5U9lNI1PMOCJX0oo4LSTISVLw2MZRMW4jBqWHv0Sx dhW/SEMp6ZuFzgQylGhx130zFM6abaEh8V1S4P6yRYVSF+hZ+ISSsIQ2RMBq2Y52OKoS 3+RDkp8idiO+IIly+5sfufjOAbwnEws+Yi7YnShsQnspUoqTJPyue8zgSFlnL3SZWYhO 0Qajiy6bhRZWH8taWBHjSmvNkavetqo2dN1E33rugXfXENcPkXkYW8jaJaIacQagbf/g etPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Xq8gwi8GSwXFvqdFVywCJSsl3feyfQ65SGiht+YKk6g=; b=LB+8gmpdNLCPmBqt3n+yBEx+R4PsL0XZVGzU5TrBWv7CJEYkvz820c/Ge6Dcf2A1Zl SiEB7wa/f/nXE3RpjvpKE9qukOdEY1UGVGJnDkYBeCO9/kidbY5npr0LPYu8KQnbWED+ 5DvS0KEGK/QdwMgitkYNbTr5QnHhe7b7GONtOxGxipOn/U2IZCDh3iEia0nhARXcE6Gt lA6bAQ9AYq1GrYRRKTMg0R1mGx7g/poPhw7A1IjBas+F3qAOK6sCx7ArJLosyimOS2UJ rzgWf7xNj/zS598iSp2k6iQSocnlNN4ySgrHPyeFSiGmBzKjWMRV9r5iIRkDQQKxou7T DSHA== X-Gm-Message-State: AGi0PuZqsfcPBspMalxUA1kCZk4jbbOc3S2BWaYdL19kUx6v+hTzzb9T VqubLwxkQynprMKyrfrD4GOWeElK X-Google-Smtp-Source: APiQypJdqqAmA5NZRljQci8YaPRabwage+tSbfJLtETNB78EkLvJaFcS7Q763kbrV3j/xjoej9nRRg== X-Received: by 2002:a5d:60ca:: with SMTP id x10mr4812672wrt.407.1588349998229; Fri, 01 May 2020 09:19:58 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id h2sm5644313wro.9.2020.05.01.09.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 09:19:57 -0700 (PDT) From: Daniel Thompson To: Catalin Marinas , Will Deacon Cc: Daniel Thompson , Douglas Anderson , Jason Wessel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH] arm64: cacheflush: Fix KGDB trap detection Date: Fri, 1 May 2020 17:19:38 +0100 Message-Id: <20200501161938.2949443-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 flush_icache_range() contains a bodge to avoid issuing IPIs when the kgdb trap handler is running because issuing IPIs is unsafe (and unnecessary) in this exection context. However the current test is flawed: it both over-matches (could skip the IPI when the kgdb trap is not running) and under-matches (does not skip the IPI for all kgdb cache operations). Fix by replacing the ad-hoc check with the proper kgdb macro. This also allows us to drop the #ifdef wrapper. Fixes: 3b8c9f1cdfc5 ("arm64: IPI each CPU after invalidating the I-cache for kernel mappings") Signed-off-by: Daniel Thompson --- arch/arm64/include/asm/cacheflush.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c -- 2.25.1 Reviewed-by: Douglas Anderson diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h index e6cca3d4acf7..ce50c1f1f1ea 100644 --- a/arch/arm64/include/asm/cacheflush.h +++ b/arch/arm64/include/asm/cacheflush.h @@ -79,7 +79,7 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) * IPI all online CPUs so that they undergo a context synchronization * event and are forced to refetch the new instructions. */ -#ifdef CONFIG_KGDB + /* * KGDB performs cache maintenance with interrupts disabled, so we * will deadlock trying to IPI the secondary CPUs. In theory, we can @@ -89,9 +89,9 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) * the patching operation, so we don't need extra IPIs here anyway. * In which case, add a KGDB-specific bodge and return early. */ - if (kgdb_connected && irqs_disabled()) + if (in_dbg_master()) return; -#endif + kick_all_cpus_sync(); }