diff mbox series

[2/6] powerpc sstep: Add darn instruction emulation

Message ID 40fccd3f879a447d32d0fa26e773674a19cb5a87.1535609090.git.sandipan@linux.ibm.com (mailing list archive)
State Changes Requested
Headers show
Series powerpc sstep: Extend instruction emulation support | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch success Test checkpatch on branch next

Commit Message

Sandipan Das Sept. 3, 2018, 3:19 p.m. UTC
This adds emulation support for the following integer instructions:
  * Deliver A Random Number (darn)

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

Comments

Michael Ellerman Feb. 20, 2019, 12:50 a.m. UTC | #1
Sandipan Das <sandipan@linux.ibm.com> writes:

> This adds emulation support for the following integer instructions:
>   * Deliver A Random Number (darn)

This doesn't build with old binutils. We need to support old binutils.

    {standard input}:4343: Error: Unrecognized opcode: `darn'


You need to use PPC_DARN().

cheers

> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index b40ec18515bd..18ac0a26c4fc 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1728,6 +1728,25 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>  				(int) regs->gpr[rb];
>  			goto arith_done;
>  
> +		case 755:	/* darn */
> +			if (!cpu_has_feature(CPU_FTR_ARCH_300))
> +				return -1;
> +			switch (ra & 0x3) {
> +			case 0:
> +				asm("darn %0,0" : "=r" (op->val));
> +				goto compute_done;
> +
> +			case 1:
> +				asm("darn %0,1" : "=r" (op->val));
> +				goto compute_done;
> +
> +			case 2:
> +				asm("darn %0,2" : "=r" (op->val));
> +				goto compute_done;
> +			}
> +
> +			return -1;
> +
>  
>  /*
>   * Logical instructions
> -- 
> 2.14.4
Sandipan Das Feb. 20, 2019, 9:49 a.m. UTC | #2
Hi Michael,

On 20/02/19 6:20 AM, Michael Ellerman wrote:
> Sandipan Das <sandipan@linux.ibm.com> writes:
> 
>> This adds emulation support for the following integer instructions:
>>   * Deliver A Random Number (darn)
> 
> This doesn't build with old binutils. We need to support old binutils.
> 
>     {standard input}:4343: Error: Unrecognized opcode: `darn'
> 
> 
> You need to use PPC_DARN().
> 
> cheers
> 
> [...]

Thanks for pointing these out. Will post v2 with the required changes.

- Sandipan
diff mbox series

Patch

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index b40ec18515bd..18ac0a26c4fc 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1728,6 +1728,25 @@  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 				(int) regs->gpr[rb];
 			goto arith_done;
 
+		case 755:	/* darn */
+			if (!cpu_has_feature(CPU_FTR_ARCH_300))
+				return -1;
+			switch (ra & 0x3) {
+			case 0:
+				asm("darn %0,0" : "=r" (op->val));
+				goto compute_done;
+
+			case 1:
+				asm("darn %0,1" : "=r" (op->val));
+				goto compute_done;
+
+			case 2:
+				asm("darn %0,2" : "=r" (op->val));
+				goto compute_done;
+			}
+
+			return -1;
+
 
 /*
  * Logical instructions