Skip to content

Commit

Permalink
spapr: implement H_SET_MODE debug facilities
Browse files Browse the repository at this point in the history
Wire up the H_SET_MODE debug resources to the CIABR and DAWR0 debug
facilities in TCG.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
  • Loading branch information
npiggin authored and legoater committed Sep 4, 2023
1 parent 446e514 commit aedafbe
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions hw/ppc/spapr_hcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "qapi/error.h"
#include "sysemu/hw_accel.h"
#include "sysemu/runstate.h"
#include "sysemu/tcg.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
Expand Down Expand Up @@ -789,6 +790,54 @@ static target_ulong h_logical_dcbf(PowerPCCPU *cpu, SpaprMachineState *spapr,
return H_SUCCESS;
}

static target_ulong h_set_mode_resource_set_ciabr(PowerPCCPU *cpu,
SpaprMachineState *spapr,
target_ulong mflags,
target_ulong value1,
target_ulong value2)
{
CPUPPCState *env = &cpu->env;

assert(tcg_enabled()); /* KVM will have handled this */

if (mflags) {
return H_UNSUPPORTED_FLAG;
}
if (value2) {
return H_P4;
}
if ((value1 & PPC_BITMASK(62, 63)) == 0x3) {
return H_P3;
}

ppc_store_ciabr(env, value1);

return H_SUCCESS;
}

static target_ulong h_set_mode_resource_set_dawr0(PowerPCCPU *cpu,
SpaprMachineState *spapr,
target_ulong mflags,
target_ulong value1,
target_ulong value2)
{
CPUPPCState *env = &cpu->env;

assert(tcg_enabled()); /* KVM will have handled this */

if (mflags) {
return H_UNSUPPORTED_FLAG;
}
if (value2 & PPC_BIT(61)) {
return H_P4;
}

ppc_store_dawr0(env, value1);
ppc_store_dawrx0(env, value2);

return H_SUCCESS;
}

static target_ulong h_set_mode_resource_le(PowerPCCPU *cpu,
SpaprMachineState *spapr,
target_ulong mflags,
Expand Down Expand Up @@ -858,6 +907,14 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, SpaprMachineState *spapr,
target_ulong ret = H_P2;

switch (resource) {
case H_SET_MODE_RESOURCE_SET_CIABR:
ret = h_set_mode_resource_set_ciabr(cpu, spapr, args[0], args[2],
args[3]);
break;
case H_SET_MODE_RESOURCE_SET_DAWR0:
ret = h_set_mode_resource_set_dawr0(cpu, spapr, args[0], args[2],
args[3]);
break;
case H_SET_MODE_RESOURCE_LE:
ret = h_set_mode_resource_le(cpu, spapr, args[0], args[2], args[3]);
break;
Expand Down

0 comments on commit aedafbe

Please sign in to comment.