linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add support for FP emulation for the e300c2 core
@ 2006-11-22 20:20 Kim Phillips
  2006-11-22 21:34 ` Benjamin Herrenschmidt
  2006-12-04  3:23 ` Paul Mackerras
  0 siblings, 2 replies; 5+ messages in thread
From: Kim Phillips @ 2006-11-22 20:20 UTC (permalink / raw)
  To: linuxppc-dev

The e300c2 has no FPU.  Its MSR[FP] is grounded to zero.  If an attempt
is made to execute a floating point instruction (including floating-point
load, store, or move instructions), the e300c2 takes a floating-point
unavailable interrupt (IVOR7).

This patch adds support for FP emulation on the e300c2 by declaring a
new CPU_FTR_FP_TAKES_FPUNAVAIL, where FP unavail interrupts are
intercepted and redirected to the ProgramCheck exception path for
correct emulation handling.

It adds a single cycle latency to "FPUfull" 32-bit powerpc processors
load_up_fpu path.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/Kconfig           |    2 +-
 arch/powerpc/kernel/cputable.c |    3 ++-
 arch/powerpc/kernel/head_32.S  |    7 +++++++
 arch/powerpc/kernel/traps.c    |    2 ++
 include/asm-powerpc/cputable.h |    1 +
 5 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1d71aff..250e4be 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -669,7 +669,7 @@ config FORCE_MAX_ZONEORDER
 
 config MATH_EMULATION
 	bool "Math emulation"
-	depends on 4xx || 8xx || E200 || E500
+	depends on 4xx || 8xx || E200 || PPC_83xx || E500
 	---help---
 	  Some PowerPC chips designed for embedded applications do not have
 	  a floating-point unit and therefore do not implement the
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 911ac44..0310be9 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -833,7 +833,8 @@ #if CLASSIC_PPC
 		.pvr_mask		= 0x7fff0000,
 		.pvr_value		= 0x00840000,
 		.cpu_name		= "e300c2",
-		.cpu_features		= CPU_FTRS_E300,
+		.cpu_features		= CPU_FTRS_E300 |
+			CPU_FTR_FP_TAKES_FPUNAVAIL,
 		.cpu_user_features	= PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
 		.icache_bsize		= 32,
 		.dcache_bsize		= 32,
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index d88e182..5bd8098 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -437,6 +437,13 @@ Alignment:
 /* Floating-point unavailable */
 	. = 0x800
 FPUnavailable:
+BEGIN_FTR_SECTION
+/*
+ * certain freescale cores treat 'normal' floating point instructions
+ * as FP Unavail exception.  Redirect to normal illegal/emulation handling.
+ */
+	b 	ProgramCheck
+END_FTR_SECTION_IFSET(CPU_FTR_FP_TAKES_FPUNAVAIL)
 	EXCEPTION_PROLOG
 	bne	load_up_fpu		/* if from user, just load it up */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 0d4e203..0de17e1 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -790,6 +790,8 @@ #ifdef CONFIG_MATH_EMULATION
 	 * hardware people - not sure if it can happen on any illegal
 	 * instruction or only on FP instructions, whether there is a
 	 * pattern to occurences etc. -dgibson 31/Mar/2003 */
+	/* certain freescale cores reach here from the FPUnavailable
+	 * exception path, also without setting ESR */
 	if (!(reason & REASON_TRAP) && do_mathemu(regs) == 0) {
 		emulate_single_step(regs);
 		return;
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index d06222a..5eae732 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -126,6 +126,7 @@ #define CPU_FTR_BIG_PHYS		ASM_CONST(0x00
 #define CPU_FTR_NODSISRALIGN		ASM_CONST(0x0000000000100000)
 #define CPU_FTR_PPC_LE			ASM_CONST(0x0000000000200000)
 #define CPU_FTR_REAL_LE			ASM_CONST(0x0000000000400000)
+#define CPU_FTR_FP_TAKES_FPUNAVAIL	ASM_CONST(0x0000000000800000)
 
 /*
  * Add the 64-bit processor unique features in the top half of the word;
-- 
1.4.2.3

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

* Re: [PATCH] Add support for FP emulation for the e300c2 core
  2006-11-22 20:20 [PATCH] Add support for FP emulation for the e300c2 core Kim Phillips
@ 2006-11-22 21:34 ` Benjamin Herrenschmidt
  2006-11-22 22:09   ` Kim Phillips
  2006-12-04  3:23 ` Paul Mackerras
  1 sibling, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2006-11-22 21:34 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev


> +BEGIN_FTR_SECTION
> +/*
> + * certain freescale cores treat 'normal' floating point instructions
> + * as FP Unavail exception.  Redirect to normal illegal/emulation handling.
> + */
> +	b 	ProgramCheck
> +END_FTR_SECTION_IFSET(CPU_FTR_FP_TAKES_FPUNAVAIL)
>  	EXCEPTION_PROLOG
>  	bne	load_up_fpu		/* if from user, just load it up */
>  	addi	r3,r1,STACK_FRAME_OVERHEAD

Do you absolutely need that ? Is there any way those cores will actually
send a "normal" FPUnavail exception ? If not, don't bother. There aren't
that many CPU feature bits left so let's not use one for something that
never happens.

Ben.

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

* Re: [PATCH] Add support for FP emulation for the e300c2 core
  2006-11-22 21:34 ` Benjamin Herrenschmidt
@ 2006-11-22 22:09   ` Kim Phillips
  0 siblings, 0 replies; 5+ messages in thread
From: Kim Phillips @ 2006-11-22 22:09 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

On Thu, 23 Nov 2006 08:34:34 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> 
> > +BEGIN_FTR_SECTION
> > +/*
> > + * certain freescale cores treat 'normal' floating point instructions
> > + * as FP Unavail exception.  Redirect to normal illegal/emulation handling.
> > + */
> > +	b 	ProgramCheck
> > +END_FTR_SECTION_IFSET(CPU_FTR_FP_TAKES_FPUNAVAIL)
> >  	EXCEPTION_PROLOG
> >  	bne	load_up_fpu		/* if from user, just load it up */
> >  	addi	r3,r1,STACK_FRAME_OVERHEAD
> 
> Do you absolutely need that ? Is there any way those cores will actually

The feature section provides a means of distinguishing among other processors (i.e. those with FPUs) at runtime.

> send a "normal" FPUnavail exception ? If not, don't bother. There aren't

no, it never takes the Illegal instruction/ProgramCheck exception by itself when a FP insn is in the pipe.

> that many CPU feature bits left so let's not use one for something that
> never happens.
> 
this happens when executing a binary with FP instructions compiled in.  This feature will be reused when support for other FPUless core variants coming from freescale are added.

Kim

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

* Re: [PATCH] Add support for FP emulation for the e300c2 core
  2006-11-22 20:20 [PATCH] Add support for FP emulation for the e300c2 core Kim Phillips
  2006-11-22 21:34 ` Benjamin Herrenschmidt
@ 2006-12-04  3:23 ` Paul Mackerras
  2006-12-04  4:41   ` Kumar Gala
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2006-12-04  3:23 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev

Kim Phillips writes:

> The e300c2 has no FPU.  Its MSR[FP] is grounded to zero.  If an attempt
> is made to execute a floating point instruction (including floating-point
> load, store, or move instructions), the e300c2 takes a floating-point
> unavailable interrupt (IVOR7).

Can't you just point IVOR7 at the program check handler on these cpus?

Paul.

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

* Re: [PATCH] Add support for FP emulation for the e300c2 core
  2006-12-04  3:23 ` Paul Mackerras
@ 2006-12-04  4:41   ` Kumar Gala
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2006-12-04  4:41 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev


On Dec 3, 2006, at 9:23 PM, Paul Mackerras wrote:

> Kim Phillips writes:
>
>> The e300c2 has no FPU.  Its MSR[FP] is grounded to zero.  If an  
>> attempt
>> is made to execute a floating point instruction (including  
>> floating-point
>> load, store, or move instructions), the e300c2 takes a floating-point
>> unavailable interrupt (IVOR7).
>
> Can't you just point IVOR7 at the program check handler on these cpus?

No, e300c2 is a 'classic' core not book-e.  It's effectively a 603 w/ 
o and FPU.  I'll cleanup the commit message in my git tree for you.

- k

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

end of thread, other threads:[~2006-12-04  4:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 20:20 [PATCH] Add support for FP emulation for the e300c2 core Kim Phillips
2006-11-22 21:34 ` Benjamin Herrenschmidt
2006-11-22 22:09   ` Kim Phillips
2006-12-04  3:23 ` Paul Mackerras
2006-12-04  4:41   ` Kumar Gala

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 NNTP newsgroup(s).