From e8314358586da783299b8a5fe2fcad8914b789f5 Mon Sep 17 00:00:00 2001
From: Davids Paskevics <davip00@mi.fu-berlin.de>
Date: Fri, 19 May 2023 10:48:20 +0200
Subject: [PATCH] Ensure unsupported arguments aren't passed when starting
 ESP32-C3

---
 hw/riscv/esp32_c3.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/hw/riscv/esp32_c3.c b/hw/riscv/esp32_c3.c
index 28564da058f..5dc308703c1 100644
--- a/hw/riscv/esp32_c3.c
+++ b/hw/riscv/esp32_c3.c
@@ -73,6 +73,24 @@ static void esp32_c3_machine_state_init(MachineState *mstate)
         error_report("This board can't load firmware");
         exit(1);
     }
+
+    if (mstate->kernel_filename) {
+        // Can't load a Linux-style kernel on an MCU
+        error_report("-device loader,file=<filename> must be used instead of -kernel");
+        exit(1);
+    }
+
+    if (mstate->fdt) {
+        // Can't load a device tree on an MCU
+        error_report("-dtb is not supported on this board");
+        exit(1);
+    }
+
+    if (mstate->initrd_filename) {
+        // Can't load an initrd on an MCU
+        error_report("-initrd is not supported on this board");
+        exit(1);
+    }
 }
 
 static void esp32_c3_machine_instance_init(Object *obj)
-- 
GitLab