Skip to contentSkip to conversation

riscv, qemu_fw_cfg: Add support for RISC-V architecture

PATCH Superseded Björn Töpel 4 participants 4 messages Oct 11, 2023 – Oct 12, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv, qemu_fw_cfg: Add support for RISC-V architecture

From: Björn Töpel <[email protected]>

Qemu fw_cfg support was missing for RISC-V, which made it hard to do proper vmcore dumps from qemu.

Add the missing RISC-V arch-defines.

You can now do vmcore dumps from qemu. Add "-device vmcoreinfo" to the qemu command-line. From the qemu montior:
(qemu) dump-guest-memory vmcore

The vmcore can now be used, e.g., with the "crash" utility.

---
 drivers/firmware/Kconfig       | 2 +-
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/Kconfig +1 -1
index b59e3041fd62..f05ff56629b3 100644
@@ -155,7 +155,7 @@ config RASPBERRYPI_FIRMWARE
 
 config FW_CFG_SYSFS
 	tristate "QEMU fw_cfg device support in sysfs"
-	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
+	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || RISCV || SPARC || X86)
 	depends on HAS_IOPORT_MAP
 	default n
 	help
drivers/firmware/qemu_fw_cfg.c +1 -1
index a69399a6b7c0..1448f61173b3 100644
@@ -211,7 +211,7 @@ static void fw_cfg_io_cleanup(void)
 
 /* arch-specific ctrl & data register offsets are not available in ACPI, DT */
 #if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CFG_DATA_OFF))
-# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
+# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV))
 #  define FW_CFG_CTRL_OFF 0x08
 #  define FW_CFG_DATA_OFF 0x00
 #  define FW_CFG_DMA_OFF 0x10

base-commit: 1c8b86a3799f7e5be903c3f49fcdaee29fd385b5

Signature · 1 line
2.39.2
Tested-by on v1 1/1
#1 lore raw

Hi Björn,

Quoted 9 lines · Björn Töpel

From: Björn Töpel <[email protected]>

Qemu fw_cfg support was missing for RISC-V, which made it hard to do proper vmcore dumps from qemu.

Add the missing RISC-V arch-defines.

You can now do vmcore dumps from qemu. Add "-device vmcoreinfo" to the qemu command-line. From the qemu montior:

small typo here: monitor

Quoted 37 lines

(qemu) dump-guest-memory vmcore

The vmcore can now be used, e.g., with the "crash" utility.

---
 drivers/firmware/Kconfig       | 2 +-
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/Kconfig +1 -1
index b59e3041fd62..f05ff56629b3 100644
@@ -155,7 +155,7 @@ config RASPBERRYPI_FIRMWARE
 
 config FW_CFG_SYSFS
 	tristate "QEMU fw_cfg device support in sysfs"
-	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
+	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || RISCV || SPARC || X86)
 	depends on HAS_IOPORT_MAP
 	default n
 	help
drivers/firmware/qemu_fw_cfg.c +1 -1
index a69399a6b7c0..1448f61173b3 100644
@@ -211,7 +211,7 @@ static void fw_cfg_io_cleanup(void)
 
 /* arch-specific ctrl & data register offsets are not available in ACPI, DT */
 #if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CFG_DATA_OFF))
-# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
+# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV))
 #  define FW_CFG_CTRL_OFF 0x08
 #  define FW_CFG_DATA_OFF 0x00
 #  define FW_CFG_DMA_OFF 0x10
Quoted 1 line

base-commit: 1c8b86a3799f7e5be903c3f49fcdaee29fd385b5

I didn't know that qemu could generate vmcore files. BTW, whenever I don't have 'crash' at hand, I often use them with gdb and vmlinux-gdb.py debugging scripts. Anyway, works as expected:

Clément

Acked-by on v1 1/1
#2 lore raw
In reply to Björn Töpel
Quoted 8 lines · Björn Töpel

From: Björn Töpel <[email protected]>

Qemu fw_cfg support was missing for RISC-V, which made it hard to do proper vmcore dumps from qemu.

Add the missing RISC-V arch-defines.

Quoted 7 lines

You can now do vmcore dumps from qemu. Add "-device vmcoreinfo" to the qemu command-line. From the qemu montior:
(qemu) dump-guest-memory vmcore

The vmcore can now be used, e.g., with the "crash" utility.

Alistair

Quoted 32 lines
---
 drivers/firmware/Kconfig       | 2 +-
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/Kconfig +1 -1
index b59e3041fd62..f05ff56629b3 100644
@@ -155,7 +155,7 @@ config RASPBERRYPI_FIRMWARE
 
 config FW_CFG_SYSFS
        tristate "QEMU fw_cfg device support in sysfs"
-       depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
+       depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || RISCV || SPARC || X86)
        depends on HAS_IOPORT_MAP
        default n
        help
drivers/firmware/qemu_fw_cfg.c +1 -1
index a69399a6b7c0..1448f61173b3 100644
@@ -211,7 +211,7 @@ static void fw_cfg_io_cleanup(void)
 
 /* arch-specific ctrl & data register offsets are not available in ACPI, DT */
 #if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CFG_DATA_OFF))
-# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
+# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV))
 #  define FW_CFG_CTRL_OFF 0x08
 #  define FW_CFG_DATA_OFF 0x00
 #  define FW_CFG_DMA_OFF 0x10
Quoted 5 lines

base-commit: 1c8b86a3799f7e5be903c3f49fcdaee29fd385b5 --
2.39.2

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Björn Töpel
Quoted 7 lines · Björn Töpel

From: Björn Töpel <[email protected]>

Qemu fw_cfg support was missing for RISC-V, which made it hard to do proper vmcore dumps from qemu.

Add the missing RISC-V arch-defines.

Quoted 8 lines

You can now do vmcore dumps from qemu. Add "-device vmcoreinfo" to the qemu command-line. From the qemu montior:
(qemu) dump-guest-memory vmcore

The vmcore can now be used, e.g., with the "crash" utility.

---

with typo fixed:

Quoted 31 lines
 drivers/firmware/Kconfig       | 2 +-
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/Kconfig +1 -1
index b59e3041fd62..f05ff56629b3 100644
@@ -155,7 +155,7 @@ config RASPBERRYPI_FIRMWARE
 
 config FW_CFG_SYSFS
 	tristate "QEMU fw_cfg device support in sysfs"
-	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
+	depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || RISCV || SPARC || X86)
 	depends on HAS_IOPORT_MAP
 	default n
 	help
drivers/firmware/qemu_fw_cfg.c +1 -1
index a69399a6b7c0..1448f61173b3 100644
@@ -211,7 +211,7 @@ static void fw_cfg_io_cleanup(void)
 
 /* arch-specific ctrl & data register offsets are not available in ACPI, DT */
 #if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CFG_DATA_OFF))
-# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
+# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV))
 #  define FW_CFG_CTRL_OFF 0x08
 #  define FW_CFG_DATA_OFF 0x00
 #  define FW_CFG_DMA_OFF 0x10
Quoted 3 lines

base-commit: 1c8b86a3799f7e5be903c3f49fcdaee29fd385b5

Signature · 1 line
2.39.2

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv