Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp539021pxb; Fri, 28 Jan 2022 04:57:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVuGgZ/wolXLuGqz31UN5HEpcD24pTaUZwP17Pi5AIa0GZ6nT5Cy4tDGO9sDwbOFCmldKw X-Received: by 2002:a17:906:c149:: with SMTP id dp9mr6797250ejc.57.1643374636599; Fri, 28 Jan 2022 04:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643374636; cv=none; d=google.com; s=arc-20160816; b=tj3fNIsH+S9GxZH2q6BCEyyjmEbMiebU7P0j9QMlka37bBBEHw41cqDPsj7vMxxF29 X5vcYpGM07XQ1Tmbsnrc11SJpCV7SwJkCC9fAq6oouvNrhBvWaiEhuJ9io8+JXp6HP19 ry1QUgcKems7tCPPiHHz/pUBSyz1WJdglVsxjOooGnwkcKX0v8OUeKlh1Lnsj9GAH0N5 2AISBcz7F07ZMVbotTvTju3EEGC5XmpadnQDaUdabhGOG5Pgt8NxFtIi9EoKk/NUbGrB Ywq8GvwgfV9Ak+8u49SFEnV3DsoDfGIB1g7Zaq9R+bf9uGFO3G0rc7Q4f9PvZiGUi1/K SF8g== 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=b7bRtuVmJAq9IYjwG7T1XmKkVHoTKUFfdHnKPK4kPI8=; b=FNZjSJdbrgMQq2R7KKzFopxsADKuqURP0mOr/g8K2XMQX3/KAkRa1GXh3MuE+akMAy exiolGd9zqb2CyAcLPlzsFHiqchzIqwEwd8Ae/JuwoFBaP8rLHZlFwOqsVrw+eJjiOAa ZmQvMaYsrkoUa5on16Wkeyu/Bjwv1qrFmDU0D1APFS3wDG5N2L/6yNTxEXPi3T80FbgR xAPYCFH5MTIRe/f5c417r3rYBe5NxIQ0Oh1dnVlTgO+T221dODr/iypBpMTdQkN2HrY0 p6A6w3brkOwhEeo5BIllrvLW/FQ8bgBZOnpIH2zbBemIGzNPM811zt32yWGn6lg92FQa aa2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YUdbiuUE; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si1005787edc.588.2022.01.28.04.56.52; Fri, 28 Jan 2022 04:57:16 -0800 (PST) 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=@intel.com header.s=Intel header.b=YUdbiuUE; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245006AbiA0R4Q (ORCPT + 99 others); Thu, 27 Jan 2022 12:56:16 -0500 Received: from mga02.intel.com ([134.134.136.20]:19415 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244846AbiA0RzZ (ORCPT ); Thu, 27 Jan 2022 12:55:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643306125; x=1674842125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IgMfD3EDPqux6N7a9kZjEZreZVxB0l9Epm9jhn3105k=; b=YUdbiuUELgzJ9uEoxR5Z07p9EQeV19TmBQNS6bxIFnNJSgW6BoE1hpda Kf211LKBOozwxKyr1Iq/h8bH039vw6OzScZIBdt2D1AmSzTe3axNkfs4W FwOr3LD2Qa1PPifhdTvp2p+kRMqwnGpwXvszBf+ZlJNWmDnSDDEjA4Tpk iJvtKkCNTDONdyzm6Td0EjTvi3sIFg317hcPpDuOKgZcLfNNjdlrJYU4e hGfEsv+PSTREG1VtN/ojE+FZzmTLPp8uErT1DBnZLlbCR8i99H5f7vEBq 8ECOOpwkz0ImnChIfGfY9Xt5qF9P8nSrIMOGfEyBNtbiicjEs6sY6cwbM w==; X-IronPort-AV: E=McAfee;i="6200,9189,10239"; a="234302436" X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="234302436" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:11 -0800 X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="674796130" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:10 -0800 From: ira.weiny@intel.com To: Dave Hansen , "H. Peter Anvin" , Dan Williams Cc: Ira Weiny , Fenghua Yu , Rick Edgecombe , linux-kernel@vger.kernel.org Subject: [PATCH V8 23/44] entry: Add architecture auxiliary pt_regs save/restore calls Date: Thu, 27 Jan 2022 09:54:44 -0800 Message-Id: <20220127175505.851391-24-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220127175505.851391-1-ira.weiny@intel.com> References: <20220127175505.851391-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Define C calls for architectures to save and restore any auxiliary data they may need and call those from the common entry code. 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 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.31.1