hw/mips: add Octeon III EBB7304 support
cover hw/mips: add Octeon III EBB7304 support
This series adds enough Cavium Octeon III CN73xx and EBB7304 board support to boot a modern U-Boot EBB7304 image and OpenBSD/octeon; the same machine also boots the U-Boot image from the Ubiquiti EdgeRouter Infinity ER-8-XG recovery set. The model intentionally covers the hardware exercised by these firmware and operating system paths.
The vendor recovery image reaches:
Octeon ubnt_e1000(Failsafe)#
This is the expected command prompt of the recovery U-Boot environment; "Failsafe" describes the recovery image and does not indicate an emulation or boot failure.
The board model is based on Amir Mehmood's original Octeon host.patch; the basic machine approach and several peripheral modelling ideas come from that work. The implementation targets CN73xx hardware and the boot paths above.
The prerequisite patches correct xHCI interrupt reassertion, use atomic access for MIPS CP0 interrupt and timer state under MTTCG, fix MIPS64 segment access checks and tlbwr replacement semantics, then add Octeon CP0 state, the CN73xx CPU model, PageMask handling, and unaligned accesses. The final patch adds the EBB7304 board and its functional test.
The machine currently models:
* the EBB7304 RAM layout, boot flash aliases, and boot-local RAM;
* CN73xx CPUs, Octeon CP0 state, CVMSEG, and configurable clocks;
* legacy CIU and CIU3 interrupt routing, mailboxes, and secondary CPU release;
* UART, TWSI and SPD, LMC state, fuses, RNG, POW, and the firmware probes required during initialization;
* two DWC3 controllers and a minimal PCIe host suitable for PCI e1000 and USB storage.
With system U-Boot, the functional test enumerates PCI, obtains a DHCP lease, downloads bsd.rd through user mode TFTP, and boots the OpenBSD/octeon 7.9 installer with four CPUs.
The series was tested with:
ninja -C build qemu-system-mips64
gmake -C build check-qtest-mips64
gmake -C build check-functional-mips64
The qtest suite reported 14 passes, 2 empty suite skips, and no failures. The functional suite reported 7 passes, 2 expected skips, and no failures; its Octeon case reached the OpenBSD installer prompt.
Before the final rebase, the machine also completed a GCC build inside OpenBSD/octeon using:
-m 16G -smp 4 -accel tcg,thread=multi
That workload ran for several days to build gcc-16.1.0 inside.
Known limitations are:
* native Octeon Ethernet and the complete MMC path are not modelled; the OpenBSD test uses PCI e1000;
* direct kernel boot through -kernel is not implemented;
* board CSR and interrupt state has no VMState description, therefore migration and savevm correctness is not established.
The first patch is a generic xHCI fix required for reliable USB interrupt delivery on this machine. Patches 2 through 4 contain generic MIPS fixes; patches 5 through 8 add Octeon target support; patch 9 adds the EBB7304 machine and functional test.
The series is based ona759542a2c62f0fd3b65f5a66ad9868201014669.
Patch layout:
1. hw/usb/xhci: reassert pending busy interrupts
2. target/mips: make CP0 interrupt state atomic
3. target/mips: fix MIPS64 segment access checks
4. target/mips: drop hidden TLB shadowing for tlbwr
5. target/mips: add Octeon CP0 register state
6. target/mips: add Octeon CN73xx CPU model
7. target/mips: accept Octeon PageMask encodings
8. target/mips: allow Octeon unaligned accesses
9. hw/mips: add Octeon III EBB7304 machine
PATCH 1/9 hw/usb/xhci: reassert pending busy interrupts
xhci_intr_raise() returned early whenever ERDP.EHB was set; that also skipped IRQ assertion after the guest cleared IMAN.IP while leaving the event handler busy bit asserted.
Track the previous IMAN.IP state and suppress only duplicate raises; when ERDP.EHB remains set after IMAN.IP is cleared, assert the IRQ again so the guest can observe the pending event.
--- hw/usb/hcd-xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/usb/hcd-xhci.c +2 -1
@@ -577,12 +577,13 @@ static void xhci_intr_update(XHCIState *xhci, int v)static void xhci_intr_raise (XHCIState *xhci,int v) {bool pending = (xhci->intr[v].erdp_low &ERDP_EHB ); +bool was_raised = (xhci->intr[v].iman &IMAN_IP ); xhci->intr[v].erdp_low |=ERDP_EHB ; xhci->intr[v].iman |=IMAN_IP ; xhci->usbsts |=USBSTS_EINT ; -if (pending) { +if (pending && was_raised) {return ; }if (!(xhci->intr[v].iman &IMAN_IE )) {
Signature · 1 line
2.54.0
Re: [PATCH 1/9] hw/usb/xhci: reassert pending busy interrupts
Hi Kirill,
Quoted 18 lines · Kirill A. Korinsky
xhci_intr_raise()returned early whenever ERDP.EHB was set; that also skipped IRQ assertion after the guest cleared IMAN.IP while leaving the event handler busy bit asserted.Track the previous IMAN.IP state and suppress only duplicate raises; when ERDP.EHB remains set after IMAN.IP is cleared, assert the IRQ again so the guest can observe the pending event.
Signed-off-by Kirill A. Korinsky <[email protected]>--- hw/usb/hcd-xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/usb/hcd-xhci.c +0
-0
hw/usb/hcd-xhci.c static void xhci_intr_update(XHCIState *xhci, int v) · line 580
Quoted 4 lines
hw/usb/hcd-xhci.c +1
-0@@ -577,12 +577,13 @@ static void xhci_intr_update(XHCIState *xhci, int v)static void xhci_intr_raise (XHCIState *xhci,int v) {bool pending = (xhci->intr[v].erdp_low &ERDP_EHB ); +bool was_raised = (xhci->intr[v].iman &IMAN_IP );
Per your description we are missing to clear ERDP_EHB?
@@ -592,6 +592,7 @@ static void xhci_intr_raise(XHCIState *xhci, int v)
}
if (xhci->intr_raise) {
if (xhci->intr_raise(xhci, v, true)) {
+ xhci->intr[v].erdp_low &= ~ERDP_EHB;
xhci->intr[v].iman &= ~IMAN_IP;
}
}Quoted 10 lines
hw/usb/hcd-xhci.c +1
-1xhci->intr[v].erdp_low |=ERDP_EHB ; xhci->intr[v].iman |=IMAN_IP ; xhci->usbsts |=USBSTS_EINT ; -if (pending) { +if (pending && was_raised) {return ; }if (!(xhci->intr[v].iman &IMAN_IE )) {
Re: [PATCH 1/9] hw/usb/xhci: reassert pending busy interrupts
Quoted 31 lines · Philippe Mathieu-Daudé
Hi Kirill,
Quoted 18 lines · Kirill A. Korinsky
xhci_intr_raise()returned early whenever ERDP.EHB was set; that also skipped IRQ assertion after the guest cleared IMAN.IP while leaving the event handler busy bit asserted.Track the previous IMAN.IP state and suppress only duplicate raises; when ERDP.EHB remains set after IMAN.IP is cleared, assert the IRQ again so the guest can observe the pending event.
Signed-off-by Kirill A. Korinsky <[email protected]>--- hw/usb/hcd-xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/usb/hcd-xhci.c +0
-0hw/usb/hcd-xhci.c static void xhci_intr_update(XHCIState *xhci, int v) · line 580
Quoted 4 lines
hw/usb/hcd-xhci.c +1
-0@@ -577,12 +577,13 @@ static void xhci_intr_update(XHCIState *xhci, int v)static void xhci_intr_raise (XHCIState *xhci,int v) {bool pending = (xhci->intr[v].erdp_low &ERDP_EHB ); +bool was_raised = (xhci->intr[v].iman &IMAN_IP );Per your description we are missing to clear
ERDP_EHB?
Review static void xhci_intr_raise(XHCIState *xhci, int v) · line 598
Quoted 7 lines
(quoted diff) +1
-0@@ -592,6 +592,7 @@ static void xhci_intr_raise(XHCIState *xhci, int v) } if (xhci->intr_raise) { if (xhci->intr_raise(xhci, v, true)) { + xhci->intr[v].erdp_low &= ~ERDP_EHB; xhci->intr[v].iman &= ~IMAN_IP; } }
What seems a real fix for that may be a real root cause.
My test is simple: I boot OpenBSD/octeon in my machine with USB disk, and inside machine, via SSH, run cvs checkout of ports with -Q option (no output). It produces ~200k files and works for about 30 minutes.
Without my or your diff the cvs process stuck in biowait, I can use any IO at all, ls is blocked.
But network and things like ps works well.
And enough input from serial console usually wake up machines.
So far I had reverted my hack and replaced by yours fix, and it survives two checkout without an issues.
I'll drop that patch from my series.
Signature · 1 line
wbr, Kirill
Re: [PATCH 1/9] hw/usb/xhci: reassert pending busy interrupts
Quoted 51 lines · Kirill A. Korinsky
Quoted 31 lines · Philippe Mathieu-Daudé
Hi Kirill,
Quoted 18 lines · Kirill A. Korinsky
xhci_intr_raise()returned early whenever ERDP.EHB was set; that also skipped IRQ assertion after the guest cleared IMAN.IP while leaving the event handler busy bit asserted.Track the previous IMAN.IP state and suppress only duplicate raises; when ERDP.EHB remains set after IMAN.IP is cleared, assert the IRQ again so the guest can observe the pending event.
Signed-off-by Kirill A. Korinsky <[email protected]>--- hw/usb/hcd-xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/usb/hcd-xhci.c +0
-0hw/usb/hcd-xhci.c static void xhci_intr_update(XHCIState *xhci, int v) · line 580
Quoted 4 lines
hw/usb/hcd-xhci.c +1
-0@@ -577,12 +577,13 @@ static void xhci_intr_update(XHCIState *xhci, int v)static void xhci_intr_raise (XHCIState *xhci,int v) {bool pending = (xhci->intr[v].erdp_low &ERDP_EHB ); +bool was_raised = (xhci->intr[v].iman &IMAN_IP );Per your description we are missing to clear
ERDP_EHB?Review static void xhci_intr_raise(XHCIState *xhci, int v) · line 598
Quoted 7 lines
(quoted diff) +1
-0@@ -592,6 +592,7 @@ static void xhci_intr_raise(XHCIState *xhci, int v) } if (xhci->intr_raise) { if (xhci->intr_raise(xhci, v, true)) { + xhci->intr[v].erdp_low &= ~ERDP_EHB; xhci->intr[v].iman &= ~IMAN_IP; } }What seems a real fix for that may be a real root cause.
My test is simple: I boot OpenBSD/octeon in my machine with USB disk, and inside machine, via SSH, run cvs checkout of ports with -Q option (no output). It produces ~200k files and works for about 30 minutes.
Without my or your diff the cvs process stuck in biowait, I can use any IO at all, ls is blocked.
Quoted 9 lines
But network and things like ps works well.
And enough input from serial console usually wake up machines.
So far I had reverted my hack and replaced by yours fix, and it survives two checkout without an issues.
I'll drop that patch from my series.
I'd like to whitdraw my claim.
I can't reproduce issue on amd64 and riscv64, and I can reproduce issue with ~ERDP_EHB.
So, it indicates that issue is my octeon machine (quite likley) or something is missed in mips implementation.
Signature · 1 line
wbr, Kirill
PATCH 2/9 target/mips: make CP0 interrupt state atomic
In reply to Kirill A. KorinskyMTTCG lets interrupt inputs and timer callbacks update CP0_Cause, CP0_Status, and CP0_Count while a vCPU checks interrupt state.
Use qatomic accessors for CP0 fields that participate in interrupt and timer decisions, and kick remote CPUs explicitly after raising a hard interrupt; MIPS interrupt line updates no longer depend on taking the BQL.
--- hw/mips/mips_int.c | 17 +++++++------ target/mips/internal.h | 13 ++++++---- target/mips/system/cp0.c | 27 +++++++++++++-------- target/mips/system/cp0_timer.c | 32 ++++++++++++++----------- target/mips/tcg/system/special_helper.c | 17 +++++++------ target/mips/tcg/system/tlb_helper.c | 21 +++++++++------- 6 files changed, 75 insertions(+), 52 deletions(-)
hw/mips/mips_int.c +10 -7
@@ -21,30 +21,33 @@*/ #include "qemu/osdep.h" -#include "qemu/main-loop.h" #include "hw/core/irq.h" #include "target/mips/cpu.h" +#include "target/mips/internal.h" static void cpu_mips_irq_request (void *opaque,int irq,int level) {MIPSCPU *cpu = opaque;CPUMIPSState *env = &cpu->env;CPUState *cs =CPU (cpu); +int32_t irq_bit;if (irq <0 || irq >7 ) {return ; } -BQL_LOCK_GUARD (); - + irq_bit =1 << (irq + CP0Ca_IP);if (level) { - env->CP0_Cause |=1 << (irq + CP0Ca_IP); +qatomic_or (&env->CP0_Cause, irq_bit); }else { - env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP)); +qatomic_and (&env->CP0_Cause, ~irq_bit); } -if (env->CP0_Cause & CP0Ca_IP_mask) { -cpu_interrupt (cs,CPU_INTERRUPT_HARD ); +if (qatomic_read (&env->CP0_Cause) & CP0Ca_IP_mask) { +cpu_set_interrupt (cs,CPU_INTERRUPT_HARD ); +if (!qemu_cpu_is_self (cs)) { +qemu_cpu_kick (cs); + } }else {cpu_reset_interrupt (cs,CPU_INTERRUPT_HARD ); }
target/mips/internal.h +8 -5
@@ -8,6 +8,7 @@#ifndef MIPS_INTERNAL_H #define MIPS_INTERNAL_H +#include "qemu/atomic.h" #include "exec/memattrs.h" #ifdef CONFIG_TCG #include "tcg/tcg-internal.h"
@@ -167,9 +168,11 @@ extern const VMStateDescription vmstate_mips_cpu;static inline bool cpu_mips_hw_interrupts_enabled (CPUMIPSState *env) { -return (env->CP0_Status & (1 << CP0St_IE)) && - !(env->CP0_Status & (1 << CP0St_EXL)) && - !(env->CP0_Status & (1 << CP0St_ERL)) && +int32_t status =qatomic_read (&env->CP0_Status); + +return (status & (1 << CP0St_IE)) && + !(status & (1 << CP0St_EXL)) && + !(status & (1 << CP0St_ERL)) && !(env->hflags &MIPS_HFLAG_DM ) &&/* * Note that the TCStatus IXMT field is initialized to zero,
@@ -186,8 +189,8 @@ static inline bool cpu_mips_hw_interrupts_pending(CPUMIPSState *env)int32_t status;bool r; - pending = env->CP0_Cause & CP0Ca_IP_mask; - status = env->CP0_Status & CP0Ca_IP_mask; + pending =qatomic_read (&env->CP0_Cause) & CP0Ca_IP_mask; + status =qatomic_read (&env->CP0_Status) & CP0Ca_IP_mask;if (env->CP0_Config3 & (1 <<CP0C3_VEIC )) {/*
target/mips/system/cp0.c +17 -10
@@ -22,6 +22,7 @@#include "cpu.h" #include "internal.h" #include "exec/cputlb.h" +#include "qemu/atomic.h" /* Called for updates to CP0_Status. */ void sync_c0_status (CPUMIPSState *env,CPUMIPSState *cpu,int tc)
@@ -61,7 +62,8 @@ void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc)void cpu_mips_store_status (CPUMIPSState *env,target_ulong val) {uint32_t mask = env->CP0_Status_rw_bitmask; -target_ulong old = env->CP0_Status; +target_ulong old; +target_ulong status;if (env->insn_flags &ISA_MIPS_R6 ) {bool has_supervisor =extract32 (mask, CP0St_KSU,2 ) ==0x3 ;
@@ -77,9 +79,11 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val) mask &= ~(((1 << CP0St_SR) | (1 << CP0St_NMI)) & val); } - env->CP0_Status = (old & ~mask) | (val & mask); + old =qatomic_read (&env->CP0_Status); + status = (old & ~mask) | (val & mask); +qatomic_set (&env->CP0_Status, status);#if defined(TARGET_MIPS64 ) -if ((env->CP0_Status ^ old) & (old & (7 << CP0St_UX))) { +if ((status ^ old) & (old & (7 << CP0St_UX))) {/* Access to at least one of the 64-bit segments has been disabled */ tlb_flush (env_cpu (env)); }
@@ -93,8 +97,9 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val)void cpu_mips_store_cause (CPUMIPSState *env,target_ulong val) { -uint32_t mask =0x00C00300 ; -uint32_t old = env->CP0_Cause; +int32_t mask =0x00C00300 ; +int32_t old; +int32_t cause;int i;if (env->insn_flags &ISA_MIPS_R2 ) {
@@ -104,10 +109,12 @@ void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val) mask &= ~((1 << CP0Ca_WP) & val); } - env->CP0_Cause = (env->CP0_Cause & ~mask) | (val & mask); + old =qatomic_fetch_and (&env->CP0_Cause, ~mask); +qatomic_or (&env->CP0_Cause, (int32_t )(val & mask)); + cause =qatomic_read (&env->CP0_Cause); -if ((old ^ env->CP0_Cause) & (1 << CP0Ca_DC)) { -if (env->CP0_Cause & (1 << CP0Ca_DC)) { +if ((old ^ cause) & (1 << CP0Ca_DC)) { +if (cause & (1 << CP0Ca_DC)) {cpu_mips_stop_count (env); }else {cpu_mips_start_count (env);
@@ -116,8 +123,8 @@ void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val)/* Set/reset software interrupts */ for (i =0 ; i <2 ; i++) { -if ((old ^ env->CP0_Cause) & (1 << (CP0Ca_IP + i))) { -cpu_mips_soft_irq (env, i, env->CP0_Cause & (1 << (CP0Ca_IP + i))); +if ((old ^ cause) & (1 << (CP0Ca_IP + i))) { +cpu_mips_soft_irq (env, i, cause & (1 << (CP0Ca_IP + i))); } } }
target/mips/system/cp0_timer.c +18 -14
@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "hw/core/irq.h" #include "qemu/timer.h" +#include "qemu/atomic.h" #include "internal.h" /* MIPS R4K timer */
@@ -31,7 +32,7 @@ static uint32_t cpu_mips_get_count_val(CPUMIPSState *env)MIPSCPU *cpu =env_archcpu (env);int64_t now_ns; now_ns =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); -return env->CP0_Count + +return qatomic_read (&env->CP0_Count) + (uint32_t )clock_ns_to_ticks (cpu->count_clock, now_ns); }
@@ -56,15 +57,15 @@ static void cpu_mips_timer_expire(CPUMIPSState *env) {cpu_mips_timer_update (env);if (env->insn_flags &ISA_MIPS_R2 ) { - env->CP0_Cause |=1 << CP0Ca_TI; +qatomic_or (&env->CP0_Cause,1 << CP0Ca_TI); }qemu_irq_raise (env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) &0x7 ]); }uint32_t cpu_mips_get_count (CPUMIPSState *env) { -if (env->CP0_Cause & (1 << CP0Ca_DC)) { -return env->CP0_Count; +if (qatomic_read (&env->CP0_Cause) & (1 << CP0Ca_DC)) { +return qatomic_read (&env->CP0_Count); }else {uint64_t now_ns;
@@ -86,12 +87,13 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t count)* So env->timer may be NULL, so treat timer as disabled in that case. */ MIPSCPU *cpu =env_archcpu (env); -if (env->CP0_Cause & (1 << CP0Ca_DC) || !env->timer) { - env->CP0_Count = count; +if ((qatomic_read (&env->CP0_Cause) & (1 << CP0Ca_DC)) || !env->timer) { +qatomic_set (&env->CP0_Count, count); }else {/* Store new count register */ - env->CP0_Count = count - (uint32_t )clock_ns_to_ticks (cpu->count_clock, -qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL )); +qatomic_set (&env->CP0_Count, + count - (uint32_t )clock_ns_to_ticks (cpu->count_clock, +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL )));/* Update timer timer */ cpu_mips_timer_update (env); }
@@ -100,26 +102,28 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t count)void cpu_mips_store_compare (CPUMIPSState *env,uint32_t value) { env->CP0_Compare = value; -if (!(env->CP0_Cause & (1 << CP0Ca_DC))) { +if (!(qatomic_read (&env->CP0_Cause) & (1 << CP0Ca_DC))) {cpu_mips_timer_update (env); }if (env->insn_flags &ISA_MIPS_R2 ) { - env->CP0_Cause &= ~(1 << CP0Ca_TI); +qatomic_and (&env->CP0_Cause, ~(1 << CP0Ca_TI)); }qemu_irq_lower (env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) &0x7 ]); }void cpu_mips_start_count (CPUMIPSState *env) { -cpu_mips_store_count (env, env->CP0_Count); +cpu_mips_store_count (env,qatomic_read (&env->CP0_Count)); }void cpu_mips_stop_count (CPUMIPSState *env) {/* Store the current value */ MIPSCPU *cpu =env_archcpu (env); - env->CP0_Count += (uint32_t )clock_ns_to_ticks (cpu->count_clock, -qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL )); + +qatomic_add (&env->CP0_Count, + (uint32_t )clock_ns_to_ticks (cpu->count_clock, +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ))); }static void mips_timer_cb (void *opaque)
@@ -128,7 +132,7 @@ static void mips_timer_cb(void *opaque) env = opaque; -if (env->CP0_Cause & (1 << CP0Ca_DC)) { +if (qatomic_read (&env->CP0_Cause) & (1 << CP0Ca_DC)) {return ; }
target/mips/tcg/system/special_helper.c +10 -7
@@ -24,21 +24,22 @@#include "exec/helper-proto.h" #include "exec/translation-block.h" #include "internal.h" +#include "qemu/atomic.h" /* Specials */ target_ulong helper_di (CPUMIPSState *env) { -target_ulong t0 = env->CP0_Status; +target_ulong t0 =qatomic_read (&env->CP0_Status); - env->CP0_Status = t0 & ~(1 << CP0St_IE); +qatomic_set (&env->CP0_Status, t0 & ~(1 << CP0St_IE));return t0; }target_ulong helper_ei (CPUMIPSState *env) { -target_ulong t0 = env->CP0_Status; +target_ulong t0 =qatomic_read (&env->CP0_Status); - env->CP0_Status = t0 | (1 << CP0St_IE); +qatomic_set (&env->CP0_Status, t0 | (1 << CP0St_IE));return t0; }
@@ -103,13 +104,15 @@ bool mips_io_recompile_replay_branch(CPUState *cs, const TranslationBlock *tb)static inline void exception_return (CPUMIPSState *env) { +target_ulong status =qatomic_read (&env->CP0_Status); +debug_pre_eret (env); -if (env->CP0_Status & (1 << CP0St_ERL)) { +if (status & (1 << CP0St_ERL)) {mips_env_set_pc (env, env->CP0_ErrorEPC); - env->CP0_Status &= ~(1 << CP0St_ERL); +qatomic_set (&env->CP0_Status, status & ~(1 << CP0St_ERL)); }else {mips_env_set_pc (env, env->CP0_EPC); - env->CP0_Status &= ~(1 << CP0St_EXL); +qatomic_set (&env->CP0_Status, status & ~(1 << CP0St_EXL)); }compute_hflags (env);debug_post_eret (env);
target/mips/tcg/system/tlb_helper.c +12 -9
@@ -1106,7 +1106,7 @@ void mips_cpu_do_interrupt(CPUState *cs) env->hflags &= ~(MIPS_HFLAG_KSU );/* EJTAG probe trap enable is not implemented... */ if (!(env->CP0_Status & (1 << CP0St_EXL))) { - env->CP0_Cause &= ~(1U << CP0Ca_BD); +qatomic_and (&env->CP0_Cause, (int32_t )~(1U << CP0Ca_BD)); } env->active_tc.PC = env->exception_base +0x480 ;set_hflags_for_handler (env);
@@ -1134,7 +1134,7 @@ void mips_cpu_do_interrupt(CPUState *cs) env->hflags |=MIPS_HFLAG_CP0 ; env->hflags &= ~(MIPS_HFLAG_KSU );if (!(env->CP0_Status & (1 << CP0St_EXL))) { - env->CP0_Cause &= ~(1U << CP0Ca_BD); +qatomic_and (&env->CP0_Cause, (int32_t )~(1U << CP0Ca_BD)); } env->active_tc.PC = env->exception_base;set_hflags_for_handler (env);
@@ -1148,7 +1148,9 @@ void mips_cpu_do_interrupt(CPUState *cs) offset =0x200 ; }else {uint32_t vector =0 ; -uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP; +uint32_t pending = + (qatomic_read (&env->CP0_Cause) & CP0Ca_IP_mask) >> + CP0Ca_IP;if (env->CP0_Config3 & (1 <<CP0C3_VEIC )) {/*
@@ -1246,8 +1248,9 @@ void mips_cpu_do_interrupt(CPUState *cs)case EXCP_CpU: cause =11 ; update_badinstr =1 ; - env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) | - (env->error_code << CP0Ca_CE); +qatomic_and (&env->CP0_Cause, (int32_t )~(0x3U << CP0Ca_CE)); +qatomic_or (&env->CP0_Cause, + (int32_t )(env->error_code << CP0Ca_CE)); goto set_EPC;case EXCP_OVERFLOW : cause =12 ;
@@ -1305,9 +1308,9 @@ void mips_cpu_do_interrupt(CPUState *cs)set_badinstr_registers (env); }if (env->hflags &MIPS_HFLAG_BMASK ) { - env->CP0_Cause |= (1U << CP0Ca_BD); +qatomic_or (&env->CP0_Cause, (int32_t )(1U << CP0Ca_BD)); }else { - env->CP0_Cause &= ~(1U << CP0Ca_BD); +qatomic_and (&env->CP0_Cause, (int32_t )~(1U << CP0Ca_BD)); } env->CP0_Status |= (1 << CP0St_EXL);if (env->insn_flags &ISA_MIPS3 ) {
@@ -1333,8 +1336,8 @@ void mips_cpu_do_interrupt(CPUState *cs) env->active_tc.PC += offset;set_hflags_for_handler (env); - env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | - (cause << CP0Ca_EC); +qatomic_and (&env->CP0_Cause, (int32_t )~(0x1f << CP0Ca_EC)); +qatomic_or (&env->CP0_Cause, cause << CP0Ca_EC);break ;default :abort ();
Signature · 1 line
2.54.0
PATCH 3/9 target/mips: fix MIPS64 segment access checks
In reply to Kirill A. KorinskyThe xuseg and xsseg checks only tested UX and SX respectively; kernel and supervisor accesses must instead use the mode bit that applies to the current execution mode.
Allow supervisor and kernel mode to use xuseg when SX or KX is set, and allow kernel mode to use xsseg when KX is set.
--- target/mips/system/physaddr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
target/mips/system/physaddr.c +5 -3
@@ -143,7 +143,9 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical,#if defined(TARGET_MIPS64 ) } else if (address < 0x4000000000000000ULL) {/* xuseg */ -if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { +if (((user_mode &&UX ) || (supervisor_mode &&SX ) || + (kernel_mode &&KX )) && + address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address (env, physical, prot, real_address, access_type); }else {
@@ -151,8 +153,8 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical, } }else if (address <0x8000000000000000ULL ) {/* xsseg */ -if ((supervisor_mode || kernel_mode) && -SX && address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { +if (((supervisor_mode &&SX ) || (kernel_mode &&KX )) && + address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address (env, physical, prot, real_address, access_type); }else {
Signature · 1 line
2.54.0
PATCH 4/9 target/mips: drop hidden TLB shadowing for tlbwr
In reply to Kirill A. Korinskytlbwr replaces a random architectural TLB entry. Once that happens, the evicted entry must stop translating guest virtual addresses.
The current helper keeps the evicted entry in QEMU-only extra TLB state. That makes the old mapping survive until some later operation discards the extra entries. A guest can observe this directly by writing through a TLB mapping, replacing that entry with tlbwr, and writing through the old virtual address again.
Invalidate the replaced entry instead of shadowing it. This keeps the translated TLB state aligned with the architectural TLB contents.
--- target/mips/tcg/system/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/system/tlb_helper.c +1 -1
@@ -165,7 +165,7 @@ static void r4k_helper_tlbwr(CPUMIPSState *env) {int r =cpu_mips_get_random (env); -r4k_invalidate_tlb (env, r,1 ); +r4k_invalidate_tlb (env, r,0 );r4k_fill_tlb (env, r); }
Signature · 1 line
2.54.0
Re: [PATCH 4/9] target/mips: drop hidden TLB shadowing for tlbwr
Hi Kirill,
Quoted 22 lines · Kirill A. Korinsky
tlbwr replaces a random architectural TLB entry. Once that happens, the evicted entry must stop translating guest virtual addresses.
The current helper keeps the evicted entry in QEMU-only extra TLB state. That makes the old mapping survive until some later operation discards the extra entries. A guest can observe this directly by writing through a TLB mapping, replacing that entry with tlbwr, and writing through the old virtual address again.
Invalidate the replaced entry instead of shadowing it. This keeps the translated TLB state aligned with the architectural TLB contents.
Signed-off-by Kirill A. Korinsky <[email protected]>--- target/mips/tcg/system/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/mips/tcg/system/tlb_helper.c +0
-0
target/mips/tcg/system/tlb_helper.c static void r4k_helper_tlbwr(CPUMIPSState *env) · line 170
Quoted 7 lines
target/mips/tcg/system/tlb_helper.c +1
-1@@ -165,7 +165,7 @@ static void r4k_helper_tlbwr(CPUMIPSState *env) {int r =cpu_mips_get_random (env); -r4k_invalidate_tlb (env, r,1 ); +r4k_invalidate_tlb (env, r,0 );r4k_fill_tlb (env, r); }
This comes from commit 814b9a47490 ("MIPS TLB performance improvements, by Daniel Jacobowitz."), 20 years ago and is the single use of @use_extra. Should we remove it altogether, along with the @tlb_in_use index and r4k_mips_tlb_flush_extra, indeed reverting that commit?
Re: [PATCH 4/9] target/mips: drop hidden TLB shadowing for tlbwr
Hi Philippe,
Sorry for the very long reply.
I had some time to actually test it under stress to be sure.
Quoted 30 lines · Philippe Mathieu-Daudé
Hi Kirill,
Quoted 26 lines · Kirill A. Korinsky
tlbwr replaces a random architectural TLB entry. Once that happens, the evicted entry must stop translating guest virtual addresses.
The current helper keeps the evicted entry in QEMU-only extra TLB state. That makes the old mapping survive until some later operation discards the extra entries. A guest can observe this directly by writing through a TLB mapping, replacing that entry with tlbwr, and writing through the old virtual address again.
Invalidate the replaced entry instead of shadowing it. This keeps the translated TLB state aligned with the architectural TLB contents.
Signed-off-by Kirill A. Korinsky <[email protected]>--- target/mips/tcg/system/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/mips/tcg/system/tlb_helper.c +1
-0@@ -165,7 +165,7 @@ static void r4k_helper_tlbwr(CPUMIPSState *env) {int r =cpu_mips_get_random (env); -r4k_invalidate_tlb (env, r,1 ); +r4k_invalidate_tlb (env, r,0 );
Quoted 8 lines
target/mips/tcg/system/tlb_helper.c static void r4k_helper_tlbwr(CPUMIPSState *env) · line 170
Quoted 2 lines
target/mips/tcg/system/tlb_helper.c +0
-0r4k_fill_tlb (env, r); }This comes from commit
814b9a47490("MIPS TLB performance improvements, by Daniel Jacobowitz."), 20 years ago and is the single use of @use_extra. Should we remove it altogether, along with the @tlb_in_use index andr4k_mips_tlb_flush_extra, indeed reverting that commit?
No, I don't think that this code shall be reverted.
After weeks of testing I very confident that the issue is missed event ring handling which I've posted here:
https://marc.info/?l=qemu-devel&m=178449808743198&w=2
With only this patch and octeon machine series, the VM survives different stress tests, which includes a few bulds of gcc with 16 CPU for weeks.
And USB was used as the only disk.
No deadlock or missed interrupts were observed so far.
Signature · 1 line
wbr, Kirill
PATCH 5/9 target/mips: add Octeon CP0 register state
In reply to Kirill A. KorinskyOcteon firmware and kernels use implementation specific CP0 registers for the cycle counter and local memory control.
Add CvmCount, CvmCtl, and CvmMemCtl accessors for Octeon CPUs; migrate the new CP0 state, and translate the enabled CVMSEG virtual window to per vCPU backing memory.
--- target/mips/cpu.h | 5 +++ target/mips/system/machine.c | 13 +++++++ target/mips/system/physaddr.c | 22 +++++++++++ target/mips/tcg/op_helper.c | 2 +- target/mips/tcg/system/cp0_helper.c | 10 +++++ target/mips/tcg/system_helper.h.inc | 1 + target/mips/tcg/translate.c | 60 +++++++++++++++++++++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-)
target/mips/cpu.h +5 -0
@@ -341,6 +341,8 @@ typedef struct mips_def_t mips_def_t;#define CP0_REG09__COUNT 0#define CP0_REG09__SAARI 6#define CP0_REG09__SAAR 7 +#define CP0_REG09__CVMCOUNT 6 +#define CP0_REG09__CVMCTL 7/* CP0 Register 10 */ #define CP0_REG10__ENTRYHI 0#define CP0_REG10__GUESTCTL1 4
@@ -349,6 +351,7 @@ typedef struct mips_def_t mips_def_t;/* CP0 Register 11 */ #define CP0_REG11__COMPARE 0#define CP0_REG11__GUESTCTL0EXT 4 +#define CP0_REG11__CVMMEMCTL 7/* CP0 Register 12 */ #define CP0_REG12__STATUS 0#define CP0_REG12__INTCTL 1
@@ -787,6 +790,7 @@ typedef struct CPUArchState {* CP0 Register 9 */ int32_t CP0_Count; +target_ulong CP0_CvmCtl;#define CP0SAARI_TARGET 0/* 5..0 */ #define CP0SAAR_BASE 12/* 43..12 */ #define CP0SAAR_SIZE 1/* 5..1 */
@@ -801,6 +805,7 @@ typedef struct CPUArchState {* CP0 Register 11 */ int32_t CP0_Compare; +target_ulong CP0_CvmMemCtl;/* * CP0 Register 12 */
target/mips/system/machine.c +13 -0
@@ -372,6 +372,18 @@ static const VMStateDescription mips_vmstate_octeon_crypto = { } }; +static const VMStateDescription mips_vmstate_octeon_cp0 = { + .name ="cpu/octeon_cp0" , + .version_id =1 , + .minimum_version_id =1 , + .needed = mips_octeon_needed, + .fields = (const VMStateField []) { +VMSTATE_UINTTL (env.CP0_CvmCtl,MIPSCPU ), +VMSTATE_UINTTL (env.CP0_CvmMemCtl,MIPSCPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_mips_cpu = { .name ="cpu" , .version_id =21 ,
@@ -490,6 +502,7 @@ const VMStateDescription vmstate_mips_cpu = { &mips_vmstate_timer, &mips_vmstate_octeon_multiplier, &mips_vmstate_octeon_crypto, + &mips_vmstate_octeon_cp0, NULL } };
target/mips/system/physaddr.c +22 -0
@@ -21,6 +21,14 @@#include "exec/page-protection.h" #include "../internal.h" +/* +* QEMU-only backing for per-core CVMSEG. Keep it outside guest DRAM; +* the guest sees the virtual CVMSEG window, not this physical address. +*/ +#define OCTEON_CVMSEG_BASE 0x10000000000ULL +#define OCTEON_CVMSEG_SIZE 0x4000ULL +#define OCTEON_CVMSEG_MASK 0x3fffULL +static int is_seg_am_mapped (unsigned int am,bool eu,int mmu_idx) {/*
@@ -128,6 +136,20 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical,int ret =TLBRET_MATCH ;target_ulong address = real_address; +#if defined(TARGET_MIPS64 ) +if ((env->insn_flags &INSN_OCTEON ) && (env->CP0_CvmMemCtl &0x100 ) && + address >=0xffffffffffff8000ULL && + address <=0xffffffffffffbfffULL ) { +MIPSCPU *cpu =env_archcpu (env); + + *physical =OCTEON_CVMSEG_BASE + +CPU (cpu)->cpu_index *OCTEON_CVMSEG_SIZE + + (address &OCTEON_CVMSEG_MASK ); + *prot =PAGE_READ |PAGE_WRITE ; +return TLBRET_MATCH ; + } +#endif +if (address <=USEG_LIMIT ) {/* useg */ uint16_t segctl;
target/mips/tcg/op_helper.c +1 -1
@@ -268,7 +268,7 @@ target_ulong helper_rdhwr_cvmcount(CPUMIPSState *env)#ifdef CONFIG_USER_ONLY return cpu_get_host_ticks ();#else -return (uint32_t )cpu_mips_get_count (env); +return helper_mfc0_cvmcount (env);#endif }
target/mips/tcg/system/cp0_helper.c +10 -0
@@ -23,6 +23,8 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/main-loop.h" +#include "qemu/timer.h" +#include "hw/core/clock.h" #include "cpu.h" #include "internal.h" #include "qemu/host-utils.h"
@@ -374,6 +376,14 @@ target_ulong helper_mfc0_count(CPUMIPSState *env)return (int32_t )cpu_mips_get_count (env); } +target_ulong helper_mfc0_cvmcount (CPUMIPSState *env) +{ +MIPSCPU *cpu =env_archcpu (env); + +return clock_ns_to_ticks (cpu->clock, +qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL )); +} +target_ulong helper_mftc0_entryhi (CPUMIPSState *env) {int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
target/mips/tcg/system_helper.h.inc +1 -0
@@ -31,6 +31,7 @@ DEF_HELPER_1(mftc0_tcschedule, tl, env) DEF_HELPER_1(mfc0_tcschefback, tl, env) DEF_HELPER_1(mftc0_tcschefback, tl, env) DEF_HELPER_1(mfc0_count, tl, env) +DEF_HELPER_1(mfc0_cvmcount, tl, env) DEF_HELPER_1(mftc0_entryhi, tl, env) DEF_HELPER_1(mftc0_status, tl, env) DEF_HELPER_1(mftc0_cause, tl, env)
target/mips/tcg/translate.c +60 -0
108 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH 6/9 target/mips: add Octeon CN73xx CPU model
In reply to Kirill A. KorinskyAdd a CN73xx CPU definition for the Octeon III machine. The PRId, FPU FIR, and L2 cache geometry come from EdgeRouter Infinity ER-8-XG data; the remaining CP0 fields come from a Juniper SRX300 CN70xx/CN71xx dump.
--- target/mips/cpu-defs.c.inc | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
target/mips/cpu-defs.c.inc +42 -0
@@ -1023,6 +1023,48 @@ const mips_def_t mips_defs[] = .insn_flags = CPU_MIPS64R2 | INSN_OCTEON, .mmu_type = MMU_TYPE_R4000, }, + { + /* + * Minimal Octeon CN73xx model for EBB7304 firmware. PRId, FPU FIR, + * and L2 cache geometry match a Ubiquiti EdgeRouter Infinity + * ER-8-XG; the remaining CP0 values are a placeholder Octeon III + * model derived from a Juniper SRX300 CN70xx/CN71xx dump. + */ + .name = "OcteonCN73XX", + .CP0_PRid = 0x000D9702, + .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | + (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI), + .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | + (0x3F << CP0C1_MMU) | + (0 << CP0C1_IS) | (6 << CP0C1_IL) | (7 << CP0C1_IA) | + (0 << CP0C1_DS) | (0 << CP0C1_DL) | (7 << CP0C1_DA) | + (1 << CP0C1_C2) | (1 << CP0C1_PC) | + (1 << CP0C1_WR) | (1 << CP0C1_EP), + .CP0_Config2 = MIPS_CONFIG2 | (5 << CP0C2_SS) | (6 << CP0C2_SL) | + (15 << CP0C2_SA), + .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | + (1 << CP0C3_BP) | (1 << CP0C3_BI) | + (1 << CP0C3_VZ) | (1 << CP0C3_ULRI) | + (1 << CP0C3_RXI) | (1 << CP0C3_LPA), + .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | + (0x3c << CP0C4_KScrExist), + .CP0_Config7 = 1 << CP0C7_WII, + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .CP0_PageGrain = (1 << CP0PG_ELPA), + .SYNCI_Step = 32, + .CCRes = 1, + .CP0_Status_rw_bitmask = 0x36F8FFFF, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | + (1 << FCR0_D) | (1 << FCR0_S) | + (0x97 << FCR0_PRID) | (0x0 << FCR0_REV), + .CP1_fcr31 = 0, + .CP1_fcr31_rw_bitmask = 0xFF83FFFF, + .SEGBITS = 42, + .PABITS = 49, + .insn_flags = CPU_MIPS64R2 | INSN_OCTEON, + .mmu_type = MMU_TYPE_R4000, + }, #endif };
Signature · 1 line
2.54.0
PATCH 7/9 target/mips: accept Octeon PageMask encodings
In reply to Kirill A. KorinskyOcteon firmware programs contiguous PageMask values that do not follow the generic R4K even maskbits rule.
Keep the generic validation rule for other MIPS CPUs, while allowing Octeon CPUs to use the contiguous masks accepted by hardware.
--- target/mips/tcg/system/cp0_helper.c | 15 ++++++++++----- target/mips/tcg/system/tlb_helper.c | 2 +- target/mips/tcg/tcg-internal.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-)
target/mips/tcg/system/cp0_helper.c +10 -5
@@ -882,14 +882,19 @@ void helper_mtc0_memorymapid(CPUMIPSState *env, target_ulong arg1) } } -uint32_t compute_pagemask (uint32_t val) +uint32_t compute_pagemask (CPUMIPSState *env,uint32_t val) {/* Don't care MASKX as we don't support 1KB page */ -uint32_t mask =extract32 (val,CP0PM_MASK ,16 ); +uint32_t mask = val >>CP0PM_MASK ;int maskbits =cto32 (mask); -/* Ensure no more set bit after first zero, and maskbits even. */ -if ((mask >> maskbits) ==0 && maskbits %2 ==0 ) { +/* +* Generic R4K PageMask values use two mask bits per size step. +* Octeon accepts contiguous byte masks such as 0x003fffff for +* two 2 MiB pages. +*/ +if ((mask & (mask +1 )) ==0 && + ((env->insn_flags &INSN_OCTEON ) || maskbits %2 ==0 )) {return mask <<CP0PM_MASK ; }else {/* When invalid, set to default target page size. */
@@ -899,7 +904,7 @@ uint32_t compute_pagemask(uint32_t val)void helper_mtc0_pagemask (CPUMIPSState *env,target_ulong arg1) { - env->CP0_PageMask =compute_pagemask (arg1); + env->CP0_PageMask =compute_pagemask (env, arg1); }void helper_mtc0_pagegrain (CPUMIPSState *env,target_ulong arg1)
target/mips/tcg/system/tlb_helper.c +1 -1
@@ -877,7 +877,7 @@ refill: } } pw_pagemask = m >>TARGET_PAGE_BITS ; - pw_pagemask =compute_pagemask (pw_pagemask <<CP0PM_MASK ); + pw_pagemask =compute_pagemask (env, pw_pagemask <<CP0PM_MASK ); pw_entryhi = (address & ~0x1fff ) | (env->CP0_EntryHi &0xFF ); {target_ulong tmp_entryhi = env->CP0_EntryHi;
target/mips/tcg/tcg-internal.h +1 -1
@@ -47,7 +47,7 @@ bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);void mmu_init (CPUMIPSState *env,const mips_def_t *def); -uint32_t compute_pagemask (uint32_t val); +uint32_t compute_pagemask (CPUMIPSState *env,uint32_t val);void r4k_invalidate_tlb (CPUMIPSState *env,int idx,int use_extra);uint32_t cpu_mips_get_random (CPUMIPSState *env);
Signature · 1 line
2.54.0
PATCH 8/9 target/mips: allow Octeon unaligned accesses
In reply to Kirill A. KorinskyOcteon firmware performs unaligned memory accesses during early DDR setup.
Use QEMU's unaligned memory operation mode for Octeon translations, matching the existing treatment for MIPS R6 and Loongson3A.
--- target/mips/tcg/translate.c | 1 + 1 file changed, 1 insertion(+)
target/mips/tcg/translate.c +1 -0
@@ -15193,6 +15193,7 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)#endif ctx->default_tcg_memop_mask = (!(ctx->insn_flags &ISA_NANOMIPS32 ) && (ctx->insn_flags & (ISA_MIPS_R6 | +INSN_OCTEON |INSN_LOONGSON3A ))) ?MO_UNALN :MO_ALIGN ;if (tb_flags &TB_FLAG_MIPS_FIXADE ) { ctx->default_tcg_memop_mask =MO_UNALN ;
Signature · 1 line
2.54.0
PATCH 9/9 hw/mips: add Octeon III EBB7304 machine
In reply to Kirill A. KorinskyAdd a minimal Cavium/Marvell Octeon III machine model for the EBB7304 evaluation board. This work is based on Amir Mehmood's original Octeon host.patch; the basic machine approach and several hardware model ideas come from that work.
The model targets modern U-Boot's EBB7304 firmware and OpenBSD/octeon. The same machine also boots the U-Boot image shipped in the ER-8-XG firmware upgrade package.
It provides the RAM layout, boot flash aliasing, CIU/CIU3 interrupt state, UART, TWSI/SPD, LMC state, RNG, POW, DWC3 USB, and minimal PCIe support needed to boot with USB storage and an attached PCI e1000.
Add a functional test that boots the OpenBSD/octeon ramdisk through U-Boot using QEMU's user mode TFTP server.
--- hw/mips/Kconfig | 10 + hw/mips/meson.build | 1 + hw/mips/octeon.c | 3829 +++++++++++++++++++++++ tests/functional/mips64/meson.build | 2 + tests/functional/mips64/test_octeon3.py | 54 + 5 files changed, 3896 insertions(+) create mode 100644 hw/mips/octeon.c create mode 100644 tests/functional/mips64/test_octeon3.py
hw/mips/Kconfig +10 -0
@@ -67,6 +67,16 @@ config LOONGSON3V select FW_CFG_MIPS select UNIMP +config MIPS_OCTEON + bool + default y + depends on MIPS64 && TARGET_BIG_ENDIAN + imply E1000_PCI + imply PCI_DEVICES + select PFLASH_CFI02 + select SERIAL_MM + select USB_DWC3 + config MIPS_CPS bool select MIPS_ITU if TCG
hw/mips/meson.build +1 -0
@@ -10,6 +10,7 @@ if 'CONFIG_TCG' in config_all_accel mips_ss.add(when: 'CONFIG_JAZZ', if_true: files('jazz.c')) mips_ss.add(when: 'CONFIG_FULOONG', if_true: files('fuloong2e.c')) mips_ss.add(when: 'CONFIG_MIPS_BOSTON', if_true: files('boston.c')) +mips_ss.add(when: 'CONFIG_MIPS_OCTEON', if_true: files('octeon.c')) endif hw_arch += {'mips': mips_ss}
hw/mips/octeon.c new file +3829 -0
2,977 lines not on this page · raw message
tests/functional/mips64/test_octeon3.py new file +54 -0
54 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.54.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH 9/9] hw/mips: add Octeon III EBB7304 machine
Hi Kirill,
Quoted 13 lines · Kirill A. Korinsky
Add a minimal Cavium/Marvell Octeon III machine model for the EBB7304 evaluation board. This work is based on Amir Mehmood's original Octeon host.patch; the basic machine approach and several hardware model ideas come from that work.
The model targets modern U-Boot's EBB7304 firmware and OpenBSD/octeon. The same machine also boots the U-Boot image shipped in the ER-8-XG firmware upgrade package.
It provides the RAM layout, boot flash aliasing, CIU/CIU3 interrupt state, UART, TWSI/SPD, LMC state, RNG, POW, DWC3 USB, and minimal PCIe support needed to boot with USB storage and an attached PCI e1000.
Quoted 8 lines
Add a functional test that boots the OpenBSD/octeon ramdisk through U-Boot using QEMU's user mode TFTP server.
Signed-off-by Kirill A. Korinsky <[email protected]>--- hw/mips/Kconfig | 10 + hw/mips/meson.build | 1 + hw/mips/octeon.c | 3829 +++++++++++++++++++++++
Thanks for this contribution! Unfortunately the patch is too big to be reviewable... Do you mind splitting it in distinct parts (add empty machine, then add pheripherals and wire them to the machine, then the test).
PCI host bridge, I2C and USB controllers deserve their own file in hw/pci-bridge/, hw/i2c/ and hw/usb/.
Do not use DEVICE_NATIVE_ENDIAN.
octeon_board_reset() seems to contain reset code from distinct peripherals. Each peripheral should have its own reset handler (please do not use the legacy reset API).
Thanks,
Phil.
Quoted 5 lines
tests/functional/mips64/meson.build | 2 + tests/functional/mips64/test_octeon3.py | 54 + 5 files changed, 3896 insertions(+)create mode 100644
hw/mips/octeon.c
create mode 100644tests/functional/mips64/test_octeon3.py