m68k: fix ColdFire support
v2 cover m68k: fix ColdFire support
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Regards
Greg
v2:
* rebased to current master head
* constant change from Peter Crosthwaite
hw/m68k/mcf_intc.c | 14 ++++++++++++++ target-m68k/op_helper.c | 7 +++---- target-m68k/translate.c | 8 ++++---- 3 files changed, 21 insertions(+), 8 deletions(-)
PATCH v2 1/3 m68k: implement more ColdFire 5208 interrupt controller functionality
From: Greg Ungerer <[email protected]>
Implement the SIMR and CIMR registers of the 5208 interrupt controller. These are used by modern versions of Linux running on ColdFire (not sure of the exact version they were introduced, but they have been in for quite a while now).
Without this change when attempting to run a linux-3.5 kernel you will see:
qemu: hardware error: mcf_intc_write: Bad write offset 28
and execution will stop and dump out.
--- hw/m68k/mcf_intc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/m68k/mcf_intc.c +14 -0
@@ -102,6 +102,20 @@ static void mcf_intc_write(void *opaque, hwaddr addr,case 0x0c : s->imr = (s->imr &0xffffffff00000000ull ) | (uint32_t )val;break ; +case 0x1c : +if (val &0x40 ) { + s->imr = ~0ull ; + }else { + s->imr |= (0x1ull << (val &0x3f )); + } +break ; +case 0x1d : +if (val &0x40 ) { + s->imr =0ull ; + }else { + s->imr &= ~(0x1ull << (val &0x3f )); + } +break ;default :hw_error ("mcf_intc_write: Bad write offset %d\n" , offset);break ;
Signature · 1 line
1.9.1
PATCH v2 2/3 m68k: implement move to/from usp register instruction
In reply to [email protected]From: Greg Ungerer <[email protected]>
Fill out the code support for the move to/from usp instructions. They are being decoded, but there is no code to support there actions. So add it.
Current versions of Linux running on the ColdFire 5208 use these instructions.
--- target-m68k/translate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target-m68k/translate.c +4 -4
@@ -1995,8 +1995,8 @@ DISAS_INSN(move_from_usp)gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); +tcg_gen_ld_i32 (AREG (insn,0 ), cpu_env, + offsetof(CPUM68KState, sp[M68K_USP])); }DISAS_INSN (move_to_usp)
@@ -2005,8 +2005,8 @@ DISAS_INSN(move_to_usp)gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); +tcg_gen_st_i32 (AREG (insn,0 ), cpu_env, + offsetof(CPUM68KState, sp[M68K_USP])); }DISAS_INSN (halt)
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH v2 2/3] m68k: implement move to/from usp register instruction
Quoted 5 lines · Le 19/06/2015 15:43, [email protected] a écrit :
From: Greg Ungerer <[email protected]>
Fill out the code support for the move to/from usp instructions. They are being decoded, but there is no code to support there actions. So add it.
Quoted 7 lines
Current versions of Linux running on the ColdFire 5208 use these instructions.
Signed-off-by Greg Ungerer <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target-m68k/translate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
PATCH v2 3/3 m68k: fix usp processing on interrupt entry and exception exit
In reply to [email protected]From: Greg Ungerer <[email protected]>
The action to potentially switch sp register is not occurring at the correct point in the interrupt entry or exception exit sequences.
For the interrupt entry case the sp on entry is used to create the stack exception frame - but this may well be the user stack pointer, since we haven't done the switch yet. Re-order the flow to switch the sp regs then use the current sp to create the exception frame.
For the return from exception case the code is unwinding the sp after switching sp registers. But it should always unwind the supervisor sp first, then carry out any required sp switch.
Note that these problems don't effect operation unless the user sp bit is set in the CACR register. Only a single sp is used in the default power up state. Previously Linux only used this single sp mode. But modern versions of Linux use the user sp mode now, so we need correct behavior for Linux to work.
--- target-m68k/op_helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
target-m68k/op_helper.c +3 -4
@@ -63,8 +63,8 @@ static void do_rte(CPUM68KState *env) env->pc =cpu_ldl_kernel (env, sp +4 ); sp |= (fmt >>28 ) &3 ; env->sr = fmt &0xffff ; -m68k_switch_sp (env); env->aregs[7 ] = sp +8 ; +m68k_switch_sp (env); }static void do_interrupt_all (CPUM68KState *env,int is_hw)
@@ -108,10 +108,7 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw) vector = cs->exception_index <<2 ; - sp = env->aregs[7 ]; - fmt |=0x40000000 ; - fmt |= (sp &3 ) <<28 ; fmt |= vector <<16 ; fmt |= env->sr;
@@ -121,6 +118,8 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw) env->sr &= ~SR_M ; }m68k_switch_sp (env); + sp = env->aregs[7 ]; + fmt |= (sp &3 ) <<28 ;/* ??? This could cause MMU faults. */ sp &= ~3 ;
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH v2 3/3] m68k: fix usp processing on interrupt entry and exception exit
Quoted 20 lines · Le 19/06/2015 15:43, [email protected] a écrit :
From: Greg Ungerer <[email protected]>
The action to potentially switch sp register is not occurring at the correct point in the interrupt entry or exception exit sequences.
For the interrupt entry case the sp on entry is used to create the stack exception frame - but this may well be the user stack pointer, since we haven't done the switch yet. Re-order the flow to switch the sp regs then use the current sp to create the exception frame.
For the return from exception case the code is unwinding the sp after switching sp registers. But it should always unwind the supervisor sp first, then carry out any required sp switch.
Note that these problems don't effect operation unless the user sp bit is set in the CACR register. Only a single sp is used in the default power up state. Previously Linux only used this single sp mode. But modern versions of Linux use the user sp mode now, so we need correct behavior for Linux to work.
Quoted 5 lines
Signed-off-by Greg Ungerer <[email protected]>Reviewed-by Peter Crosthwaite <[email protected]>--- target-m68k/op_helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Re: [Qemu-devel] [PATCH v2 3/3] m68k: fix usp processing on interrupt entry and exception exit
Hi Laurent,
Quoted 21 lines · Laurent Vivier
Quoted 20 lines · Le 19/06/2015 15:43, [email protected] a écrit :
From: Greg Ungerer <[email protected]>
The action to potentially switch sp register is not occurring at the correct point in the interrupt entry or exception exit sequences.
For the interrupt entry case the sp on entry is used to create the stack exception frame - but this may well be the user stack pointer, since we haven't done the switch yet. Re-order the flow to switch the sp regs then use the current sp to create the exception frame.
For the return from exception case the code is unwinding the sp after switching sp registers. But it should always unwind the supervisor sp first, then carry out any required sp switch.
Note that these problems don't effect operation unless the user sp bit is set in the CACR register. Only a single sp is used in the default power up state. Previously Linux only used this single sp mode. But modern versions of Linux use the user sp mode now, so we need correct behavior for Linux to work.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Greg Ungerer <[email protected]>Reviewed-by Peter Crosthwaite <[email protected]>--- target-m68k/op_helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)Reviewed-by Laurent Vivier <[email protected]>
Thanks for the reviews.
Regards
Greg
Quoted 5 lines · Le 19/06/2015 15:43, [email protected] a écrit :
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Do you have disk image allowing to test Coldfire platform emulation ?
Laurent
Hi Laurent,
Quoted 8 lines · Laurent Vivier
Quoted 5 lines · Le 19/06/2015 15:43, [email protected] a écrit :
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Do you have disk image allowing to test Coldfire platform emulation ?
Not a disk image, but a small kernel with builtin root filesystem. This points at one I am running at the moment.
http://www.uclinux.org/ports/coldfire/vmlinux.m5208evb-20150620
It is a linux-4.1.0-rc8 kernel.
I have one more fix still to come for the qemu mcf_fec.c net driver. It currently doesn't support the mdio actions or any attached phy and this will cause the linux fec driver to fail probing.
Regards
Greg
Quoted 1 line · Greg Ungerer
Hi Laurent,
Hi Greg,
Quoted 9 lines · Laurent Vivier
Quoted 8 lines · Le 19/06/2015 15:43, [email protected] a écrit :
Quoted 6 lines
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Quoted 8 lines
Quoted 1 line
Do you have disk image allowing to test Coldfire platform emulation ?
Not a disk image, but a small kernel with builtin root filesystem. This points at one I am running at the moment.
http://www.uclinux.org/ports/coldfire/vmlinux.m5208evb-20150620
It is a linux-4.1.0-rc8 kernel.
Thank you.
Quoted 4 lines
I have one more fix still to come for the qemu
mcf_fec.cnet driver. It currently doesn't support the mdio actions or any attached phy and this will cause the linux fec driver to fail probing.
I'd like to merge my qemu-m68k tree, at least the non privileged instructions (https://github.com/vivier/qemu-m68k/tree/680x0-v2.3.0) but I'm afraid it breaks coldfire support. So I need to test before.
Laurent
Hi Greg,
Am 20.06.2015 um 06:55 schrieb Greg Ungerer:
Quoted 3 lines
I have one more fix still to come for the qemu
mcf_fec.cnet driver. It currently doesn't support the mdio actions or any attached phy and this will cause the linux fec driver to fail probing.
I still have some mcf_* device conversions back from KVM Forum 2012 lying around somewhere, waiting for further cleanups for submission...
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Hi Andreas,
Quoted 7 lines · Andreas Färber
Am 20.06.2015 um 06:55 schrieb Greg Ungerer:
Quoted 3 lines
I have one more fix still to come for the qemu
mcf_fec.cnet driver. It currently doesn't support the mdio actions or any attached phy and this will cause the linux fec driver to fail probing.I still have some mcf_* device conversions back from KVM Forum 2012 lying around somewhere, waiting for further cleanups for submission...
Please dust of and send if you have the time. Would be great to have more.
Regards
Greg
Quoted 10 lines · Le 19/06/2015 15:43, [email protected] a écrit :
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Regards
Greg
Quoted 9 lines
v2:
* rebased to current master head
* constant change from Peter Crosthwaitehw/m68k/mcf_intc.c | 14 ++++++++++++++ target-m68k/op_helper.c | 7 +++---- target-m68k/translate.c | 8 ++++---- 3 files changed, 21 insertions(+), 8 deletions(-)
Peter Maydell
AppliedQuoted 6 lines · On 19 June 2015 at 14:43, <[email protected]> wrote:
Some small issues are causing problems with running modern versions of Linux on the m68k/ColdFire 5208 target. These 3 patches fix those problems.
They are all due to use of more advanced architecture features not used in older Linux kernels.
Applied to master, thanks (and thanks to all for review).
-- PMM