Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
podman run --pull newer --init --rm -it -v $(pwd):$(pwd)
-w $(pwd)/tests/docker/
docker.io/pboqemu/qemu-ci:${{matrix.container}}
env QEMU_SRC=$(pwd) QEMU_WERROR="${{ env.QEMU_WERROR }}" ENABLE_RUST=0 INSTALL_DIR=/ BUILD_DIR=/tmp MAKEFLAGS="-j $(nproc)"
env QEMU_SRC=$(pwd) QEMU_WERROR="${{ env.QEMU_WERROR }}" ENABLE_RUST=0 EXTRA_CONFIGURE_OPTS=--disable-docs INSTALL_DIR=/ BUILD_DIR=/tmp MAKEFLAGS="-j $(nproc)"
./test-build

build:
Expand Down
14 changes: 14 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,20 @@ F: include/hw/watchdog/k230_wdt.h
F: tests/qtest/k230-sysctl-test.c
F: tests/qtest/k230-wdt-test.c

SpacemiT K3 Pico-ITX
M: Chao Liu <[email protected]>
L: [email protected]
S: Maintained
F: docs/system/riscv/spacemit-k3.rst
F: hw/misc/spacemit-k3.c
F: hw/riscv/spacemit-k3.c
F: hw/sd/spacemit-k3-sdhci.c
F: include/hw/misc/spacemit-k3.h
F: include/hw/riscv/spacemit-k3.h
F: include/hw/sd/spacemit-k3-sdhci.h
F: tests/functional/riscv64/test_spacemit_k3.py
F: tests/qtest/spacemit-k3-test.c

Milk-V Duo
M: Kuan-Wei Chiu <[email protected]>
S: Maintained
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for new machine requests or bug reports.
| arch | machine | direct | firmware | src |
| --- | --- | --- | --- | --- |
| RISC-V | [`k230-canmv`](docs/system/riscv/k230-canmv.rst) | ✅ | ✅ | PM |
| RISC-V | [`k3-pico-itx`](docs/system/riscv/spacemit-k3.rst) | ✅ | ✅ | PM |
| RISC-V | [`milkv-duo`](docs/system/riscv/milkv-duo.rst) | ✅ | ✅ | UP |
| RISC-V | [`riscv-server-ref`](docs/system/riscv/riscv-server-ref.rst) | ✅ | ✅ | UP |
| ARM | [`phytium-pi`](docs/system/arm/phytium-pi.rst) | ✅ | ✅ | PM |
Expand Down
37 changes: 21 additions & 16 deletions accel/tcg/user-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,16 @@ void page_dump(FILE *f)

int page_get_flags(vaddr address)
{
PageFlagsNode *p = pageflags_find(address, address);
PageFlagsNode *p;

RCU_READ_LOCK_GUARD();

/*
* See util/interval-tree.c re lockless lookups: no false positives but
* there are false negatives. If we find nothing, retry with the mmap
* lock acquired.
*/
p = pageflags_find(address, address);
if (p) {
return p->flags;
}
Expand Down Expand Up @@ -300,15 +303,15 @@ static void pageflags_create_merge(vaddr start, vaddr last, int flags)

if (prev) {
if (next) {
prev->itree.last = next->itree.last;
pageflags_create(prev->itree.start, next->itree.last, flags);
g_free_rcu(next, rcu);
} else {
prev->itree.last = last;
pageflags_create(prev->itree.start, last, flags);
}
interval_tree_insert(&prev->itree, &pageflags_root);
g_free_rcu(prev, rcu);
} else if (next) {
next->itree.start = start;
interval_tree_insert(&next->itree, &pageflags_root);
pageflags_create(start, next->itree.last, flags);
g_free_rcu(next, rcu);
} else {
pageflags_create(start, last, flags);
}
Expand Down Expand Up @@ -370,8 +373,8 @@ static bool pageflags_set_clear(vaddr start, vaddr last,
if (set_flags != merge_flags) {
if (p_start < start) {
interval_tree_remove(&p->itree, &pageflags_root);
p->itree.last = start - 1;
interval_tree_insert(&p->itree, &pageflags_root);
pageflags_create(p_start, start - 1, p_flags);
g_free_rcu(p, rcu);

if (last < p_last) {
if (merge_flags & PAGE_VALID) {
Expand All @@ -393,11 +396,11 @@ static bool pageflags_set_clear(vaddr start, vaddr last,
}
if (last < p_last) {
interval_tree_remove(&p->itree, &pageflags_root);
p->itree.start = last + 1;
interval_tree_insert(&p->itree, &pageflags_root);
pageflags_create(last + 1, p_last, p_flags);
if (merge_flags & PAGE_VALID) {
pageflags_create(start, last, merge_flags);
}
g_free_rcu(p, rcu);
} else {
if (merge_flags & PAGE_VALID) {
p->flags = merge_flags;
Expand All @@ -418,8 +421,8 @@ static bool pageflags_set_clear(vaddr start, vaddr last,
if (set_flags == p_flags) {
if (start < p_start) {
interval_tree_remove(&p->itree, &pageflags_root);
p->itree.start = start;
interval_tree_insert(&p->itree, &pageflags_root);
pageflags_create(start, p_last, p_flags);
g_free_rcu(p, rcu);
}
if (p_last < last) {
start = p_last + 1;
Expand All @@ -431,8 +434,8 @@ static bool pageflags_set_clear(vaddr start, vaddr last,
/* Maybe split out head and/or tail ranges with the original flags. */
interval_tree_remove(&p->itree, &pageflags_root);
if (p_start < start) {
p->itree.last = start - 1;
interval_tree_insert(&p->itree, &pageflags_root);
pageflags_create(p_start, start - 1, p_flags);
g_free_rcu(p, rcu);

if (p_last < last) {
goto restart;
Expand All @@ -441,8 +444,8 @@ static bool pageflags_set_clear(vaddr start, vaddr last,
pageflags_create(last + 1, p_last, p_flags);
}
} else if (last < p_last) {
p->itree.start = last + 1;
interval_tree_insert(&p->itree, &pageflags_root);
pageflags_create(last + 1, p_last, p_flags);
g_free_rcu(p, rcu);
} else {
g_free_rcu(p, rcu);
goto restart;
Expand Down Expand Up @@ -504,6 +507,8 @@ bool page_check_range(vaddr start, vaddr len, int flags)
return false; /* wrap around */
}

RCU_READ_LOCK_GUARD();

locked = have_mmap_lock();
while (true) {
PageFlagsNode *p = pageflags_find(start, last);
Expand Down
1 change: 1 addition & 0 deletions configs/devices/riscv64-softmmu/default.mak
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# CONFIG_SIFIVE_U=n
# CONFIG_RISCV_VIRT=n
# CONFIG_RISCV_SERVER_PLATFORM_REF=n
# CONFIG_SPACEMIT_K3=n
# CONFIG_MICROCHIP_PFSOC=n
# CONFIG_SHAKTI_C=n
# CONFIG_K230=n
Expand Down
95 changes: 95 additions & 0 deletions docs/system/riscv/spacemit-k3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.. SPDX-License-Identifier: GPL-2.0-or-later

SpacemiT K3 Pico-ITX board (``k3-pico-itx``)
================================================

The ``k3-pico-itx`` machine models the standard RISC-V platform subset
needed to boot a SpacemiT K3 SDK Linux kernel directly or through U-Boot on
the K3 Pico-ITX board. It focuses on the eight X100 application harts and
does not expose the K3 A100 or IME harts.

The machine has a fixed CPU topology and memory layout matching the Linux
view of the board. The default configuration must be used without overriding
the CPU type, RAM size, or SMP topology.

Supported devices
-----------------

The ``k3-pico-itx`` machine supports:

* eight SpacemiT X100 harts implementing RVA23S64 in two clusters of four;
* 256-bit RISC-V vector registers, Sstc, and the Smaia/Ssaia extensions;
* 2 GiB of RAM starting at ``0x102000000``;
* a 32 MiB firmware window starting at ``0x100000000``;
* an ACLINT software interrupt and machine timer block with a 24 MHz timebase;
* machine- and supervisor-level APLIC and IMSIC interrupt controllers;
* the 8250-compatible UART0 at ``0xd4017000``, using interrupt source 42; and
* the K3 SDHCI controller at ``0xd4280000``, using interrupt source 99.

Boot options
------------

Both supported Linux boot paths start generic OpenSBI directly. QEMU can
either load Linux and its initramfs, or load U-Boot proper and let U-Boot load
Linux from an SD image. An external device tree is required because the
machine validates the exact K3 topology and address map before boot.

The following examples use artifacts built from the SpacemiT K3 Buildroot SDK
v1.0.2 and published in the ``sdk-v1.0.2-qemu2`` release of
``spacemit-k3-qemu-images``.

Direct Linux boot
~~~~~~~~~~~~~~~~~

.. code-block:: bash

$ qemu-system-riscv64 \
-machine k3-pico-itx \
-bios fw_dynamic.bin \
-kernel Image \
-initrd k3-qemu-initramfs.cpio.gz \
-dtb k3-pico-itx-qemu.dtb \
-append "earlycon=uart8250,mmio32,0xd4017000,115200 \
console=ttyS0,115200 rdinit=/init" \
-nographic -no-reboot

The machine supplies the fixed 2 GiB RAM size and 8-hart topology, so no
``-m`` or ``-smp`` options are needed. Direct kernel boot requires
OpenSBI; ``-bios none`` is rejected when ``-kernel`` is present.
The machine uses the fixed ``spacemit-x100`` CPU model.

U-Boot and SD boot
~~~~~~~~~~~~~~~~~~

Decompress ``k3-qemu-sd.raw.xz``, then start U-Boot proper as OpenSBI's next
stage:

.. code-block:: bash

$ xz -dk k3-qemu-sd.raw.xz
$ qemu-system-riscv64 \
-machine k3-pico-itx \
-bios fw_dynamic.bin \
-kernel u-boot.bin \
-dtb k3-pico-itx-qemu-uboot.dtb \
-drive file=k3-qemu-sd.raw,if=sd,format=raw,snapshot=on \
-nographic -no-reboot

U-Boot imports its deterministic environment from the SD boot partition and
loads the Linux kernel, Linux device tree, and initramfs from that partition.
The successful path prints ``K3-QEMU: Starting kernel from SD`` before Linux
prints ``K3_LINUX_MVP_PASS``.

Limitations
-----------

This machine is a Linux boot subset rather than a complete K3 hardware model.
It disables the X100 H extension because the VS interrupt files and
virtualization path are not modeled. The A100 and IME harts, PCIe,
networking, multimedia accelerators, power management, and most board
peripherals are not implemented.

The K3 BootROM, bootinfo parser, U-Boot SPL, and LPDDR training are not
modeled. QEMU provides initialized RAM and starts generic OpenSBI directly;
the firmware boot path therefore uses U-Boot proper rather than the vendor
SPL chain.
1 change: 1 addition & 0 deletions docs/system/target-riscv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ undocumented; you can get a complete list by running
riscv/mips
riscv/shakti-c
riscv/sifive_u
riscv/spacemit-k3
riscv/virt
riscv/xiangshan-kunminghu
riscv/riscv-server-ref
Expand Down
3 changes: 3 additions & 0 deletions hw/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ config RK3588_CRU
config RK3588_SCMI
bool

config SPACEMIT_K3_CTRL
bool

config MAC_VIA
bool
select MOS6522
Expand Down
1 change: 1 addition & 0 deletions hw/misc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ system_ss.add(when: 'CONFIG_MAC_VIA', if_true: files('mac_via.c'))

system_ss.add(when: 'CONFIG_RK3588_CRU', if_true: files('rk3588_cru.c'))
system_ss.add(when: 'CONFIG_RK3588_SCMI', if_true: files('rk3588_scmi.c'))
system_ss.add(when: 'CONFIG_SPACEMIT_K3_CTRL', if_true: files('spacemit-k3.c'))
system_ss.add(when: 'CONFIG_NXP_S32_MC_ME', if_true: files('nxp_s32_mc_me.c'))

specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cpc.c'))
Expand Down
Loading
Loading