Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp743217pxp; Fri, 11 Mar 2022 13:59:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxH6qNxyldBeoHsDno/3OELsjxl22QtCSO+7a/twp/zZ/93bioIiIlCThIsIlSGB6WljmUL X-Received: by 2002:a17:902:cf04:b0:14d:79fd:a2c9 with SMTP id i4-20020a170902cf0400b0014d79fda2c9mr12563468plg.104.1647035948284; Fri, 11 Mar 2022 13:59:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647035948; cv=none; d=google.com; s=arc-20160816; b=rGRIRbwJkc+3/P8K1KeiSjmyYDp2CfIDfcrxAYPHok6tVCsp21Bun3wZWtsukzEbR0 Kg3JHf1rHlMy2qR3Hq7IR5UeR/Y7VknQuC6fBhlh0VputxjpnpAPMF4eyie+SRzhQC7E 1nmM6YNPkENPi3elkSC596nUakOQQMQ8DmjNyY3+mWGIaHm+3Z8srEq8zO+hiyJYQ9X1 RE3s9J5iZ1FOtPGzVfZyvDDExdZYv+Wv+pzCoNR1Am5BVzaoLol6rnwWJMhYGGxzF408 YeCDV+L2GYk9+8Cwbqd/0+Us9iesoVDwu/L/bxJPDvn+Iq5HkXGAIFmbux34Lvoc5Pe8 j5Uw== 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=jJwBMdeQwKWvPNPRbgPFWKL5WOr8SuMQu5+4XvrVEBY=; b=LLRXPHeaGk5gdsBPMKdEXMf/INJScyBwTGC1dWDH0983GrPtGqB5DhxI16DlPZHMz5 3Rdn9embZdSHfgJpkE89QjpaC5XWAMc7RlP7zN9qwzi9HFty15TOgGiLMsXTy3bSaqO+ lvXTyLCcQDji0wqEtP3j3e7fqWhGe9e2xfg8OcZ+SWFgAa3G0cz3kRZh3IECh/xYZQMX grZcamKhyY6OYeUE0Qf1o/DDlgndTMvLa0nR05cdMAs5ujRz9s+1DSACyYAvsNpztMsg sZS0eH1TcgW2ZxjDY40GwNsJy2xl66nhRxX4uqMa8rf5mVdwcPg/5ha6blSBAB+86+ha +ZqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JBgHT1yg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h8-20020a170902ac8800b00151e09a4e0fsi8213222plr.43.2022.03.11.13.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:59:08 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JBgHT1yg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE9562B2C3A; Fri, 11 Mar 2022 13:16:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244871AbiCJRY1 (ORCPT + 99 others); Thu, 10 Mar 2022 12:24:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245008AbiCJRXA (ORCPT ); Thu, 10 Mar 2022 12:23:00 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E34919CCE8 for ; Thu, 10 Mar 2022 09:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646932907; x=1678468907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wDzy7/RxYYla9YQcCGWvWwhXgP+kSYMWIjEIrYoEqH4=; b=JBgHT1ygOpimoYGEBoEaZaLErJWIYwqrHaTbkj09FHYYV2qCcm0GQWOj nfnDkWAeL6XVlSNlQ/9aKRHkZ0gL/0tCxjGz4gOfaxpmaNBe8GQVupE3z dfdw5dyW1agJ+Q7QsDIs9s1yP35o1OQOeUqKq9qvrb52gWmywaWyfnH84 dZ/pp8e5jMNJeq0FOK6QTK6b3IYVkWdVFAMNIutVzwuOE5y651Tgsxlg8 YQUR0RsgV1JBjHLICFbwcyyP527AzWQEqA2TQ6bbGSKE7F76y98Bl8JSi KBf/2kNoiK+06scGjOuKeASvNzuBwmooap/MKvGHvTPVuCn1lkZMec66C g==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="255505014" X-IronPort-AV: E=Sophos;i="5.90,171,1643702400"; d="scan'208";a="255505014" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 09:21:21 -0800 X-IronPort-AV: E=Sophos;i="5.90,171,1643702400"; d="scan'208";a="688732500" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 09:21:21 -0800 From: ira.weiny@intel.com To: Dave Hansen , "H. Peter Anvin" , Dan Williams Cc: Ira Weiny , Fenghua Yu , Rick Edgecombe , "Shankar, Ravi V" , linux-kernel@vger.kernel.org Subject: [PATCH V9 25/45] entry: Add calls for save/restore auxiliary pt_regs Date: Thu, 10 Mar 2022 09:19:59 -0800 Message-Id: <20220310172019.850939-26-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310172019.850939-1-ira.weiny@intel.com> References: <20220310172019.850939-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Some architectures have auxiliary pt_regs space which is available to store extra information on the stack. For ease of implementation the common C code was left to fill in the data when needed. Add calls to the architecture save and restore auxiliary pt_regs functions. Define empty calls for any architecture which does not have auxiliary pt_regs. NOTE: Due to the split nature of the Xen exit code irqentry_exit_cond_resched() requires an unbalanced call to arch_restore_aux_pt_regs() regardless of the nature of the preemption configuration. Signed-off-by: Ira Weiny --- Changes for V9 Update commit message Changes for V8 New patch which introduces a generic auxiliary pt_register save restore. --- include/linux/entry-common.h | 7 +++++++ kernel/entry/common.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 14fd329847e7..b243f1cfd491 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -99,6 +99,13 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs } #endif +#ifndef CONFIG_ARCH_HAS_PTREGS_AUXILIARY + +static inline void arch_save_aux_pt_regs(struct pt_regs *regs) { } +static inline void arch_restore_aux_pt_regs(struct pt_regs *regs) { } + +#endif + /** * enter_from_user_mode - Establish state when coming from user mode * diff --git a/kernel/entry/common.c b/kernel/entry/common.c index f4210a7fc84d..c778e9783361 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -323,7 +323,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) if (user_mode(regs)) { irqentry_enter_from_user_mode(regs); - return ret; + goto aux_save; } /* @@ -362,7 +362,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) instrumentation_end(); ret.exit_rcu = true; - return ret; + goto aux_save; } /* @@ -377,6 +377,11 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) trace_hardirqs_off_finish(); instrumentation_end(); +aux_save: + instrumentation_begin(); + arch_save_aux_pt_regs(regs); + instrumentation_end(); + return ret; } @@ -408,6 +413,7 @@ static void exit_cond_resched(void) void irqentry_exit_cond_resched(struct pt_regs *regs) { + arch_restore_aux_pt_regs(regs); exit_cond_resched(); } @@ -415,6 +421,10 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) { lockdep_assert_irqs_disabled(); + instrumentation_begin(); + arch_restore_aux_pt_regs(regs); + instrumentation_end(); + /* Check whether this returns to user mode */ if (user_mode(regs)) { irqentry_exit_to_user_mode(regs); @@ -464,6 +474,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs) instrumentation_begin(); trace_hardirqs_off_finish(); ftrace_nmi_enter(); + arch_save_aux_pt_regs(regs); instrumentation_end(); return irq_state; @@ -472,6 +483,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs) void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state) { instrumentation_begin(); + arch_restore_aux_pt_regs(regs); ftrace_nmi_exit(); if (irq_state.lockdep) { trace_hardirqs_on_prepare(); -- 2.35.1