2022-05-11 10:39:58

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:

{standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
{standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
{standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
{standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored

The math emulation support code is intended for 68020 and higher, and
uses several instructions or instruction modes not available on coldfire
or 68000.

Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
support was only available on 68020 or higher. But this assumption
was broken by the introduction of MMU support for M547x and M548x.

Drop the dependency on MMU, as the code should work fine on 68020 and up
without MMU (which are not yet supported by Linux, though).
Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
out 68xxx below 68020).

Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
To be queued in the m68k for-v5.19 branch.

arch/m68k/Kconfig.cpu | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 16ea9a67723c09dc..9abddbbee819f1d3 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -327,7 +327,7 @@ comment "Processor Specific Options"

config M68KFPU_EMU
bool "Math emulation support"
- depends on MMU
+ depends on M68K_CLASSIC && FPU
help
At some point in the future, this will cause floating-point math
instructions to be emulated by the kernel on machines that lack a
--
2.25.1



2022-05-11 13:18:48

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

On Wed, May 11, 2022 at 11:48 AM Geert Uytterhoeven
<[email protected]> wrote:
> If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:
>
> {standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
> {standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
> {standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
> {standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored
>
> The math emulation support code is intended for 68020 and higher, and
> uses several instructions or instruction modes not available on coldfire
> or 68000.
>
> Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
> support was only available on 68020 or higher. But this assumption
> was broken by the introduction of MMU support for M547x and M548x.
>
> Drop the dependency on MMU, as the code should work fine on 68020 and up
> without MMU (which are not yet supported by Linux, though).
> Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
> out 68xxx below 68020).
>
> Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Geert Uytterhoeven <[email protected]>
> ---
> To be queued in the m68k for-v5.19 branch.
>
> arch/m68k/Kconfig.cpu | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index 16ea9a67723c09dc..9abddbbee819f1d3 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -327,7 +327,7 @@ comment "Processor Specific Options"
>
> config M68KFPU_EMU
> bool "Math emulation support"
> - depends on MMU
> + depends on M68K_CLASSIC && FPU
^^^^^^^^^^^^
Whoops, that's a silly typo...

> help
> At some point in the future, this will cause floating-point math
> instructions to be emulated by the kernel on machines that lack a

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2022-05-11 13:35:27

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

On Mai 11 2022, Geert Uytterhoeven wrote:

> The FPU emu code also relies on the CPU trapping on the proper
> instructions, which I believe you need a 68020+ for, too?

While pre-020 doesn't have the coprocessor interface (which is not
fpu-specific, though), they still use the same exception vector.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."

2022-05-11 15:20:32

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

On Mai 11 2022, Geert Uytterhoeven wrote:

> Drop the dependency on MMU, as the code should work fine on 68020 and up
> without MMU (which are not yet supported by Linux, though).
> Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
> out 68xxx below 68020).

Depending on FPU looks strange, since that is supposed to be an FPU
emulation, for CPUs that _lack_ an FPU (ie. 680[23]0 without the
6888[12], or 68LC0[46]0).

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."

2022-05-12 17:19:47

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

Hi Andreas,

On Wed, May 11, 2022 at 1:43 PM Andreas Schwab <[email protected]> wrote:
> On Mai 11 2022, Geert Uytterhoeven wrote:
> > Drop the dependency on MMU, as the code should work fine on 68020 and up
> > without MMU (which are not yet supported by Linux, though).
> > Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
> > out 68xxx below 68020).
>
> Depending on FPU looks strange, since that is supposed to be an FPU
> emulation, for CPUs that _lack_ an FPU (ie. 680[23]0 without the
> 6888[12], or 68LC0[46]0).

I picked FPU because it is selected by all of M680[2346]0.
Upon closer look, both the hard FPU and soft FPU code are protected
by CONFIG_FPU, so the latter looks like the right symbol.
The FPU emu code also relies on the CPU trapping on the proper
instructions, which I believe you need a 68020+ for, too?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2022-05-14 00:52:56

by Greg Ungerer

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

Hi Geert,

On 11/5/22 22:54, Geert Uytterhoeven wrote:
> On Wed, May 11, 2022 at 11:48 AM Geert Uytterhoeven
> <[email protected]> wrote:
>> If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:
>>
>> {standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
>> {standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
>> {standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
>> {standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored
>>
>> The math emulation support code is intended for 68020 and higher, and
>> uses several instructions or instruction modes not available on coldfire
>> or 68000.
>>
>> Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
>> support was only available on 68020 or higher. But this assumption
>> was broken by the introduction of MMU support for M547x and M548x.
>>
>> Drop the dependency on MMU, as the code should work fine on 68020 and up
>> without MMU (which are not yet supported by Linux, though).
>> Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
>> out 68xxx below 68020).
>>
>> Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
>> Reported-by: kernel test robot <[email protected]>
>> Signed-off-by: Geert Uytterhoeven <[email protected]>
>> ---
>> To be queued in the m68k for-v5.19 branch.
>>
>> arch/m68k/Kconfig.cpu | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
>> index 16ea9a67723c09dc..9abddbbee819f1d3 100644
>> --- a/arch/m68k/Kconfig.cpu
>> +++ b/arch/m68k/Kconfig.cpu
>> @@ -327,7 +327,7 @@ comment "Processor Specific Options"
>>
>> config M68KFPU_EMU
>> bool "Math emulation support"
>> - depends on MMU
>> + depends on M68K_CLASSIC && FPU
> ^^^^^^^^^^^^
> Whoops, that's a silly typo...

Are you going to resend, or are you thinking of changing the way this is done?

I had thought that CONFIG_FPU enabled meant you had some type of
floating point support in the kernel - be it hardware or software emulated.
So I don't have a problem with this "as is".

Regards
Greg



2022-05-14 01:23:43

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

Hi Greg,

On Fri, May 13, 2022 at 1:23 AM Greg Ungerer <[email protected]> wrote:
> On 11/5/22 22:54, Geert Uytterhoeven wrote:
> > On Wed, May 11, 2022 at 11:48 AM Geert Uytterhoeven
> > <[email protected]> wrote:
> >> If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:
> >>
> >> {standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
> >> {standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
> >> {standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
> >> {standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored
> >>
> >> The math emulation support code is intended for 68020 and higher, and
> >> uses several instructions or instruction modes not available on coldfire
> >> or 68000.
> >>
> >> Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
> >> support was only available on 68020 or higher. But this assumption
> >> was broken by the introduction of MMU support for M547x and M548x.
> >>
> >> Drop the dependency on MMU, as the code should work fine on 68020 and up
> >> without MMU (which are not yet supported by Linux, though).
> >> Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
> >> out 68xxx below 68020).
> >>
> >> Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
> >> Reported-by: kernel test robot <[email protected]>
> >> Signed-off-by: Geert Uytterhoeven <[email protected]>
> >> ---
> >> To be queued in the m68k for-v5.19 branch.
> >>
> >> arch/m68k/Kconfig.cpu | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> >> index 16ea9a67723c09dc..9abddbbee819f1d3 100644
> >> --- a/arch/m68k/Kconfig.cpu
> >> +++ b/arch/m68k/Kconfig.cpu
> >> @@ -327,7 +327,7 @@ comment "Processor Specific Options"
> >>
> >> config M68KFPU_EMU
> >> bool "Math emulation support"
> >> - depends on MMU
> >> + depends on M68K_CLASSIC && FPU
> > ^^^^^^^^^^^^
> > Whoops, that's a silly typo...
>
> Are you going to resend, or are you thinking of changing the way this is done?

I was going to resend, with the above fixed, and an improved patch
description w.r.t. the dependency on FPU.

> I had thought that CONFIG_FPU enabled meant you had some type of
> floating point support in the kernel - be it hardware or software emulated.
> So I don't have a problem with this "as is".

That matches my understanding, too.

BTW, I'm not familiar with Coldfire FPU support. Does it rely on any
emulation (e.g. for transcendental functions, like '040/'060)?
Would there be any point in making the math emulation code
Coldfire-proof?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2022-05-14 02:32:16

by Greg Ungerer

[permalink] [raw]
Subject: Re: [PATCH] m68k: math-emu: Fix dependencies of math emulation support

Hi Geert,

On 13/5/22 16:56, Geert Uytterhoeven wrote:
> Hi Greg,
>
> On Fri, May 13, 2022 at 1:23 AM Greg Ungerer <[email protected]> wrote:
>> On 11/5/22 22:54, Geert Uytterhoeven wrote:
>>> On Wed, May 11, 2022 at 11:48 AM Geert Uytterhoeven
>>> <[email protected]> wrote:
>>>> If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:
>>>>
>>>> {standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
>>>> {standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
>>>> {standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
>>>> {standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored
>>>>
>>>> The math emulation support code is intended for 68020 and higher, and
>>>> uses several instructions or instruction modes not available on coldfire
>>>> or 68000.
>>>>
>>>> Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
>>>> support was only available on 68020 or higher. But this assumption
>>>> was broken by the introduction of MMU support for M547x and M548x.
>>>>
>>>> Drop the dependency on MMU, as the code should work fine on 68020 and up
>>>> without MMU (which are not yet supported by Linux, though).
>>>> Add dependencies on M68K_CLASSIC (to rule out Coldfire) and FPU (to rule
>>>> out 68xxx below 68020).
>>>>
>>>> Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
>>>> Reported-by: kernel test robot <[email protected]>
>>>> Signed-off-by: Geert Uytterhoeven <[email protected]>
>>>> ---
>>>> To be queued in the m68k for-v5.19 branch.
>>>>
>>>> arch/m68k/Kconfig.cpu | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
>>>> index 16ea9a67723c09dc..9abddbbee819f1d3 100644
>>>> --- a/arch/m68k/Kconfig.cpu
>>>> +++ b/arch/m68k/Kconfig.cpu
>>>> @@ -327,7 +327,7 @@ comment "Processor Specific Options"
>>>>
>>>> config M68KFPU_EMU
>>>> bool "Math emulation support"
>>>> - depends on MMU
>>>> + depends on M68K_CLASSIC && FPU
>>> ^^^^^^^^^^^^
>>> Whoops, that's a silly typo...
>>
>> Are you going to resend, or are you thinking of changing the way this is done?
>
> I was going to resend, with the above fixed, and an improved patch
> description w.r.t. the dependency on FPU.
>
>> I had thought that CONFIG_FPU enabled meant you had some type of
>> floating point support in the kernel - be it hardware or software emulated.
>> So I don't have a problem with this "as is".
>
> That matches my understanding, too.
>
> BTW, I'm not familiar with Coldfire FPU support. Does it rely on any
> emulation (e.g. for transcendental functions, like '040/'060)?
> Would there be any point in making the math emulation code
> Coldfire-proof?

I have never really looked closely at it either. The FPU is optionally
present only in the v4 cores. But the operations looks like just the
basic set to me, so I expect it will need emulations for transcendentals.

Section 4.4.3 of the CF4e Core User Manual gives some guidance on the differences
between the traditional m68k FPU and the ColdFire FPU.

It would be nice if the code could deal with ColdFire FPU as well.
For the most part it looks possible, but might end up a little ugly.

Regards
Greg



> Thanks!
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds