All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG.
@ 2013-01-17 17:36 Steven J. Hill
  2013-01-17 18:15 ` David Daney
  0 siblings, 1 reply; 5+ messages in thread
From: Steven J. Hill @ 2013-01-17 17:36 UTC (permalink / raw)
  To: linux-mips; +Cc: Steven J. Hill, ralf

From: "Steven J. Hill" <sjhill@mips.com>

The BRK_BUG value is used in the BUG and __BUG_ON inline macros. For
standard MIPS cores the code in the 'tne' instruction is 10-bits long.
In microMIPS, the 'tne' instruction is recoded and the code can only be
4-bits long. We use the value of 12 instead of 512 when building a
microMIPS kernel.

Signed-off-by: Steven J. Hill <sjhill@mips.com>
---
 arch/mips/include/asm/break.h |    1 +
 arch/mips/include/asm/bug.h   |    4 ++++
 2 files changed, 5 insertions(+)

diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
index 9161e68..df9d090 100644
--- a/arch/mips/include/asm/break.h
+++ b/arch/mips/include/asm/break.h
@@ -27,6 +27,7 @@
 #define BRK_STACKOVERFLOW 9	/* For Ada stackchecking */
 #define BRK_NORLD	10	/* No rld found - not used by Linux/MIPS */
 #define _BRK_THREADBP	11	/* For threads, user bp (used by debuggers) */
+#define BRK_BUG_MM	12	/* Used by BUG() in microMIPS mode */
 #define BRK_BUG		512	/* Used by BUG() */
 #define BRK_KDB		513	/* Used in KDB_ENTER() */
 #define BRK_MEMU	514	/* Used by FPU emulator */
diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
index 540c98a..b716fb9 100644
--- a/arch/mips/include/asm/bug.h
+++ b/arch/mips/include/asm/bug.h
@@ -7,6 +7,10 @@
 #ifdef CONFIG_BUG
 
 #include <asm/break.h>
+#ifdef CONFIG_CPU_MICROMIPS
+#undef BRK_BUG
+#define BRK_BUG		BRK_BUG_MM
+#endif
 
 static inline void __noreturn BUG(void)
 {
-- 
1.7.9.5

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

* Re: [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG.
  2013-01-17 17:36 [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG Steven J. Hill
@ 2013-01-17 18:15 ` David Daney
  2013-01-17 19:07   ` Hill, Steven
  2013-01-17 22:54   ` Ralf Baechle
  0 siblings, 2 replies; 5+ messages in thread
From: David Daney @ 2013-01-17 18:15 UTC (permalink / raw)
  To: Steven J. Hill; +Cc: linux-mips, ralf

On 01/17/2013 09:36 AM, Steven J. Hill wrote:
> From: "Steven J. Hill" <sjhill@mips.com>
>
> The BRK_BUG value is used in the BUG and __BUG_ON inline macros. For
> standard MIPS cores the code in the 'tne' instruction is 10-bits long.
> In microMIPS, the 'tne' instruction is recoded and the code can only be
> 4-bits long. We use the value of 12 instead of 512 when building a
> microMIPS kernel.
>
> Signed-off-by: Steven J. Hill <sjhill@mips.com>
> ---
>   arch/mips/include/asm/break.h |    1 +
>   arch/mips/include/asm/bug.h   |    4 ++++
>   2 files changed, 5 insertions(+)
>
> diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
> index 9161e68..df9d090 100644
> --- a/arch/mips/include/asm/break.h
> +++ b/arch/mips/include/asm/break.h
> @@ -27,6 +27,7 @@
>   #define BRK_STACKOVERFLOW 9	/* For Ada stackchecking */
>   #define BRK_NORLD	10	/* No rld found - not used by Linux/MIPS */
>   #define _BRK_THREADBP	11	/* For threads, user bp (used by debuggers) */
> +#define BRK_BUG_MM	12	/* Used by BUG() in microMIPS mode */
>   #define BRK_BUG		512	/* Used by BUG() */

Can we move the CONFIG_CPU_MICROMIPS to here and just call the thing 
BRK_BUG?

Or perhaps redefining it unconditionally.  I am not sure what the 
implications of doing that would be.

That way...


>   #define BRK_KDB		513	/* Used in KDB_ENTER() */
>   #define BRK_MEMU	514	/* Used by FPU emulator */
> diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
> index 540c98a..b716fb9 100644
> --- a/arch/mips/include/asm/bug.h
> +++ b/arch/mips/include/asm/bug.h
> @@ -7,6 +7,10 @@
>   #ifdef CONFIG_BUG
>
>   #include <asm/break.h>
> +#ifdef CONFIG_CPU_MICROMIPS
> +#undef BRK_BUG
> +#define BRK_BUG		BRK_BUG_MM
> +#endif
>

...We don't need this bit.   Doing an #undef risks using different 
values for BRK_BUG depending on whether or not asm/bug.h is included.

>   static inline void __noreturn BUG(void)
>   {
>

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

* RE: [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG.
  2013-01-17 18:15 ` David Daney
@ 2013-01-17 19:07   ` Hill, Steven
  2013-01-17 22:54   ` Ralf Baechle
  1 sibling, 0 replies; 5+ messages in thread
From: Hill, Steven @ 2013-01-17 19:07 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips@linux-mips.org, ralf@linux-mips.org

>> diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
>> index 9161e68..df9d090 100644
>> --- a/arch/mips/include/asm/break.h
>> +++ b/arch/mips/include/asm/break.h
>> @@ -27,6 +27,7 @@
>>   #define BRK_STACKOVERFLOW 9 /* For Ada stackchecking */
>>   #define BRK_NORLD   10      /* No rld found - not used by Linux/MIPS */
>>   #define _BRK_THREADBP       11      /* For threads, user bp (used by debuggers) */
>> +#define BRK_BUG_MM   12      /* Used by BUG() in microMIPS mode */
>>   #define BRK_BUG             512     /* Used by BUG() */
>
> Can we move the CONFIG_CPU_MICROMIPS to here and just call the thing
> BRK_BUG?
>
No, because this header file is exported in 'arch/mips/include/uapi/asm' now. I already discussed this with Ralf.

>>   #include <asm/break.h>
>> +#ifdef CONFIG_CPU_MICROMIPS
>> +#undef BRK_BUG
>> +#define BRK_BUG              BRK_BUG_MM
>> +#endif
>>
>
> ...We don't need this bit.   Doing an #undef risks using different
> values for BRK_BUG depending on whether or not asm/bug.h is included.
>
I was trying to avoid two #ifdef's in 'bug.h' but I can certainly get rid of the above and use two #ifdef's instead.

-Steve

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

* Re: [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG.
  2013-01-17 18:15 ` David Daney
  2013-01-17 19:07   ` Hill, Steven
@ 2013-01-17 22:54   ` Ralf Baechle
  2013-01-18  0:42     ` David Daney
  1 sibling, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2013-01-17 22:54 UTC (permalink / raw)
  To: David Daney; +Cc: Steven J. Hill, linux-mips

On Thu, Jan 17, 2013 at 10:15:49AM -0800, David Daney wrote:

> >diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
> >index 9161e68..df9d090 100644
> >--- a/arch/mips/include/asm/break.h
> >+++ b/arch/mips/include/asm/break.h
> >@@ -27,6 +27,7 @@
> >  #define BRK_STACKOVERFLOW 9	/* For Ada stackchecking */
> >  #define BRK_NORLD	10	/* No rld found - not used by Linux/MIPS */
> >  #define _BRK_THREADBP	11	/* For threads, user bp (used by debuggers) */
> >+#define BRK_BUG_MM	12	/* Used by BUG() in microMIPS mode */
> >  #define BRK_BUG		512	/* Used by BUG() */
> 
> Can we move the CONFIG_CPU_MICROMIPS to here and just call the thing
> BRK_BUG?
> 
> Or perhaps redefining it unconditionally.  I am not sure what the
> implications of doing that would be.
> 
> That way...

The kernel decodes break and trap instruction in traps.c.  For a microMIPS-
enabled kernel it needs to be able to decode both classic and microMIPS
encoded instructions so we want separate symbols.

Or we do something like

#define BRK_MM_BUG	 12      /* Used by BUG() in microMIPS mode */
#define BRK_CM_BUG	512     /* Used by BUG() */

#ifdef __mips_micromips
#define BRK_BUG		BRK_MM_BUG
#else
#define BRK_BUG		BRK_CM_BUG
#endif

This makes the BRK_MM_* / BRK_CM_* macros available for decoding instructions
and the microMIPS-agnostic BRK_BUG for code such as BUG().

> >  #define BRK_KDB		513	/* Used in KDB_ENTER() */
> >  #define BRK_MEMU	514	/* Used by FPU emulator */
> >diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
> >index 540c98a..b716fb9 100644
> >--- a/arch/mips/include/asm/bug.h
> >+++ b/arch/mips/include/asm/bug.h
> >@@ -7,6 +7,10 @@
> >  #ifdef CONFIG_BUG
> >
> >  #include <asm/break.h>
> >+#ifdef CONFIG_CPU_MICROMIPS
> >+#undef BRK_BUG
> >+#define BRK_BUG		BRK_BUG_MM
> >+#endif
> >
> 
> ...We don't need this bit.   Doing an #undef risks using different
> values for BRK_BUG depending on whether or not asm/bug.h is
> included.

And generally is not very elegant.

  Ralf

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

* Re: [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG.
  2013-01-17 22:54   ` Ralf Baechle
@ 2013-01-18  0:42     ` David Daney
  0 siblings, 0 replies; 5+ messages in thread
From: David Daney @ 2013-01-18  0:42 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Steven J. Hill, linux-mips

On 01/17/2013 02:54 PM, Ralf Baechle wrote:
> On Thu, Jan 17, 2013 at 10:15:49AM -0800, David Daney wrote:
>
>>> diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
>>> index 9161e68..df9d090 100644
>>> --- a/arch/mips/include/asm/break.h
>>> +++ b/arch/mips/include/asm/break.h
>>> @@ -27,6 +27,7 @@
>>>   #define BRK_STACKOVERFLOW 9	/* For Ada stackchecking */
>>>   #define BRK_NORLD	10	/* No rld found - not used by Linux/MIPS */
>>>   #define _BRK_THREADBP	11	/* For threads, user bp (used by debuggers) */
>>> +#define BRK_BUG_MM	12	/* Used by BUG() in microMIPS mode */
>>>   #define BRK_BUG		512	/* Used by BUG() */
>>
>> Can we move the CONFIG_CPU_MICROMIPS to here and just call the thing
>> BRK_BUG?
>>
>> Or perhaps redefining it unconditionally.  I am not sure what the
>> implications of doing that would be.
>>
>> That way...
>
> The kernel decodes break and trap instruction in traps.c.  For a microMIPS-
> enabled kernel it needs to be able to decode both classic and microMIPS
> encoded instructions so we want separate symbols.

For any given kernel, BUG() will be implemented using exactly one trap 
value.  That should be the value tested in traps.c

So we could make non-microMIPS use the same value as microMIPS and then 
we don't have to test for two values.

Side note:  The values used only internally to the kernel should not be 
exported in a userspace visible header file.


>
> Or we do something like
>
> #define BRK_MM_BUG	 12      /* Used by BUG() in microMIPS mode */
> #define BRK_CM_BUG	512     /* Used by BUG() */
>
> #ifdef __mips_micromips
> #define BRK_BUG		BRK_MM_BUG
> #else
> #define BRK_BUG		BRK_CM_BUG
> #endif
>
> This makes the BRK_MM_* / BRK_CM_* macros available for decoding instructions
> and the microMIPS-agnostic BRK_BUG for code such as BUG().
>
>>>   #define BRK_KDB		513	/* Used in KDB_ENTER() */
>>>   #define BRK_MEMU	514	/* Used by FPU emulator */
>>> diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
>>> index 540c98a..b716fb9 100644
>>> --- a/arch/mips/include/asm/bug.h
>>> +++ b/arch/mips/include/asm/bug.h
>>> @@ -7,6 +7,10 @@
>>>   #ifdef CONFIG_BUG
>>>
>>>   #include <asm/break.h>
>>> +#ifdef CONFIG_CPU_MICROMIPS
>>> +#undef BRK_BUG
>>> +#define BRK_BUG		BRK_BUG_MM
>>> +#endif
>>>
>>
>> ...We don't need this bit.   Doing an #undef risks using different
>> values for BRK_BUG depending on whether or not asm/bug.h is
>> included.
>
> And generally is not very elegant.
>
>    Ralf
>
>

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

end of thread, other threads:[~2013-01-18  0:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17 17:36 [PATCH] MIPS: microMIPS: Redefine value of BRK_BUG Steven J. Hill
2013-01-17 18:15 ` David Daney
2013-01-17 19:07   ` Hill, Steven
2013-01-17 22:54   ` Ralf Baechle
2013-01-18  0:42     ` David Daney

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.