Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1520997pxb; Thu, 14 Apr 2022 07:57:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT69GVDj6JENAyyoVXEls8HHFhPzHCztnKNMNPwW0hPAYGFUKzoD5GC0w8UEo0APiqHpzP X-Received: by 2002:a05:6402:1385:b0:413:2bc6:4400 with SMTP id b5-20020a056402138500b004132bc64400mr3499214edv.94.1649948245649; Thu, 14 Apr 2022 07:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649948245; cv=none; d=google.com; s=arc-20160816; b=oL/mvdqpuTzIAM+/fzZSZP/jKkTbNRaJbdGlePfAusXaBo+jsx0WqO6iyhvXbSIlQ7 vbx7gy/yR8G6FITiwJ6lZ/npxGFG45GGm0DRAtit2jzQxFGXCGEz2qDFeJdYn5eQImab C9/RXnXTiGzzJm5IgaA939Y6EOw3YcfMUEw0Oo4n26RZmd3AhxEJNjrxmVoWnvrbwhTl Eya8KnLKNFV4CG5ThtDii2OF/+Bu3dgwO1+VHMhvU7Q1mtJcNws98aLIfNcfeMD+3Xy4 zptqH6A4rkBogg+H0I9jl+4CC0gdWi/F68wBfyGrun0bVi+5SANKxCh0aFpskdLy17vh OwGA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k1Ti9WI7kQjXH/LtbtJpqTp8bomGV2aI21uzEA+/hgk=; b=QD8/0Vh48BYbpNeejzWArsisgN5KjSqQgOn2yQYYljqBNCxigj5wgHEDpV7id6nRBk /IgZa4YAooS4MlJ108KyWPmtDIKy0p7uLI30u5RaYOKUBpqeb8Pry+LFw6X3LR5iGiS8 f3SmpwTFWqQQvlH42sR4LijhtfWzBWUSY3NbOtfaRPozy5opAyKTnqtXuSfi7EZ4RGHr NnYo8xEuvB2sHKHKxTQTMxlDSlTktyTrOlwdXvoIZvOsSbFnUmmt+KPu/BI06tG9BAO9 QaMbkUCAshmdl7XdMFslzH9aHgWXp/xzgh8zUwU9VQaZ9sR9GcGI5Bp819FI9arPfLxr ilAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nykjmmr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt20-20020a170906aad400b006e8bbe5043fsi2002187ejb.588.2022.04.14.07.56.59; Thu, 14 Apr 2022 07:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nykjmmr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238370AbiDMTau (ORCPT + 99 others); Wed, 13 Apr 2022 15:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238342AbiDMTal (ORCPT ); Wed, 13 Apr 2022 15:30:41 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50AEF73070 for ; Wed, 13 Apr 2022 12:28:19 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1649878095; 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: in-reply-to:in-reply-to:references:references; bh=k1Ti9WI7kQjXH/LtbtJpqTp8bomGV2aI21uzEA+/hgk=; b=nykjmmr0sgX45Kb38uAO4roxOKHuFvGqKVhaS7htTLEqnKboJlyPfvkJ7xqMlLAFN7fzbn 3YYgvkl0RZ4Ec+gP9PtkVsgLLXTl5jPx7gAw4RlzgAdUTBNII6VaYVnmBXQoYKlKY9XQnv 1JRuxhqmlIdwpkIELUxCGbVISHZ0MR8= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko , Mark Rutland Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Catalin Marinas , Will Deacon , Vincenzo Frascino , Sami Tolvanen , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v3 1/3] arm64, scs: expose irq_shadow_call_stack_ptr Date: Wed, 13 Apr 2022 21:26:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov When a hardirq happens, the Shadow Call Stack (SCS) pointer is switched to a per-hardirq one, which is stored in irq_shadow_call_stack_ptr per-CPU. Collecting stack traces based on SCS in hardirqs requires access to irq_shadow_call_stack_ptr. Expose irq_shadow_call_stack_ptr in arch/arm64/include/asm/scs.h. For symmetry, move sdei_shadow_call_stack_normal_ptr and sdei_shadow_call_stack_critical_ptr declarations there too. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/scs.h | 10 +++++++++- arch/arm64/kernel/irq.c | 4 +--- arch/arm64/kernel/sdei.c | 3 --- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/scs.h b/arch/arm64/include/asm/scs.h index 8297bccf0784..9d9ac04014f1 100644 --- a/arch/arm64/include/asm/scs.h +++ b/arch/arm64/include/asm/scs.h @@ -24,6 +24,14 @@ .endm #endif /* CONFIG_SHADOW_CALL_STACK */ -#endif /* __ASSEMBLY __ */ +#else /* __ASSEMBLY__ */ + +#include + +DECLARE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr); +DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr); +DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr); + +#endif /* __ASSEMBLY__ */ #endif /* _ASM_SCS_H */ diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index bda49430c9ea..9d85c82f0b1c 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -21,6 +21,7 @@ #include #include #include +#include #include /* Only access this in an NMI enter/exit */ @@ -28,9 +29,6 @@ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts); DEFINE_PER_CPU(unsigned long *, irq_stack_ptr); - -DECLARE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr); - #ifdef CONFIG_SHADOW_CALL_STACK DEFINE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr); #endif diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c index d20620a1c51a..882f88ce8d4d 100644 --- a/arch/arm64/kernel/sdei.c +++ b/arch/arm64/kernel/sdei.c @@ -39,9 +39,6 @@ DEFINE_PER_CPU(unsigned long *, sdei_stack_normal_ptr); DEFINE_PER_CPU(unsigned long *, sdei_stack_critical_ptr); #endif -DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr); -DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr); - #ifdef CONFIG_SHADOW_CALL_STACK DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr); DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr); -- 2.25.1