Skip to contentSkip to conversation

hw/core/generic-loader: Allow PC to be set on command line

PATCH In review Peter Maydell 3 participants 3 messages Feb 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/core/generic-loader: Allow PC to be set on command line

The documentation for the generic loader claims that you can set the PC for a CPU with an option of the form
-device loader,cpu-num=0,addr=0x10000004

However if you try this QEMU complains:
cpu_num must be specified when setting a program counter

This is because we were testing against 0 rather than CPU_NONE.

---
I've also noticed that you can't use this to specify that the starting address should be in Thumb mode for Arm CPUs, but I'm not so sure of the right way to fix that...

 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -1
index 46012673c3..cb0e68486d 100644
@@ -105,7 +105,7 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
             error_setg(errp, "data can not be specified when setting a "
                        "program counter");
             return;
-        } else if (!s->cpu_num) {
+        } else if (s->cpu_num == CPU_NONE) {
             error_setg(errp, "cpu_num must be specified when setting a "
                        "program counter");
             return;
Signature · 1 line
2.16.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Peter Maydell

The documentation for the generic loader claims that you can set the PC for a CPU with an option of the form
-device loader,cpu-num=0,addr=0x10000004

However if you try this QEMU complains:
cpu_num must be specified when setting a program counter

This is because we were testing against 0 rather than CPU_NONE.

Quoted 4 lines

---
I've also noticed that you can't use this to specify that the starting address should be in Thumb mode for Arm CPUs, but I'm not so sure of the right way to fix that...

Should we at least update the documentation to mention this then?

Alistair

Quoted 21 lines
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -2
index 46012673c3..cb0e68486d 100644
@@ -105,7 +105,7 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
             error_setg(errp, "data can not be specified when setting a "
                        "program counter");
             return;
-        } else if (!s->cpu_num) {
+        } else if (s->cpu_num == CPU_NONE) {
             error_setg(errp, "cpu_num must be specified when setting a "
                        "program counter");
             return;
--

2.16.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell

The documentation for the generic loader claims that you can set the PC for a CPU with an option of the form
-device loader,cpu-num=0,addr=0x10000004

However if you try this QEMU complains:
cpu_num must be specified when setting a program counter

Quoted 7 lines

This is because we were testing against 0 rather than CPU_NONE.

---
I've also noticed that you can't use this to specify that the starting address should be in Thumb mode for Arm CPUs, but I'm not so sure of the right way to fix that...

Can using an impair addr work? (no arch-specific parser)

Quoted 10 lines
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +0 -0
index 46012673c3..cb0e68486d 100644

hw/core/generic-loader.c static void generic_loader_realize(DeviceState *dev, Error **errp) · line 111

Quoted 8 lines
hw/core/generic-loader.c +1 -1
@@ -105,7 +105,7 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
             error_setg(errp, "data can not be specified when setting a "
                        "program counter");
             return;
-        } else if (!s->cpu_num) {
+        } else if (s->cpu_num == CPU_NONE) {
             error_setg(errp, "cpu_num must be specified when setting a "
                        "program counter");
             return;