public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vineet Gupta <vgupta@kernel.org>
To: linux-snps-arc@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
	Shahab Vahedi <Shahab.Vahedi@synopsys.com>,
	Alexey Brodkin <abrodkin@synopsys.com>,
	Vineet Gupta <vgupta@kernel.org>
Subject: [PATCH 19/20] ARCv2: entry: rearrange pt_regs slightly
Date: Mon, 14 Aug 2023 17:48:12 -0700	[thread overview]
Message-ID: <20230815004813.555115-20-vgupta@kernel.org> (raw)
In-Reply-To: <20230815004813.555115-1-vgupta@kernel.org>

Instead of r26,fp,sp,r12,r30 order as fp,r30,r12,r26,sp

 - keeps SP at well known position (right abive hardware autosave)
 - r26,r12 saved specifically for ARCv2 (and not in ARCv3) kept
   closer for easy ifdef'ry later

Signed-off-by: Vineet Gupta <vgupta@kernel.org>
---
 arch/arc/include/asm/entry-arcv2.h | 12 ++++++------
 arch/arc/include/asm/ptrace.h      |  9 +++++----
 arch/arc/kernel/asm-offsets.c      |  7 ++++---
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/arch/arc/include/asm/entry-arcv2.h b/arch/arc/include/asm/entry-arcv2.h
index a030eae93d35..4d13320e0c1b 100644
--- a/arch/arc/include/asm/entry-arcv2.h
+++ b/arch/arc/include/asm/entry-arcv2.h
@@ -149,10 +149,10 @@
  */
 .macro __SAVE_REGFILE_SOFT
 
-	ST2	gp, fp, PT_r26		; gp (r26), fp (r27)
-
-	st	r12, [sp, PT_r12]
+	st	fp,  [sp, PT_fp]	; r27
 	st	r30, [sp, PT_r30]
+	st	r12, [sp, PT_r12]
+	st	r26, [sp, PT_r26]	; gp
 
 	; Saving pt_regs->sp correctly requires some extra work due to the way
 	; Auto stack switch works
@@ -187,10 +187,10 @@
 /*------------------------------------------------------------------------*/
 .macro __RESTORE_REGFILE_SOFT
 
-	LD2	gp, fp, PT_r26		; gp (r26), fp (r27)
-
-	ld	r12, [sp, PT_r12]
+	ld	fp,  [sp, PT_fp]
 	ld	r30, [sp, PT_r30]
+	ld	r12, [sp, PT_r12]
+	ld	r26, [sp, PT_r26]
 
 	; Restore SP (into AUX_USER_SP) only if returning to U mode
 	;  - for K mode, it will be implicitly restored as stack is unwound
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 2bf8ea96ea21..3a054b695f28 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -77,11 +77,10 @@ struct pt_regs {
 
 	unsigned long bta;	/* erbta */
 
-	unsigned long r26;	/* gp */
 	unsigned long fp;
-	unsigned long sp;	/* user/kernel sp depending on where we came from  */
-
-	unsigned long r12, r30;
+	unsigned long r30;
+	unsigned long r12;
+	unsigned long r26;	/* gp */
 
 #ifdef CONFIG_ARC_HAS_ACCL_REGS
 	unsigned long r58, r59;	/* ACCL/ACCH used by FPU / DSP MPY */
@@ -90,6 +89,8 @@ struct pt_regs {
 	unsigned long DSP_CTRL;
 #endif
 
+	unsigned long sp;	/* user/kernel sp depending on entry  */
+
 	/*------- Below list auto saved by h/w -----------*/
 	unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
 
diff --git a/arch/arc/kernel/asm-offsets.c b/arch/arc/kernel/asm-offsets.c
index e46688975868..478768c88f46 100644
--- a/arch/arc/kernel/asm-offsets.c
+++ b/arch/arc/kernel/asm-offsets.c
@@ -62,11 +62,9 @@ int main(void)
 	DEFINE(PT_r26, offsetof(struct pt_regs, r26));
 	DEFINE(PT_ret, offsetof(struct pt_regs, ret));
 	DEFINE(PT_blink, offsetof(struct pt_regs, blink));
+	OFFSET(PT_fp, pt_regs, fp);
 	DEFINE(PT_lpe, offsetof(struct pt_regs, lp_end));
 	DEFINE(PT_lpc, offsetof(struct pt_regs, lp_count));
-	DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs));
-	DEFINE(SZ_PT_REGS, sizeof(struct pt_regs));
-
 #ifdef CONFIG_ISA_ARCV2
 	OFFSET(PT_r12, pt_regs, r12);
 	OFFSET(PT_r30, pt_regs, r30);
@@ -79,5 +77,8 @@ int main(void)
 	OFFSET(PT_DSP_CTRL, pt_regs, DSP_CTRL);
 #endif
 
+	DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs));
+	DEFINE(SZ_PT_REGS, sizeof(struct pt_regs));
+
 	return 0;
 }
-- 
2.34.1


  parent reply	other threads:[~2023-08-15  0:49 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15  0:47 [PATCH 00/20] ARC updates Vineet Gupta
2023-08-15  0:47 ` [PATCH 01/20] ARC: uaccess: remove arc specific out-of-line handles for -Os Vineet Gupta
2023-08-15  0:47 ` [PATCH 02/20] ARC: uaccess: use optimized generic __strnlen_user/__strncpy_from_user Vineet Gupta
2023-08-15  0:47 ` [PATCH 03/20] ARC: uaccess: elide unaliged handling if hardware supports Vineet Gupta
2023-08-15  0:47 ` [PATCH 04/20] ARCv2: memset: don't prefetch for len == 0 which happens a alot Vineet Gupta
2023-08-15  0:47 ` [PATCH 05/20] ARC: boot log: eliminate struct cpuinfo_arc #1: mm Vineet Gupta
2023-08-15  0:47 ` [PATCH 06/20] ARC: boot log: eliminate struct cpuinfo_arc #2: cache Vineet Gupta
2023-08-15  0:48 ` [PATCH 07/20] ARC: boot log: eliminate struct cpuinfo_arc #3: don't export Vineet Gupta
2023-08-15  0:48 ` [PATCH 08/20] ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA Vineet Gupta
2023-08-15  0:48 ` [PATCH 09/20] ARC: entry: use gp to cache task pointer (vs. r25) Vineet Gupta
2023-08-15  0:48 ` [PATCH 10/20] ARC: kernel stack: INIT_THREAD need not setup @init_stack in @ksp Vineet Gupta
2023-08-15  0:48 ` [PATCH 11/20] ARC: __switch_to: asm with dwarf ops (vs. inline asm) Vineet Gupta
2023-08-15  0:48 ` [PATCH 12/20] ARC: __switch_to: move ksp to thread_info from thread_struct Vineet Gupta
2023-08-15  0:48 ` [PATCH 13/20] ARC: entry: rework (non-functional) Vineet Gupta
2023-08-15  0:48 ` [PATCH 14/20] ARC: entry: ARcompact EV_ProtV to use r10 directly Vineet Gupta
2023-08-15  0:48 ` [PATCH 15/20] ARC: entry: EV_MachineCheck dont re-read ECR Vineet Gupta
2023-08-15  0:48 ` [PATCH 16/20] ARC: entry: Add more common chores to EXCEPTION_PROLOGUE Vineet Gupta
2023-08-18 12:56   ` Pavel.Kozlov
2023-08-19 23:13     ` Vineet Gupta
2023-08-19 23:14     ` [PATCH v2 " Vineet Gupta
2023-08-15  0:48 ` [PATCH 17/20] ARC: entry: replace 8 byte OR with 4 byte BSET Vineet Gupta
2023-08-15  0:48 ` [PATCH 18/20] ARC: entry: replace 8 byte ADD.ne with 4 byte ADD2.ne Vineet Gupta
2023-08-15  0:48 ` Vineet Gupta [this message]
2023-08-15  0:48 ` [PATCH 20/20] ARC: pt_regs: create seperate type for ecr Vineet Gupta
2023-08-15  6:03   ` kernel test robot
2023-08-18  3:35     ` [PATCH v2 " Vineet Gupta
2023-08-17 12:09   ` [PATCH " Pavel.Kozlov
2023-08-18  3:37     ` Vineet Gupta
2023-08-22 14:07 ` [PATCH 00/20] ARC updates Pavel Kozlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815004813.555115-20-vgupta@kernel.org \
    --to=vgupta@kernel.org \
    --cc=Shahab.Vahedi@synopsys.com \
    --cc=abrodkin@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox