Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1960856rwb; Fri, 5 Aug 2022 10:34:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5GCT8CLZDx8jdgEbYIizgaCt2LOQjkKUamfd/aP+uWdDEa2Vm9o89MDIrXsoJlaB/sQNFK X-Received: by 2002:a17:902:8343:b0:16d:d2ff:c91d with SMTP id z3-20020a170902834300b0016dd2ffc91dmr7528753pln.142.1659720880157; Fri, 05 Aug 2022 10:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659720880; cv=none; d=google.com; s=arc-20160816; b=orCnuWKcyR1lbEvOrNB/kw21x0cQ8sVfFs95+wSy83nFIV22AlZVVS7QYuG97puPRE WrmN4wPP0tYODmGt2371Li3YjRTQmNOtFhhTLZJL5M+sdndnPur7GqMOYeHJKf7b6rhR lN786dt5Rw8INwGDl/1awi5ZqXRiBcO+cydUKnxliHNS7Z1Kg/aPbAELtsm/L3mQ6D8t twqEVBw4BPIuGNOs42Jkw49AShLpDg8Y17Pzr1Lmz7cwEXJhwBskwsXYofpQ+KFI7gbs s2MezXc17n4WuKUqFydIhTH1MJy6zqL8d8jdhdWJGaCXMJJUSrWItcRDByv8bMjJRu9x QkXA== 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=0rOxPQq1uw5Jn1JaQNKLcUOiXP7MGx8vXz9UqAzyV2k=; b=qixy2u2HMQvGss/mtsB/vw/T3zkNt9FvWkhGs8h9tiD0uaRFVn6ZPqNR5mJ6K4s1ji lD0cW6WIS6IbgFD61ZeJ9/MdSZ9AGRI+FWBG38WBRSf803294FQx0rhicrYD1vgXlkKt xxffi+3c64sFLIE3y1B+PT4f3Ad9s7L6jeFXnobDhT8HU88OyZZe1L6qolT0cRdpN769 gMBfbQR138xxtPU950pyk+cWLsh2Aa+igDvAg1pFpCHhpsqqxcGZp3IVOiEW25MAU2ld uesN49E7JVR7+4RiRkke0GbX9njZF9tkyASVRIIr0aTfXGb6OnM+OKoolJbG6jBKBpr+ m8EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dwf8tOHy; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902bd9100b0016ec9cebe10si4155220pls.507.2022.08.05.10.34.26; Fri, 05 Aug 2022 10:34:40 -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=@intel.com header.s=Intel header.b=Dwf8tOHy; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241319AbiHERbR (ORCPT + 99 others); Fri, 5 Aug 2022 13:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241318AbiHERah (ORCPT ); Fri, 5 Aug 2022 13:30:37 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A051DA45 for ; Fri, 5 Aug 2022 10:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659720630; x=1691256630; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iUggmBbv/Gb/pP6+Y41ZS7OmaZpg2F4gACjroqSJRII=; b=Dwf8tOHyzbEVprbqAc9GRqWsYyOXda4W7shOayppfpqjLZYrT6ojQ0MH qKuVwoa8rGH+hEYVL9gV5vPA6LgYi8GPmzKVNYGZIQ0FQhUNiADH1VUCc wCXO7f6B5IYnXNd4cOQeDqq2V3yRsxwAQbYD24vHRk1Mua7wJzh2xLu4S 9hlfEEgaQ1vSErUCiB5finiUBy3pnwSkri94qckClO8fU8wQMS225IkAf Vo7BPpZxjInrXxH651zKd7Sb4VqAvw9FhdclyMeNpKV4MFNG5VVjGKgdd eFyAaok4nJ9QGjNG+K1c/i3PBTLzHMEyeyCQT6IRgbgiYM8t2k1vNttwC Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="316144805" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="316144805" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 10:30:29 -0700 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="636565369" Received: from amecham-mobl.amr.corp.intel.com (HELO localhost) ([10.255.0.242]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 10:30:28 -0700 From: ira.weiny@intel.com To: Rik van Riel , Borislav Petkov , Dave Hansen Cc: Ira Weiny , x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [RFC PATCH 5/5] x86/entry: Store CPU info on exception entry Date: Fri, 5 Aug 2022 10:30:09 -0700 Message-Id: <20220805173009.3128098-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220805173009.3128098-1-ira.weiny@intel.com> References: <20220805173009.3128098-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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: Ira Weiny The CPU information of an exception is useful in determining where bad CPUs are in a large data center. Define arch_{save|restore}_auxiliary_pt_regs() and set ARCH_HAS_PTREGS_AUXILIARY default to yes. Store the CPU on exception entry and use it later. Cc: Rik van Riel Suggested-by: Borislav Petkov Suggested-by: Dave Hansen Signed-off-by: Ira Weiny --- arch/x86/Kconfig | 2 +- arch/x86/include/asm/entry-common.h | 12 ++++++++++++ arch/x86/include/asm/ptrace.h | 1 + arch/x86/mm/fault.c | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index b35f6a472e09..707650a6ecb2 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1876,7 +1876,7 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS config ARCH_HAS_PTREGS_AUXILIARY depends on X86_64 - bool + def_bool y choice prompt "TSX enable mode" diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h index 674ed46d3ced..eb145106929a 100644 --- a/arch/x86/include/asm/entry-common.h +++ b/arch/x86/include/asm/entry-common.h @@ -95,4 +95,16 @@ static __always_inline void arch_exit_to_user_mode(void) } #define arch_exit_to_user_mode arch_exit_to_user_mode +#ifdef CONFIG_ARCH_HAS_PTREGS_AUXILIARY + +static inline void arch_save_aux_pt_regs(struct pt_regs *regs) +{ + struct pt_regs_auxiliary *aux_pt_regs = &to_extended_pt_regs(regs)->aux; + + aux_pt_regs->cpu = raw_smp_processor_id(); +} +#define arch_save_aux_pt_regs arch_save_aux_pt_regs + +#endif + #endif diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h index 5a9c85893459..b403b469996f 100644 --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -97,6 +97,7 @@ struct pt_regs { * ARCH_HAS_PTREGS_AUXILIARY. Failure to do so will result in a build failure. */ struct pt_regs_auxiliary { + int cpu; }; struct pt_regs_extended { diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 82cf23975aa1..5df99fe49494 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -768,9 +768,9 @@ static inline void show_signal_msg(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk) { + struct pt_regs_auxiliary *aux_pt_regs = &to_extended_pt_regs(regs)->aux; const char *loglvl = task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG; - /* This is a racy snapshot, but it's better than nothing. */ - int cpu = raw_smp_processor_id(); + int cpu = aux_pt_regs->cpu; if (!unhandled_signal(tsk, SIGSEGV)) return; -- 2.35.3