aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajnesh Kanwal <rkanwal@rivosinc.com>2023-02-03 12:29:34 +0000
committerWill Deacon <will@kernel.org>2023-03-24 17:34:17 +0000
commit2f030d283c0e7a417f50cf0d70d076870815f3e6 (patch)
tree363f9770417382cc4da72162a5a177e0a9143e00
parente17d182ad3f797f01947fc234d95c96c050c534b (diff)
downloadkvmtool-2f030d283c0e7a417f50cf0d70d076870815f3e6.tar.gz
riscv: Move serial and rtc from IO port space to MMIO area.
The default serial and rtc IO region overlaps with PCI IO bar region leading bar 0 activation to fail. Moving these devices to MMIO region similar to ARM. Given serial has been moved from 0x3f8 to 0x10000000, this requires us to now pass earlycon=uart8250,mmio,0x10000000 from cmdline rather than earlycon=uart8250,mmio,0x3f8. To avoid the need to change the address every time the tool is updated, we can also just pass "earlycon" from cmdline and guest then finds the type and base address by following the Device Tree's stdout-path property. Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com> Tested-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Link: https://lore.kernel.org/r/20230203122934.18714-1-rkanwal@rivosinc.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--hw/rtc.c3
-rw-r--r--hw/serial.c4
-rw-r--r--riscv/include/kvm/kvm-arch.h8
3 files changed, 14 insertions, 1 deletions
diff --git a/hw/rtc.c b/hw/rtc.c
index 9b8785a8..da696e13 100644
--- a/hw/rtc.c
+++ b/hw/rtc.c
@@ -9,6 +9,9 @@
#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
#define RTC_BUS_TYPE DEVICE_BUS_MMIO
#define RTC_BASE_ADDRESS ARM_RTC_MMIO_BASE
+#elif defined(CONFIG_RISCV)
+#define RTC_BUS_TYPE DEVICE_BUS_MMIO
+#define RTC_BASE_ADDRESS RISCV_RTC_MMIO_BASE
#else
/* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */
#define RTC_BUS_TYPE DEVICE_BUS_IOPORT
diff --git a/hw/serial.c b/hw/serial.c
index 3d533623..b6263a01 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -17,6 +17,10 @@
#define serial_iobase(nr) (ARM_UART_MMIO_BASE + (nr) * 0x1000)
#define serial_irq(nr) (32 + (nr))
#define SERIAL8250_BUS_TYPE DEVICE_BUS_MMIO
+#elif defined(CONFIG_RISCV)
+#define serial_iobase(nr) (RISCV_UART_MMIO_BASE + (nr) * 0x1000)
+#define serial_irq(nr) (1 + (nr))
+#define SERIAL8250_BUS_TYPE DEVICE_BUS_MMIO
#else
#define serial_iobase_0 (KVM_IOPORT_AREA + 0x3f8)
#define serial_iobase_1 (KVM_IOPORT_AREA + 0x2f8)
diff --git a/riscv/include/kvm/kvm-arch.h b/riscv/include/kvm/kvm-arch.h
index 1e130f59..d32d2af0 100644
--- a/riscv/include/kvm/kvm-arch.h
+++ b/riscv/include/kvm/kvm-arch.h
@@ -35,10 +35,16 @@
#define RISCV_MAX_MEMORY(kvm) RISCV_LOMAP_MAX_MEMORY
#endif
+#define RISCV_UART_MMIO_BASE RISCV_MMIO
+#define RISCV_UART_MMIO_SIZE 0x10000
+
+#define RISCV_RTC_MMIO_BASE (RISCV_UART_MMIO_BASE + RISCV_UART_MMIO_SIZE)
+#define RISCV_RTC_MMIO_SIZE 0x10000
+
#define KVM_IOPORT_AREA RISCV_IOPORT
#define KVM_PCI_CFG_AREA RISCV_PCI
#define KVM_PCI_MMIO_AREA (KVM_PCI_CFG_AREA + RISCV_PCI_CFG_SIZE)
-#define KVM_VIRTIO_MMIO_AREA RISCV_MMIO
+#define KVM_VIRTIO_MMIO_AREA (RISCV_RTC_MMIO_BASE + RISCV_RTC_MMIO_SIZE)
#define KVM_IOEVENTFD_HAS_PIO 0