All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0
@ 2017-09-29  5:44 Sandipan Das
  2017-09-29  5:44 ` [PATCH 2/3] powerpc/lib/sstep: Fix fixed-point arithmetic instructions that set CA32 Sandipan Das
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sandipan Das @ 2017-09-29  5:44 UTC (permalink / raw)
  To: mpe; +Cc: naveen.n.rao, anton, paulus, linuxppc-dev

This adds definitions for the OV32 and CA32 bits of XER that
were introduced in POWER ISA v3.0. There are some existing
instructions that currently set the OV and CA bits based on
certain conditions.

The emulation behaviour of all these instructions needs to
be updated to set these new bits accordingly.

Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
---
 arch/powerpc/lib/sstep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 5e8418c28bd8..16814bfc01da 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -31,6 +31,8 @@ extern char system_call_common[];
 #define XER_SO		0x80000000U
 #define XER_OV		0x40000000U
 #define XER_CA		0x20000000U
+#define XER_OV32	0x00080000U
+#define XER_CA32	0x00040000U
 
 #ifdef CONFIG_PPC_FPU
 /*
-- 
2.13.5

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

* [PATCH 2/3] powerpc/lib/sstep: Fix fixed-point arithmetic instructions that set CA32
  2017-09-29  5:44 [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Sandipan Das
@ 2017-09-29  5:44 ` Sandipan Das
  2017-09-29  5:44 ` [PATCH 3/3] powerpc/lib/sstep: Fix fixed-point shift " Sandipan Das
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sandipan Das @ 2017-09-29  5:44 UTC (permalink / raw)
  To: mpe; +Cc: naveen.n.rao, anton, paulus, linuxppc-dev

There are existing fixed-point arithmetic instructions that always set the
CA bit of XER to reflect the carry out of bit 0 in 64-bit mode and out of
bit 32 in 32-bit mode. In ISA v3.0, these instructions also always set the
CA32 bit of XER to reflect the carry out of bit 32.

This fixes the emulated behaviour of such instructions when running on a
system that is compliant with POWER ISA v3.0. The following instructions
are affected:
  * Add Immediate Carrying (addic)
  * Add Immediate Carrying and Record (addic.)
  * Subtract From Immediate Carrying (subfic)
  * Add Carrying (addc[.])
  * Subtract From Carrying (subfc[.])
  * Add Extended (adde[.])
  * Subtract From Extended (subfe[.])
  * Add to Minus One Extended (addme[.])
  * Subtract From Minus One Extended (subfme[.])
  * Add to Zero Extended (addze[.])
  * Subtract From Zero Extended (subfze[.])

Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
---
 arch/powerpc/lib/sstep.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 16814bfc01da..fe1910733e55 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -964,6 +964,16 @@ static nokprobe_inline void set_cr0(const struct pt_regs *regs,
 		op->ccval |= 0x20000000;
 }
 
+static nokprobe_inline void set_ca32(struct instruction_op *op, bool val)
+{
+	if (cpu_has_feature(CPU_FTR_ARCH_300)) {
+		if (val)
+			op->xerval |= XER_CA32;
+		else
+			op->xerval &= ~XER_CA32;
+	}
+}
+
 static nokprobe_inline void add_with_carry(const struct pt_regs *regs,
 				     struct instruction_op *op, int rd,
 				     unsigned long val1, unsigned long val2,
@@ -987,6 +997,9 @@ static nokprobe_inline void add_with_carry(const struct pt_regs *regs,
 		op->xerval |= XER_CA;
 	else
 		op->xerval &= ~XER_CA;
+
+	set_ca32(op, (unsigned int)val < (unsigned int)val1 ||
+			(carry_in && (unsigned int)val == (unsigned int)val1));
 }
 
 static nokprobe_inline void do_cmp_signed(const struct pt_regs *regs,
-- 
2.13.5

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

* [PATCH 3/3] powerpc/lib/sstep: Fix fixed-point shift instructions that set CA32
  2017-09-29  5:44 [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Sandipan Das
  2017-09-29  5:44 ` [PATCH 2/3] powerpc/lib/sstep: Fix fixed-point arithmetic instructions that set CA32 Sandipan Das
@ 2017-09-29  5:44 ` Sandipan Das
  2017-09-29  7:31 ` [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Naveen N. Rao
  2017-10-05  4:21 ` [1/3] " Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Sandipan Das @ 2017-09-29  5:44 UTC (permalink / raw)
  To: mpe; +Cc: naveen.n.rao, anton, paulus, linuxppc-dev

This fixes the emulated behaviour of existing fixed-point shift right
algebraic instructions that are supposed to set both the CA and CA32
bits of XER when running on a system that is compliant with POWER ISA
v3.0 independent of whether the system is executing in 32-bit mode or
64-bit mode. The following instructions are affected:
  * Shift Right Algebraic Word Immediate (srawi[.])
  * Shift Right Algebraic Word (sraw[.])
  * Shift Right Algebraic Doubleword Immediate (sradi[.])
  * Shift Right Algebraic Doubleword (srad[.])

Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
---
 arch/powerpc/lib/sstep.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index fe1910733e55..5118110c3983 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1804,6 +1804,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 				op->xerval |= XER_CA;
 			else
 				op->xerval &= ~XER_CA;
+			set_ca32(op, op->xerval & XER_CA);
 			goto logical_done;
 
 		case 824:	/* srawi */
@@ -1816,6 +1817,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 				op->xerval |= XER_CA;
 			else
 				op->xerval &= ~XER_CA;
+			set_ca32(op, op->xerval & XER_CA);
 			goto logical_done;
 
 #ifdef __powerpc64__
@@ -1845,6 +1847,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 				op->xerval |= XER_CA;
 			else
 				op->xerval &= ~XER_CA;
+			set_ca32(op, op->xerval & XER_CA);
 			goto logical_done;
 
 		case 826:	/* sradi with sh_5 = 0 */
@@ -1858,6 +1861,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 				op->xerval |= XER_CA;
 			else
 				op->xerval &= ~XER_CA;
+			set_ca32(op, op->xerval & XER_CA);
 			goto logical_done;
 #endif /* __powerpc64__ */
 
-- 
2.13.5

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

* Re: [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0
  2017-09-29  5:44 [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Sandipan Das
  2017-09-29  5:44 ` [PATCH 2/3] powerpc/lib/sstep: Fix fixed-point arithmetic instructions that set CA32 Sandipan Das
  2017-09-29  5:44 ` [PATCH 3/3] powerpc/lib/sstep: Fix fixed-point shift " Sandipan Das
@ 2017-09-29  7:31 ` Naveen N. Rao
  2017-10-05  4:21 ` [1/3] " Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Naveen N. Rao @ 2017-09-29  7:31 UTC (permalink / raw)
  To: Sandipan Das; +Cc: mpe, anton, paulus, linuxppc-dev

On 2017/09/29 05:44AM, Sandipan Das wrote:
> This adds definitions for the OV32 and CA32 bits of XER that
> were introduced in POWER ISA v3.0. There are some existing
> instructions that currently set the OV and CA bits based on
> certain conditions.
> 
> The emulation behaviour of all these instructions needs to
> be updated to set these new bits accordingly.
> 
> Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>

For this series:
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

> ---
>  arch/powerpc/lib/sstep.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 5e8418c28bd8..16814bfc01da 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -31,6 +31,8 @@ extern char system_call_common[];
>  #define XER_SO		0x80000000U
>  #define XER_OV		0x40000000U
>  #define XER_CA		0x20000000U
> +#define XER_OV32	0x00080000U
> +#define XER_CA32	0x00040000U
> 
>  #ifdef CONFIG_PPC_FPU
>  /*
> -- 
> 2.13.5
> 

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

* Re: [1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0
  2017-09-29  5:44 [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Sandipan Das
                   ` (2 preceding siblings ...)
  2017-09-29  7:31 ` [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Naveen N. Rao
@ 2017-10-05  4:21 ` Michael Ellerman
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-10-05  4:21 UTC (permalink / raw)
  To: Sandipan Das; +Cc: linuxppc-dev, naveen.n.rao, paulus, anton

On Fri, 2017-09-29 at 05:44:08 UTC, Sandipan Das wrote:
> This adds definitions for the OV32 and CA32 bits of XER that
> were introduced in POWER ISA v3.0. There are some existing
> instructions that currently set the OV and CA bits based on
> certain conditions.
> 
> The emulation behaviour of all these instructions needs to
> be updated to set these new bits accordingly.
> 
> Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
> Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/924c8feb041c3ef22d46ac2e746816

cheers

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

end of thread, other threads:[~2017-10-05  4:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29  5:44 [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Sandipan Das
2017-09-29  5:44 ` [PATCH 2/3] powerpc/lib/sstep: Fix fixed-point arithmetic instructions that set CA32 Sandipan Das
2017-09-29  5:44 ` [PATCH 3/3] powerpc/lib/sstep: Fix fixed-point shift " Sandipan Das
2017-09-29  7:31 ` [PATCH 1/3] powerpc/lib/sstep: Add XER bits introduced in POWER ISA v3.0 Naveen N. Rao
2017-10-05  4:21 ` [1/3] " Michael Ellerman

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.