Skip to content
Open
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VERSION = 6
PATCHLEVEL = 18
SUBLEVEL = 38
EXTRAVERSION =
EXTRAVERSION = -ctsi-1
NAME = Baby Opossum Posse

# *DOCUMENTATION*
Expand Down
98 changes: 98 additions & 0 deletions arch/riscv/configs/cartesi_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
CONFIG_DEFAULT_HOSTNAME="cartesi-machine"
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
# CONFIG_CROSS_MEMORY_ATTACH is not set
CONFIG_HIGH_RES_TIMERS=y
CONFIG_BPF_SYSCALL=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_CGROUPS=y
CONFIG_MEMCG=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_BPF=y
CONFIG_USER_NS=y
CONFIG_ARCH_VIRT=y
CONFIG_NONPORTABLE=y
CONFIG_HZ_100=y
CONFIG_RISCV_SBI_V01=y
CONFIG_RISCV_EMULATED_UNALIGNED_ACCESS=y
# CONFIG_RISCV_ISA_C is not set
# CONFIG_COMPAT is not set
CONFIG_CMDLINE="earlyprintk"
# CONFIG_EFI is not set
# CONFIG_SUSPEND is not set
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=y
CONFIG_JUMP_LABEL=y
CONFIG_BLK_DEV_THROTTLING=y
CONFIG_PARTITION_ADVANCED=y
# CONFIG_MQ_IOSCHED_DEADLINE is not set
# CONFIG_MQ_IOSCHED_KYBER is not set
# CONFIG_COMPACTION is not set
CONFIG_NET=y
CONFIG_PACKET=y
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
CONFIG_BRIDGE=y
CONFIG_VSOCKETS=y
CONFIG_VIRTIO_VSOCKETS=y
# CONFIG_WIRELESS is not set
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_VIRTIO_BLK=y
CONFIG_NETDEVICES=y
CONFIG_TUN=y
CONFIG_VIRTIO_NET=y
# CONFIG_ETHERNET is not set
# CONFIG_WLAN is not set
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_SERIO is not set
# CONFIG_LEGACY_PTYS is not set
CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
CONFIG_HVC_RISCV_SBI=y
CONFIG_VIRTIO_CONSOLE=y
CONFIG_HW_RANDOM_VIRTIO=y
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
CONFIG_VIRTIO_BALLOON=y
CONFIG_VIRTIO_MMIO=y
CONFIG_VHOST_NET=y
CONFIG_VHOST_VSOCK=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_LIBNVDIMM=y
CONFIG_UIO=y
CONFIG_UIO_PDRV_GENIRQ=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT2_FS_POSIX_ACL=y
CONFIG_EXT2_FS_SECURITY=y
CONFIG_EXT4_FS=y
CONFIG_TMPFS=y
CONFIG_HUGETLBFS=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_FILE_DIRECT=y
CONFIG_SQUASHFS_LZ4=y
CONFIG_SQUASHFS_LZO=y
CONFIG_SQUASHFS_XZ=y
CONFIG_SQUASHFS_ZSTD=y
CONFIG_9P_FS=y
CONFIG_FUSE_FS=y
CONFIG_EROFS_FS=y
CONFIG_OVERLAY_FS=y
CONFIG_PRINTK_TIME=y
CONFIG_STRIP_ASM_SYMS=y
# CONFIG_RUNTIME_TESTING_MENU is not set
CONFIG_BINFMT_MISC=y
CONFIG_SECURITY=y
CONFIG_FORTIFY_SOURCE=y
CONFIG_HARDENED_USERCOPY=y
CONFIG_SECURITY_LANDLOCK=y
CONFIG_CHECKPOINT_RESTORE=y
20 changes: 14 additions & 6 deletions arch/riscv/kernel/sbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ EXPORT_SYMBOL(sbi_remote_hfence_vvma_asid);

static void sbi_srst_reset(unsigned long type, unsigned long reason)
{
sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
sbi_ecall(SBI_EXT_0_1_SHUTDOWN, 0, type, reason,
0, 0, 0, 0);
pr_warn("%s: type=0x%lx reason=0x%lx failed\n",
__func__, type, reason);
Expand All @@ -519,10 +519,14 @@ static void sbi_srst_reset(unsigned long type, unsigned long reason)
static int sbi_srst_reboot(struct notifier_block *this,
unsigned long mode, void *cmd)
{
sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ?
SBI_SRST_RESET_TYPE_WARM_REBOOT :
SBI_SRST_RESET_TYPE_COLD_REBOOT,
SBI_SRST_RESET_REASON_NONE);
int32_t reason = 255;
/* use the original value if we fail to parse */
if (kstrtoint(cmd, 10, &reason)) {
;
}

sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
reason);
return NOTIFY_DONE;
}

Expand Down Expand Up @@ -658,7 +662,7 @@ void __init sbi_init(void)
pr_info("SBI specification v%lu.%lu detected\n",
sbi_major_version(), sbi_minor_version());

if (!sbi_spec_is_0_1()) {
if (!sbi_spec_is_0_1() && !IS_ENABLED(CONFIG_RISCV_SBI_V01)) {
pr_info("SBI implementation ID=0x%lx Version=0x%lx\n",
sbi_get_firmware_id(), sbi_get_firmware_version());
if (sbi_probe_extension(SBI_EXT_TIME)) {
Expand Down Expand Up @@ -702,6 +706,10 @@ void __init sbi_init(void)
__sbi_set_timer = __sbi_set_timer_v01;
__sbi_send_ipi = __sbi_send_ipi_v01;
__sbi_rfence = __sbi_rfence_v01;

sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
sbi_srst_reboot_nb.priority = 192;
register_restart_handler(&sbi_srst_reboot_nb);
}

if (!srst_power_off)
Expand Down
2 changes: 2 additions & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,6 @@ source "drivers/hte/Kconfig"

source "drivers/cdx/Kconfig"

source "drivers/cartesi/Kconfig"

endmenu
1 change: 1 addition & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,4 @@ obj-$(CONFIG_DPLL) += dpll/

obj-$(CONFIG_DIBS) += dibs/
obj-$(CONFIG_S390) += s390/
obj-$(CONFIG_CARTESI_MACHINE) += cartesi/
30 changes: 30 additions & 0 deletions drivers/cartesi/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
menu "Cartesi Machine"

config CARTESI_MACHINE
bool "Cartesi Machine"
depends on RISCV_SBI
default y if RISCV_SBI
help
Enable support for the Cartesi Machine RISC-V platform.
This enables the Cartesi Machine specific drivers and
configuration options.

config CARTESI_MACHINE_IO_DRIVER
bool "Cartesi Machine IO Device"
depends on CARTESI_MACHINE
default y
help
Driver for the Cartesi Machine IO (cmio) device, which
provides guest-host communication via shared memory
buffers and SBI yield calls. Exposes /dev/cmio.

config CARTESI_HALT_ON_PANIC
bool "Halt machine on kernel panic"
depends on CARTESI_MACHINE
default y
help
Halt the Cartesi Machine on kernel panic by issuing an
SBI shutdown call. This is useful for debugging to
prevent the machine from continuing in an undefined state.

endmenu
1 change: 1 addition & 0 deletions drivers/cartesi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-$(CONFIG_CARTESI_MACHINE_IO_DRIVER) += cmio.o
Loading