public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: sam@ravnborg.org
Cc: carlos@redhat.com, triegel@redhat.com,
	adhemerval.zanella@linaro.org, andreas@gaisler.com,
	libc-alpha@sourceware.org, software@gaisler.com
Subject: Re: Remove sparcv8 support
Date: Tue, 08 Nov 2016 01:06:00 -0000	[thread overview]
Message-ID: <20161107.200618.307872104473677470.davem@davemloft.net> (raw)
In-Reply-To: <20161107212050.GA27481@ravnborg.org>

[-- Attachment #1: Type: Text/Plain, Size: 289 bytes --]

From: Sam Ravnborg <sam@ravnborg.org>
Date: Mon, 7 Nov 2016 22:20:50 +0100

> casemul.S is missing.
> So all the fun kernel stuf was not included in the patch...

Ugh, someone asked me about this but asked me privately so I only
sent the corrected patch to them privately :-/

Here it is:

[-- Attachment #2: casemul_kernel.diff --]
[-- Type: Text/X-Patch, Size: 5115 bytes --]

From acdd40e01a98e2c4bf477d5d66c183716e7562c5 Mon Sep 17 00:00:00 2001
From: "David S. Miller" <davem@davemloft.net>
Date: Mon, 7 Nov 2016 08:27:05 -0800
Subject: [PATCH] sparc64: Add CAS emulation trap.

Older 32-bit sparc cpus (other than LEON) lack a CAS instruction, so
we need to provide some kind of helper infrastructure in the kernel
to emulate it.

This is the first part which firstly defines the basic infrastructure
and the simplest implementation, which is to just directly execute the
instruction on sparc64.

We make use of the window fill/spill fault unwind facilities to make
this as simple as possible.  When we take a full TSB miss, we check if
the trap level is greater than one, and if so unwind the trap to one
of the final 3 instructions of the interrupted trap handler's block.
Which of the three to use is based upon whether this is a real fault,
an unaligned access, or a data access exception (ie. bus error).

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/include/uapi/asm/unistd.h |  1 +
 arch/sparc/kernel/Makefile           |  1 +
 arch/sparc/kernel/casemul.S          | 66 ++++++++++++++++++++++++++++++++++++
 arch/sparc/kernel/sys_sparc_64.c     |  2 +-
 arch/sparc/kernel/ttable_64.S        |  3 +-
 5 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 arch/sparc/kernel/casemul.S

diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h
index 36eee81..0725911 100644
--- a/arch/sparc/include/uapi/asm/unistd.h
+++ b/arch/sparc/include/uapi/asm/unistd.h
@@ -430,6 +430,7 @@
 
 /* Bitmask values returned from kern_features system call.  */
 #define KERN_FEATURE_MIXED_MODE_STACK	0x00000001
+#define KERN_FEATURE_CAS_EMUL		0x00000002
 
 #ifdef __32bit_syscall_numbers__
 /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index fa3c02d..1166638 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -21,6 +21,7 @@ CFLAGS_REMOVE_perf_event.o := -pg
 CFLAGS_REMOVE_pcr.o := -pg
 endif
 
+obj-$(CONFIG_SPARC64)   += casemul.o
 obj-$(CONFIG_SPARC64)   += urtt_fill.o
 obj-$(CONFIG_SPARC32)   += entry.o wof.o wuf.o
 obj-$(CONFIG_SPARC32)   += etrap_32.o
diff --git a/arch/sparc/kernel/casemul.S b/arch/sparc/kernel/casemul.S
new file mode 100644
index 0000000..237221f
--- /dev/null
+++ b/arch/sparc/kernel/casemul.S
@@ -0,0 +1,66 @@
+#include <asm/asi.h>
+#include <asm/thread_info.h>
+#include <asm/trap_block.h>
+#include <asm/ptrace.h>
+#include <asm/head.h>
+
+	.text
+	.align		128
+	.globl		emulate_cas
+	.type		emulate_cas,#function
+emulate_cas:
+	casa		[%o0] ASI_AIUP, %o1, %o2
+	done
+	nop; nop; nop; nop; nop; nop;
+	nop; nop; nop; nop; nop; nop; nop; nop
+	nop; nop; nop; nop; nop; nop; nop; nop
+	nop; nop; nop; nop; nop;
+	ba,a,pt		%xcc, 3f
+	ba,a,pt		%xcc, 2f
+	ba,a,pt		%xcc, 1f
+	.size		emulate_cas,.-emulate_cas
+
+	/* Fault */
+1:	TRAP_LOAD_THREAD_REG(%g6, %g1)
+	stb		%g4, [%g6 + TI_FAULT_CODE]
+	stx		%g5, [%g6 + TI_FAULT_ADDR]
+	ba,pt		%xcc, etrap
+	 rd		%pc, %g7
+	call		do_sparc64_fault
+	 add		%sp, PTREGS_OFF, %o0
+	ba,a,pt		%xcc, rtrap
+
+	/* Memory address unaligned */
+2:	ba,pt	%xcc, etrap
+	 rd	%pc, %g7
+	sethi	%hi(tlb_type), %g1
+	lduw	[%g1 + %lo(tlb_type)], %g1
+	cmp	%g1, 3
+	bne,pt	%icc, 1f
+	 add	%sp, PTREGS_OFF, %o0
+	mov	%l4, %o2
+	call	sun4v_do_mna
+	 mov	%l5, %o1
+	ba,a,pt	%xcc, rtrap
+1:	mov	%l4, %o1
+	mov	%l5, %o2
+	call	mem_address_unaligned
+	 nop
+	ba,a,pt	%xcc, rtrap
+
+	/* Data access exception */
+3:	ba,pt	%xcc, etrap
+	 rd	%pc, %g7
+	sethi	%hi(tlb_type), %g1
+	mov	%l4, %o1
+	lduw	[%g1 + %lo(tlb_type)], %g1
+	mov	%l5, %o2
+	cmp	%g1, 3
+	bne,pt	%icc, 1f
+	 add	%sp, PTREGS_OFF, %o0
+	call	sun4v_data_access_exception
+	 nop
+	ba,a,pt	%xcc, rtrap
+1:	call	spitfire_data_access_exception
+	 nop
+	ba,a,pt	%xcc, rtrap
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index fe8b8ee..d55e8b8 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -643,5 +643,5 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
 
 asmlinkage long sys_kern_features(void)
 {
-	return KERN_FEATURE_MIXED_MODE_STACK;
+	return KERN_FEATURE_MIXED_MODE_STACK | KERN_FEATURE_CAS_EMUL;
 }
diff --git a/arch/sparc/kernel/ttable_64.S b/arch/sparc/kernel/ttable_64.S
index c6dfdaa..3364019 100644
--- a/arch/sparc/kernel/ttable_64.S
+++ b/arch/sparc/kernel/ttable_64.S
@@ -147,7 +147,8 @@ tl0_resv11e:	TRAP_UTRAP(UT_TRAP_INSTRUCTION_30,0x11e) TRAP_UTRAP(UT_TRAP_INSTRUC
 tl0_getcc:	GETCC_TRAP
 tl0_setcc:	SETCC_TRAP
 tl0_getpsr:	TRAP(do_getpsr)
-tl0_resv123:	BTRAP(0x123) BTRAP(0x124) BTRAP(0x125) BTRAP(0x126) BTRAP(0x127)
+tl0_cas:	TRAP_NOSAVE(emulate_cas)
+tl0_resv124:	BTRAP(0x124) BTRAP(0x125) BTRAP(0x126) BTRAP(0x127)
 tl0_resv128:	BTRAP(0x128) BTRAP(0x129) BTRAP(0x12a) BTRAP(0x12b) BTRAP(0x12c)
 tl0_resv12d:	BTRAP(0x12d) BTRAP(0x12e) BTRAP(0x12f) BTRAP(0x130) BTRAP(0x131)
 tl0_resv132:	BTRAP(0x132) BTRAP(0x133) BTRAP(0x134) BTRAP(0x135) BTRAP(0x136)
-- 
2.1.2.532.g19b5d50


  reply	other threads:[~2016-11-08  1:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 19:47 Adhemerval Zanella
2016-10-20 20:56 ` David Miller
2016-10-21  9:02 ` Andreas Larsson
2016-10-21 13:13   ` Adhemerval Zanella
2016-10-21 15:03     ` David Miller
2016-10-24 17:14       ` Torvald Riegel
2016-10-24 17:25   ` Torvald Riegel
2016-10-24 17:43     ` Adhemerval Zanella
2016-10-25 14:34       ` Andreas Larsson
2016-10-25 14:45         ` Adhemerval Zanella
2016-10-26 14:46           ` Andreas Larsson
2016-10-26 18:03             ` Adhemerval Zanella
2016-10-26 18:47               ` David Miller
2016-10-26 19:39                 ` Adhemerval Zanella
2016-10-27 10:54                 ` Torvald Riegel
2016-10-27 14:36                   ` Carlos O'Donell
2016-11-07 16:38                     ` David Miller
2016-11-07 21:21                       ` Sam Ravnborg
2016-11-08  1:06                         ` David Miller [this message]
2016-11-09  5:49                           ` Sam Ravnborg
2016-11-10 23:33                             ` David Miller
2016-11-09 17:08                       ` Torvald Riegel
2016-11-09 17:16                         ` David Miller
2016-11-10  5:05                           ` Torvald Riegel
2016-11-10 16:41                           ` Chris Metcalf
2016-11-10 17:08                             ` Torvald Riegel
2016-11-10 18:22                               ` Chris Metcalf
2016-11-10 23:38                                 ` Torvald Riegel
2016-10-27 10:38             ` Torvald Riegel
2016-11-01 15:27               ` Andreas Larsson
2016-10-25 14:34     ` Andreas Larsson
2016-10-25 16:22       ` Torvald Riegel

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20161107.200618.307872104473677470.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=adhemerval.zanella@linaro.org \
    --cc=andreas@gaisler.com \
    --cc=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=sam@ravnborg.org \
    --cc=software@gaisler.com \
    --cc=triegel@redhat.com \
    /path/to/YOUR_REPLY

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

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