Hi Kirill,
On 13/11/26 22:45, Kirill A. Korinsky wrote:
Greetings,
This is rebased to 29760efaf96bbe5928f8111881eddbf5ac06439e
(v11.2.0-rc0) and addressed a few remarks from Philippe Mathieu-Daudé,
and additional fix of two typos.
Thanks, I was reviewing v7 last week and you respan faster than I
can process. So far my first comments were:
-- >8 --
diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h
index 5e4341003ae4..c86e0d6ecbea 100644
--- a/target/mips/tcg/tcg-internal.h
+++ b/target/mips/tcg/tcg-internal.h
@@ -47,3 +47,3 @@ void mmu_init(CPUMIPSState *env, const mips_def_t *def);
-uint32_t compute_pagemask(CPUMIPSState *env, uint32_t val);
+uint32_t compute_pagemask(const CPUMIPSState *env, uint32_t val);
diff --git a/target/mips/system/physaddr.c b/target/mips/system/physaddr.c
index e9e233d3b366..ecf9109a4576 100644
--- a/target/mips/system/physaddr.c
+++ b/target/mips/system/physaddr.c
@@ -144,3 +144,3 @@ int get_physical_address(const CPUMIPSState *env,
hwaddr *physical,
address <= 0xffffffffffffbfffULL) {
- MIPSCPU *cpu = env_archcpu(env);
+ const MIPSCPU *cpu = env_archcpu(env);
---
And rdhwr_cvmcount() breaks all non-Octeon CPU models.
Please list the change between versions in your cover letter.
This series adds enough Cavium Octeon III CN73xx and EBB7304 board
support for upstream U-Boot 2026.04 to boot OpenBSD/octeon from USB
storage or through PCI e1000 and TFTP; the same machine also reaches
the prompt of the vendor U-Boot 2013.07 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 is U-Boot 2013.07, UBNT build
e1000_002_ef3a9; it 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.
Early Octeon investigation used Amir Mehmood's original Octeon
host.patch as a behavioral reference; the basic machine approach and
several hardware model ideas come from that work. No code from that
patch remains in this implementation.
The series starts with three generic MIPS correctness fixes for MTTCG
interrupt state, MIPS64 segment checks, and architectural tlbwr
replacement semantics. It then adds Octeon CP0 state, the CN73xx CPU
model, PageMask handling, and unaligned accesses before introducing an
empty EBB7304 machine. The remaining patches add the machine state and
peripherals incrementally, followed by the 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;
* reset control, legacy CIU and CIU3 interrupt routing, mailboxes, and
secondary CPU release;
* UART, two TWSI controllers, synthesized DDR4 SPD, four LMC register
banks, fuses, RNG, POW, and the firmware probes used during platform
initialization;
* the EMM registers needed for firmware MMC initialization;
* two UCTL-wrapped DWC3 controllers, sufficient for U-Boot USB storage;
* a minimal PCIe host bridge, sufficient for a PCI e1000 device.
The functional test starts upstream U-Boot with four CPUs, enumerates
PCI, obtains a DHCP lease, downloads bsd.rd through user mode TFTP, and
boots the OpenBSD/octeon 7.9 installer.
The OpenBSD boot and USB stress testing requires additional patch for
xHCI which I haven't included into this series:
https://patchew.org/QEMU/[email protected]/
Each submitted commit was built in sequence and given the meaningful
smoke test available at that point. The final tree was tested with:
ninja -C build qemu-system-mips64
gmake -C build check-qtest-mips64
gmake -C build check-functional-mips64
The machine was used to build a few GCC build and full OpenBSD/octeon
release with LLVM inside OpenBSD/octeon using:
-m 32G -smp 8 -accel tcg,thread=multi
The longest non interrupted workload was near two weeks.
Known limitations are:
* native Octeon Ethernet is not modelled; the OpenBSD test uses PCI
e1000;
* EMM implements the firmware initialization path, not a complete MMC
data path;
* direct kernel boot through -kernel is not implemented;
* the newly modelled board and peripheral state lacks VMState
descriptions; migration and savevm are not expected to preserve the
complete machine state.
Patch layout:
1. target/mips: make CP0 interrupt state atomic
2. target/mips: fix MIPS64 segment access checks
3. target/mips: drop hidden TLB shadowing for tlbwr
4. target/mips: add Octeon CP0 register state
5. target/mips: add Octeon CN73xx CPU model
I ended adding the CN71xx instead which is the one I could test,
why start with the CN73xx, do you really need this one?
-- >8 --
target/mips: Add Octeon CN71xx CPU model
Add a model of the Cavium Octeon III CN71XX, as found on the
Ubiquiti UBNT_E300 (Linux 4.9.79, "Cavium Octeon III V0.2 FPU V0.0",
MIPS64r2 with VZ). Values read from that board:
PRId = 0x000D9602 (ProcessorID 0x96 = CN71XX, pass 1.2)
FIR = 0x00739600 (S, D, W, L, F64; no PS, 3D, Has2008)
FCSR = 0 at reset; ABS2008 and NAN2008 read-only 0 (a probe
writing all ones except Enables/Cause reads back
0xff80007f)
The remaining CP0 fields are copied from OcteonCN73XX, which already
matches the CN71XX hardware manual (CN71XX-HM-0.991E) except for
Config2.SS (secondary cache sets per way), which the manual gives as
4 (1024 sets) instead of 7.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
index 7f7a33c5e5a1..45974da950c8 100644
--- a/target/mips/cpu-defs.c.inc
+++ b/target/mips/cpu-defs.c.inc
@@ -1117,2 +1117,50 @@ const mips_def_t mips_defs[] =
},
+ {
+ /*
+ * Based on register reads and write/readback probes on a Ubiquiti
+ * UBNT_E300 (Cavium Octeon III V0.2) running Linux, cross-checked
+ * with the CN71XX hardware manual.
+ */
+ .name = "OcteonCN71XX",
+ .CP0_PRid = 0x000D9602,
+ .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 | (4 << CP0C2_SS) | (6 << CP0C2_SL) |
+ (7 << 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) | (1U <<
CP0C4_MMUExtDef) |
+ (3U << CP0C4_MMUSizeExt),
+ .CP0_Config5 = MIPS_CONFIG5,
+ .CP0_Config6 = 0x0800007C, /* Octeon III CVMMEMCTL2 */
+ .CP0_Config7 = 0x000FF0FF, /* Octeon III CVMVMConfig */
+ .CP0_LLAddr_rw_bitmask = 0,
+ .CP0_LLAddr_shift = 4,
+ .CP0_PageGrain = (1 << CP0PG_ELPA),
+ .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1U << CP0PG_XIE) |
+ (1U << CP0PG_ELPA) | (1U << CP0PG_IEC),
+ .SYNCI_Step = 4096,
+ .CCRes = 1,
+ .CP0_Status_rw_bitmask = 0x74F8FFFF,
+ .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
+ (1 << FCR0_D) | (1 << FCR0_S) |
+ (0x96 << FCR0_PRID) | (0x0 << FCR0_REV),
+ .CP1_fcr31 = 0,
+ .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
+ .SEGBITS = 49,
+ .PABITS = 49,
+ .insn_flags = CPU_MIPS64R2 | INSN_OCTEON,
+ .mmu_type = MMU_TYPE_R4000,
+ },
---
6. target/mips: pass env to compute_pagemask
7. target/mips: accept Octeon PageMask encodings
8. target/mips: allow Octeon unaligned accesses
9. hw/mips: add empty Octeon III machine
10. hw/mips: add Octeon CPUs and boot memory
11. hw/mips: add Octeon reset controller
12. hw/mips: add Octeon CIU3 CPU control
13. hw/mips: add Octeon CIU3 interrupt routing
14. hw/mips: add Octeon legacy CIU
15. hw/mips: add Octeon CSR window
16. hw/mips: expose Octeon reset CSRs
17. hw/mips: add Octeon MIO boot support
18. hw/mips: wire the Octeon UART
19. hw/i2c: add Octeon TWSI controller
20. hw/mips: add Octeon EMM controller
21. hw/mips: add Octeon LMC controllers
22. hw/mips: add Octeon boot support registers
23. hw/usb: add Octeon USB controller
24. hw/pci-bridge: add Octeon PCI host bridge
25. hw/pci-bridge: add Octeon PCI memory window
26. tests/functional: test Octeon III boot