Skip to contentSkip to conversation

ARC updates

PATCH In review Vineet Gupta 4 participants 33 messages Aug 15, 2023 – Aug 22, 2023

Subsystems (2)
lore
Share & tools
lore

Vineet Gupta

author maintainer
#0 lore raw

cover ARC updates

Hi,

This is a pile of miscll improvements/updates sitting in one of my local trees.
Given the recent warning fix, we coudl also push them out.
@Alexey, @Shahab: care to give these a spin on hsdk (and test ARC700 build/boot on nSIM if possible).

Thx,
-Vineet

Vineet Gupta (20):
ARC: uaccess: remove arc specific out-of-line handles for -Os
ARC: uaccess: use optimized generic __strnlen_user/__strncpy_from_user
ARC: uaccess: elide unaliged handling if hardware supports
ARCv2: memset: don't prefetch for len == 0 which happens a alot
ARC: boot log: eliminate struct cpuinfo_arc #1: mm
ARC: boot log: eliminate struct cpuinfo_arc #2: cache
ARC: boot log: eliminate struct cpuinfo_arc #3: don't export
ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA
ARC: entry: use gp to cache task pointer (vs. r25)
ARC: kernel stack: INIT_THREAD need not setup @init_stack in @ksp
ARC: __switch_to: asm with dwarf ops (vs. inline asm)
ARC: __switch_to: move ksp to thread_info from thread_struct
ARC: entry: rework (non-functional)
ARC: entry: ARcompact EV_ProtV to use r10 directly
ARC: entry: EV_MachineCheck dont re-read ECR
ARC: entry: Add more common chores to EXCEPTION_PROLOGUE
ARC: entry: replace 8 byte OR with 4 byte BSET
ARC: entry: replace 8 byte ADD.ne with 4 byte ADD2.ne
ARCv2: entry: rearrange pt_regs slightly
ARC: pt_regs: create seperate type for ecr

 arch/arc/Kconfig                     |   8 +-
 arch/arc/Makefile                    |   6 +-
 arch/arc/include/asm/arcregs.h       |  99 ++---
 arch/arc/include/asm/current.h       |   2 +-
 arch/arc/include/asm/dwarf.h         |  32 +-
 arch/arc/include/asm/entry-arcv2.h   |  66 ++--
 arch/arc/include/asm/entry-compact.h |  50 ++-
 arch/arc/include/asm/entry.h         | 107 ++---
 arch/arc/include/asm/processor.h     |   7 +-
 arch/arc/include/asm/ptrace.h        |  62 ++-
 arch/arc/include/asm/setup.h         |   6 +-
 arch/arc/include/asm/thread_info.h   |  10 +-
 arch/arc/include/asm/uaccess.h       |  21 +-
 arch/arc/kernel/Makefile             |   9 +-
 arch/arc/kernel/asm-offsets.c        |  14 +-
 arch/arc/kernel/ctx_sw.c             | 112 ------
 arch/arc/kernel/ctx_sw_asm.S         |  76 ++--
 arch/arc/kernel/entry-arcv2.S        |  15 -
 arch/arc/kernel/entry-compact.S      |  16 +-
 arch/arc/kernel/entry.S              |  70 ++--
 arch/arc/kernel/kgdb.c               |   2 +-
 arch/arc/kernel/mcip.c               |   2 -
 arch/arc/kernel/process.c            |  17 +-
 arch/arc/kernel/ptrace.c             |   8 +-
 arch/arc/kernel/setup.c              | 561 ++++++++++++---------------
 arch/arc/kernel/traps.c              |   4 +-
 arch/arc/kernel/troubleshoot.c       |  13 +-
 arch/arc/lib/memset-archs.S          |   3 +-
 arch/arc/mm/cache.c                  | 171 +++-----
 arch/arc/mm/extable.c                |  11 -
 arch/arc/mm/fault.c                  |   6 +-
 arch/arc/mm/tlb.c                    |  94 ++---
 32 files changed, 667 insertions(+), 1013 deletions(-)
 delete mode 100644 arch/arc/kernel/ctx_sw.c
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#1 lore raw

PATCH 1/20 ARC: uaccess: remove arc specific out-of-line handles for -Os

Everything is now out-of-line in lib/usercopy.c

---
 arch/arc/include/asm/uaccess.h | 11 ++---------
 arch/arc/mm/extable.c          | 11 -----------
 2 files changed, 2 insertions(+), 20 deletions(-)
arch/arc/include/asm/uaccess.h +2 -9
index 99712471c96a..d2da159bb80a 100644
@@ -584,7 +584,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 	return res;
 }
 
-static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)
+static inline unsigned long __clear_user(void __user *to, unsigned long n)
 {
 	long res = n;
 	unsigned char *d_char = to;
@@ -626,17 +626,10 @@ static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)
 	return res;
 }
 
-#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
-
 #define INLINE_COPY_TO_USER
 #define INLINE_COPY_FROM_USER
 
-#define __clear_user(d, n)		__arc_clear_user(d, n)
-#else
-extern unsigned long arc_clear_user_noinline(void __user *to,
-		unsigned long n);
-#define __clear_user(d, n)		arc_clear_user_noinline(d, n)
-#endif
+#define __clear_user			__clear_user
 
 #include <asm-generic/uaccess.h>
 
arch/arc/mm/extable.c +0 -11
index 4e14c4244ea2..88fa3a4d4906 100644
@@ -22,14 +22,3 @@ int fixup_exception(struct pt_regs *regs)
 
 	return 0;
 }
-
-#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-
-unsigned long arc_clear_user_noinline(void __user *to,
-		unsigned long n)
-{
-	return __arc_clear_user(to, n);
-}
-EXPORT_SYMBOL(arc_clear_user_noinline);
-
-#endif
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#2 lore raw

PATCH 2/20 ARC: uaccess: use optimized generic __strnlen_user/__strncpy_from_user

In reply to Vineet Gupta

The existing ARC variants have 2 issues
- Use ZOL which may not be present in forthcoming architecture
- Byte loop based vs. generic version which is word loop based

---
 arch/arc/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/arc/Kconfig +2 -0
index 96cf8720bb93..47b4acc7d0c9 100644
@@ -26,6 +26,8 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER if MMU
+	select GENERIC_STRNLEN_USER if MMU
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#3 lore raw

PATCH 3/20 ARC: uaccess: elide unaliged handling if hardware supports

In reply to Vineet Gupta
---
 arch/arc/include/asm/uaccess.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arc/include/asm/uaccess.h +6 -4
index d2da159bb80a..1e8809ea000a 100644
@@ -146,8 +146,9 @@ raw_copy_from_user(void *to, const void __user *from, unsigned long n)
 	if (n == 0)
 		return 0;
 
-	/* unaligned */
-	if (((unsigned long)to & 0x3) || ((unsigned long)from & 0x3)) {
+	/* fallback for unaligned access when hardware doesn't support */
+	if (!IS_ENABLED(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS) &&
+	     (((unsigned long)to & 0x3) || ((unsigned long)from & 0x3))) {
 
 		unsigned char tmp;
 
@@ -373,8 +374,9 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 	if (n == 0)
 		return 0;
 
-	/* unaligned */
-	if (((unsigned long)to & 0x3) || ((unsigned long)from & 0x3)) {
+	/* fallback for unaligned access when hardware doesn't support */
+	if (!IS_ENABLED(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS) &&
+	     (((unsigned long)to & 0x3) || ((unsigned long)from & 0x3))) {
 
 		unsigned char tmp;
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#4 lore raw

PATCH 4/20 ARCv2: memset: don't prefetch for len == 0 which happens a alot

In reply to Vineet Gupta

This avoids potential "bleeding" when size == 0 as cache line would be dirtied (and possibly fetched from other cores) and due to the same reaons more optimal too.

---
 arch/arc/lib/memset-archs.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arc/lib/memset-archs.S +2 -1
index d2e09fece5bc..d0a5cec4cdca 100644
@@ -36,12 +36,13 @@
 #endif
 
 ENTRY_CFI(memset)
-	PREFETCHW_INSTR	r0, 0	; Prefetch the first write location
 	mov.f	0, r2
 ;;; if size is zero
 	jz.d	[blink]
 	mov	r3, r0		; don't clobber ret val
 
+	PREFETCHW_INSTR	r0, 0	; Prefetch the first write location
+
 ;;; if length < 8
 	brls.d.nt	r2, 8, .Lsmallchunk
 	mov.f	lp_count,r2
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#5 lore raw

PATCH 5/20 ARC: boot log: eliminate struct cpuinfo_arc #1: mm

In reply to Vineet Gupta

This is first step in eliminating struct cpuinfo_arc[NR_CPUS]

Back when we had just ARCompact ISA, the idea was to read/bit-fiddle the BCRs once and and cache decoded information in a global struct ready to use.

With ARCv2 it was modified to contained abstract / ISA agnostic information.

However with ARCv3 there 's too much disparity to abstract in common structures. So drop the entire decode once and store paradigm. Afterall there's only 2 users of this machinery anyways: boot printing and cat /proc/cpuinfo. None is performance critical to warrant locking away resident memory per cpu.

This patch is first step in that direction
- decouples struct cpuinfo_arc_mmu from global struct cpuinfo_arc
- mmu code still has a trimmed down static version of struct cpuinfo_arc_mmu to cache information needed in performance critical code such as tlb flush routines
- folds read_decode_mmu_bcr() into arc_mmu_mumbojumbo()
- setup_processor() directly calls arc_mmu_init() and not via arc_cpu_init()

---
 arch/arc/include/asm/arcregs.h | 27 +++++++---
 arch/arc/include/asm/setup.h   |  1 -
 arch/arc/kernel/setup.c        |  4 +-
 arch/arc/mm/tlb.c              | 92 +++++++++++++---------------------
 4 files changed, 57 insertions(+), 67 deletions(-)
arch/arc/include/asm/arcregs.h +21 -6
index 2162023195c5..af00cbe9b850 100644
@@ -185,6 +185,27 @@ struct bcr_uarch_build_arcv2 {
 #endif
 };
 
+struct bcr_mmu_3 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, ways:4, sets:4, res:3, sasid:1, pg_sz:4,
+		     u_itlb:4, u_dtlb:4;
+#else
+	unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, sasid:1, res:3, sets:4,
+		     ways:4, ver:8;
+#endif
+};
+
+struct bcr_mmu_4 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1,
+		     n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3;
+#else
+	/*           DTLB      ITLB      JES        JE         JA      */
+	unsigned int u_dtlb:3, u_itlb:3, n_super:2, n_entry:2, n_ways:2,
+		     pae:1, res:2, sz0:4, sz1:4, sasid:1, ver:8;
+#endif
+};
+
 struct bcr_mpy {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:8, x1616:8, dsp:4, cycles:2, type:2, ver:8;
@@ -307,11 +328,6 @@ struct bcr_generic {
  * Generic structures to hold build configuration used at runtime
  */
 
-struct cpuinfo_arc_mmu {
-	unsigned int ver:4, pg_sz_k:8, s_pg_sz_m:8, pad:10, sasid:1, pae:1;
-	unsigned int sets:12, ways:4, u_dtlb:8, u_itlb:8;
-};
-
 struct cpuinfo_arc_cache {
 	unsigned int sz_k:14, line_len:8, assoc:4, alias:1, vipt:1, pad:4;
 };
@@ -326,7 +342,6 @@ struct cpuinfo_arc_ccm {
 
 struct cpuinfo_arc {
 	struct cpuinfo_arc_cache icache, dcache, slc;
-	struct cpuinfo_arc_mmu mmu;
 	struct cpuinfo_arc_bpu bpu;
 	struct bcr_identity core;
 	struct bcr_isa_arcv2 isa;
arch/arc/include/asm/setup.h +0 -1
index 374138832c5a..76443f198778 100644
@@ -36,7 +36,6 @@ long __init arc_get_mem_sz(void);
 
 extern void arc_mmu_init(void);
 extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
-extern void read_decode_mmu_bcr(void);
 
 extern void arc_cache_init(void);
 extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
arch/arc/kernel/setup.c +2 -2
index 41f07b3e594e..094461540f8a 100644
@@ -186,7 +186,6 @@ static void read_arc_build_cfg_regs(void)
 	/* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
 	read_decode_ccm_bcr(cpu);
 
-	read_decode_mmu_bcr();
 	read_decode_cache_bcr();
 
 	if (is_isa_arcompact()) {
@@ -256,7 +255,7 @@ static void read_arc_build_cfg_regs(void)
 		cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
 
 		 /* there's no direct way to distinguish 750 vs. 770 */
-		if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
+		if (unlikely(cpu->core.family < 0x34))
 			cpu->name = "ARC750";
 	} else {
 		cpu->isa = isa;
@@ -463,6 +462,7 @@ void setup_processor(void)
 	arc_init_IRQ();
 
 	pr_info("%s", arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
+	pr_info("%s", arc_mmu_mumbojumbo(cpu_id, str, sizeof(str)));
 
 	arc_mmu_init();
 	arc_cache_init();
arch/arc/mm/tlb.c +34 -58

144 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#6 lore raw

Re: [PATCH 05/20] ARC: boot log: eliminate struct cpuinfo_arc #1: mm

kernel test robot noticed the following build warnings:

Hi Vineet,

kernel test robot noticed the following build warnings:

[auto build test WARNING on vgupta-arc/for-curr]
[also build test WARNING on linus/master v6.5-rc6]
[cannot apply to vgupta-arc/for-next next-20230809]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vineet-Gupta/ARC-uaccess-remove-arc-specific-out-of-line-handles-for-Os/20230815-085308
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git for-curr
patch link:    https://lore.kernel.org/r/20230815004813.555115-6-vgupta%40kernel.org
patch subject: [PATCH 05/20] ARC: boot log: eliminate struct cpuinfo_arc #1: mm
config: arc-defconfig (https://download.01.org/0day-ci/archive/20230815/[email protected]/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230815/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

arch/arc/mm/tlb.c: In function 'arc_mmu_mumbojumbo':

>> arch/arc/mm/tlb.c:568:43: warning: variable 'sasid' set but not used [-Wunused-but-set-variable]
     568 |         unsigned int bcr, u_dtlb, u_itlb, sasid;
         |                                           ^~~~~

vim +/sasid +568 arch/arc/mm/tlb.c

560
561 /* Read the Cache Build Configuration Registers, Decode them and save into
562 * the cpuinfo structure for later use.
563 * No Validation is done here, simply read/convert the BCRs
564 */
565 char *arc_mmu_mumbojumbo(int c, char *buf, int len)
566 {
567 struct cpuinfo_arc_mmu *mmu = &mmuinfo;

 > 568		unsigned int bcr, u_dtlb, u_itlb, sasid;
   569		struct bcr_mmu_3 *mmu3;
   570		struct bcr_mmu_4 *mmu4;
   571		char super_pg[64] = "";
   572		int n = 0;
   573	
   574		bcr = read_aux_reg(ARC_REG_MMU_BCR);
   575		mmu->ver = (bcr >> 24);
   576	
   577		if (is_isa_arcompact() && mmu->ver == 3) {
   578			mmu3 = (struct bcr_mmu_3 *)&bcr;
   579			mmu->pg_sz_k = 1 << (mmu3->pg_sz - 1);
   580			mmu->sets = 1 << mmu3->sets;
   581			mmu->ways = 1 << mmu3->ways;
   582			u_dtlb = mmu3->u_dtlb;
   583			u_itlb = mmu3->u_itlb;
   584			sasid = mmu3->sasid;
   585		} else {
   586			mmu4 = (struct bcr_mmu_4 *)&bcr;
   587			mmu->pg_sz_k = 1 << (mmu4->sz0 - 1);
   588			mmu->s_pg_sz_m = 1 << (mmu4->sz1 - 11);
   589			mmu->sets = 64 << mmu4->n_entry;
   590			mmu->ways = mmu4->n_ways * 2;
   591			u_dtlb = mmu4->u_dtlb * 4;
   592			u_itlb = mmu4->u_itlb * 4;
   593			sasid = mmu4->sasid;
   594			mmu->pae = mmu4->pae;
   595		}
   596	
   597		if (mmu->s_pg_sz_m)
   598			scnprintf(super_pg, 64, "/%dM%s",
   599				  mmu->s_pg_sz_m,
   600				  IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) ? " (THP enabled)":"");
   601	
   602		n += scnprintf(buf + n, len - n,
   603			      "MMU [v%x]\t: %dk%s, swalk %d lvl, JTLB %dx%d, uDTLB %d, uITLB %d%s%s\n",
   604			       mmu->ver, mmu->pg_sz_k, super_pg, CONFIG_PGTABLE_LEVELS,
   605			       mmu->sets, mmu->ways,
   606			       u_dtlb, u_itlb,
   607			       IS_AVAIL2(mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));

608
609 return buf;
610 }
611

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#7 lore raw

PATCH v2 5/20 ARC: boot log: eliminate struct cpuinfo_arc #1: mm

This is first step in eliminating struct cpuinfo_arc[NR_CPUS]

Back when we had just ARCompact ISA, the idea was to read/bit-fiddle the BCRs once and and cache decoded information in a global struct ready to use.

With ARCv2 it was modified to contained abstract / ISA agnostic information.

However with ARCv3 there 's too much disparity to abstract in common structures. So drop the entire decode once and store paradigm. Afterall there's only 2 users of this machinery anyways: boot printing and cat /proc/cpuinfo. None is performance critical to warrant locking away resident memory per cpu.

This patch is first step in that direction
- decouples struct cpuinfo_arc_mmu from global struct cpuinfo_arc
- mmu code still has a trimmed down static version of struct cpuinfo_arc_mmu to cache information needed in performance critical code such as tlb flush routines
- folds read_decode_mmu_bcr() into arc_mmu_mumbojumbo()
- setup_processor() directly calls arc_mmu_init() and not via arc_cpu_init()

---
 arch/arc/include/asm/arcregs.h | 27 +++++++---
 arch/arc/include/asm/setup.h   |  1 -
 arch/arc/kernel/setup.c        |  4 +-
 arch/arc/mm/tlb.c              | 93 +++++++++++++---------------------
 4 files changed, 58 insertions(+), 67 deletions(-)
arch/arc/include/asm/arcregs.h +21 -6
index 2162023195c5..af00cbe9b850 100644
@@ -185,6 +185,27 @@ struct bcr_uarch_build_arcv2 {
 #endif
 };
 
+struct bcr_mmu_3 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, ways:4, sets:4, res:3, sasid:1, pg_sz:4,
+		     u_itlb:4, u_dtlb:4;
+#else
+	unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, sasid:1, res:3, sets:4,
+		     ways:4, ver:8;
+#endif
+};
+
+struct bcr_mmu_4 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1,
+		     n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3;
+#else
+	/*           DTLB      ITLB      JES        JE         JA      */
+	unsigned int u_dtlb:3, u_itlb:3, n_super:2, n_entry:2, n_ways:2,
+		     pae:1, res:2, sz0:4, sz1:4, sasid:1, ver:8;
+#endif
+};
+
 struct bcr_mpy {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:8, x1616:8, dsp:4, cycles:2, type:2, ver:8;
@@ -307,11 +328,6 @@ struct bcr_generic {
  * Generic structures to hold build configuration used at runtime
  */
 
-struct cpuinfo_arc_mmu {
-	unsigned int ver:4, pg_sz_k:8, s_pg_sz_m:8, pad:10, sasid:1, pae:1;
-	unsigned int sets:12, ways:4, u_dtlb:8, u_itlb:8;
-};
-
 struct cpuinfo_arc_cache {
 	unsigned int sz_k:14, line_len:8, assoc:4, alias:1, vipt:1, pad:4;
 };
@@ -326,7 +342,6 @@ struct cpuinfo_arc_ccm {
 
 struct cpuinfo_arc {
 	struct cpuinfo_arc_cache icache, dcache, slc;
-	struct cpuinfo_arc_mmu mmu;
 	struct cpuinfo_arc_bpu bpu;
 	struct bcr_identity core;
 	struct bcr_isa_arcv2 isa;
arch/arc/include/asm/setup.h +0 -1
index 374138832c5a..76443f198778 100644
@@ -36,7 +36,6 @@ long __init arc_get_mem_sz(void);
 
 extern void arc_mmu_init(void);
 extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
-extern void read_decode_mmu_bcr(void);
 
 extern void arc_cache_init(void);
 extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
arch/arc/kernel/setup.c +2 -2
index 41f07b3e594e..094461540f8a 100644
@@ -186,7 +186,6 @@ static void read_arc_build_cfg_regs(void)
 	/* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
 	read_decode_ccm_bcr(cpu);
 
-	read_decode_mmu_bcr();
 	read_decode_cache_bcr();
 
 	if (is_isa_arcompact()) {
@@ -256,7 +255,7 @@ static void read_arc_build_cfg_regs(void)
 		cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
 
 		 /* there's no direct way to distinguish 750 vs. 770 */
-		if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
+		if (unlikely(cpu->core.family < 0x34))
 			cpu->name = "ARC750";
 	} else {
 		cpu->isa = isa;
@@ -463,6 +462,7 @@ void setup_processor(void)
 	arc_init_IRQ();
 
 	pr_info("%s", arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
+	pr_info("%s", arc_mmu_mumbojumbo(cpu_id, str, sizeof(str)));
 
 	arc_mmu_init();
 	arc_cache_init();
arch/arc/mm/tlb.c +35 -58

145 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#8 lore raw

PATCH 6/20 ARC: boot log: eliminate struct cpuinfo_arc #2: cache

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h |  37 ++++++-
 arch/arc/include/asm/setup.h   |   1 -
 arch/arc/kernel/setup.c        |   3 +-
 arch/arc/mm/cache.c            | 171 ++++++++++++---------------------
 4 files changed, 97 insertions(+), 115 deletions(-)
arch/arc/include/asm/arcregs.h +32 -5
index af00cbe9b850..cb1ad1bb4ece 100644
@@ -206,6 +206,38 @@ struct bcr_mmu_4 {
 #endif
 };
 
+struct bcr_cache {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
+#else
+	unsigned int ver:8, config:4, sz:4, line_len:4, pad:12;
+#endif
+};
+
+struct bcr_slc_cfg {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int pad:24, way:2, lsz:2, sz:4;
+#else
+	unsigned int sz:4, lsz:2, way:2, pad:24;
+#endif
+};
+
+struct bcr_clust_cfg {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int pad:7, c:1, num_entries:8, num_cores:8, ver:8;
+#else
+	unsigned int ver:8, num_cores:8, num_entries:8, c:1, pad:7;
+#endif
+};
+
+struct bcr_volatile {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int start:4, limit:4, pad:22, order:1, disable:1;
+#else
+	unsigned int disable:1, order:1, pad:22, limit:4, start:4;
+#endif
+};
+
 struct bcr_mpy {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:8, x1616:8, dsp:4, cycles:2, type:2, ver:8;
@@ -328,10 +360,6 @@ struct bcr_generic {
  * Generic structures to hold build configuration used at runtime
  */
 
-struct cpuinfo_arc_cache {
-	unsigned int sz_k:14, line_len:8, assoc:4, alias:1, vipt:1, pad:4;
-};
-
 struct cpuinfo_arc_bpu {
 	unsigned int ver, full, num_cache, num_pred, ret_stk;
 };
@@ -341,7 +369,6 @@ struct cpuinfo_arc_ccm {
 };
 
 struct cpuinfo_arc {
-	struct cpuinfo_arc_cache icache, dcache, slc;
 	struct cpuinfo_arc_bpu bpu;
 	struct bcr_identity core;
 	struct bcr_isa_arcv2 isa;
arch/arc/include/asm/setup.h +0 -1
index 76443f198778..4c0bacd0ff5c 100644
@@ -39,7 +39,6 @@ extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
 
 extern void arc_cache_init(void);
 extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
-extern void read_decode_cache_bcr(void);
 
 extern void __init handle_uboot_args(void);
 
arch/arc/kernel/setup.c +1 -2
index 094461540f8a..3ea834941c1f 100644
@@ -186,8 +186,6 @@ static void read_arc_build_cfg_regs(void)
 	/* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
 	read_decode_ccm_bcr(cpu);
 
-	read_decode_cache_bcr();
-
 	if (is_isa_arcompact()) {
 		struct bcr_fp_arcompact sp, dp;
 		struct bcr_bpu_arcompact bpu;
@@ -463,6 +461,7 @@ void setup_processor(void)
 
 	pr_info("%s", arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
 	pr_info("%s", arc_mmu_mumbojumbo(cpu_id, str, sizeof(str)));
+	pr_info("%s", arc_cache_mumbojumbo(cpu_id, str, sizeof(str)));
 
 	arc_mmu_init();
 	arc_cache_init();
arch/arc/mm/cache.c +64 -107

265 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#9 lore raw

PATCH 7/20 ARC: boot log: eliminate struct cpuinfo_arc #3: don't export

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h | 2 --
 arch/arc/kernel/mcip.c         | 2 --
 2 files changed, 4 deletions(-)
arch/arc/include/asm/arcregs.h +0 -2
index cb1ad1bb4ece..160ee3fab1bd 100644
@@ -384,8 +384,6 @@ struct cpuinfo_arc {
 	struct bcr_mpy extn_mpy;
 };
 
-extern struct cpuinfo_arc cpuinfo_arc700[];
-
 static inline int is_isa_arcv2(void)
 {
 	return IS_ENABLED(CONFIG_ISA_ARCV2);
arch/arc/kernel/mcip.c +0 -2
index f9fdb557c263..55373ca0d28b 100644
@@ -165,8 +165,6 @@ static void mcip_probe_n_setup(void)
 		IS_AVAIL1(mp.idu, "IDU "),
 		IS_AVAIL1(mp.dbg, "DEBUG "),
 		IS_AVAIL1(mp.gfrc, "GFRC"));
-
-	cpuinfo_arc700[0].extn.gfrc = mp.gfrc;
 }
 
 struct plat_smp_ops plat_smp_ops = {
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#10 lore raw

PATCH 8/20 ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA

In reply to Vineet Gupta

- boot log now clearly per ISA
- global struct cpuinfo_arc[] elimiated
- local struct struct arcinfo kept for passing info between functions

---
 arch/arc/include/asm/arcregs.h |  33 +-
 arch/arc/include/asm/setup.h   |   4 +-
 arch/arc/kernel/setup.c        | 560 +++++++++++++++------------------
 arch/arc/mm/cache.c            |  10 +-
 arch/arc/mm/tlb.c              |   4 +-
 5 files changed, 268 insertions(+), 343 deletions(-)
arch/arc/include/asm/arcregs.h +2 -31
index 160ee3fab1bd..4b13f60fe7ca 100644
@@ -23,7 +23,7 @@
 #define ARC_REG_ICCM_BUILD	0x78	/* ICCM size (common) */
 #define ARC_REG_XY_MEM_BCR	0x79
 #define ARC_REG_MAC_BCR		0x7a
-#define ARC_REG_MUL_BCR		0x7b
+#define ARC_REG_MPY_BCR		0x7b
 #define ARC_REG_SWAP_BCR	0x7c
 #define ARC_REG_NORM_BCR	0x7d
 #define ARC_REG_MIXMAX_BCR	0x7e
@@ -177,7 +177,7 @@ struct bcr_isa_arcv2 {
 #endif
 };
 
-struct bcr_uarch_build_arcv2 {
+struct bcr_uarch_build {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:8, prod:8, maj:8, min:8;
 #else
@@ -355,35 +355,6 @@ struct bcr_generic {
 #endif
 };
 
-/*
- *******************************************************************
- * Generic structures to hold build configuration used at runtime
- */
-
-struct cpuinfo_arc_bpu {
-	unsigned int ver, full, num_cache, num_pred, ret_stk;
-};
-
-struct cpuinfo_arc_ccm {
-	unsigned int base_addr, sz;
-};
-
-struct cpuinfo_arc {
-	struct cpuinfo_arc_bpu bpu;
-	struct bcr_identity core;
-	struct bcr_isa_arcv2 isa;
-	const char *release, *name;
-	unsigned int vec_base;
-	struct cpuinfo_arc_ccm iccm, dccm;
-	struct {
-		unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2,
-			     fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4,
-			     ap_num:4, ap_full:1, smart:1, rtt:1, pad3:1,
-			     timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
-	} extn;
-	struct bcr_mpy extn_mpy;
-};
-
 static inline int is_isa_arcv2(void)
 {
 	return IS_ENABLED(CONFIG_ISA_ARCV2);
arch/arc/include/asm/setup.h +2 -2
index 4c0bacd0ff5c..1c6db599e1fc 100644
@@ -35,10 +35,10 @@ long __init arc_get_mem_sz(void);
 #define IS_AVAIL3(v, v2, s)	IS_AVAIL1(v, s), IS_AVAIL1(v, IS_DISABLED_RUN(v2))
 
 extern void arc_mmu_init(void);
-extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
+extern int arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
 
 extern void arc_cache_init(void);
-extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
+extern int arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
 
 extern void __init handle_uboot_args(void);
 
arch/arc/kernel/setup.c +257 -303

697 lines not on this page · raw message

arch/arc/mm/cache.c +5 -5
index 7197bb845a40..4510f805b21d 100644
@@ -39,7 +39,7 @@ void (*__dma_cache_wback_inv)(phys_addr_t start, unsigned long sz);
 void (*__dma_cache_inv)(phys_addr_t start, unsigned long sz);
 void (*__dma_cache_wback)(phys_addr_t start, unsigned long sz);
 
-static char *read_decode_cache_bcr_arcv2(int c, char *buf, int len)
+static int read_decode_cache_bcr_arcv2(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_cache *p_slc = &slc_info;
 	struct bcr_identity ident;
@@ -94,10 +94,10 @@ static char *read_decode_cache_bcr_arcv2(int c, char *buf, int len)
 		       perip_base,
 		       IS_AVAIL3(ioc_exists, ioc_enable, ", IO-Coherency (per-device) "));
 
-	return buf;
+	return n;
 }
 
-char *arc_cache_mumbojumbo(int c, char *buf, int len)
+int arc_cache_mumbojumbo(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_cache *p_ic = &ic_info, *p_dc = &dc_info;
 	struct bcr_cache ibcr, dbcr;
@@ -153,9 +153,9 @@ char *arc_cache_mumbojumbo(int c, char *buf, int len)
 
 slc_chk:
 	if (is_isa_arcv2())
-		read_decode_cache_bcr_arcv2(c, buf + n, len - n);
+		n += read_decode_cache_bcr_arcv2(c, buf + n, len - n);
 
-	return buf;
+	return n;
 }
 
 /*
arch/arc/mm/tlb.c +2 -2
index 17e32c707367..19deb8ca9c28 100644
@@ -562,7 +562,7 @@ void local_flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
  * the cpuinfo structure for later use.
  * No Validation is done here, simply read/convert the BCRs
  */
-char *arc_mmu_mumbojumbo(int c, char *buf, int len)
+int arc_mmu_mumbojumbo(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_mmu *mmu = &mmuinfo;
 	unsigned int bcr, u_dtlb, u_itlb, sasid;
@@ -606,7 +606,7 @@ char *arc_mmu_mumbojumbo(int c, char *buf, int len)
 		       u_dtlb, u_itlb,
 		       IS_AVAIL2(mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));
 
-	return buf;
+	return n;
 }
 
 int pae40_exist_but_not_enab(void)
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#11 lore raw

Re: [PATCH 08/20] ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA

kernel test robot noticed the following build warnings:

Hi Vineet,

kernel test robot noticed the following build warnings:

[auto build test WARNING on vgupta-arc/for-curr]
[also build test WARNING on linus/master v6.5-rc6]
[cannot apply to vgupta-arc/for-next next-20230816]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vineet-Gupta/ARC-uaccess-remove-arc-specific-out-of-line-handles-for-Os/20230815-085308
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git for-curr
patch link:    https://lore.kernel.org/r/20230815004813.555115-9-vgupta%40kernel.org
patch subject: [PATCH 08/20] ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA
config: arc-nsimosci_hs_smp_defconfig (https://download.01.org/0day-ci/archive/20230816/[email protected]/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230816/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

cocci warnings: (new ones prefixed by >>)

>> arch/arc/kernel/setup.c:299:17-23: ERROR: application of sizeof to pointer
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#12 lore raw

PATCH v2 8/20 ARC: boot log: eliminate struct cpuinfo_arc #4: boot log per ISA

- boot log now clearly per ISA
- global struct cpuinfo_arc[] elimiated
- local struct struct arcinfo kept for passing info between functions

---
 arch/arc/include/asm/arcregs.h |  33 +-
 arch/arc/include/asm/setup.h   |   4 +-
 arch/arc/kernel/setup.c        | 560 +++++++++++++++------------------
 arch/arc/mm/cache.c            |  10 +-
 arch/arc/mm/tlb.c              |   4 +-
 5 files changed, 268 insertions(+), 343 deletions(-)
arch/arc/include/asm/arcregs.h +2 -31
index 160ee3fab1bd..4b13f60fe7ca 100644
@@ -23,7 +23,7 @@
 #define ARC_REG_ICCM_BUILD	0x78	/* ICCM size (common) */
 #define ARC_REG_XY_MEM_BCR	0x79
 #define ARC_REG_MAC_BCR		0x7a
-#define ARC_REG_MUL_BCR		0x7b
+#define ARC_REG_MPY_BCR		0x7b
 #define ARC_REG_SWAP_BCR	0x7c
 #define ARC_REG_NORM_BCR	0x7d
 #define ARC_REG_MIXMAX_BCR	0x7e
@@ -177,7 +177,7 @@ struct bcr_isa_arcv2 {
 #endif
 };
 
-struct bcr_uarch_build_arcv2 {
+struct bcr_uarch_build {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:8, prod:8, maj:8, min:8;
 #else
@@ -355,35 +355,6 @@ struct bcr_generic {
 #endif
 };
 
-/*
- *******************************************************************
- * Generic structures to hold build configuration used at runtime
- */
-
-struct cpuinfo_arc_bpu {
-	unsigned int ver, full, num_cache, num_pred, ret_stk;
-};
-
-struct cpuinfo_arc_ccm {
-	unsigned int base_addr, sz;
-};
-
-struct cpuinfo_arc {
-	struct cpuinfo_arc_bpu bpu;
-	struct bcr_identity core;
-	struct bcr_isa_arcv2 isa;
-	const char *release, *name;
-	unsigned int vec_base;
-	struct cpuinfo_arc_ccm iccm, dccm;
-	struct {
-		unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2,
-			     fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4,
-			     ap_num:4, ap_full:1, smart:1, rtt:1, pad3:1,
-			     timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
-	} extn;
-	struct bcr_mpy extn_mpy;
-};
-
 static inline int is_isa_arcv2(void)
 {
 	return IS_ENABLED(CONFIG_ISA_ARCV2);
arch/arc/include/asm/setup.h +2 -2
index 4c0bacd0ff5c..1c6db599e1fc 100644
@@ -35,10 +35,10 @@ long __init arc_get_mem_sz(void);
 #define IS_AVAIL3(v, v2, s)	IS_AVAIL1(v, s), IS_AVAIL1(v, IS_DISABLED_RUN(v2))
 
 extern void arc_mmu_init(void);
-extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
+extern int arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
 
 extern void arc_cache_init(void);
-extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
+extern int arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
 
 extern void __init handle_uboot_args(void);
 
arch/arc/kernel/setup.c +257 -303

697 lines not on this page · raw message

arch/arc/mm/cache.c +5 -5
index 7197bb845a40..4510f805b21d 100644
@@ -39,7 +39,7 @@ void (*__dma_cache_wback_inv)(phys_addr_t start, unsigned long sz);
 void (*__dma_cache_inv)(phys_addr_t start, unsigned long sz);
 void (*__dma_cache_wback)(phys_addr_t start, unsigned long sz);
 
-static char *read_decode_cache_bcr_arcv2(int c, char *buf, int len)
+static int read_decode_cache_bcr_arcv2(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_cache *p_slc = &slc_info;
 	struct bcr_identity ident;
@@ -94,10 +94,10 @@ static char *read_decode_cache_bcr_arcv2(int c, char *buf, int len)
 		       perip_base,
 		       IS_AVAIL3(ioc_exists, ioc_enable, ", IO-Coherency (per-device) "));
 
-	return buf;
+	return n;
 }
 
-char *arc_cache_mumbojumbo(int c, char *buf, int len)
+int arc_cache_mumbojumbo(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_cache *p_ic = &ic_info, *p_dc = &dc_info;
 	struct bcr_cache ibcr, dbcr;
@@ -153,9 +153,9 @@ char *arc_cache_mumbojumbo(int c, char *buf, int len)
 
 slc_chk:
 	if (is_isa_arcv2())
-		read_decode_cache_bcr_arcv2(c, buf + n, len - n);
+		n += read_decode_cache_bcr_arcv2(c, buf + n, len - n);
 
-	return buf;
+	return n;
 }
 
 /*
arch/arc/mm/tlb.c +2 -2
index 861cabe81e87..d70eaff71759 100644
@@ -562,7 +562,7 @@ void local_flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
  * the cpuinfo structure for later use.
  * No Validation is done here, simply read/convert the BCRs
  */
-char *arc_mmu_mumbojumbo(int c, char *buf, int len)
+int arc_mmu_mumbojumbo(int c, char *buf, int len)
 {
 	struct cpuinfo_arc_mmu *mmu = &mmuinfo;
 	unsigned int bcr, u_dtlb, u_itlb, sasid;
@@ -607,7 +607,7 @@ char *arc_mmu_mumbojumbo(int c, char *buf, int len)
 		       IS_AVAIL1(sasid, ", SASID"),
 		       IS_AVAIL2(mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));
 
-	return buf;
+	return n;
 }
 
 int pae40_exist_but_not_enab(void)
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#13 lore raw

PATCH 9/20 ARC: entry: use gp to cache task pointer (vs. r25)

In reply to Vineet Gupta

The motivation is eventual ABI considerations for ARCv3 but even without it this change us worthwhile as diffstat reduces 100 net lines

r25 is a callee saved register, normally not saved by entry code in pt_regs. However because of its usage in CONFIG_ARC_CURR_IN_REG it needs to be. This in turn requires a whole bunch of special casing when we need to access r25. Then there is distinction between user mode r25 vs. kernel mode r25 - hence distinct SAVE_CALLEE_SAVED_{USER,KERNEL}

Instead use gp which is a scratch register and thus saved already in entry code. This cleans things up significantly and much nocer on eyes:

- SAVE_CALLEE_SAVED_{USER,KERNEL} are now exactly same
- no special user_r25 slot in pt_reggs

Note that typical global asm registers are callee-saved (r25), but gp is not callee-saved thus needs additional -ffixed-<reg> toggle

---
 arch/arc/Kconfig                     |   6 +-
 arch/arc/Makefile                    |   6 +-
 arch/arc/include/asm/current.h       |   2 +-
 arch/arc/include/asm/entry-arcv2.h   |  17 ++---
 arch/arc/include/asm/entry-compact.h |  35 +++------
 arch/arc/include/asm/entry.h         | 107 ++++++++-------------------
 arch/arc/include/asm/ptrace.h        |   6 +-
 arch/arc/kernel/asm-offsets.c        |   2 -
 arch/arc/kernel/ctx_sw.c             |  13 +---
 arch/arc/kernel/ctx_sw_asm.S         |   2 +-
 arch/arc/kernel/entry.S              |   3 +-
 arch/arc/kernel/process.c            |  11 ---
 arch/arc/kernel/ptrace.c             |   2 -
 13 files changed, 58 insertions(+), 154 deletions(-)
arch/arc/Kconfig +3 -3
index 47b4acc7d0c9..c92bacc1ff4c 100644
@@ -492,11 +492,11 @@ config ARC_KVADDR_SIZE
 	  kernel-user gutter)
 
 config ARC_CURR_IN_REG
-	bool "Dedicate Register r25 for current_task pointer"
+	bool "cache current task pointer in gp"
 	default y
 	help
-	  This reserved Register R25 to point to Current Task in
-	  kernel mode. This saves memory access for each such access
+	  This reserves gp register to point to Current Task in
+	  kernel mode eliding memory access for each access
 
 
 config ARC_EMUL_UNALIGNED
arch/arc/Makefile +3 -3
index 329400a1c355..2390dd042e36 100644
@@ -28,14 +28,14 @@ cflags-y				+= $(tune-mcpu-def-y)
 endif
 endif
 
-
 ifdef CONFIG_ARC_CURR_IN_REG
 # For a global register definition, make sure it gets passed to every file
 # We had a customer reported bug where some code built in kernel was NOT using
-# any kernel headers, and missing the r25 global register
+# any kernel headers, and missing the global register
 # Can't do unconditionally because of recursive include issues
 # due to <linux/thread_info.h>
 LINUXINCLUDE	+=  -include $(srctree)/arch/arc/include/asm/current.h
+cflags-y	+= -ffixed-gp
 endif
 
 cflags-y				+= -fsection-anchors
@@ -67,7 +67,7 @@ cflags-$(CONFIG_ARC_DW2_UNWIND)		+= -fasynchronous-unwind-tables $(cfi)
 # small data is default for elf32 tool-chain. If not usable, disable it
 # This also allows repurposing GP as scratch reg to gcc reg allocator
 disable_small_data := y
-cflags-$(disable_small_data)		+= -mno-sdata -fcall-used-gp
+cflags-$(disable_small_data)		+= -mno-sdata
 
 cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= -mbig-endian
 ldflags-$(CONFIG_CPU_BIG_ENDIAN)	+= -EB
arch/arc/include/asm/current.h +1 -1
index 9b9bdd3e6538..06be89f6f2f0 100644
@@ -13,7 +13,7 @@
 
 #ifdef CONFIG_ARC_CURR_IN_REG
 
-register struct task_struct *curr_arc asm("r25");
+register struct task_struct *curr_arc asm("gp");
 #define current (curr_arc)
 
 #else
arch/arc/include/asm/entry-arcv2.h +6 -11
index 0ff4c0610561..858742feab71 100644
@@ -18,7 +18,6 @@
  *              |      orig_r0      |
  *              |      event/ECR    |
  *              |      bta          |
- *              |      user_r25     |
  *              |      gp           |
  *              |      fp           |
  *              |      sp           |
@@ -56,7 +55,7 @@
 	;                 hardware does even if CONFIG_ARC_IRQ_NO_AUTOSAVE
 	;   4. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI
 	;
-	; (B) Manually saved some regs: r12,r25,r30, sp,fp,gp, ACCL pair
+	; (B) Manually saved some regs: r12,r30, sp,fp,gp, ACCL pair
 
 #ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE
 	; carve pt_regs on stack (case #3), PC/STAT32 already on stack
@@ -157,17 +156,17 @@
 
 	st	r10, [sp, PT_sp]	; SP (pt_regs->sp)
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	st	r25, [sp, PT_user_r25]
-	GET_CURR_TASK_ON_CPU	r25
-#endif
-
 #ifdef CONFIG_ARC_HAS_ACCL_REGS
 	ST2	r58, r59, PT_r58
 #endif
 
 	/* clobbers r10, r11 registers pair */
 	DSP_SAVE_REGFILE_IRQ
+
+#ifdef CONFIG_ARC_CURR_IN_REG
+	GET_CURR_TASK_ON_CPU	gp
+#endif
+
 .endm
 
 /*------------------------------------------------------------------------*/
@@ -188,10 +187,6 @@
 	sr	r10, [AUX_USER_SP]
 1:
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	ld	r25, [sp, PT_user_r25]
-#endif
-
 	/* clobbers r10, r11 registers pair */
 	DSP_RESTORE_REGFILE_IRQ
 
arch/arc/include/asm/entry-compact.h +11 -24
index 67ff06e15cea..e3383e1cb040 100644
@@ -151,14 +151,6 @@
 	/* ARC700 doesn't provide auto-stack switching */
 	SWITCH_TO_KERNEL_STK
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	/* Treat r25 as scratch reg (save on stack) and load with "current" */
-	PUSH    r25
-	GET_CURR_TASK_ON_CPU   r25
-#else
-	sub     sp, sp, 4
-#endif
-
 	st.a	r0, [sp, -8]    /* orig_r0 needed for syscall (skip ECR slot) */
 	sub	sp, sp, 4	/* skip pt_regs->sp, already saved above */
 
@@ -179,6 +171,11 @@
 
 	lr	r10, [ecr]
 	st      r10, [sp, PT_event]    /* EV_Trap expects r10 to have ECR */
+
+#ifdef CONFIG_ARC_CURR_IN_REG
+	/* gp already saved on stack: now load with "current" */
+	GET_CURR_TASK_ON_CPU   gp
+#endif
 .endm
 
 /*--------------------------------------------------------------
@@ -208,11 +205,8 @@
 	POP	gp
 	RESTORE_R12_TO_R0
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	ld	r25, [sp, 12]
-#endif
 	ld  sp, [sp] /* restore original sp */
-	/* orig_r0, ECR, user_r25 skipped automatically */
+	/* orig_r0, ECR skipped automatically */
 .endm
 
 /* Dummy ECR values for Interrupts */
@@ -229,13 +223,6 @@
 
 	SWITCH_TO_KERNEL_STK
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	/* Treat r25 as scratch reg (save on stack) and load with "current" */
-	PUSH    r25
-	GET_CURR_TASK_ON_CPU   r25
-#else
-	sub     sp, sp, 4
-#endif
 
 	PUSH	0x003\LVL\()abcd    /* Dummy ECR */
 	sub	sp, sp, 8	    /* skip orig_r0 (not needed)
@@ -255,6 +242,10 @@
 	PUSHAX	lp_start
 	PUSHAX	bta_l\LVL\()
 
+#ifdef CONFIG_ARC_CURR_IN_REG
+	/* gp already saved on stack: now load with "current" */
+	GET_CURR_TASK_ON_CPU   gp
+#endif
 .endm
 
 /*--------------------------------------------------------------
@@ -282,11 +273,7 @@
 	POP	gp
 	RESTORE_R12_TO_R0
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	ld	r25, [sp, 12]
-#endif
-	ld  sp, [sp] /* restore original sp */
-	/* orig_r0, ECR, user_r25 skipped automatically */
+	ld  sp, [sp] /* restore original sp; orig_r0, ECR skipped implicitly */
 .endm
 
 /* Get thread_info of "current" tsk */
arch/arc/include/asm/entry.h +29 -78

164 lines not on this page · raw message

arch/arc/include/asm/ptrace.h +1 -5
index cf90fcd2a628..e9798f46cdc4 100644
@@ -52,11 +52,9 @@ struct pt_regs {
 		};
 		unsigned long event;
 	};
-
-	unsigned long user_r25;
 };
 
-#define MAX_REG_OFFSET offsetof(struct pt_regs, user_r25)
+#define MAX_REG_OFFSET offsetof(struct pt_regs, event)
 
 #else
 
@@ -79,8 +77,6 @@ struct pt_regs {
 
 	unsigned long bta;	/* bta_l1, bta_l2, erbta */
 
-	unsigned long user_r25;
-
 	unsigned long r26;	/* gp */
 	unsigned long fp;
 	unsigned long sp;	/* user/kernel sp depending on where we came from  */
arch/arc/kernel/asm-offsets.c +0 -2
index 0e884036ab74..37324fd9a72f 100644
@@ -63,8 +63,6 @@ int main(void)
 	DEFINE(PT_blink, offsetof(struct pt_regs, blink));
 	DEFINE(PT_lpe, offsetof(struct pt_regs, lp_end));
 	DEFINE(PT_lpc, offsetof(struct pt_regs, lp_count));
-	DEFINE(PT_user_r25, offsetof(struct pt_regs, user_r25));
-
 	DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs));
 	DEFINE(SZ_PT_REGS, sizeof(struct pt_regs));
 
arch/arc/kernel/ctx_sw.c +2 -11
index bf16f777a0bc..40d89440b7e4 100644
@@ -38,11 +38,7 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 		"st.a    r22, [sp, -4]   \n\t"
 		"st.a    r23, [sp, -4]   \n\t"
 		"st.a    r24, [sp, -4]   \n\t"
-#ifndef CONFIG_ARC_CURR_IN_REG
 		"st.a    r25, [sp, -4]   \n\t"
-#else
-		"sub     sp, sp, 4      \n\t"	/* usual r25 placeholder */
-#endif
 
 		/* set ksp of outgoing task in tsk->thread.ksp */
 #if KSP_WORD_OFF <= 255
@@ -58,7 +54,7 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 
 		/*
 		 * setup _current_task with incoming tsk.
-		 * optionally, set r25 to that as well
+		 * optionally, set caching reg to that as well
 		 * For SMP extra work to get to &_current_task[cpu]
 		 * (open coded SET_CURR_TASK_ON_CPU)
 		 */
@@ -72,19 +68,14 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 		"st   %2,  [r24]		\n\t"
 #endif
 #ifdef CONFIG_ARC_CURR_IN_REG
-		"mov r25, %2   \n\t"
+		"mov gp, %2   \n\t"
 #endif
 
 		/* get ksp of incoming task from tsk->thread.ksp */
 		"ld.as  sp, [%2, %1]   \n\t"
 
 		/* start loading it's CALLEE reg file */
-
-#ifndef CONFIG_ARC_CURR_IN_REG
 		"ld.ab   r25, [sp, 4]   \n\t"
-#else
-		"add    sp, sp, 4       \n\t"
-#endif
 		"ld.ab   r24, [sp, 4]   \n\t"
 		"ld.ab   r23, [sp, 4]   \n\t"
 		"ld.ab   r22, [sp, 4]   \n\t"
arch/arc/kernel/ctx_sw_asm.S +1 -1
index 02c461484761..95cba6265e2b 100644
@@ -49,7 +49,7 @@ __switch_to:
 	SET_CURR_TASK_ON_CPU  r1, r3
 
 	/* reload SP with kernel mode stack pointer in task->thread.ksp */
-	ld.as  sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
+	ld.as  sp, [r1, KSP_WORD_OFF]
 
 	/* restore the registers */
 	RESTORE_CALLEE_SAVED_KERNEL
arch/arc/kernel/entry.S +1 -2
index 54e91df678dd..cd26e0fa5044 100644
@@ -210,7 +210,6 @@ trap_with_param:
 
 	; Save callee regs in case gdb wants to have a look
 	; SP will grow up by size of CALLEE Reg-File
-	; NOTE: clobbers r12
 	SAVE_CALLEE_SAVED_USER
 
 	; save location of saved Callee Regs @ thread_struct->pc
@@ -318,7 +317,7 @@ resume_user_mode_begin:
 	;      tracer might call PEEKUSR(CALLEE reg)
 	;
 	; NOTE: SP will grow up by size of CALLEE Reg-File
-	SAVE_CALLEE_SAVED_USER		; clobbers r12
+	SAVE_CALLEE_SAVED_USER
 
 	; save location of saved Callee Regs @ thread_struct->callee
 	GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r10
arch/arc/kernel/process.c +0 -11
index 980b71da2f61..96f591508142 100644
@@ -162,7 +162,6 @@ asmlinkage void ret_from_fork(void);
  * |      SP        |
  * |    orig_r0     |
  * |    event/ECR   |
- * |    user_r25    |
  * ------------------  <===== END of PAGE
  */
 int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
@@ -243,16 +242,6 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
 	 */
 	c_callee->r25 = task_thread_info(p)->thr_ptr;
 
-#ifdef CONFIG_ARC_CURR_IN_REG
-	/*
-	 * setup usermode thread pointer #2:
-	 * however for this special use of r25 in kernel, __switch_to() sets
-	 * r25 for kernel needs and only in the final return path is usermode
-	 * r25 setup, from pt_regs->user_r25. So set that up as well
-	 */
-	c_regs->user_r25 = c_callee->r25;
-#endif
-
 	return 0;
 }
 
arch/arc/kernel/ptrace.c +0 -2
index 2abdcd9b09e8..8226df3163fe 100644
@@ -47,7 +47,6 @@ static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(sp),
 	REG_OFFSET_NAME(orig_r0),
 	REG_OFFSET_NAME(event),
-	REG_OFFSET_NAME(user_r25),
 	REG_OFFSET_END,
 };
 
@@ -57,7 +56,6 @@ static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(orig_r0),
 	REG_OFFSET_NAME(event),
 	REG_OFFSET_NAME(bta),
-	REG_OFFSET_NAME(user_r25),
 	REG_OFFSET_NAME(r26),
 	REG_OFFSET_NAME(fp),
 	REG_OFFSET_NAME(sp),
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#14 lore raw

PATCH 10/20 ARC: kernel stack: INIT_THREAD need not setup @init_stack in @ksp

In reply to Vineet Gupta

There are 2 pointers to kernel mode stack of a task
- task_struct.stack: base address of stack page (max possible stack top)
- thread_info.ksp : runtime stack top in __switch_to

INIT_THREAD was setting up ksp to stack base which was not really needed
- it would get overwritten with dynamic value on first call to __switch_to when init is switched out for the very first time.
- generic code already does
init_task.stack = init_stack
and ARC code uses that to retrieve task's stack base.

---
 arch/arc/include/asm/processor.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arc/include/asm/processor.h +1 -3
index fb844fce1ab6..82ddc929d6e7 100644
@@ -33,9 +33,7 @@ struct thread_struct {
 #endif
 };
 
-#define INIT_THREAD  {                          \
-	.ksp = sizeof(init_stack) + (unsigned long) init_stack, \
-}
+#define INIT_THREAD  { }
 
 /* Forward declaration, a strange C thing */
 struct task_struct;
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#15 lore raw

PATCH 11/20 ARC: __switch_to: asm with dwarf ops (vs. inline asm)

In reply to Vineet Gupta

__switch_to() is final step of context switch, swapping kernel modes stack (and callee regs) of outgoing task with next task.

It is also the starting point of stack unwinging of a sleeping task and captures SP, FP, BLINK and the corresponding dwarf info. Back when dinosaurs still roamed around, ARC gas didn't support CFI pseudo ops and gcc was responsible for generating dwarf info. Thus it had to be written in "C" with inline asm to do the hand crafting of stack. The function prologue (and crucial saving of blink etc) was still gcc generated but not visible in code. Likewise dwarf info was missing.

Now with modern tools, we can make things more obvious by writing the code in asm and adding approproate dwarf cfi pseudo ops.

This is mostly non functional change, except for slight chnages to asm

- ARCompact doesn't support MOV_S fp, sp, so we use MOV

---
 arch/arc/include/asm/dwarf.h |  32 +++++++----
 arch/arc/kernel/Makefile     |   9 +--
 arch/arc/kernel/ctx_sw.c     | 103 -----------------------------------
 arch/arc/kernel/ctx_sw_asm.S |  72 +++++++++++++-----------
 4 files changed, 61 insertions(+), 155 deletions(-)
 delete mode 100644 arch/arc/kernel/ctx_sw.c
arch/arc/include/asm/dwarf.h +20 -12
index 5f4de05bd4ee..a0d5ebe1bc3f 100644
@@ -10,23 +10,31 @@
 
 #ifdef ARC_DW2_UNWIND_AS_CFI
 
-#define CFI_STARTPROC	.cfi_startproc
-#define CFI_ENDPROC	.cfi_endproc
-#define CFI_DEF_CFA	.cfi_def_cfa
-#define CFI_REGISTER	.cfi_register
-#define CFI_REL_OFFSET	.cfi_rel_offset
-#define CFI_UNDEFINED	.cfi_undefined
+#define CFI_STARTPROC		.cfi_startproc
+#define CFI_ENDPROC		.cfi_endproc
+#define CFI_DEF_CFA		.cfi_def_cfa
+#define CFI_DEF_CFA_OFFSET	.cfi_def_cfa_offset
+#define CFI_DEF_CFA_REGISTER	.cfi_def_cfa_register
+#define CFI_OFFSET		.cfi_offset
+#define CFI_REL_OFFSET		.cfi_rel_offset
+#define CFI_REGISTER		.cfi_register
+#define CFI_RESTORE		.cfi_restore
+#define CFI_UNDEFINED		.cfi_undefined
 
 #else
 
 #define CFI_IGNORE	#
 
-#define CFI_STARTPROC	CFI_IGNORE
-#define CFI_ENDPROC	CFI_IGNORE
-#define CFI_DEF_CFA	CFI_IGNORE
-#define CFI_REGISTER	CFI_IGNORE
-#define CFI_REL_OFFSET	CFI_IGNORE
-#define CFI_UNDEFINED	CFI_IGNORE
+#define CFI_STARTPROC		CFI_IGNORE
+#define CFI_ENDPROC		CFI_IGNORE
+#define CFI_DEF_CFA		CFI_IGNORE
+#define CFI_DEF_CFA_OFFSET	CFI_IGNORE
+#define CFI_DEF_CFA_REGISTER	CFI_IGNORE
+#define CFI_OFFSET		CFI_IGNORE
+#define CFI_REL_OFFSET		CFI_IGNORE
+#define CFI_REGISTER		CFI_IGNORE
+#define CFI_RESTORE		CFI_IGNORE
+#define CFI_UNDEFINED		CFI_IGNORE
 
 #endif	/* !ARC_DW2_UNWIND_AS_CFI */
 
arch/arc/kernel/Makefile +2 -7
index 0723d888ac44..95fbf9364c67 100644
@@ -5,6 +5,8 @@
 
 obj-y	:= head.o arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
 obj-y	+= signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
+obj-y	+= ctx_sw_asm.o
+
 obj-$(CONFIG_ISA_ARCOMPACT)		+= entry-compact.o intc-compact.o
 obj-$(CONFIG_ISA_ARCV2)			+= entry-arcv2.o intc-arcv2.o
 
@@ -24,11 +26,4 @@ ifdef CONFIG_ISA_ARCOMPACT
 CFLAGS_fpu.o   += -mdpfp
 endif
 
-ifdef CONFIG_ARC_DW2_UNWIND
-CFLAGS_ctx_sw.o += -fno-omit-frame-pointer
-obj-y += ctx_sw.o
-else
-obj-y += ctx_sw_asm.o
-endif
-
 extra-y := vmlinux.lds
arch/arc/kernel/ctx_sw.c deleted +0 -103

103 lines not on this page · raw message

arch/arc/kernel/ctx_sw_asm.S +39 -33

87 lines not on this page · raw message

Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#16 lore raw

PATCH 12/20 ARC: __switch_to: move ksp to thread_info from thread_struct

In reply to Vineet Gupta

task's arch specific bits are carried in 2 places
- embedded thread_struct in task_struct
- associated thread_info (hoisted in task's stack page) and
syntactically: (thread_info *)(task_struct->stack)

ksp (dynamic kernel stack top) currently lives in thread_struct but given its deep location in task struct likely to cache miss when accessed from __switch_to(). Moving it to thread_info would be more efficient given proximity to frequently accessed items such as preempt_count thus very likely to be in cache, specially in schedular code.

Note however that currently tsk.thread.ksp takes 1 memory access (off of tsk pointer) while new code tsk->stack.ksp would take 2, but likely to be in cache. Moreover if task is current the 2nd reference can be elided and instead derived from SP as (SP & ~(THREAD_SIZE - 1))

All of this also makes __switch_to() code simpler and we can see the 2 ways of retirving ksp (descrobed above) in new code.

---
 arch/arc/include/asm/processor.h   |  3 +--
 arch/arc/include/asm/thread_info.h | 10 +++++-----
 arch/arc/kernel/asm-offsets.c      |  2 +-
 arch/arc/kernel/ctx_sw_asm.S       | 22 ++++++++++------------
 arch/arc/kernel/process.c          |  6 +++---
 5 files changed, 20 insertions(+), 23 deletions(-)
arch/arc/include/asm/processor.h +1 -2
index 82ddc929d6e7..d606658e2fe7 100644
@@ -22,7 +22,6 @@
  * struct thread_info
  */
 struct thread_struct {
-	unsigned long ksp;	/* kernel mode stack pointer */
 	unsigned long callee_reg;	/* pointer to callee regs */
 	unsigned long fault_address;	/* dbls as brkpt holder as well */
 #ifdef CONFIG_ARC_DSP_SAVE_RESTORE_REGS
@@ -54,7 +53,7 @@ struct task_struct;
  * Where about of Task's sp, fp, blink when it was last seen in kernel mode.
  * Look in process.c for details of kernel stack layout
  */
-#define TSK_K_ESP(tsk)		(tsk->thread.ksp)
+#define TSK_K_ESP(tsk)		(task_thread_info(tsk)->ksp)
 
 #define TSK_K_REG(tsk, off)	(*((unsigned long *)(TSK_K_ESP(tsk) + \
 					sizeof(struct callee_regs) + off)))
arch/arc/include/asm/thread_info.h +5 -5
index 6ba7fe417095..4c530cf131f3 100644
@@ -37,16 +37,16 @@
  */
 struct thread_info {
 	unsigned long flags;		/* low level flags */
+	unsigned long ksp;		/* kernel mode stack top in __switch_to */
 	int preempt_count;		/* 0 => preemptable, <0 => BUG */
-	struct task_struct *task;	/* main task structure */
-	__u32 cpu;			/* current CPU */
+	int cpu;			/* current CPU */
 	unsigned long thr_ptr;		/* TLS ptr */
+	struct task_struct *task;	/* main task structure */
 };
 
 /*
- * macros/functions for gaining access to the thread information structure
- *
- * preempt_count needs to be 1 initially, until the scheduler is functional.
+ * initilaize thread_info for any @tsk
+ *  - this is not related to init_task per se
  */
 #define INIT_THREAD_INFO(tsk)			\
 {						\
arch/arc/kernel/asm-offsets.c +1 -1
index 37324fd9a72f..5b47d09b925e 100644
@@ -20,13 +20,13 @@ int main(void)
 
 	BLANK();
 
-	DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
 	DEFINE(THREAD_CALLEE_REG, offsetof(struct thread_struct, callee_reg));
 	DEFINE(THREAD_FAULT_ADDR,
 	       offsetof(struct thread_struct, fault_address));
 
 	BLANK();
 
+	DEFINE(THREAD_INFO_KSP, offsetof(struct thread_info, ksp));
 	DEFINE(THREAD_INFO_FLAGS, offsetof(struct thread_info, flags));
 	DEFINE(THREAD_INFO_PREEMPT_COUNT,
 	       offsetof(struct thread_info, preempt_count));
arch/arc/kernel/ctx_sw_asm.S +10 -12
index 59d779004e64..48e1f21976ed 100644
@@ -11,8 +11,6 @@
 #include <asm/entry.h>       /* For the SAVE_* macros */
 #include <asm/asm-offsets.h>
 
-#define KSP_WORD_OFF 	((TASK_THREAD + THREAD_KSP) / 4)
-
 ; IN
 ;  - r0: prev task (also current)
 ;  - r1: next task
@@ -37,19 +35,19 @@ ENTRY_CFI(__switch_to)
 	/* kernel mode callee regs of @prev */
 	SAVE_CALLEE_SAVED_KERNEL
 
-	/* save final SP to @prev->thread.ksp */
-#if KSP_WORD_OFF  <= 255
-	st.as  sp, [r0, KSP_WORD_OFF]
-#else
-	/* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
-	add2	r10, r0, KSP_WORD_OFF
-	st	sp, [r10]
-#endif
+	/*
+	 * save final SP to @prev->thread_info.ksp
+	 * @prev is "current" so thread_info derived from SP
+	 */
+	GET_CURR_THR_INFO_FROM_SP  r10
+	st	sp,  [r10, THREAD_INFO_KSP]
+
 	/* update @next in _current_task[] and GP register caching it */
 	SET_CURR_TASK_ON_CPU  r1, r10
 
-	/* load SP from @next->thread.ksp */
-	ld.as	sp, [r1, KSP_WORD_OFF]
+	/* load SP from @next->thread_info.ksp */
+	ld	r10, [r1, TASK_THREAD_INFO]
+	ld	sp,  [r10, THREAD_INFO_KSP]
 
 	/* restore callee regs, stack frame regs of @next */
 	RESTORE_CALLEE_SAVED_KERNEL
arch/arc/kernel/process.c +3 -3
index 96f591508142..186ceab661eb 100644
@@ -141,7 +141,7 @@ asmlinkage void ret_from_fork(void);
  * |    unused      |
  * |                |
  * ------------------
- * |     r25        |   <==== top of Stack (thread.ksp)
+ * |     r25        |   <==== top of Stack (thread_info.ksp)
  * ~                ~
  * |    --to--      |   (CALLEE Regs of kernel mode)
  * |     r13        |
@@ -181,14 +181,14 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
 	c_callee = ((struct callee_regs *)childksp) - 1;
 
 	/*
-	 * __switch_to() uses thread.ksp to start unwinding stack
+	 * __switch_to() uses thread_info.ksp to start unwinding stack
 	 * For kernel threads we don't need to create callee regs, the
 	 * stack layout nevertheless needs to remain the same.
 	 * Also, since __switch_to anyways unwinds callee regs, we use
 	 * this to populate kernel thread entry-pt/args into callee regs,
 	 * so that ret_from_kernel_thread() becomes simpler.
 	 */
-	p->thread.ksp = (unsigned long)c_callee;	/* THREAD_KSP */
+	task_thread_info(p)->ksp = (unsigned long)c_callee;	/* THREAD_INFO_KSP */
 
 	/* __switch_to expects FP(0), BLINK(return addr) at top */
 	childksp[0] = 0;			/* fp */
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#17 lore raw

PATCH 13/20 ARC: entry: rework (non-functional)

In reply to Vineet Gupta

- comments update
- rename syscall_trace_entry
- use PT_xxx in entry code

---
 arch/arc/include/asm/entry-arcv2.h   | 23 ++++++++------
 arch/arc/include/asm/entry-compact.h |  3 +-
 arch/arc/include/asm/ptrace.h        |  2 +-
 arch/arc/kernel/asm-offsets.c        |  1 +
 arch/arc/kernel/entry.S              | 45 +++++++++++++---------------
 arch/arc/kernel/ptrace.c             |  2 +-
 6 files changed, 39 insertions(+), 37 deletions(-)
arch/arc/include/asm/entry-arcv2.h +14 -9
index 858742feab71..a38ed505b3de 100644
@@ -48,14 +48,18 @@
 /*------------------------------------------------------------------------*/
 .macro INTERRUPT_PROLOGUE
 
-	; (A) Before jumping to Interrupt Vector, hardware micro-ops did following:
+	; Before jumping to Interrupt Vector, hardware micro-ops did following:
 	;   1. SP auto-switched to kernel mode stack
 	;   2. STATUS32.Z flag set if in U mode at time of interrupt (U:1,K:0)
 	;   3. Auto save: (mandatory) Push PC and STAT32 on stack
 	;                 hardware does even if CONFIG_ARC_IRQ_NO_AUTOSAVE
-	;   4. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI
+	;  4a. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI
 	;
-	; (B) Manually saved some regs: r12,r30, sp,fp,gp, ACCL pair
+	; Now
+	;  4b. If Auto-save (optional) not enabled in hw, manually save them
+	;   5. Manually save: r12,r30, sp,fp,gp, ACCL pair
+	;
+	; At the end, SP points to pt_regs
 
 #ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE
 	; carve pt_regs on stack (case #3), PC/STAT32 already on stack
@@ -73,13 +77,14 @@
 /*------------------------------------------------------------------------*/
 .macro EXCEPTION_PROLOGUE
 
-	; (A) Before jumping to Exception Vector, hardware micro-ops did following:
+	; Before jumping to Exception Vector, hardware micro-ops did following:
 	;   1. SP auto-switched to kernel mode stack
 	;   2. STATUS32.Z flag set if in U mode at time of exception (U:1,K:0)
 	;
-	; (B) Manually save the complete reg file below
+	; Now manually save rest of reg file
+	; At the end, SP points to pt_regs
 
-	sub	sp, sp, SZ_PT_REGS	; carve pt_regs
+	sub	sp, sp, SZ_PT_REGS	; carve space for pt_regs
 
 	; _HARD saves r10 clobbered by _SOFT as scratch hence comes first
 
@@ -136,8 +141,8 @@
 
 	ST2	gp, fp, PT_r26		; gp (r26), fp (r27)
 
-	st	r12, [sp, PT_sp + 4]
-	st	r30, [sp, PT_sp + 8]
+	st	r12, [sp, PT_r12]
+	st	r30, [sp, PT_r30]
 
 	; Saving pt_regs->sp correctly requires some extra work due to the way
 	; Auto stack switch works
@@ -244,7 +249,7 @@
 
 	btst	r0, STATUS_U_BIT	; Z flag set if K, used in restoring SP
 
-	ld	r10, [sp, PT_event + 4]
+	ld	r10, [sp, PT_bta]
 	sr	r10, [erbta]
 
 	LD2	r10, r11, PT_ret
arch/arc/include/asm/entry-compact.h +2 -1
index e3383e1cb040..4e2ae82779ed 100644
@@ -170,12 +170,13 @@
 	PUSHAX	erbta
 
 	lr	r10, [ecr]
-	st      r10, [sp, PT_event]    /* EV_Trap expects r10 to have ECR */
+	st      r10, [sp, PT_event]
 
 #ifdef CONFIG_ARC_CURR_IN_REG
 	/* gp already saved on stack: now load with "current" */
 	GET_CURR_TASK_ON_CPU   gp
 #endif
+	; OUTPUT: r10 has ECR expected by EV_Trap
 .endm
 
 /*--------------------------------------------------------------
arch/arc/include/asm/ptrace.h +1 -1
index e9798f46cdc4..2bf8ea96ea21 100644
@@ -75,7 +75,7 @@ struct pt_regs {
 		unsigned long event;
 	};
 
-	unsigned long bta;	/* bta_l1, bta_l2, erbta */
+	unsigned long bta;	/* erbta */
 
 	unsigned long r26;	/* gp */
 	unsigned long fp;
arch/arc/kernel/asm-offsets.c +1 -0
index 5b47d09b925e..e46688975868 100644
@@ -47,6 +47,7 @@ int main(void)
 
 	DEFINE(PT_status32, offsetof(struct pt_regs, status32));
 	DEFINE(PT_event, offsetof(struct pt_regs, event));
+	DEFINE(PT_bta, offsetof(struct pt_regs, bta));
 	DEFINE(PT_sp, offsetof(struct pt_regs, sp));
 	DEFINE(PT_r0, offsetof(struct pt_regs, r0));
 	DEFINE(PT_r1, offsetof(struct pt_regs, r1));
arch/arc/kernel/entry.S +20 -25

107 lines not on this page · raw message

arch/arc/kernel/ptrace.c +1 -1
index 8226df3163fe..14ea7406f5cd 100644
@@ -339,7 +339,7 @@ long arch_ptrace(struct task_struct *child, long request,
 	return ret;
 }
 
-asmlinkage int syscall_trace_entry(struct pt_regs *regs)
+asmlinkage int syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		if (ptrace_report_syscall_entry(regs))
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#18 lore raw

PATCH 14/20 ARC: entry: ARcompact EV_ProtV to use r10 directly

In reply to Vineet Gupta
---
 arch/arc/kernel/entry-compact.S | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arc/kernel/entry-compact.S +2 -4
index 5cb0cd7e4eab..77f0090554c5 100644
@@ -254,9 +254,8 @@ END(handle_interrupt_level1)
 
 ENTRY(EV_TLBProtV)
 
-	EXCEPTION_PROLOGUE
+	EXCEPTION_PROLOGUE	; ECR returned in r10
 
-	mov r2, r10	; ECR set into r10 already
 	lr  r0, [efa]	; Faulting Data address (not part of pt_regs saved above)
 
 	; Exception auto-disables further Intr/exceptions.
@@ -273,8 +272,7 @@ ENTRY(EV_TLBProtV)
 	;   -Access Violation	: 00_23_(00|01|02|03)_00
 	;			         x  r  w  r+w
 	;   -Unaligned Access	: 00_23_04_00
-	;
-	bbit1 r2, ECR_C_BIT_PROTV_MISALIG_DATA, 4f
+	bbit1 r10, ECR_C_BIT_PROTV_MISALIG_DATA, 4f
 
 	;========= (6a) Access Violation Processing ========
 	bl  do_page_fault
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#19 lore raw

PATCH 15/20 ARC: entry: EV_MachineCheck dont re-read ECR

In reply to Vineet Gupta
---
 arch/arc/kernel/entry.S | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arc/kernel/entry.S +2 -3
index f291fc8476d7..46582fbebcf2 100644
@@ -95,16 +95,15 @@ END(instr_service)
 
 ENTRY(EV_MachineCheck)
 
-	EXCEPTION_PROLOGUE
+	EXCEPTION_PROLOGUE	; ECR returned in r10
 
-	lr  r2, [ecr]
 	lr  r0, [efa]
 	mov r1, sp
 
 	; MC excpetions disable MMU
 	ARC_MMU_REENABLE r3
 
-	lsr  	r3, r2, 8
+	lsr  	r3, r10, 8
 	bmsk 	r3, r3, 7
 	brne    r3, ECR_C_MCHK_DUP_TLB, 1f
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#20 lore raw

PATCH 16/20 ARC: entry: Add more common chores to EXCEPTION_PROLOGUE

In reply to Vineet Gupta

THe high level structure of most ARC exception handlers is
1. save regfile with EXCEPTION_PROLOGUE
2. setup r0: EFA (not part of pt_regs)
3. setup r1: pointer to pt_regs (SP)
4. drop down to pure kernel mode (from exception)
5. call the Linux "C" handler

Remove the boiler plate code by moving #2, #3, #4 into #1.

The exceptions to most exceptions are syscall Trap and Machine check which don't do some of above for various reasons, so call a newly introduced variant EXCEPTION_PROLOGUE_KEEP_AE (same as original EXCEPTION_PROLOGUE)

---
 arch/arc/include/asm/entry-arcv2.h   | 12 +++++++++++-
 arch/arc/include/asm/entry-compact.h | 12 +++++++++++-
 arch/arc/kernel/entry-arcv2.S        | 15 ---------------
 arch/arc/kernel/entry-compact.S      | 10 ----------
 arch/arc/kernel/entry.S              | 19 ++-----------------
 5 files changed, 24 insertions(+), 44 deletions(-)
arch/arc/include/asm/entry-arcv2.h +11 -1
index a38ed505b3de..11b48ab39154 100644
@@ -75,7 +75,7 @@
 .endm
 
 /*------------------------------------------------------------------------*/
-.macro EXCEPTION_PROLOGUE
+.macro EXCEPTION_PROLOGUE_KEEP_AE
 
 	; Before jumping to Exception Vector, hardware micro-ops did following:
 	;   1. SP auto-switched to kernel mode stack
@@ -104,6 +104,16 @@
 	; OUTPUT: r10 has ECR expected by EV_Trap
 .endm
 
+.macro EXCEPTION_PROLOGUE
+
+	EXCEPTION_PROLOGUE_KEEP_AE	; return ECR in r10
+
+	lr  r0, [efa]
+	mov r1, sp
+
+	FAKE_RET_FROM_EXCPN		; clobbers r9
+.endm
+
 /*------------------------------------------------------------------------
  * This macro saves the registers manually which would normally be autosaved
  * by hardware on taken interrupts. It is used by
arch/arc/include/asm/entry-compact.h +11 -1
index 4e2ae82779ed..a0e760eb35a8 100644
@@ -140,7 +140,7 @@
  *
  * After this it is safe to call the "C" handlers
  *-------------------------------------------------------------*/
-.macro EXCEPTION_PROLOGUE
+.macro EXCEPTION_PROLOGUE_KEEP_AE
 
 	/* Need at least 1 reg to code the early exception prologue */
 	PROLOG_FREEUP_REG r9, @ex_saved_reg1
@@ -179,6 +179,16 @@
 	; OUTPUT: r10 has ECR expected by EV_Trap
 .endm
 
+.macro EXCEPTION_PROLOGUE
+
+	EXCEPTION_PROLOGUE_KEEP_AE	; return ECR in r10
+
+	lr  r0, [efa]
+	mov r1, sp
+
+	FAKE_RET_FROM_EXCPN		; clobbers r9
+.endm
+
 /*--------------------------------------------------------------
  * Restore all registers used by system call or Exceptions
  * SP should always be pointing to the next free stack element
arch/arc/kernel/entry-arcv2.S +0 -15
index a7e6a2174187..2e49c81c8086 100644
@@ -125,11 +125,6 @@ ENTRY(mem_service)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_memory_error
 	b   ret_from_exception
 END(mem_service)
@@ -138,11 +133,6 @@ ENTRY(EV_Misaligned)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]	; Faulting Data address
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	SAVE_CALLEE_SAVED_USER
 	mov r2, sp              ; callee_regs
 
@@ -163,11 +153,6 @@ ENTRY(EV_TLBProtV)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]	; Faulting Data address
-	mov r1, sp	; pt_regs
-
-	FAKE_RET_FROM_EXCPN
-
 	mov blink, ret_from_exception
 	b   do_page_fault
 
arch/arc/kernel/entry-compact.S +0 -10
index 77f0090554c5..c218285cff87 100644
@@ -256,16 +256,6 @@ ENTRY(EV_TLBProtV)
 
 	EXCEPTION_PROLOGUE	; ECR returned in r10
 
-	lr  r0, [efa]	; Faulting Data address (not part of pt_regs saved above)
-
-	; Exception auto-disables further Intr/exceptions.
-	; Re-enable them by pretending to return from exception
-	; (so rest of handler executes in pure K mode)
-
-	FAKE_RET_FROM_EXCPN
-
-	mov   r1, sp	; Handle to pt_regs
-
 	;------ (5) Type of Protection Violation? ----------
 	;
 	; ProtV Hardware Exception is triggered for Access Faults of 2 types
arch/arc/kernel/entry.S +2 -17
index 46582fbebcf2..089f6680518f 100644
@@ -80,11 +80,6 @@ ENTRY(instr_service)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_insterror_or_kprobe
 	b   ret_from_exception
 END(instr_service)
@@ -95,7 +90,7 @@ END(instr_service)
 
 ENTRY(EV_MachineCheck)
 
-	EXCEPTION_PROLOGUE	; ECR returned in r10
+	EXCEPTION_PROLOGUE_KEEP_AE	; ECR returned in r10
 
 	lr  r0, [efa]
 	mov r1, sp
@@ -128,11 +123,6 @@ ENTRY(EV_PrivilegeV)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_privilege_fault
 	b   ret_from_exception
 END(EV_PrivilegeV)
@@ -144,11 +134,6 @@ ENTRY(EV_Extension)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_extension_fault
 	b   ret_from_exception
 END(EV_Extension)
@@ -229,7 +214,7 @@ trap_with_param:
 
 ENTRY(EV_Trap)
 
-	EXCEPTION_PROLOGUE
+	EXCEPTION_PROLOGUE_KEEP_AE
 
 	lr  r12, [efa]
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#21 lore raw

Re: [PATCH 16/20] ARC: entry: Add more common chores to EXCEPTION_PROLOGUE

Hi Vineet,

Quoted 10 lines

Subject: [PATCH 16/20] ARC: entry: Add more common chores to
EXCEPTION_PROLOGUE

THe high level structure of most ARC exception handlers is
1. save regfile with EXCEPTION_PROLOGUE
2. setup r0: EFA (not part of pt_regs)
3. setup r1: pointer to pt_regs (SP)
4. drop down to pure kernel mode (from exception)
5. call the Linux "C" handler

Quoted 6 lines

Remove the boiler plate code by moving #2, #3, #4 into #1.

The exceptions to most exceptions are syscall Trap and Machine check which don't do some of above for various reasons, so call a newly introduced variant EXCEPTION_PROLOGUE_KEEP_AE (same as original EXCEPTION_PROLOGUE)

I'm observing the ARC700 (nSIM) system freeze after this patch.

...
f0000000.serial: ttyS0 at MMIO 0xf0000000 (irq = 24, base_baud = 3125000) is a 16550A
printk: console [ttyS0] enabled
printk: console [ttyS0] enabled
printk: bootconsole [uart8250] disabled
printk: bootconsole [uart8250] disabled
NET: Registered PF_PACKET protocol family
NET: Registered PF_KEY protocol family
clk: Disabling unused clocks
Freeing unused kernel image (initmem) memory: 2856K
This architecture does not have kernel memory protection.
Run /init as init process

arch/arc/kernel/entry.S ENTRY(EV_PrivilegeV) · line 127

Quoted 11 lines
arch/arc/kernel/entry.S +0 -5
@@ -128,11 +123,6 @@ ENTRY(EV_PrivilegeV)
 
         EXCEPTION_PROLOGUE
 
-       lr  r0, [efa]
-       mov r1, sp
-
-       FAKE_RET_FROM_EXCPN
-
         bl  do_privilege_fault
         b   ret_from_exception

The same update is also required for the call_do_page_fault wrapper for ARcompact.

Regards,
Pavel

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

author maintainer
#22 lore raw

Re: [PATCH 16/20] ARC: entry: Add more common chores to EXCEPTION_PROLOGUE

Quoted 37 lines · On 8/18/23 05:56, [email protected] wrote:

Hi Vineet,

Quoted 10 lines

Subject: [PATCH 16/20] ARC: entry: Add more common chores to
EXCEPTION_PROLOGUE

THe high level structure of most ARC exception handlers is
1. save regfile with EXCEPTION_PROLOGUE
2. setup r0: EFA (not part of pt_regs)
3. setup r1: pointer to pt_regs (SP)
4. drop down to pure kernel mode (from exception)
5. call the Linux "C" handler

Quoted 6 lines

Remove the boiler plate code by moving #2, #3, #4 into #1.

The exceptions to most exceptions are syscall Trap and Machine check which don't do some of above for various reasons, so call a newly introduced variant EXCEPTION_PROLOGUE_KEEP_AE (same as original EXCEPTION_PROLOGUE)

I'm observing the ARC700 (nSIM) system freeze after this patch.

...
f0000000.serial: ttyS0 at MMIO 0xf0000000 (irq = 24, base_baud = 3125000) is a 16550A
printk: console [ttyS0] enabled
printk: console [ttyS0] enabled
printk: bootconsole [uart8250] disabled
printk: bootconsole [uart8250] disabled
NET: Registered PF_PACKET protocol family
NET: Registered PF_KEY protocol family
clk: Disabling unused clocks
Freeing unused kernel image (initmem) memory: 2856K
This architecture does not have kernel memory protection.
Run /init as init process

Quoted 4 lines
arch/arc/kernel/entry-arcv2.S +0 -0
@@ -128,11 +123,6 @@ ENTRY(EV_PrivilegeV)
 
          EXCEPTION_PROLOGUE
 
Quoted 8 lines

arch/arc/kernel/entry.S ENTRY(EV_PrivilegeV) · line 127

Quoted 7 lines
arch/arc/kernel/entry.S +0 -5
-       lr  r0, [efa]
-       mov r1, sp
-
-       FAKE_RET_FROM_EXCPN
-
          bl  do_privilege_fault
          b   ret_from_exception

The same update is also required for the call_do_page_fault wrapper for ARcompact.

Indeed I missed that part.

-Vineet

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

author maintainer
#23 lore raw

PATCH v2 16/20 ARC: entry: Add more common chores to EXCEPTION_PROLOGUE

In reply to [email protected]

THe high level structure of most ARC exception handlers is
1. save regfile with EXCEPTION_PROLOGUE
2. setup r0: EFA (not part of pt_regs)
3. setup r1: pointer to pt_regs (SP)
4. drop down to pure kernel mode (from exception)
5. call the Linux "C" handler

Remove the boiler plate code by moving #2, #3, #4 into #1.

The exceptions to most exceptions are syscall Trap and Machine check which don't do some of above for various reasons, so call a newly introduced variant EXCEPTION_PROLOGUE_KEEP_AE (same as original EXCEPTION_PROLOGUE)

---
 arch/arc/include/asm/entry-arcv2.h   | 12 +++++++++++-
 arch/arc/include/asm/entry-compact.h | 12 +++++++++++-
 arch/arc/kernel/entry-arcv2.S        | 15 ---------------
 arch/arc/kernel/entry-compact.S      | 13 -------------
 arch/arc/kernel/entry.S              | 19 ++-----------------
 5 files changed, 24 insertions(+), 47 deletions(-)
arch/arc/include/asm/entry-arcv2.h +11 -1
index a38ed505b3de..11b48ab39154 100644
@@ -75,7 +75,7 @@
 .endm
 
 /*------------------------------------------------------------------------*/
-.macro EXCEPTION_PROLOGUE
+.macro EXCEPTION_PROLOGUE_KEEP_AE
 
 	; Before jumping to Exception Vector, hardware micro-ops did following:
 	;   1. SP auto-switched to kernel mode stack
@@ -104,6 +104,16 @@
 	; OUTPUT: r10 has ECR expected by EV_Trap
 .endm
 
+.macro EXCEPTION_PROLOGUE
+
+	EXCEPTION_PROLOGUE_KEEP_AE	; return ECR in r10
+
+	lr  r0, [efa]
+	mov r1, sp
+
+	FAKE_RET_FROM_EXCPN		; clobbers r9
+.endm
+
 /*------------------------------------------------------------------------
  * This macro saves the registers manually which would normally be autosaved
  * by hardware on taken interrupts. It is used by
arch/arc/include/asm/entry-compact.h +11 -1
index 4e2ae82779ed..a0e760eb35a8 100644
@@ -140,7 +140,7 @@
  *
  * After this it is safe to call the "C" handlers
  *-------------------------------------------------------------*/
-.macro EXCEPTION_PROLOGUE
+.macro EXCEPTION_PROLOGUE_KEEP_AE
 
 	/* Need at least 1 reg to code the early exception prologue */
 	PROLOG_FREEUP_REG r9, @ex_saved_reg1
@@ -179,6 +179,16 @@
 	; OUTPUT: r10 has ECR expected by EV_Trap
 .endm
 
+.macro EXCEPTION_PROLOGUE
+
+	EXCEPTION_PROLOGUE_KEEP_AE	; return ECR in r10
+
+	lr  r0, [efa]
+	mov r1, sp
+
+	FAKE_RET_FROM_EXCPN		; clobbers r9
+.endm
+
 /*--------------------------------------------------------------
  * Restore all registers used by system call or Exceptions
  * SP should always be pointing to the next free stack element
arch/arc/kernel/entry-arcv2.S +0 -15
index a7e6a2174187..2e49c81c8086 100644
@@ -125,11 +125,6 @@ ENTRY(mem_service)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_memory_error
 	b   ret_from_exception
 END(mem_service)
@@ -138,11 +133,6 @@ ENTRY(EV_Misaligned)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]	; Faulting Data address
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	SAVE_CALLEE_SAVED_USER
 	mov r2, sp              ; callee_regs
 
@@ -163,11 +153,6 @@ ENTRY(EV_TLBProtV)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]	; Faulting Data address
-	mov r1, sp	; pt_regs
-
-	FAKE_RET_FROM_EXCPN
-
 	mov blink, ret_from_exception
 	b   do_page_fault
 
arch/arc/kernel/entry-compact.S +0 -13
index 77f0090554c5..774c03cc1d1a 100644
@@ -256,16 +256,6 @@ ENTRY(EV_TLBProtV)
 
 	EXCEPTION_PROLOGUE	; ECR returned in r10
 
-	lr  r0, [efa]	; Faulting Data address (not part of pt_regs saved above)
-
-	; Exception auto-disables further Intr/exceptions.
-	; Re-enable them by pretending to return from exception
-	; (so rest of handler executes in pure K mode)
-
-	FAKE_RET_FROM_EXCPN
-
-	mov   r1, sp	; Handle to pt_regs
-
 	;------ (5) Type of Protection Violation? ----------
 	;
 	; ProtV Hardware Exception is triggered for Access Faults of 2 types
@@ -301,9 +291,6 @@ END(EV_TLBProtV)
 ENTRY(call_do_page_fault)
 
 	EXCEPTION_PROLOGUE
-	lr  r0, [efa]	; Faulting Data address
-	mov   r1, sp
-	FAKE_RET_FROM_EXCPN
 
 	mov blink, ret_from_exception
 	b  do_page_fault
arch/arc/kernel/entry.S +2 -17
index 46582fbebcf2..089f6680518f 100644
@@ -80,11 +80,6 @@ ENTRY(instr_service)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_insterror_or_kprobe
 	b   ret_from_exception
 END(instr_service)
@@ -95,7 +90,7 @@ END(instr_service)
 
 ENTRY(EV_MachineCheck)
 
-	EXCEPTION_PROLOGUE	; ECR returned in r10
+	EXCEPTION_PROLOGUE_KEEP_AE	; ECR returned in r10
 
 	lr  r0, [efa]
 	mov r1, sp
@@ -128,11 +123,6 @@ ENTRY(EV_PrivilegeV)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_privilege_fault
 	b   ret_from_exception
 END(EV_PrivilegeV)
@@ -144,11 +134,6 @@ ENTRY(EV_Extension)
 
 	EXCEPTION_PROLOGUE
 
-	lr  r0, [efa]
-	mov r1, sp
-
-	FAKE_RET_FROM_EXCPN
-
 	bl  do_extension_fault
 	b   ret_from_exception
 END(EV_Extension)
@@ -229,7 +214,7 @@ trap_with_param:
 
 ENTRY(EV_Trap)
 
-	EXCEPTION_PROLOGUE
+	EXCEPTION_PROLOGUE_KEEP_AE
 
 	lr  r12, [efa]
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#24 lore raw

PATCH 17/20 ARC: entry: replace 8 byte OR with 4 byte BSET

In reply to Vineet Gupta

FAKE_RET_FROM_EXCEPTION drops down to pure kernel mode. It currently has an 8 byte instruction which can be replaced with 4 byte BSET

This is applicable to both ARCv2 and ARCv3 entr code.

ARCv2 current
------------
00000804 <EV_Trap>:
...

 874:   216a 1280               lr      r9,[status32]
 878:   2146 1809               bic     r9,r9,0x20
 87c:   2105 1f89 8000 0000     or      r9,r9,0x80000000
                  ^^^^^^^^^

884: 2029 8240 kflag r9

ARCv2 after
----------
000007e0 <EV_Trap>:
...

 850:   216a 1280               lr      r9,[status32]
 854:   2150 1149               bclr    r9,r9,0x5
 858:   214f 17c9               bset    r9,r9,0x1f
 85c:   2029 8240               kflag   r9
---
 arch/arc/include/asm/entry-arcv2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arc/include/asm/entry-arcv2.h +2 -2
index 11b48ab39154..f7c9b3915d10 100644
@@ -274,8 +274,8 @@
 
 .macro FAKE_RET_FROM_EXCPN
 	lr      r9, [status32]
-	bic     r9, r9, STATUS_AE_MASK
-	or      r9, r9, STATUS_IE_MASK
+	bclr    r9, r9, STATUS_AE_BIT
+	bset    r9, r9, STATUS_IE_BIT
 	kflag   r9
 .endm
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#25 lore raw

PATCH 18/20 ARC: entry: replace 8 byte ADD.ne with 4 byte ADD2.ne

In reply to Vineet Gupta

ARCv2 current
------------
000007e0 <EV_Trap>:

 7e0:   2482 3c01               sub     sp,sp,112
 7e4:   1c28 3006               std     r0r1,[sp,40]
 7e8:   1c30 3086               std     r2r3,[sp,48]
 7ec:   1c38 3106               std     r4r5,[sp,56]
 7f0:   1c40 3186               std     r6r7,[sp,64]
 7f4:   1c48 3206               std     r8r9,[sp,72]
 7f8:   1c50 3286               std     r10r11,[sp,80]
 7fc:   1c58 37c0               st      blink,[sp,88]
 800:   1c0c 36c0               st      fp,[sp,12]
 804:   1c18 3680               st      gp,[sp,24]
 808:   1c10 3780               st      r30,[sp,16]
 80c:   1c14 3300               st      r12,[sp,20]
 810:   226a 1340               lr      r10,[aux_user_sp]
 814:   22ca 1702               mov.ne  r10,sp
 818:   22c0 1f82 0000 0070     add.ne  r10,r10,0x70
                  ^^^^^^^^^
With fix
--------
000007b4 <EV_Trap>:
 7b4:   2482 3c01               sub     sp,sp,112
 7b8:   1c28 3006               std     r0r1,[sp,40]
 7bc:   1c30 3086               std     r2r3,[sp,48]
 7c0:   1c38 3106               std     r4r5,[sp,56]
 7c4:   1c40 3186               std     r6r7,[sp,64]
 7c8:   1c48 3206               std     r8r9,[sp,72]
 7cc:   1c50 3286               std     r10r11,[sp,80]
 7d0:   1c58 37c0               st      blink,[sp,88]
 7d4:   1c0c 36c0               st      fp,[sp,12]
 7d8:   1c18 3680               st      gp,[sp,24]
 7dc:   1c10 3780               st      r30,[sp,16]
 7e0:   1c14 3300               st      r12,[sp,20]
 7e4:   226a 1340               lr      r10,[aux_user_sp]
 7e8:   22ca 1702               mov.ne  r10,sp
 7ec:   22d5 1722               add2.ne r10,r10,0x1c
---
 arch/arc/include/asm/entry-arcv2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/include/asm/entry-arcv2.h +1 -1
index f7c9b3915d10..a030eae93d35 100644
@@ -167,7 +167,7 @@
 
 	; ISA requires ADD.nz to have same dest and src reg operands
 	mov.nz	r10, sp
-	add.nz	r10, r10, SZ_PT_REGS	; K mode SP
+	add2.nz	r10, r10, SZ_PT_REGS/4	; K mode SP
 
 	st	r10, [sp, PT_sp]	; SP (pt_regs->sp)
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#26 lore raw

PATCH 19/20 ARCv2: entry: rearrange pt_regs slightly

In reply to Vineet Gupta

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

---
 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(-)
arch/arc/include/asm/entry-arcv2.h +6 -6
index a030eae93d35..4d13320e0c1b 100644
@@ -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
arch/arc/include/asm/ptrace.h +5 -4
index 2bf8ea96ea21..3a054b695f28 100644
@@ -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;
 
arch/arc/kernel/asm-offsets.c +4 -3
index e46688975868..478768c88f46 100644
@@ -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;
 }
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
author maintainer
#27 lore raw

PATCH 20/20 ARC: pt_regs: create seperate type for ecr

In reply to Vineet Gupta

Reduces duplication in each ISA specific pt_regs

---
 arch/arc/include/asm/ptrace.h  | 45 +++++++++++++---------------------
 arch/arc/kernel/asm-offsets.c  |  2 +-
 arch/arc/kernel/kgdb.c         |  2 +-
 arch/arc/kernel/ptrace.c       |  4 +--
 arch/arc/kernel/traps.c        |  4 +--
 arch/arc/kernel/troubleshoot.c | 13 +++++-----
 arch/arc/mm/fault.c            |  6 ++---
 7 files changed, 32 insertions(+), 44 deletions(-)
arch/arc/include/asm/ptrace.h +17 -28
index 3a054b695f28..724e3fe31ed5 100644
@@ -12,6 +12,17 @@
 
 #ifndef __ASSEMBLY__
 
+typedef union {
+	struct {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+		unsigned long state:8, vec:8, cause:8, param:8;
+#else
+		unsigned long param:8, cause:8, vec:8, state:8;
+#endif
+	};
+	unsigned long full;
+} ecr_reg;
+
 /* THE pt_regs: Defines how regs are saved during entry into kernel */
 
 #ifdef CONFIG_ISA_ARCOMPACT
@@ -40,18 +51,7 @@ struct pt_regs {
 	 * 	Last word used by Linux for extra state mgmt (syscall-restart)
 	 * For interrupts, use artificial ECR values to note current prio-level
 	 */
-	union {
-		struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-			unsigned long state:8, ecr_vec:8,
-				      ecr_cause:8, ecr_param:8;
-#else
-			unsigned long ecr_param:8, ecr_cause:8,
-				      ecr_vec:8, state:8;
-#endif
-		};
-		unsigned long event;
-	};
+	ecr_reg ecr;
 };
 
 #define MAX_REG_OFFSET offsetof(struct pt_regs, event)
@@ -62,18 +62,7 @@ struct pt_regs {
 
 	unsigned long orig_r0;
 
-	union {
-		struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-			unsigned long state:8, ecr_vec:8,
-				      ecr_cause:8, ecr_param:8;
-#else
-			unsigned long ecr_param:8, ecr_cause:8,
-				      ecr_vec:8, state:8;
-#endif
-		};
-		unsigned long event;
-	};
+	ecr_reg ecr;		/* Exception Cause Reg */
 
 	unsigned long bta;	/* erbta */
 
@@ -131,13 +120,13 @@ struct callee_regs {
 /* return 1 if PC in delay slot */
 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
 
-#define in_syscall(regs)    ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
-#define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
+#define in_syscall(regs)    ((regs->ecr.vec == ECR_V_TRAP) && !regs->ecr.param)
+#define in_brkpt_trap(regs) ((regs->ecr.vec == ECR_V_TRAP) && regs->ecr.param)
 
 #define STATE_SCALL_RESTARTED	0x01
 
-#define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
-#define syscall_restartable(reg) !(reg->state &  STATE_SCALL_RESTARTED)
+#define syscall_wont_restart(regs) (regs->ecr.state |= STATE_SCALL_RESTARTED)
+#define syscall_restartable(regs) !(regs->ecr.state &  STATE_SCALL_RESTARTED)
 
 #define current_pt_regs()					\
 ({								\
arch/arc/kernel/asm-offsets.c +1 -1
index 478768c88f46..f77deb799175 100644
@@ -46,7 +46,7 @@ int main(void)
 	BLANK();
 
 	DEFINE(PT_status32, offsetof(struct pt_regs, status32));
-	DEFINE(PT_event, offsetof(struct pt_regs, event));
+	DEFINE(PT_event, offsetof(struct pt_regs, ecr));
 	DEFINE(PT_bta, offsetof(struct pt_regs, bta));
 	DEFINE(PT_sp, offsetof(struct pt_regs, sp));
 	DEFINE(PT_r0, offsetof(struct pt_regs, r0));
arch/arc/kernel/kgdb.c +1 -1
index 345a0000554c..4f2b5951454f 100644
@@ -175,7 +175,7 @@ void kgdb_trap(struct pt_regs *regs)
 	 * with trap_s 4 (compiled) breakpoints, continuation needs to
 	 * start after the breakpoint.
 	 */
-	if (regs->ecr_param == 3)
+	if (regs->ecr.param == 3)
 		instruction_pointer(regs) -= BREAK_INSTR_SIZE;
 
 	kgdb_handle_exception(1, SIGTRAP, 0, regs);
arch/arc/kernel/ptrace.c +2 -2
index 14ea7406f5cd..e0c233c178b1 100644
@@ -46,7 +46,7 @@ static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(r0),
 	REG_OFFSET_NAME(sp),
 	REG_OFFSET_NAME(orig_r0),
-	REG_OFFSET_NAME(event),
+	REG_OFFSET_NAME(ecr),
 	REG_OFFSET_END,
 };
 
@@ -54,7 +54,7 @@ static const struct pt_regs_offset regoffset_table[] = {
 
 static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(orig_r0),
-	REG_OFFSET_NAME(event),
+	REG_OFFSET_NAME(ecr),
 	REG_OFFSET_NAME(bta),
 	REG_OFFSET_NAME(r26),
 	REG_OFFSET_NAME(fp),
arch/arc/kernel/traps.c +1 -3
index 2f7eb786695b..9b9570b79362 100644
@@ -110,9 +110,7 @@ void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
  */
 void do_non_swi_trap(unsigned long address, struct pt_regs *regs)
 {
-	unsigned int param = regs->ecr_param;
-
-	switch (param) {
+	switch (regs->ecr.param) {
 	case 1:
 		trap_is_brkpt(address, regs);
 		break;
arch/arc/kernel/troubleshoot.c +7 -6
index 7654c2e42dc0..d5b3ed2c58f5 100644
@@ -115,8 +115,8 @@ static void show_ecr_verbose(struct pt_regs *regs)
 	/* For Data fault, this is data address not instruction addr */
 	address = current->thread.fault_address;
 
-	vec = regs->ecr_vec;
-	cause_code = regs->ecr_cause;
+	vec = regs->ecr.vec;
+	cause_code = regs->ecr.cause;
 
 	/* For DTLB Miss or ProtV, display the memory involved too */
 	if (vec == ECR_V_DTLB_MISS) {
@@ -154,7 +154,7 @@ static void show_ecr_verbose(struct pt_regs *regs)
 		pr_cont("Misaligned r/w from 0x%08lx\n", address);
 #endif
 	} else if (vec == ECR_V_TRAP) {
-		if (regs->ecr_param == 5)
+		if (regs->ecr.param == 5)
 			pr_cont("gcc generated __builtin_trap\n");
 	} else {
 		pr_cont("Check Programmer's Manual\n");
@@ -184,9 +184,10 @@ void show_regs(struct pt_regs *regs)
 	if (user_mode(regs))
 		show_faulting_vma(regs->ret); /* faulting code, not data */
 
-	pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\nSTAT: 0x%08lx",
-		regs->event, current->thread.fault_address, regs->ret,
-		regs->status32);
+	pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\n",
+		regs->ecr.full, current->thread.fault_address, regs->ret);
+
+	pr_info("STAT32: 0x%08lx", regs->status32);
 
 #define STS_BIT(r, bit)	r->status32 & STATUS_##bit##_MASK ? #bit" " : ""
 
arch/arc/mm/fault.c +3 -3
index 26e5823c5710..95119a5e7761 100644
@@ -100,10 +100,10 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	if (faulthandler_disabled() || !mm)
 		goto no_context;
 
-	if (regs->ecr_cause & ECR_C_PROTV_STORE)	/* ST/EX */
+	if (regs->ecr.cause & ECR_C_PROTV_STORE)	/* ST/EX */
 		write = 1;
-	else if ((regs->ecr_vec == ECR_V_PROTV) &&
-	         (regs->ecr_cause == ECR_C_PROTV_INST_FETCH))
+	else if ((regs->ecr.vec == ECR_V_PROTV) &&
+	         (regs->ecr.cause == ECR_C_PROTV_INST_FETCH))
 		exec = 1;
 
 	flags = FAULT_FLAG_DEFAULT;
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#28 lore raw

Re: [PATCH 20/20] ARC: pt_regs: create seperate type for ecr

kernel test robot noticed the following build errors:

Hi Vineet,

kernel test robot noticed the following build errors:

[auto build test ERROR on vgupta-arc/for-curr]
[cannot apply to vgupta-arc/for-next linus/master v6.5-rc6 next-20230809] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vineet-Gupta/ARC-uaccess-remove-arc-specific-out-of-line-handles-for-Os/20230815-085308
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git for-curr
patch link:    https://lore.kernel.org/r/20230815004813.555115-21-vgupta%40kernel.org
patch subject: [PATCH 20/20] ARC: pt_regs: create seperate type for ecr
config: arc-randconfig-r043-20230815 (https://download.01.org/0day-ci/archive/20230815/[email protected]/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230815/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from arch/arc/include/asm/ptrace.h:11,

                    from arch/arc/include/asm/bug.h:11,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   arch/arc/include/asm/ptrace.h: In function 'regs_get_register':
>> include/linux/stddef.h:16:33: error: 'struct pt_regs' has no member named 'event'
      16 | #define offsetof(TYPE, MEMBER)  __builtin_offsetof(TYPE, MEMBER)
         |                                 ^~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:77:45: note: in definition of macro 'unlikely'
      77 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^

arch/arc/include/asm/ptrace.h:57:24: note: in expansion of macro 'offsetof'
57 | #define MAX_REG_OFFSET offsetof(struct pt_regs, event)
| ^~~~~~~~
arch/arc/include/asm/ptrace.h:164:31: note: in expansion of macro 'MAX_REG_OFFSET'
164 | if (unlikely(offset > MAX_REG_OFFSET))
| ^~~~~~~~~~~~~~
make[3]: *** [scripts/Makefile.build:116: kernel/bounds.s] Error 1 shuffle=716081594 make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1287: prepare0] Error 2 shuffle=716081594 make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2 shuffle=716081594 make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:234: __sub-make] Error 2 shuffle=716081594
make: Target 'prepare' not remade because of errors.

vim +16 include/linux/stddef.h

6e218287432472 Richard Knutsson 2006-09-30 14
^1da177e4c3f41 Linus Torvalds 2005-04-16 15 #undef offsetof
14e83077d55ff4 Rasmus Villemoes 2022-03-23 @16 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
3876488444e712 Denys Vlasenko 2015-03-09 17

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#29 lore raw

PATCH v2 20/20 ARC: pt_regs: create seperate type for ecr

Reduces duplication in each ISA specific pt_regs

---
 arch/arc/include/asm/ptrace.h  | 47 +++++++++++++---------------------
 arch/arc/kernel/asm-offsets.c  |  2 +-
 arch/arc/kernel/kgdb.c         |  2 +-
 arch/arc/kernel/ptrace.c       |  4 +--
 arch/arc/kernel/traps.c        |  4 +--
 arch/arc/kernel/troubleshoot.c | 13 +++++-----
 arch/arc/mm/fault.c            |  6 ++---
 7 files changed, 33 insertions(+), 45 deletions(-)
arch/arc/include/asm/ptrace.h +18 -29
index 3a054b695f28..4a2b30fb5a98 100644
@@ -12,6 +12,17 @@
 
 #ifndef __ASSEMBLY__
 
+typedef union {
+	struct {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+		unsigned long state:8, vec:8, cause:8, param:8;
+#else
+		unsigned long param:8, cause:8, vec:8, state:8;
+#endif
+	};
+	unsigned long full;
+} ecr_reg;
+
 /* THE pt_regs: Defines how regs are saved during entry into kernel */
 
 #ifdef CONFIG_ISA_ARCOMPACT
@@ -40,21 +51,10 @@ struct pt_regs {
 	 * 	Last word used by Linux for extra state mgmt (syscall-restart)
 	 * For interrupts, use artificial ECR values to note current prio-level
 	 */
-	union {
-		struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-			unsigned long state:8, ecr_vec:8,
-				      ecr_cause:8, ecr_param:8;
-#else
-			unsigned long ecr_param:8, ecr_cause:8,
-				      ecr_vec:8, state:8;
-#endif
-		};
-		unsigned long event;
-	};
+	ecr_reg ecr;
 };
 
-#define MAX_REG_OFFSET offsetof(struct pt_regs, event)
+#define MAX_REG_OFFSET offsetof(struct pt_regs, ecr)
 
 #else
 
@@ -62,18 +62,7 @@ struct pt_regs {
 
 	unsigned long orig_r0;
 
-	union {
-		struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-			unsigned long state:8, ecr_vec:8,
-				      ecr_cause:8, ecr_param:8;
-#else
-			unsigned long ecr_param:8, ecr_cause:8,
-				      ecr_vec:8, state:8;
-#endif
-		};
-		unsigned long event;
-	};
+	ecr_reg ecr;		/* Exception Cause Reg */
 
 	unsigned long bta;	/* erbta */
 
@@ -131,13 +120,13 @@ struct callee_regs {
 /* return 1 if PC in delay slot */
 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
 
-#define in_syscall(regs)    ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
-#define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
+#define in_syscall(regs)    ((regs->ecr.vec == ECR_V_TRAP) && !regs->ecr.param)
+#define in_brkpt_trap(regs) ((regs->ecr.vec == ECR_V_TRAP) && regs->ecr.param)
 
 #define STATE_SCALL_RESTARTED	0x01
 
-#define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
-#define syscall_restartable(reg) !(reg->state &  STATE_SCALL_RESTARTED)
+#define syscall_wont_restart(regs) (regs->ecr.state |= STATE_SCALL_RESTARTED)
+#define syscall_restartable(regs) !(regs->ecr.state &  STATE_SCALL_RESTARTED)
 
 #define current_pt_regs()					\
 ({								\
arch/arc/kernel/asm-offsets.c +1 -1
index 478768c88f46..f77deb799175 100644
@@ -46,7 +46,7 @@ int main(void)
 	BLANK();
 
 	DEFINE(PT_status32, offsetof(struct pt_regs, status32));
-	DEFINE(PT_event, offsetof(struct pt_regs, event));
+	DEFINE(PT_event, offsetof(struct pt_regs, ecr));
 	DEFINE(PT_bta, offsetof(struct pt_regs, bta));
 	DEFINE(PT_sp, offsetof(struct pt_regs, sp));
 	DEFINE(PT_r0, offsetof(struct pt_regs, r0));
arch/arc/kernel/kgdb.c +1 -1
index 345a0000554c..4f2b5951454f 100644
@@ -175,7 +175,7 @@ void kgdb_trap(struct pt_regs *regs)
 	 * with trap_s 4 (compiled) breakpoints, continuation needs to
 	 * start after the breakpoint.
 	 */
-	if (regs->ecr_param == 3)
+	if (regs->ecr.param == 3)
 		instruction_pointer(regs) -= BREAK_INSTR_SIZE;
 
 	kgdb_handle_exception(1, SIGTRAP, 0, regs);
arch/arc/kernel/ptrace.c +2 -2
index 14ea7406f5cd..e0c233c178b1 100644
@@ -46,7 +46,7 @@ static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(r0),
 	REG_OFFSET_NAME(sp),
 	REG_OFFSET_NAME(orig_r0),
-	REG_OFFSET_NAME(event),
+	REG_OFFSET_NAME(ecr),
 	REG_OFFSET_END,
 };
 
@@ -54,7 +54,7 @@ static const struct pt_regs_offset regoffset_table[] = {
 
 static const struct pt_regs_offset regoffset_table[] = {
 	REG_OFFSET_NAME(orig_r0),
-	REG_OFFSET_NAME(event),
+	REG_OFFSET_NAME(ecr),
 	REG_OFFSET_NAME(bta),
 	REG_OFFSET_NAME(r26),
 	REG_OFFSET_NAME(fp),
arch/arc/kernel/traps.c +1 -3
index 2f7eb786695b..9b9570b79362 100644
@@ -110,9 +110,7 @@ void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
  */
 void do_non_swi_trap(unsigned long address, struct pt_regs *regs)
 {
-	unsigned int param = regs->ecr_param;
-
-	switch (param) {
+	switch (regs->ecr.param) {
 	case 1:
 		trap_is_brkpt(address, regs);
 		break;
arch/arc/kernel/troubleshoot.c +7 -6
index 7654c2e42dc0..d5b3ed2c58f5 100644
@@ -115,8 +115,8 @@ static void show_ecr_verbose(struct pt_regs *regs)
 	/* For Data fault, this is data address not instruction addr */
 	address = current->thread.fault_address;
 
-	vec = regs->ecr_vec;
-	cause_code = regs->ecr_cause;
+	vec = regs->ecr.vec;
+	cause_code = regs->ecr.cause;
 
 	/* For DTLB Miss or ProtV, display the memory involved too */
 	if (vec == ECR_V_DTLB_MISS) {
@@ -154,7 +154,7 @@ static void show_ecr_verbose(struct pt_regs *regs)
 		pr_cont("Misaligned r/w from 0x%08lx\n", address);
 #endif
 	} else if (vec == ECR_V_TRAP) {
-		if (regs->ecr_param == 5)
+		if (regs->ecr.param == 5)
 			pr_cont("gcc generated __builtin_trap\n");
 	} else {
 		pr_cont("Check Programmer's Manual\n");
@@ -184,9 +184,10 @@ void show_regs(struct pt_regs *regs)
 	if (user_mode(regs))
 		show_faulting_vma(regs->ret); /* faulting code, not data */
 
-	pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\nSTAT: 0x%08lx",
-		regs->event, current->thread.fault_address, regs->ret,
-		regs->status32);
+	pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\n",
+		regs->ecr.full, current->thread.fault_address, regs->ret);
+
+	pr_info("STAT32: 0x%08lx", regs->status32);
 
 #define STS_BIT(r, bit)	r->status32 & STATUS_##bit##_MASK ? #bit" " : ""
 
arch/arc/mm/fault.c +3 -3
index 26e5823c5710..95119a5e7761 100644
@@ -100,10 +100,10 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	if (faulthandler_disabled() || !mm)
 		goto no_context;
 
-	if (regs->ecr_cause & ECR_C_PROTV_STORE)	/* ST/EX */
+	if (regs->ecr.cause & ECR_C_PROTV_STORE)	/* ST/EX */
 		write = 1;
-	else if ((regs->ecr_vec == ECR_V_PROTV) &&
-	         (regs->ecr_cause == ECR_C_PROTV_INST_FETCH))
+	else if ((regs->ecr.vec == ECR_V_PROTV) &&
+	         (regs->ecr.cause == ECR_C_PROTV_INST_FETCH))
 		exec = 1;
 
 	flags = FAULT_FLAG_DEFAULT;
Signature · 7 lines
2.34.1


_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
#30 lore raw

Re: [PATCH 20/20] ARC: pt_regs: create seperate type for ecr

In reply to Vineet Gupta

Hi Vineet,

I'm testing your updates and ran into the same build issue reported by the build robot.
http://lists.infradead.org/pipermail/linux-snps-arc/2023-August/007522.html

Quoted 11 lines

#ifdef CONFIG_ISA_ARCOMPACT

arch/arc/include/asm/ptrace.h +0 -6
@@ -40,18 +51,7 @@ struct pt_regs {
          *        Last word used by Linux for extra state mgmt (syscall-restart)
          * For interrupts, use artificial ECR values to note current prio-level
          */
-       union {
-               struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-                       unsigned long state:8, ecr_vec:8,
-                                     ecr_cause:8, ecr_param:8;
-#else

arch/arc/include/asm/ptrace.h struct pt_regs { · line 57

Quoted 10 lines
arch/arc/include/asm/ptrace.h +1 -6
-                       unsigned long ecr_param:8, ecr_cause:8,
-                                     ecr_vec:8, state:8;
-#endif
-               };
-               unsigned long event;
-       };
+       ecr_reg ecr;
 }
 
 #define MAX_REG_OFFSET offsetof(struct pt_regs, event)

This change causes a build issue for ARC700, as the event field has been removed and the MAX_REG_OFFSET macro hasn't been updated.

Regards,
Pavel

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

#31 lore raw

Re: [PATCH 20/20] ARC: pt_regs: create seperate type for ecr

Quoted 9 lines · On 8/17/23 05:09, [email protected] wrote:

Hi Vineet,

I'm testing your updates and ran into the same build issue reported by the build robot.
http://lists.infradead.org/pipermail/linux-snps-arc/2023-August/007522.html

Quoted 1 line

#define MAX_REG_OFFSET offsetof(struct pt_regs, event)

This change causes a build issue for ARC700, as the event field has been removed and the MAX_REG_OFFSET macro hasn't been updated.

I've posted v2 for 3 patches. Please reapply/retest the whole series.

Thx,
-Vineet

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Tested-by on the v1 series
#32 lore raw
In reply to Vineet Gupta
Quoted 8 lines

Hi,

This is a pile of miscll improvements/updates sitting in one of my local trees.
Given the recent warning fix, we coudl also push them out.
@Alexey, @Shahab: care to give these a spin on hsdk (and test ARC700 build/boot on nSIM if possible).

Thx,
-Vineet

The entire "ARC updates" patch series (with all subsequent patches with updates) has been tested on the HSDK borard for ARCv2 using the glibc and ksefltest test framworks and on nSIM for ARCompact using the uclibc tests. No regressions found.

Regards,
Pavel

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc