Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
@ 2018-02-26 17:02 Matt Redfearn
  2018-02-26 17:02 ` Matt Redfearn
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel,
	Maciej W. Rozycki, David Daney

There are multiple instances in the kernel where we need to include or
exclude particular instructions based on the ISA revision of the target
processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
define. However, when targeting MIPS I - V, this define is absent. This
leads to each use of __mips_isa_rev having to check that it is defined
first. To simplify this, this series introduces the isa-rev.h header
which always exports MIPS_ISA_REV (the name is changed so as to avoid
confusion with the compiler builtin and to avoid accidentally using the
builtin). All uses of __mips_isa_rev are then replaced with the new
define, removing the check that it is defined.

Applies on v4.16-rc1


Matt Redfearn (4):
  MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
  MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
  MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV

 arch/mips/include/asm/cpu-features.h |  5 +++--
 arch/mips/include/asm/isa-rev.h      | 24 ++++++++++++++++++++++++
 arch/mips/net/bpf_jit_asm.S          |  9 +++++----
 arch/mips/vdso/elf.S                 | 10 ++++------
 4 files changed, 36 insertions(+), 12 deletions(-)
 create mode 100644 arch/mips/include/asm/isa-rev.h

-- 
2.7.4

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

* [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
@ 2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02 ` [PATCH 1/4] " Matt Redfearn
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel,
	Maciej W. Rozycki, David Daney

There are multiple instances in the kernel where we need to include or
exclude particular instructions based on the ISA revision of the target
processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
define. However, when targeting MIPS I - V, this define is absent. This
leads to each use of __mips_isa_rev having to check that it is defined
first. To simplify this, this series introduces the isa-rev.h header
which always exports MIPS_ISA_REV (the name is changed so as to avoid
confusion with the compiler builtin and to avoid accidentally using the
builtin). All uses of __mips_isa_rev are then replaced with the new
define, removing the check that it is defined.

Applies on v4.16-rc1


Matt Redfearn (4):
  MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
  MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
  MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV

 arch/mips/include/asm/cpu-features.h |  5 +++--
 arch/mips/include/asm/isa-rev.h      | 24 ++++++++++++++++++++++++
 arch/mips/net/bpf_jit_asm.S          |  9 +++++----
 arch/mips/vdso/elf.S                 | 10 ++++------
 4 files changed, 36 insertions(+), 12 deletions(-)
 create mode 100644 arch/mips/include/asm/isa-rev.h

-- 
2.7.4

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

* [PATCH 1/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
  2018-02-26 17:02 ` Matt Redfearn
@ 2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02   ` Matt Redfearn
  2018-02-26 20:05   ` Maciej W. Rozycki
  2018-02-26 17:02 ` [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV Matt Redfearn
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel

There are multiple instances in the kernel where we need to include or
exclude particular instructions based on the ISA revision of the target
processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
define. However, when targeting MIPS I - V, this define is absent. This
leads to each use of __mips_isa_rev having to check that it is defined
first. To simplify this, introduce the isa-rev.h header which always
exports MIPS_ISA_REV. The name is changed so as to avoid confusion with
the compiler builtin and to avoid accidentally using the builtin.
MIPS_ISA_REV is defined to the compilers builtin if provided, or 0,
which satisfies all current usages.

Suggested-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>

---

 arch/mips/include/asm/isa-rev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/mips/include/asm/isa-rev.h

diff --git a/arch/mips/include/asm/isa-rev.h b/arch/mips/include/asm/isa-rev.h
new file mode 100644
index 000000000000..683ea3454dcb
--- /dev/null
+++ b/arch/mips/include/asm/isa-rev.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 MIPS Tech, LLC
+ * Author: Matt Redfearn <matt.redfearn@mips.com>
+ */
+
+#ifndef __MIPS_ASM_ISA_REV_H__
+#define __MIPS_ASM_ISA_REV_H__
+
+/*
+ * The ISA revision level. This is 0 for MIPS I to V and N for
+ * MIPS{32,64}rN.
+ */
+
+/* If the compiler has defined __mips_isa_rev, believe it. */
+#ifdef __mips_isa_rev
+#define MIPS_ISA_REV __mips_isa_rev
+#else
+/* The compiler hasn't defined the isa rev so assume it's MIPS I - V (0) */
+#define MIPS_ISA_REV 0
+#endif
+
+
+#endif /* __MIPS_ASM_ISA_REV_H__ */
-- 
2.7.4

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

* [PATCH 1/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 17:02 ` [PATCH 1/4] " Matt Redfearn
@ 2018-02-26 17:02   ` Matt Redfearn
  2018-02-26 20:05   ` Maciej W. Rozycki
  1 sibling, 0 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel

There are multiple instances in the kernel where we need to include or
exclude particular instructions based on the ISA revision of the target
processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
define. However, when targeting MIPS I - V, this define is absent. This
leads to each use of __mips_isa_rev having to check that it is defined
first. To simplify this, introduce the isa-rev.h header which always
exports MIPS_ISA_REV. The name is changed so as to avoid confusion with
the compiler builtin and to avoid accidentally using the builtin.
MIPS_ISA_REV is defined to the compilers builtin if provided, or 0,
which satisfies all current usages.

Suggested-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>

---

 arch/mips/include/asm/isa-rev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 arch/mips/include/asm/isa-rev.h

diff --git a/arch/mips/include/asm/isa-rev.h b/arch/mips/include/asm/isa-rev.h
new file mode 100644
index 000000000000..683ea3454dcb
--- /dev/null
+++ b/arch/mips/include/asm/isa-rev.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 MIPS Tech, LLC
+ * Author: Matt Redfearn <matt.redfearn@mips.com>
+ */
+
+#ifndef __MIPS_ASM_ISA_REV_H__
+#define __MIPS_ASM_ISA_REV_H__
+
+/*
+ * The ISA revision level. This is 0 for MIPS I to V and N for
+ * MIPS{32,64}rN.
+ */
+
+/* If the compiler has defined __mips_isa_rev, believe it. */
+#ifdef __mips_isa_rev
+#define MIPS_ISA_REV __mips_isa_rev
+#else
+/* The compiler hasn't defined the isa rev so assume it's MIPS I - V (0) */
+#define MIPS_ISA_REV 0
+#endif
+
+
+#endif /* __MIPS_ASM_ISA_REV_H__ */
-- 
2.7.4

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

* [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
  2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02 ` [PATCH 1/4] " Matt Redfearn
@ 2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02   ` Matt Redfearn
  2018-02-26 17:02 ` [PATCH 3/4] MIPS: BPF: " Matt Redfearn
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel,
	Maciej W. Rozycki

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/include/asm/cpu-features.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 721b698bfe3c..5f74590e0bea 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -11,6 +11,7 @@
 
 #include <asm/cpu.h>
 #include <asm/cpu-info.h>
+#include <asm/isa-rev.h>
 #include <cpu-feature-overrides.h>
 
 /*
@@ -493,7 +494,7 @@
 # define cpu_has_perf		(cpu_data[0].options & MIPS_CPU_PERF)
 #endif
 
-#if defined(CONFIG_SMP) && defined(__mips_isa_rev) && (__mips_isa_rev >= 6)
+#if defined(CONFIG_SMP) && (MIPS_ISA_REV >= 6)
 /*
  * Some systems share FTLB RAMs between threads within a core (siblings in
  * kernel parlance). This means that FTLB entries may become invalid at almost
@@ -525,7 +526,7 @@
 #  define cpu_has_shared_ftlb_entries \
 	(current_cpu_data.options & MIPS_CPU_SHARED_FTLB_ENTRIES)
 # endif
-#endif /* SMP && __mips_isa_rev >= 6 */
+#endif /* SMP && MIPS_ISA_REV >= 6 */
 
 #ifndef cpu_has_shared_ftlb_ram
 # define cpu_has_shared_ftlb_ram 0
-- 
2.7.4

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

* [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 ` [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV Matt Redfearn
@ 2018-02-26 17:02   ` Matt Redfearn
  0 siblings, 0 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel,
	Maciej W. Rozycki

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/include/asm/cpu-features.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 721b698bfe3c..5f74590e0bea 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -11,6 +11,7 @@
 
 #include <asm/cpu.h>
 #include <asm/cpu-info.h>
+#include <asm/isa-rev.h>
 #include <cpu-feature-overrides.h>
 
 /*
@@ -493,7 +494,7 @@
 # define cpu_has_perf		(cpu_data[0].options & MIPS_CPU_PERF)
 #endif
 
-#if defined(CONFIG_SMP) && defined(__mips_isa_rev) && (__mips_isa_rev >= 6)
+#if defined(CONFIG_SMP) && (MIPS_ISA_REV >= 6)
 /*
  * Some systems share FTLB RAMs between threads within a core (siblings in
  * kernel parlance). This means that FTLB entries may become invalid at almost
@@ -525,7 +526,7 @@
 #  define cpu_has_shared_ftlb_entries \
 	(current_cpu_data.options & MIPS_CPU_SHARED_FTLB_ENTRIES)
 # endif
-#endif /* SMP && __mips_isa_rev >= 6 */
+#endif /* SMP && MIPS_ISA_REV >= 6 */
 
 #ifndef cpu_has_shared_ftlb_ram
 # define cpu_has_shared_ftlb_ram 0
-- 
2.7.4

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

* [PATCH 3/4] MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
                   ` (2 preceding siblings ...)
  2018-02-26 17:02 ` [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV Matt Redfearn
@ 2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02   ` Matt Redfearn
  2018-02-26 17:02 ` [PATCH 4/4] MIPS: VDSO: " Matt Redfearn
  2018-03-09 11:25 ` [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV James Hogan
  5 siblings, 1 reply; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel, David Daney

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/net/bpf_jit_asm.S | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
index 88a2075305d1..57154c5883b6 100644
--- a/arch/mips/net/bpf_jit_asm.S
+++ b/arch/mips/net/bpf_jit_asm.S
@@ -11,6 +11,7 @@
  */
 
 #include <asm/asm.h>
+#include <asm/isa-rev.h>
 #include <asm/regdef.h>
 #include "bpf_jit.h"
 
@@ -65,7 +66,7 @@ FEXPORT(sk_load_word_positive)
 	lw	$r_A, 0(t1)
 	.set	noreorder
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	t0, $r_A
 	rotr	$r_A, t0, 16
 # else
@@ -92,7 +93,7 @@ FEXPORT(sk_load_half_positive)
 	PTR_ADDU t1, $r_skb_data, offset
 	lhu	$r_A, 0(t1)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	$r_A, $r_A
 # else
 	sll	t0, $r_A, 8
@@ -170,7 +171,7 @@ FEXPORT(sk_load_byte_positive)
 NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(4)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	t0, $r_s0
 	jr	$r_ra
 	 rotr	$r_A, t0, 16
@@ -196,7 +197,7 @@ NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 NESTED(bpf_slow_path_half, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(2)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	jr	$r_ra
 	 wsbh	$r_A, $r_s0
 # else
-- 
2.7.4

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

* [PATCH 3/4] MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 ` [PATCH 3/4] MIPS: BPF: " Matt Redfearn
@ 2018-02-26 17:02   ` Matt Redfearn
  0 siblings, 0 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel, David Daney

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/net/bpf_jit_asm.S | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
index 88a2075305d1..57154c5883b6 100644
--- a/arch/mips/net/bpf_jit_asm.S
+++ b/arch/mips/net/bpf_jit_asm.S
@@ -11,6 +11,7 @@
  */
 
 #include <asm/asm.h>
+#include <asm/isa-rev.h>
 #include <asm/regdef.h>
 #include "bpf_jit.h"
 
@@ -65,7 +66,7 @@ FEXPORT(sk_load_word_positive)
 	lw	$r_A, 0(t1)
 	.set	noreorder
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	t0, $r_A
 	rotr	$r_A, t0, 16
 # else
@@ -92,7 +93,7 @@ FEXPORT(sk_load_half_positive)
 	PTR_ADDU t1, $r_skb_data, offset
 	lhu	$r_A, 0(t1)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	$r_A, $r_A
 # else
 	sll	t0, $r_A, 8
@@ -170,7 +171,7 @@ FEXPORT(sk_load_byte_positive)
 NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(4)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	wsbh	t0, $r_s0
 	jr	$r_ra
 	 rotr	$r_A, t0, 16
@@ -196,7 +197,7 @@ NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 NESTED(bpf_slow_path_half, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(2)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+# if MIPS_ISA_REV >= 2
 	jr	$r_ra
 	 wsbh	$r_A, $r_s0
 # else
-- 
2.7.4

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

* [PATCH 4/4] MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
                   ` (3 preceding siblings ...)
  2018-02-26 17:02 ` [PATCH 3/4] MIPS: BPF: " Matt Redfearn
@ 2018-02-26 17:02 ` Matt Redfearn
  2018-02-26 17:02   ` Matt Redfearn
  2018-03-09 11:25 ` [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV James Hogan
  5 siblings, 1 reply; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/vdso/elf.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/mips/vdso/elf.S b/arch/mips/vdso/elf.S
index be37bbb1f061..428a1917afc6 100644
--- a/arch/mips/vdso/elf.S
+++ b/arch/mips/vdso/elf.S
@@ -10,6 +10,8 @@
 
 #include "vdso.h"
 
+#include <asm/isa-rev.h>
+
 #include <linux/elfnote.h>
 #include <linux/version.h>
 
@@ -40,11 +42,7 @@ __mips_abiflags:
 	.byte	__mips		/* isa_level */
 
 	/* isa_rev */
-#ifdef __mips_isa_rev
-	.byte	__mips_isa_rev
-#else
-	.byte	0
-#endif
+	.byte	MIPS_ISA_REV
 
 	/* gpr_size */
 #ifdef __mips64
@@ -54,7 +52,7 @@ __mips_abiflags:
 #endif
 
 	/* cpr1_size */
-#if (defined(__mips_isa_rev) && __mips_isa_rev >= 6) || defined(__mips64)
+#if (MIPS_ISA_REV >= 6) || defined(__mips64)
 	.byte	2		/* AFL_REG_64 */
 #else
 	.byte	1		/* AFL_REG_32 */
-- 
2.7.4

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

* [PATCH 4/4] MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV
  2018-02-26 17:02 ` [PATCH 4/4] MIPS: VDSO: " Matt Redfearn
@ 2018-02-26 17:02   ` Matt Redfearn
  0 siblings, 0 replies; 13+ messages in thread
From: Matt Redfearn @ 2018-02-26 17:02 UTC (permalink / raw)
  To: James Hogan, Ralf Baechle
  Cc: linux-mips, Paul Burton, Matt Redfearn, linux-kernel

Remove the need to check that __mips_isa_rev is defined by using the
newly added MIPS_ISA_REV.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---

 arch/mips/vdso/elf.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/mips/vdso/elf.S b/arch/mips/vdso/elf.S
index be37bbb1f061..428a1917afc6 100644
--- a/arch/mips/vdso/elf.S
+++ b/arch/mips/vdso/elf.S
@@ -10,6 +10,8 @@
 
 #include "vdso.h"
 
+#include <asm/isa-rev.h>
+
 #include <linux/elfnote.h>
 #include <linux/version.h>
 
@@ -40,11 +42,7 @@ __mips_abiflags:
 	.byte	__mips		/* isa_level */
 
 	/* isa_rev */
-#ifdef __mips_isa_rev
-	.byte	__mips_isa_rev
-#else
-	.byte	0
-#endif
+	.byte	MIPS_ISA_REV
 
 	/* gpr_size */
 #ifdef __mips64
@@ -54,7 +52,7 @@ __mips_abiflags:
 #endif
 
 	/* cpr1_size */
-#if (defined(__mips_isa_rev) && __mips_isa_rev >= 6) || defined(__mips64)
+#if (MIPS_ISA_REV >= 6) || defined(__mips64)
 	.byte	2		/* AFL_REG_64 */
 #else
 	.byte	1		/* AFL_REG_32 */
-- 
2.7.4

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

* Re: [PATCH 1/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 17:02 ` [PATCH 1/4] " Matt Redfearn
  2018-02-26 17:02   ` Matt Redfearn
@ 2018-02-26 20:05   ` Maciej W. Rozycki
  2018-02-26 20:05     ` Maciej W. Rozycki
  1 sibling, 1 reply; 13+ messages in thread
From: Maciej W. Rozycki @ 2018-02-26 20:05 UTC (permalink / raw)
  To: Matt Redfearn
  Cc: James Hogan, Ralf Baechle, linux-mips, Paul Burton, linux-kernel

On Mon, 26 Feb 2018, Matt Redfearn wrote:

> +/* If the compiler has defined __mips_isa_rev, believe it. */
> +#ifdef __mips_isa_rev
> +#define MIPS_ISA_REV __mips_isa_rev
> +#else
> +/* The compiler hasn't defined the isa rev so assume it's MIPS I - V (0) */
> +#define MIPS_ISA_REV 0
> +#endif

 FYI, GCC has this:

/* The ISA revision level.  This is 0 for MIPS I to V and N for
   MIPS{32,64}rN.  */
int mips_isa_rev;

and this:

      if (mips_isa < 32)
	mips_isa_rev = 0;
      else
	mips_isa_rev = (mips_isa & 31) + 1;

and then:

      if (mips_isa_rev > 0)						\
	builtin_define_with_int_value ("__mips_isa_rev",		\
				       mips_isa_rev);			\

so your proposal looks like the right approach to me.  I think we should 
have the various target macros documented in the GCC manual.

Reviewed-by: Maciej W. Rozycki <macro@mips.com>

  Maciej

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

* Re: [PATCH 1/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 20:05   ` Maciej W. Rozycki
@ 2018-02-26 20:05     ` Maciej W. Rozycki
  0 siblings, 0 replies; 13+ messages in thread
From: Maciej W. Rozycki @ 2018-02-26 20:05 UTC (permalink / raw)
  To: Matt Redfearn
  Cc: James Hogan, Ralf Baechle, linux-mips, Paul Burton, linux-kernel

On Mon, 26 Feb 2018, Matt Redfearn wrote:

> +/* If the compiler has defined __mips_isa_rev, believe it. */
> +#ifdef __mips_isa_rev
> +#define MIPS_ISA_REV __mips_isa_rev
> +#else
> +/* The compiler hasn't defined the isa rev so assume it's MIPS I - V (0) */
> +#define MIPS_ISA_REV 0
> +#endif

 FYI, GCC has this:

/* The ISA revision level.  This is 0 for MIPS I to V and N for
   MIPS{32,64}rN.  */
int mips_isa_rev;

and this:

      if (mips_isa < 32)
	mips_isa_rev = 0;
      else
	mips_isa_rev = (mips_isa & 31) + 1;

and then:

      if (mips_isa_rev > 0)						\
	builtin_define_with_int_value ("__mips_isa_rev",		\
				       mips_isa_rev);			\

so your proposal looks like the right approach to me.  I think we should 
have the various target macros documented in the GCC manual.

Reviewed-by: Maciej W. Rozycki <macro@mips.com>

  Maciej

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

* Re: [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
  2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
                   ` (4 preceding siblings ...)
  2018-02-26 17:02 ` [PATCH 4/4] MIPS: VDSO: " Matt Redfearn
@ 2018-03-09 11:25 ` James Hogan
  5 siblings, 0 replies; 13+ messages in thread
From: James Hogan @ 2018-03-09 11:25 UTC (permalink / raw)
  To: Matt Redfearn
  Cc: Ralf Baechle, linux-mips, Paul Burton, linux-kernel,
	Maciej W. Rozycki, David Daney

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

On Mon, Feb 26, 2018 at 05:02:41PM +0000, Matt Redfearn wrote:
> There are multiple instances in the kernel where we need to include or
> exclude particular instructions based on the ISA revision of the target
> processor. For MIPS32 / MIPS64, the compiler exports a __mips_isa_rev
> define. However, when targeting MIPS I - V, this define is absent. This
> leads to each use of __mips_isa_rev having to check that it is defined
> first. To simplify this, this series introduces the isa-rev.h header
> which always exports MIPS_ISA_REV (the name is changed so as to avoid
> confusion with the compiler builtin and to avoid accidentally using the
> builtin). All uses of __mips_isa_rev are then replaced with the new
> define, removing the check that it is defined.
> 
> Applies on v4.16-rc1
> 
> 
> Matt Redfearn (4):
>   MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
>   MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
>   MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
>   MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV

Applied for 4.17,

Thanks
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-03-09 11:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-26 17:02 [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV Matt Redfearn
2018-02-26 17:02 ` Matt Redfearn
2018-02-26 17:02 ` [PATCH 1/4] " Matt Redfearn
2018-02-26 17:02   ` Matt Redfearn
2018-02-26 20:05   ` Maciej W. Rozycki
2018-02-26 20:05     ` Maciej W. Rozycki
2018-02-26 17:02 ` [PATCH 2/4] MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV Matt Redfearn
2018-02-26 17:02   ` Matt Redfearn
2018-02-26 17:02 ` [PATCH 3/4] MIPS: BPF: " Matt Redfearn
2018-02-26 17:02   ` Matt Redfearn
2018-02-26 17:02 ` [PATCH 4/4] MIPS: VDSO: " Matt Redfearn
2018-02-26 17:02   ` Matt Redfearn
2018-03-09 11:25 ` [PATCH 0/4] MIPS: Introduce isa-rev.h to define MIPS_ISA_REV James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox