[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v7 1/6] ppc: spapr: Handle "ibm, nmi-register" and
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v7 1/6] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls |
Date: |
Mon, 25 Mar 2019 17:16:56 +1100 |
User-agent: |
Mutt/1.11.3 (2019-02-01) |
On Fri, Mar 22, 2019 at 12:03:39PM +0530, Aravinda Prasad wrote:
> This patch adds support in QEMU to handle "ibm,nmi-register"
> and "ibm,nmi-interlock" RTAS calls.
>
> The machine check notification address is saved when the
> OS issues "ibm,nmi-register" RTAS call.
>
> This patch also handles the case when multiple processors
> experience machine check at or about the same time by
> handling "ibm,nmi-interlock" call. In such cases, as per
> PAPR, subsequent processors serialize waiting for the first
> processor to issue the "ibm,nmi-interlock" call. The second
> processor that also received a machine check error waits
> till the first processor is done reading the error log.
> The first processor issues "ibm,nmi-interlock" call
> when the error log is consumed. This patch implements the
> releasing part of the error-log while subsequent patch
> (which builds error log) handles the locking part.
>
> Signed-off-by: Aravinda Prasad <address@hidden>
> ---
> hw/ppc/spapr.c | 25 +++++++++++++++++++++++++
> hw/ppc/spapr_rtas.c | 36 ++++++++++++++++++++++++++++++++++++
> include/hw/ppc/spapr.h | 15 ++++++++++++++-
> 3 files changed, 75 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index adde36a..744dcad 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1788,6 +1788,16 @@ static void spapr_machine_reset(void)
> first_ppc_cpu->env.gpr[5] = 0;
>
> spapr->cas_reboot = false;
> +
> + spapr->mc_reset = 1;
> + spapr->mc_status = -1;
I don't love adding these fields so early, when they're never actually
tested until later in the series.
> + spapr->guest_machine_check_addr = -1;
> +
> + /* Before destroying, signal vCPUs waiting on this condition */
> + qemu_cond_broadcast(&spapr->mc_delivery_cond);
> + /* It is safe to call destroy as broadcast unblocks all vCPUs */
> + qemu_cond_destroy(&spapr->mc_delivery_cond);
> + qemu_cond_init(&spapr->mc_delivery_cond);
Why do you need to destroy and re-create the condition variable?
> }
>
> static void spapr_create_nvram(SpaprMachineState *spapr)
> @@ -2078,6 +2088,16 @@ static const VMStateDescription vmstate_spapr_dtb = {
> },
> };
>
> +static const VMStateDescription vmstate_spapr_guest_mc_addr = {
> + .name = "spapr_guest_mc_addr",
> + .version_id = 1,
> + .minimum_version_id = 1,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT64(guest_machine_check_addr, SpaprMachineState),
It looks like mc_reset and mc_status would also need migration, at
least once they actually do something.
> + VMSTATE_END_OF_LIST()
> + },
> +};
> +
> static const VMStateDescription vmstate_spapr = {
> .name = "spapr",
> .version_id = 3,
> @@ -2110,6 +2130,7 @@ static const VMStateDescription vmstate_spapr = {
> &vmstate_spapr_dtb,
> &vmstate_spapr_cap_large_decr,
> &vmstate_spapr_cap_ccf_assist,
> + &vmstate_spapr_guest_mc_addr,
> NULL
> }
> };
> @@ -3057,6 +3078,10 @@ static void spapr_machine_init(MachineState *machine)
>
> kvmppc_spapr_enable_inkernel_multitce();
> }
> +
> + spapr->mc_status = -1;
> + spapr->mc_reset = 0;
Since this is a bool, you should use true/false rather than 0/1.
> + qemu_cond_init(&spapr->mc_delivery_cond);
> }
>
> static int spapr_kvm_type(MachineState *machine, const char *vm_type)
> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
> index 24c45b1..fb594a4 100644
> --- a/hw/ppc/spapr_rtas.c
> +++ b/hw/ppc/spapr_rtas.c
> @@ -348,6 +348,38 @@ static void rtas_get_power_level(PowerPCCPU *cpu,
> SpaprMachineState *spapr,
> rtas_st(rets, 1, 100);
> }
>
> +static void rtas_ibm_nmi_register(PowerPCCPU *cpu,
> + SpaprMachineState *spapr,
> + uint32_t token, uint32_t nargs,
> + target_ulong args,
> + uint32_t nret, target_ulong rets)
> +{
> + spapr->mc_reset = 0;
> + spapr->guest_machine_check_addr = rtas_ld(args, 1);
> + rtas_st(rets, 0, RTAS_OUT_SUCCESS);
> +}
> +
> +static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu,
> + SpaprMachineState *spapr,
> + uint32_t token, uint32_t nargs,
> + target_ulong args,
> + uint32_t nret, target_ulong rets)
> +{
> + if (!spapr->guest_machine_check_addr) {
> + /* NMI register not called */
> + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> + } else {
> + /*
> + * VCPU issuing "ibm,nmi-interlock" is done with NMI handling,
> + * hence unset mc_status.
> + */
> + spapr->mc_status = -1;
> + qemu_cond_signal(&spapr->mc_delivery_cond);
> + rtas_st(rets, 0, RTAS_OUT_SUCCESS);
> + }
> +}
> +
> +
> static struct rtas_call {
> const char *name;
> spapr_rtas_fn fn;
> @@ -489,6 +521,10 @@ static void core_rtas_register_types(void)
> rtas_set_power_level);
> spapr_rtas_register(RTAS_GET_POWER_LEVEL, "get-power-level",
> rtas_get_power_level);
> + spapr_rtas_register(RTAS_IBM_NMI_REGISTER, "ibm,nmi-register",
> + rtas_ibm_nmi_register);
> + spapr_rtas_register(RTAS_IBM_NMI_INTERLOCK, "ibm,nmi-interlock",
> + rtas_ibm_nmi_interlock);
> }
>
> type_init(core_rtas_register_types)
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 74ce638..ee5589d 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -186,6 +186,17 @@ struct SpaprMachineState {
> * occurs during the unplug process. */
> QTAILQ_HEAD(, SpaprDimmState) pending_dimm_unplugs;
>
> + /* State related to "ibm,nmi-register" and "ibm,nmi-interlock" calls */
> + target_ulong guest_machine_check_addr;
> + /*
> + * mc_status is set to -1 if mc is not in progress, else is set to the
> CPU
> + * handling the mc.
> + */
> + int mc_status;
> + /* mc_reset is set to 1 if machine reset is in progress */
> + bool mc_reset;
> + QemuCond mc_delivery_cond;
> +
> /*< public >*/
> char *kvm_type;
> char *host_model;
> @@ -622,8 +633,10 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu,
> target_ulong opcode,
> #define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27)
> #define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28)
> #define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29)
> +#define RTAS_IBM_NMI_REGISTER (RTAS_TOKEN_BASE + 0x2A)
> +#define RTAS_IBM_NMI_INTERLOCK (RTAS_TOKEN_BASE + 0x2B)
>
> -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A)
> +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2C)
>
> /* RTAS ibm,get-system-parameter token values */
> #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
- Re: [Qemu-ppc] [PATCH v7 2/6] Wrapper function to wait on condition for the main loop mutex, (continued)
[Qemu-ppc] [PATCH v7 3/6] target/ppc: Handle NMI guest exit, Aravinda Prasad, 2019/03/22
[Qemu-ppc] [PATCH v7 1/6] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls, Aravinda Prasad, 2019/03/22
- Re: [Qemu-ppc] [PATCH v7 1/6] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls,
David Gibson <=
[Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Aravinda Prasad, 2019/03/22
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, David Gibson, 2019/03/25
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Aravinda Prasad, 2019/03/25
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, David Gibson, 2019/03/25
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Greg Kurz, 2019/03/26
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Aravinda Prasad, 2019/03/26
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Greg Kurz, 2019/03/26
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, David Gibson, 2019/03/27
- Re: [Qemu-ppc] [PATCH v7 4/6] target/ppc: Build rtas error log, Aravinda Prasad, 2019/03/27