All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:pending-fixes 265/302] arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
@ 2021-06-10  4:17 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-06-10  4:17 UTC (permalink / raw)
  To: Vineet Gupta; +Cc: kbuild-all, Linux Memory Management List, linux-snps-arc

[-- Attachment #1: Type: text/plain, Size: 4059 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git pending-fixes
head:   2413b547bbb10e9b0d9da0e15040d2228ef17a76
commit: 98ec2edf58c820ef953fbdfcf98d706aa804b822 [265/302] ARCv2: save ABI registers across signal handling
config: arc-randconfig-r001-20210610 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=98ec2edf58c820ef953fbdfcf98d706aa804b822
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next pending-fixes
        git checkout 98ec2edf58c820ef953fbdfcf98d706aa804b822
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arc/kernel/signal.c: In function 'stash_usr_regs':
>> arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     101 |   v2abi.r30 = regs->r30;
         |                     ^~~
         |                     r10
   arch/arc/kernel/signal.c: In function 'restore_usr_regs':
   arch/arc/kernel/signal.c:134:9: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     134 |   regs->r30 = v2abi.r30;
         |         ^~~
         |         r10
   arch/arc/kernel/signal.c: At top level:
   arch/arc/kernel/signal.c:387:6: warning: no previous prototype for 'do_signal' [-Wmissing-prototypes]
     387 | void do_signal(struct pt_regs *regs)
         |      ^~~~~~~~~
   arch/arc/kernel/signal.c:420:6: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes]
     420 | void do_notify_resume(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~~~


vim +101 arch/arc/kernel/signal.c

    63	
    64	static int
    65	stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
    66		       sigset_t *set)
    67	{
    68		int err;
    69		struct user_regs_struct uregs;
    70	
    71		uregs.scratch.bta	= regs->bta;
    72		uregs.scratch.lp_start	= regs->lp_start;
    73		uregs.scratch.lp_end	= regs->lp_end;
    74		uregs.scratch.lp_count	= regs->lp_count;
    75		uregs.scratch.status32	= regs->status32;
    76		uregs.scratch.ret	= regs->ret;
    77		uregs.scratch.blink	= regs->blink;
    78		uregs.scratch.fp	= regs->fp;
    79		uregs.scratch.gp	= regs->r26;
    80		uregs.scratch.r12	= regs->r12;
    81		uregs.scratch.r11	= regs->r11;
    82		uregs.scratch.r10	= regs->r10;
    83		uregs.scratch.r9	= regs->r9;
    84		uregs.scratch.r8	= regs->r8;
    85		uregs.scratch.r7	= regs->r7;
    86		uregs.scratch.r6	= regs->r6;
    87		uregs.scratch.r5	= regs->r5;
    88		uregs.scratch.r4	= regs->r4;
    89		uregs.scratch.r3	= regs->r3;
    90		uregs.scratch.r2	= regs->r2;
    91		uregs.scratch.r1	= regs->r1;
    92		uregs.scratch.r0	= regs->r0;
    93		uregs.scratch.sp	= regs->sp;
    94	
    95		err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
    96				     sizeof(sf->uc.uc_mcontext.regs.scratch));
    97	
    98		if (is_isa_arcv2()) {
    99			struct user_regs_arcv2 v2abi;
   100	
 > 101			v2abi.r30 = regs->r30;
   102	#ifdef CONFIG_ARC_HAS_ACCL_REGS
   103			v2abi.r58 = regs->r58;
   104			v2abi.r59 = regs->r59;
   105	#else
   106			v2abi.r58 = v2abi.r59 = 0;
   107	#endif
   108			err |= __copy_to_user(&(sf->uc.uc_mcontext.v2abi), &v2abi,
   109					      sizeof(sf->uc.uc_mcontext.v2abi));
   110		}
   111	
   112		err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
   113	
   114		return err ? -EFAULT : 0;
   115	}
   116	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38751 bytes --]

[-- Attachment #3: Type: text/plain, Size: 170 bytes --]

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [linux-next:pending-fixes 265/302] arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
@ 2021-06-10  4:17 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-06-10  4:17 UTC (permalink / raw)
  To: Vineet Gupta; +Cc: kbuild-all, Linux Memory Management List, linux-snps-arc

[-- Attachment #1: Type: text/plain, Size: 4059 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git pending-fixes
head:   2413b547bbb10e9b0d9da0e15040d2228ef17a76
commit: 98ec2edf58c820ef953fbdfcf98d706aa804b822 [265/302] ARCv2: save ABI registers across signal handling
config: arc-randconfig-r001-20210610 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=98ec2edf58c820ef953fbdfcf98d706aa804b822
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next pending-fixes
        git checkout 98ec2edf58c820ef953fbdfcf98d706aa804b822
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arc/kernel/signal.c: In function 'stash_usr_regs':
>> arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     101 |   v2abi.r30 = regs->r30;
         |                     ^~~
         |                     r10
   arch/arc/kernel/signal.c: In function 'restore_usr_regs':
   arch/arc/kernel/signal.c:134:9: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     134 |   regs->r30 = v2abi.r30;
         |         ^~~
         |         r10
   arch/arc/kernel/signal.c: At top level:
   arch/arc/kernel/signal.c:387:6: warning: no previous prototype for 'do_signal' [-Wmissing-prototypes]
     387 | void do_signal(struct pt_regs *regs)
         |      ^~~~~~~~~
   arch/arc/kernel/signal.c:420:6: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes]
     420 | void do_notify_resume(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~~~


vim +101 arch/arc/kernel/signal.c

    63	
    64	static int
    65	stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
    66		       sigset_t *set)
    67	{
    68		int err;
    69		struct user_regs_struct uregs;
    70	
    71		uregs.scratch.bta	= regs->bta;
    72		uregs.scratch.lp_start	= regs->lp_start;
    73		uregs.scratch.lp_end	= regs->lp_end;
    74		uregs.scratch.lp_count	= regs->lp_count;
    75		uregs.scratch.status32	= regs->status32;
    76		uregs.scratch.ret	= regs->ret;
    77		uregs.scratch.blink	= regs->blink;
    78		uregs.scratch.fp	= regs->fp;
    79		uregs.scratch.gp	= regs->r26;
    80		uregs.scratch.r12	= regs->r12;
    81		uregs.scratch.r11	= regs->r11;
    82		uregs.scratch.r10	= regs->r10;
    83		uregs.scratch.r9	= regs->r9;
    84		uregs.scratch.r8	= regs->r8;
    85		uregs.scratch.r7	= regs->r7;
    86		uregs.scratch.r6	= regs->r6;
    87		uregs.scratch.r5	= regs->r5;
    88		uregs.scratch.r4	= regs->r4;
    89		uregs.scratch.r3	= regs->r3;
    90		uregs.scratch.r2	= regs->r2;
    91		uregs.scratch.r1	= regs->r1;
    92		uregs.scratch.r0	= regs->r0;
    93		uregs.scratch.sp	= regs->sp;
    94	
    95		err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
    96				     sizeof(sf->uc.uc_mcontext.regs.scratch));
    97	
    98		if (is_isa_arcv2()) {
    99			struct user_regs_arcv2 v2abi;
   100	
 > 101			v2abi.r30 = regs->r30;
   102	#ifdef CONFIG_ARC_HAS_ACCL_REGS
   103			v2abi.r58 = regs->r58;
   104			v2abi.r59 = regs->r59;
   105	#else
   106			v2abi.r58 = v2abi.r59 = 0;
   107	#endif
   108			err |= __copy_to_user(&(sf->uc.uc_mcontext.v2abi), &v2abi,
   109					      sizeof(sf->uc.uc_mcontext.v2abi));
   110		}
   111	
   112		err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
   113	
   114		return err ? -EFAULT : 0;
   115	}
   116	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38751 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [linux-next:pending-fixes 265/302] arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
@ 2021-06-10  4:17 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-06-10  4:17 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4160 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git pending-fixes
head:   2413b547bbb10e9b0d9da0e15040d2228ef17a76
commit: 98ec2edf58c820ef953fbdfcf98d706aa804b822 [265/302] ARCv2: save ABI registers across signal handling
config: arc-randconfig-r001-20210610 (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=98ec2edf58c820ef953fbdfcf98d706aa804b822
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next pending-fixes
        git checkout 98ec2edf58c820ef953fbdfcf98d706aa804b822
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/arc/kernel/signal.c: In function 'stash_usr_regs':
>> arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     101 |   v2abi.r30 = regs->r30;
         |                     ^~~
         |                     r10
   arch/arc/kernel/signal.c: In function 'restore_usr_regs':
   arch/arc/kernel/signal.c:134:9: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'?
     134 |   regs->r30 = v2abi.r30;
         |         ^~~
         |         r10
   arch/arc/kernel/signal.c: At top level:
   arch/arc/kernel/signal.c:387:6: warning: no previous prototype for 'do_signal' [-Wmissing-prototypes]
     387 | void do_signal(struct pt_regs *regs)
         |      ^~~~~~~~~
   arch/arc/kernel/signal.c:420:6: warning: no previous prototype for 'do_notify_resume' [-Wmissing-prototypes]
     420 | void do_notify_resume(struct pt_regs *regs)
         |      ^~~~~~~~~~~~~~~~


vim +101 arch/arc/kernel/signal.c

    63	
    64	static int
    65	stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
    66		       sigset_t *set)
    67	{
    68		int err;
    69		struct user_regs_struct uregs;
    70	
    71		uregs.scratch.bta	= regs->bta;
    72		uregs.scratch.lp_start	= regs->lp_start;
    73		uregs.scratch.lp_end	= regs->lp_end;
    74		uregs.scratch.lp_count	= regs->lp_count;
    75		uregs.scratch.status32	= regs->status32;
    76		uregs.scratch.ret	= regs->ret;
    77		uregs.scratch.blink	= regs->blink;
    78		uregs.scratch.fp	= regs->fp;
    79		uregs.scratch.gp	= regs->r26;
    80		uregs.scratch.r12	= regs->r12;
    81		uregs.scratch.r11	= regs->r11;
    82		uregs.scratch.r10	= regs->r10;
    83		uregs.scratch.r9	= regs->r9;
    84		uregs.scratch.r8	= regs->r8;
    85		uregs.scratch.r7	= regs->r7;
    86		uregs.scratch.r6	= regs->r6;
    87		uregs.scratch.r5	= regs->r5;
    88		uregs.scratch.r4	= regs->r4;
    89		uregs.scratch.r3	= regs->r3;
    90		uregs.scratch.r2	= regs->r2;
    91		uregs.scratch.r1	= regs->r1;
    92		uregs.scratch.r0	= regs->r0;
    93		uregs.scratch.sp	= regs->sp;
    94	
    95		err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
    96				     sizeof(sf->uc.uc_mcontext.regs.scratch));
    97	
    98		if (is_isa_arcv2()) {
    99			struct user_regs_arcv2 v2abi;
   100	
 > 101			v2abi.r30 = regs->r30;
   102	#ifdef CONFIG_ARC_HAS_ACCL_REGS
   103			v2abi.r58 = regs->r58;
   104			v2abi.r59 = regs->r59;
   105	#else
   106			v2abi.r58 = v2abi.r59 = 0;
   107	#endif
   108			err |= __copy_to_user(&(sf->uc.uc_mcontext.v2abi), &v2abi,
   109					      sizeof(sf->uc.uc_mcontext.v2abi));
   110		}
   111	
   112		err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
   113	
   114		return err ? -EFAULT : 0;
   115	}
   116	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38751 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] ARCv2: save ABI registers across signal handling
  2021-06-10  4:17 ` kernel test robot
@ 2021-06-10 19:12   ` Vineet Gupta
  -1 siblings, 0 replies; 5+ messages in thread
From: Vineet Gupta @ 2021-06-10 19:12 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: linux-kernel, Vineet Gupta, stable, kernel test robot,
	Vladimir Isaev

ARCv2 has some configuration dependent registers (r30, r58, r59) which
could be targetted by the compiler. To keep the ABI stable, these were
unconditionally part of the glibc ABI
(sysdeps/unix/sysv/linux/arc/sys/ucontext.h:mcontext_t) however we
missed populating them (by saving/restoring them across signal
handling).

This patch fixes the issue by
 - adding arcv2 ABI regs to kernel struct sigcontext
 - populating them during signal handling

Change to struct sigcontext might seem like a glibc ABI change (although
it primarily uses ucontext_t:mcontext_t) but the fact is
 - it has only been extended (existing fields are not touched)
 - the old sigcontext was ABI incomplete to begin with anyways

Fixes: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/53
Cc: <stable@vger.kernel.org>
Tested-by: kernel test robot <lkp@intel.com>
Reported-by: Vladimir Isaev <isaev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/include/uapi/asm/sigcontext.h |  1 +
 arch/arc/kernel/signal.c               | 43 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/arch/arc/include/uapi/asm/sigcontext.h b/arch/arc/include/uapi/asm/sigcontext.h
index 95f8a4380e11..7a5449dfcb29 100644
--- a/arch/arc/include/uapi/asm/sigcontext.h
+++ b/arch/arc/include/uapi/asm/sigcontext.h
@@ -18,6 +18,7 @@
  */
 struct sigcontext {
 	struct user_regs_struct regs;
+	struct user_regs_arcv2 v2abi;
 };
 
 #endif /* _ASM_ARC_SIGCONTEXT_H */
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
index b3ccb9e5ffe4..cb2f88502baf 100644
--- a/arch/arc/kernel/signal.c
+++ b/arch/arc/kernel/signal.c
@@ -61,6 +61,41 @@ struct rt_sigframe {
 	unsigned int sigret_magic;
 };
 
+static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
+{
+	int err = 0;
+#ifndef CONFIG_ISA_ARCOMPACT
+	struct user_regs_arcv2 v2abi;
+
+	v2abi.r30 = regs->r30;
+#ifdef CONFIG_ARC_HAS_ACCL_REGS
+	v2abi.r58 = regs->r58;
+	v2abi.r59 = regs->r59;
+#else
+	v2abi.r58 = v2abi.r59 = 0;
+#endif
+	err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi));
+#endif
+	return err;
+}
+
+static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
+{
+	int err = 0;
+#ifndef CONFIG_ISA_ARCOMPACT
+	struct user_regs_arcv2 v2abi;
+
+	err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi));
+
+	regs->r30 = v2abi.r30;
+#ifdef CONFIG_ARC_HAS_ACCL_REGS
+	regs->r58 = v2abi.r58;
+	regs->r59 = v2abi.r59;
+#endif
+#endif
+	return err;
+}
+
 static int
 stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
 	       sigset_t *set)
@@ -94,6 +129,10 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
 
 	err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
 			     sizeof(sf->uc.uc_mcontext.regs.scratch));
+
+	if (is_isa_arcv2())
+		err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs);
+
 	err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
 
 	return err ? -EFAULT : 0;
@@ -109,6 +148,10 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf)
 	err |= __copy_from_user(&uregs.scratch,
 				&(sf->uc.uc_mcontext.regs.scratch),
 				sizeof(sf->uc.uc_mcontext.regs.scratch));
+
+	if (is_isa_arcv2())
+		err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs);
+
 	if (err)
 		return -EFAULT;
 
-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] ARCv2: save ABI registers across signal handling
@ 2021-06-10 19:12   ` Vineet Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Vineet Gupta @ 2021-06-10 19:12 UTC (permalink / raw)
  To: linux-snps-arc
  Cc: linux-kernel, Vineet Gupta, stable, kernel test robot,
	Vladimir Isaev

ARCv2 has some configuration dependent registers (r30, r58, r59) which
could be targetted by the compiler. To keep the ABI stable, these were
unconditionally part of the glibc ABI
(sysdeps/unix/sysv/linux/arc/sys/ucontext.h:mcontext_t) however we
missed populating them (by saving/restoring them across signal
handling).

This patch fixes the issue by
 - adding arcv2 ABI regs to kernel struct sigcontext
 - populating them during signal handling

Change to struct sigcontext might seem like a glibc ABI change (although
it primarily uses ucontext_t:mcontext_t) but the fact is
 - it has only been extended (existing fields are not touched)
 - the old sigcontext was ABI incomplete to begin with anyways

Fixes: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/53
Cc: <stable@vger.kernel.org>
Tested-by: kernel test robot <lkp@intel.com>
Reported-by: Vladimir Isaev <isaev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/include/uapi/asm/sigcontext.h |  1 +
 arch/arc/kernel/signal.c               | 43 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/arch/arc/include/uapi/asm/sigcontext.h b/arch/arc/include/uapi/asm/sigcontext.h
index 95f8a4380e11..7a5449dfcb29 100644
--- a/arch/arc/include/uapi/asm/sigcontext.h
+++ b/arch/arc/include/uapi/asm/sigcontext.h
@@ -18,6 +18,7 @@
  */
 struct sigcontext {
 	struct user_regs_struct regs;
+	struct user_regs_arcv2 v2abi;
 };
 
 #endif /* _ASM_ARC_SIGCONTEXT_H */
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
index b3ccb9e5ffe4..cb2f88502baf 100644
--- a/arch/arc/kernel/signal.c
+++ b/arch/arc/kernel/signal.c
@@ -61,6 +61,41 @@ struct rt_sigframe {
 	unsigned int sigret_magic;
 };
 
+static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
+{
+	int err = 0;
+#ifndef CONFIG_ISA_ARCOMPACT
+	struct user_regs_arcv2 v2abi;
+
+	v2abi.r30 = regs->r30;
+#ifdef CONFIG_ARC_HAS_ACCL_REGS
+	v2abi.r58 = regs->r58;
+	v2abi.r59 = regs->r59;
+#else
+	v2abi.r58 = v2abi.r59 = 0;
+#endif
+	err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi));
+#endif
+	return err;
+}
+
+static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
+{
+	int err = 0;
+#ifndef CONFIG_ISA_ARCOMPACT
+	struct user_regs_arcv2 v2abi;
+
+	err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi));
+
+	regs->r30 = v2abi.r30;
+#ifdef CONFIG_ARC_HAS_ACCL_REGS
+	regs->r58 = v2abi.r58;
+	regs->r59 = v2abi.r59;
+#endif
+#endif
+	return err;
+}
+
 static int
 stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
 	       sigset_t *set)
@@ -94,6 +129,10 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
 
 	err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
 			     sizeof(sf->uc.uc_mcontext.regs.scratch));
+
+	if (is_isa_arcv2())
+		err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs);
+
 	err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
 
 	return err ? -EFAULT : 0;
@@ -109,6 +148,10 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf)
 	err |= __copy_from_user(&uregs.scratch,
 				&(sf->uc.uc_mcontext.regs.scratch),
 				sizeof(sf->uc.uc_mcontext.regs.scratch));
+
+	if (is_isa_arcv2())
+		err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs);
+
 	if (err)
 		return -EFAULT;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-10 19:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  4:17 [linux-next:pending-fixes 265/302] arch/arc/kernel/signal.c:101:21: error: 'struct pt_regs' has no member named 'r30'; did you mean 'r10'? kernel test robot
2021-06-10  4:17 ` kernel test robot
2021-06-10  4:17 ` kernel test robot
2021-06-10 19:12 ` [PATCH v2] ARCv2: save ABI registers across signal handling Vineet Gupta
2021-06-10 19:12   ` Vineet Gupta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.