Skip to content

Commit

Permalink
ppc/spapr: Move GPRs setup to one place
Browse files Browse the repository at this point in the history
At the moment "pseries" starts in SLOF which only expects the FDT blob
pointer in r3. As we are going to introduce a OpenFirmware support in
QEMU, we will be booting OF clients directly and these expect a stack
pointer in r1, Linux looks at r3/r4 for the initramdisk location
(although vmlinux can find this from the device tree but zImage from
distro kernels cannot).

This extends spapr_cpu_set_entry_state() to take more registers. This
should cause no behavioral change.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-Id: <20200310050733.29805-2-aik@ozlabs.ru>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
aik authored and dgibson committed Mar 17, 2020
1 parent 94f040a commit 395a20d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hw/ppc/spapr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ static void spapr_machine_reset(MachineState *machine)
spapr->fdt_blob = fdt;

/* Set up the entry state */
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, fdt_addr);
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, 0, fdt_addr, 0);
first_ppc_cpu->env.gpr[5] = 0;

spapr->cas_reboot = false;
Expand Down
6 changes: 5 additions & 1 deletion hw/ppc/spapr_cpu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ static void spapr_reset_vcpu(PowerPCCPU *cpu)
spapr_irq_cpu_intc_reset(spapr, cpu);
}

void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong r3)
void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip,
target_ulong r1, target_ulong r3,
target_ulong r4)
{
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
CPUPPCState *env = &cpu->env;

env->nip = nip;
env->gpr[1] = r1;
env->gpr[3] = r3;
env->gpr[4] = r4;
kvmppc_set_reg_ppc_online(cpu, 1);
CPU(cpu)->halted = 0;
/* Enable Power-saving mode Exit Cause exceptions */
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/spapr_rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMachineState *spapr,
*/
newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset;

spapr_cpu_set_entry_state(newcpu, start, r3);
spapr_cpu_set_entry_state(newcpu, start, 0, r3, 0);

qemu_cpu_kick(CPU(newcpu));

Expand Down
4 changes: 3 additions & 1 deletion include/hw/ppc/spapr_cpu_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ typedef struct SpaprCpuCoreClass {
} SpaprCpuCoreClass;

const char *spapr_get_cpu_core_type(const char *cpu_type);
void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong r3);
void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip,
target_ulong r1, target_ulong r3,
target_ulong r4);

typedef struct SpaprCpuState {
uint64_t vpa_addr;
Expand Down

0 comments on commit 395a20d

Please sign in to comment.