Skip to contentSkip to conversation

qom-cpu: Wrap set_pc hook and use in bootloaders

PATCH Superseded Peter Crosthwaite 4 participants 19 messages Jun 16, 2015 – Jun 24, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover qom-cpu: Wrap set_pc hook and use in bootloaders

Wrap the CPUClass::set_pc fn hook in a caller helper to reduce verbosity of calls. Simplify the call from the gdbstub.

Then use the call to abstract away the PC env fields from the ARM and Microblaze bootloaders.

This moves towards the goal of minimising system level code of the CPU env (and one step closer to common-obj'ing the bootloaders). There's a long way to go (at least for ARM, not so far for MB), but this is a small win in that direction.

This helps with multi-arch where the current thinking is to compile out the maximum content possible from cpu.h. This removes program counter definitions from the multi-arch cpu.h compile-in list.

changed since v1:
Remove thumb changes

Peter Crosthwaite (4):
qom: cpu: Add wrapper to the set-pc hook
gdbstub: Use cpu_set_pc helper
arm: boot: Use cpu_set_pc
microblaze: boot: Use cpu_set_pc

 gdbstub.c            |  5 +----
 hw/arm/boot.c        | 19 +++++++------------
 hw/microblaze/boot.c |  2 +-
 include/qom/cpu.h    | 21 +++++++++++++++++++++
 4 files changed, 30 insertions(+), 17 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/4 qom: cpu: Add wrapper to the set-pc hook

Add a wrapper around the CPUClass::set_pc hook. Accepts an error pointer to report the case where the hook is not set.

---
 include/qom/cpu.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/qom/cpu.h +21 -0
index 7db310e..97d4edf 100644
@@ -600,6 +600,27 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
 #endif
 
 /**
+ * cpu_set_pc:
+ * @cpu: The CPU to set the program counter for.
+ * @addr: Program counter value.
+ * @errp: Error pointer to populate in case of error.
+ *
+ * Set the program counter for a CPU. If there is no available implementation
+ * an error is raised.
+ */
+
+static inline void cpu_set_pc(CPUState *cpu, vaddr addr, Error **errp)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    if (cc->set_pc) {
+        cc->set_pc(cpu, addr);
+    } else {
+        error_setg(errp, "CPU does not implement set PC");
+    }
+}
+
+/**
  * cpu_reset_interrupt:
  * @cpu: The CPU to clear the interrupt on.
  * @mask: The interrupt mask to clear.
Signature · 1 line
1.9.1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] qom: cpu: Add wrapper to the set-pc hook

Quoted 25 lines · Peter Crosthwaite

Add a wrapper around the CPUClass::set_pc hook. Accepts an error pointer to report the case where the hook is not set.

---
 include/qom/cpu.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/qom/cpu.h +9 -0
index 7db310e..97d4edf 100644
@@ -600,6 +600,27 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
 #endif
 
 /**
+ * cpu_set_pc:
+ * @cpu: The CPU to set the program counter for.
+ * @addr: Program counter value.
+ * @errp: Error pointer to populate in case of error.
+ *
+ * Set the program counter for a CPU. If there is no available implementation
+ * an error is raised.
+ */
+

include/qom/cpu.h static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, · line 621

Quoted 10 lines
include/qom/cpu.h +10 -0
+static inline void cpu_set_pc(CPUState *cpu, vaddr addr, Error **errp)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    if (cc->set_pc) {
+        cc->set_pc(cpu, addr);
+    } else {
+        error_setg(errp, "CPU does not implement set PC");
+    }
+}

I don't think there are any CPUClass implementations which don't implement set_pc. The code in cpu-exec.c which does this:

        if (cc->synchronize_from_tb) {
            cc->synchronize_from_tb(cpu, tb);
        } else {
            assert(cc->set_pc);
            cc->set_pc(cpu, tb->pc);
        }

demonstrates that we only need to check the CPUs which implement synchronize_from_tb (i386, mips, sh4, sparc, tricore) to check they have a set_pc method too, and they all do. (You can also just grep for 'cc->set_pc' in target-*/ and confirm they all have one, as a crosscheck.)

So I think this can simplify down to just calling the class method unconditionally.

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] qom: cpu: Add wrapper to the set-pc hook

In reply to Peter Crosthwaite

Hi,

Just "cpu: " please, compare git-log.

Am 16.06.2015 um 07:46 schrieb Peter Crosthwaite:

Quoted 15 lines

Add a wrapper around the CPUClass::set_pc hook. Accepts an error pointer to report the case where the hook is not set.

---
 include/qom/cpu.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/qom/cpu.h +0 -0
index 7db310e..97d4edf 100644
@@ -600,6 +600,27 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
 #endif
 

include/qom/cpu.h static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, · line 611

Quoted 10 lines
include/qom/cpu.h +9 -0
 /**
+ * cpu_set_pc:
+ * @cpu: The CPU to set the program counter for.
+ * @addr: Program counter value.
+ * @errp: Error pointer to populate in case of error.
+ *
+ * Set the program counter for a CPU. If there is no available implementation
+ * an error is raised.
+ */
+

Please drop the white line here for consistency.

Quoted 5 lines
include/qom/cpu.h +5 -0
+static inline void cpu_set_pc(CPUState *cpu, vaddr addr, Error **errp)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    if (cc->set_pc) {

include/qom/cpu.h static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, · line 626

Quoted 10 lines
include/qom/cpu.h +7 -0
+        cc->set_pc(cpu, addr);
+    } else {
+        error_setg(errp, "CPU does not implement set PC");
+    }
+}
+
+/**
  * cpu_reset_interrupt:
  * @cpu: The CPU to clear the interrupt on.
  * @mask: The interrupt mask to clear.

Otherwise, modulo Peter M.'s comment, looks okay.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
#4 lore raw

PATCH v2 2/4 gdbstub: Use cpu_set_pc helper

In reply to Peter Crosthwaite

Use the cpu_set_pc helper which will take care of CPUClass retrieval for us.

---
 gdbstub.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
gdbstub.c +1 -4
index 75563db..ceb60ac 100644
@@ -754,12 +754,9 @@ static void gdb_breakpoint_remove_all(void)
 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
 {
     CPUState *cpu = s->c_cpu;
-    CPUClass *cc = CPU_GET_CLASS(cpu);
 
     cpu_synchronize_state(cpu);
-    if (cc->set_pc) {
-        cc->set_pc(cpu, pc);
-    }
+    cpu_set_pc(cpu, pc, NULL);
 }
 
 static CPUState *find_cpu(uint32_t thread_id)
Signature · 1 line
1.9.1
#5 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Am 16.06.2015 um 07:46 schrieb Peter Crosthwaite:

Quoted 13 lines

Use the cpu_set_pc helper which will take care of CPUClass retrieval for us.

---
 gdbstub.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
gdbstub.c +0 -0
index 75563db..ceb60ac 100644

gdbstub.c static void gdb_breakpoint_remove_all(void) · line 759

Quoted 10 lines
gdbstub.c +1 -4
@@ -754,12 +754,9 @@ static void gdb_breakpoint_remove_all(void)
 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
 {
     CPUState *cpu = s->c_cpu;
-    CPUClass *cc = CPU_GET_CLASS(cpu);
 
     cpu_synchronize_state(cpu);
-    if (cc->set_pc) {
-        cc->set_pc(cpu, pc);
-    }
+    cpu_set_pc(cpu, pc, NULL);

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

Regards,
Andreas

Quoted 4 lines
gdbstub.c +0 -0
 }
 
 static CPUState *find_cpu(uint32_t thread_id)
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Quoted 19 lines · Andreas Färber

Am 16.06.2015 um 07:46 schrieb Peter Crosthwaite:

Quoted 18 lines

Use the cpu_set_pc helper which will take care of CPUClass retrieval for us.

---
 gdbstub.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
gdbstub.c +0 -1
index 75563db..ceb60ac 100644
@@ -754,12 +754,9 @@ static void gdb_breakpoint_remove_all(void)
 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
 {
     CPUState *cpu = s->c_cpu;
-    CPUClass *cc = CPU_GET_CLASS(cpu);
 
Quoted 9 lines

gdbstub.c static void gdb_breakpoint_remove_all(void) · line 759

Quoted 5 lines
gdbstub.c +1 -3
     cpu_synchronize_state(cpu);
-    if (cc->set_pc) {
-        cc->set_pc(cpu, pc);
-    }
+    cpu_set_pc(cpu, pc, NULL);

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

I'm not sure. As I don't see what is catching the case of a gdb 'c' packet for a CPU that doesn't implement set_pc. I'd rather preserve the existing behaviour, and have the qom wrapper do nothing if it is not implemented.

Regards,
Peter

Quoted 14 lines

Regards,
Andreas

gdbstub.c static void gdb_breakpoint_remove_all(void) · line 762

Quoted 4 lines
gdbstub.c +0 -0
 }
 
 static CPUState *find_cpu(uint32_t thread_id)

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

#7 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Quoted 9 lines · Peter Crosthwaite
Quoted 3 lines · Andreas Färber

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

I'm not sure. As I don't see what is catching the case of a gdb 'c' packet for a CPU that doesn't implement set_pc. I'd rather preserve the existing behaviour, and have the qom wrapper do nothing if it is not implemented.

Well, this is one reason why every CPU needs to implement set_pc...

-- PMM

#8 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Quoted 7 lines · Peter Maydell
Quoted 5 lines · Peter Crosthwaite
Quoted 3 lines · Andreas Färber

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

Quoted 7 lines
Quoted 4 lines

I'm not sure. As I don't see what is catching the case of a gdb 'c' packet for a CPU that doesn't implement set_pc. I'd rather preserve the existing behaviour, and have the qom wrapper do nothing if it is not implemented.

Well, this is one reason why every CPU needs to implement set_pc...

Well. I guess it works for a common case where a continue doesn't change the PC? If the debugger doesn't change the PC the "c" should work even without a set_pc call so we don't want to assert on this valid use case.

Regards,
Peter

Quoted 2 lines

-- PMM

#9 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Am 24.06.2015 um 19:04 schrieb Peter Crosthwaite:

Quoted 13 lines · Peter Maydell
Quoted 12 lines
Quoted 9 lines · Peter Crosthwaite
Quoted 3 lines · Andreas Färber

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

I'm not sure. As I don't see what is catching the case of a gdb 'c' packet for a CPU that doesn't implement set_pc. I'd rather preserve the existing behaviour, and have the qom wrapper do nothing if it is not implemented.

Quoted 7 lines
Quoted 2 lines

Well, this is one reason why every CPU needs to implement set_pc...

Well. I guess it works for a common case where a continue doesn't change the PC? If the debugger doesn't change the PC the "c" should work even without a set_pc call so we don't want to assert on this valid use case.

Guys, is there any target that does not implement set_pc today? If so, which? I'd rather implement it than carry around the iffery and resulting complications.

I quickly counted 17 target-* in my tree and all 17 seemed to show up in git-grep. Can you confirm? Didn't check the latest tilegx series.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
#10 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

Quoted 22 lines · Andreas Färber

Am 24.06.2015 um 19:04 schrieb Peter Crosthwaite:

Quoted 13 lines · Peter Maydell
Quoted 12 lines
Quoted 9 lines · Peter Crosthwaite
Quoted 3 lines · Andreas Färber

I believe this argument will probably go away; otherwise this should've been &error_abort or something instead of NULL.

I'm not sure. As I don't see what is catching the case of a gdb 'c' packet for a CPU that doesn't implement set_pc. I'd rather preserve the existing behaviour, and have the qom wrapper do nothing if it is not implemented.

Quoted 7 lines
Quoted 2 lines

Well, this is one reason why every CPU needs to implement set_pc...

Well. I guess it works for a common case where a continue doesn't change the PC? If the debugger doesn't change the PC the "c" should work even without a set_pc call so we don't want to assert on this valid use case.

Quoted 7 lines

Guys, is there any target that does not implement set_pc today? If so, which? I'd rather implement it than carry around the iffery and resulting complications.

I quickly counted 17 target-* in my tree and all 17 seemed to show up in git-grep. Can you confirm? Didn't check the latest tilegx series.

There are 17 targets and 18 sets by my count:

$ git grep "set_pc.*=.*set_pc" target-*
target-alpha/cpu.c:    cc->set_pc = alpha_cpu_set_pc;
target-arm/cpu.c:    cc->set_pc = arm_cpu_set_pc;
target-arm/cpu64.c:    cc->set_pc = aarch64_cpu_set_pc;
target-cris/cpu.c:    cc->set_pc = cris_cpu_set_pc;
target-i386/cpu.c:    cc->set_pc = x86_cpu_set_pc;
target-lm32/cpu.c:    cc->set_pc = lm32_cpu_set_pc;
target-m68k/cpu.c:    cc->set_pc = m68k_cpu_set_pc;
target-microblaze/cpu.c:    cc->set_pc = mb_cpu_set_pc;
target-mips/cpu.c:    cc->set_pc = mips_cpu_set_pc;
target-moxie/cpu.c:    cc->set_pc = moxie_cpu_set_pc;
target-openrisc/cpu.c:    cc->set_pc = openrisc_cpu_set_pc;
target-ppc/translate_init.c:    cc->set_pc = ppc_cpu_set_pc;
target-s390x/cpu.c:    cc->set_pc = s390_cpu_set_pc;
target-sh4/cpu.c:    cc->set_pc = superh_cpu_set_pc;
target-sparc/cpu.c:    cc->set_pc = sparc_cpu_set_pc;
target-tricore/cpu.c:    cc->set_pc = tricore_cpu_set_pc;
target-unicore32/cpu.c:    cc->set_pc = uc32_cpu_set_pc;
target-xtensa/cpu.c:    cc->set_pc = xtensa_cpu_set_pc;

ARM is doubled up. As long as no one else is missing a double up where there is not default set by a single base class we are OK. If there is a missing double up with a base class implementation, then there will be no change by your proposal anyway.

Regards,
Peter

Quoted 8 lines

Regards,
Andreas

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

#11 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] gdbstub: Use cpu_set_pc helper

In reply to Andreas Färber
Quoted 3 lines · Andreas Färber

Guys, is there any target that does not implement set_pc today? If so, which? I'd rather implement it than carry around the iffery and resulting complications.

No, there are none, see my analysis in my review of patch 1 in this set.

-- PMM

#12 lore raw

PATCH v2 3/4 arm: boot: Use cpu_set_pc

In reply to Peter Crosthwaite

Use cpu_set_pc across the board for setting program counters. This removes instances of system level code having to reach into the CPU env.

---
Changed since v1:
Lease thumb masking in boot.c

---
 hw/arm/boot.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
hw/arm/boot.c +7 -12
index d036624..a54add6 100644
@@ -168,11 +168,9 @@ static void default_write_secondary(ARMCPU *cpu,
 static void default_reset_secondary(ARMCPU *cpu,
                                     const struct arm_boot_info *info)
 {
-    CPUARMState *env = &cpu->env;
-
     address_space_stl_notdirty(&address_space_memory, info->smp_bootreg_addr,
                                0, MEMTXATTRS_UNSPECIFIED, NULL);
-    env->regs[15] = info->smp_loader_start;
+    cpu_set_pc(CPU(cpu), info->smp_loader_start, &error_abort);
 }
 
 static inline bool have_dtb(const struct arm_boot_info *info)
@@ -452,12 +450,13 @@ static void do_cpu_reset(void *opaque)
     if (info) {
         if (!info->is_linux) {
             /* Jump to the entry point.  */
-            if (env->aarch64) {
-                env->pc = info->entry;
-            } else {
-                env->regs[15] = info->entry & 0xfffffffe;
+            uint64_t entry = info->entry;
+
+            if (!env->aarch64) {
                 env->thumb = info->entry & 1;
+                entry &= 0xfffffffe;
             }
+            cpu_set_pc(CPU(cpu), entry, &error_abort);
         } else {
             /* If we are booting Linux then we need to check whether we are
              * booting into secure or non-secure state and adjust the state
@@ -488,11 +487,7 @@ static void do_cpu_reset(void *opaque)
             }
 
             if (CPU(cpu) == first_cpu) {
-                if (env->aarch64) {
-                    env->pc = info->loader_start;
-                } else {
-                    env->regs[15] = info->loader_start;
-                }
+                cpu_set_pc(CPU(cpu), info->loader_start, &error_abort);
 
                 if (!have_dtb(info)) {
                     if (old_param) {
Signature · 1 line
1.9.1
Reviewed-by on v2 3/4
#13 lore raw

Re: [Qemu-devel] [PATCH v2 3/4] arm: boot: Use cpu_set_pc

Quoted 6 lines · Peter Crosthwaite

Use cpu_set_pc across the board for setting program counters. This removes instances of system level code having to reach into the CPU env.

---

though you'll want to drop the &error_abort argument to cpu_set_pc() (see my review on patch 1).

thanks
-- PMM

Reviewed-by
#14 lore raw

Re: [Qemu-devel] [PATCH v2 3/4] arm: boot: Use cpu_set_pc

Am 16.06.2015 um 13:32 schrieb Peter Maydell:

Quoted 9 lines · Peter Crosthwaite
Quoted 6 lines

Use cpu_set_pc across the board for setting program counters. This removes instances of system level code having to reach into the CPU env.

---

Quoted 3 lines

though you'll want to drop the &error_abort argument to cpu_set_pc() (see my review on patch 1).

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
#15 lore raw

PATCH v2 4/4 microblaze: boot: Use cpu_set_pc

In reply to Peter Crosthwaite

Use cpu_set_pc for setting program counters when bootloading. This removes an instance of system level code having to reach into the CPU env.

---
 hw/microblaze/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/microblaze/boot.c +1 -1
index 4c44317..ec68479 100644
@@ -54,7 +54,7 @@ static void main_cpu_reset(void *opaque)
     env->regs[5] = boot_info.cmdline;
     env->regs[6] = boot_info.initrd_start;
     env->regs[7] = boot_info.fdt;
-    env->sregs[SR_PC] = boot_info.bootstrap_pc;
+    cpu_set_pc(CPU(cpu), boot_info.bootstrap_pc, &error_abort);
     if (boot_info.machine_cpu_reset) {
         boot_info.machine_cpu_reset(cpu);
     }
Signature · 1 line
1.9.1
#16 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] microblaze: boot: Use cpu_set_pc

Quoted 14 lines · Peter Crosthwaite

Use cpu_set_pc for setting program counters when bootloading. This removes an instance of system level code having to reach into the CPU env.

---
 hw/microblaze/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/microblaze/boot.c +0 -0
index 4c44317..ec68479 100644

hw/microblaze/boot.c static void main_cpu_reset(void *opaque) · line 57

Quoted 5 lines
hw/microblaze/boot.c +1 -1
@@ -54,7 +54,7 @@ static void main_cpu_reset(void *opaque)
     env->regs[5] = boot_info.cmdline;
     env->regs[6] = boot_info.initrd_start;
     env->regs[7] = boot_info.fdt;
-    env->sregs[SR_PC] = boot_info.bootstrap_pc;
+    cpu_set_pc(CPU(cpu), boot_info.bootstrap_pc, &error_abort);

Well, it sort of removes an instance of reaching into the CPU env, but there's all those other ones in plain sight just above. Is there much point in setting SR_PC indirectly if we don't have a mechanism for setting the other regs indirectly?

-- PMM

#17 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] microblaze: boot: Use cpu_set_pc

Quoted 10 lines · Peter Maydell
Quoted 9 lines · Peter Crosthwaite

Use cpu_set_pc for setting program counters when bootloading. This removes an instance of system level code having to reach into the CPU env.

---
 hw/microblaze/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

hw/microblaze/boot.c static void main_cpu_reset(void *opaque) · line 57

Quoted 10 lines
hw/microblaze/boot.c +1 -1
index 4c44317..ec68479 100644
@@ -54,7 +54,7 @@ static void main_cpu_reset(void *opaque)
     env->regs[5] = boot_info.cmdline;
     env->regs[6] = boot_info.initrd_start;
     env->regs[7] = boot_info.fdt;
-    env->sregs[SR_PC] = boot_info.bootstrap_pc;
+    cpu_set_pc(CPU(cpu), boot_info.bootstrap_pc, &error_abort);

Well, it sort of removes an instance of reaching into the CPU env, but there's all those other ones in plain sight just above. Is there much point in setting SR_PC indirectly if we don't have a mechanism for setting the other regs indirectly?

Yes. Needs more patches :). I'm starting with the easy stuff, and I am actually more interested in getting rid of the SR_PC macro usage at this stage. ARMs solution to this is the machine code bootloader. That would be one way. But what I want to propose was that we add a virtual method to CPUs that sets these offsets that bootloaders can call. This brings us closer to one bootloader that can do it all.

Regards,
Peter

Quoted 2 lines

-- PMM

Reviewed-by on v2 4/4
#18 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] microblaze: boot: Use cpu_set_pc

In reply to Peter Crosthwaite

Am 16.06.2015 um 07:46 schrieb Peter Crosthwaite:

Quoted 5 lines

Use cpu_set_pc for setting program counters when bootloading. This removes an instance of system level code having to reach into the CPU env.

but please remember to use "cpu_set_pc()" convention here and elsewhere in the commit messages including subjects.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)