[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v14 4/7] target/ppc: Build rtas error log upon an MCE
From: |
Greg Kurz |
Subject: |
Re: [PATCH v14 4/7] target/ppc: Build rtas error log upon an MCE |
Date: |
Wed, 25 Sep 2019 08:16:54 +0200 |
On Wed, 25 Sep 2019 11:31:30 +0530
Aravinda Prasad <address@hidden> wrote:
>
>
> On Wednesday 25 September 2019 07:00 AM, David Gibson wrote:
> > On Wed, Sep 18, 2019 at 01:42:34PM +0530, Aravinda Prasad wrote:
> >> Upon a machine check exception (MCE) in a guest address space,
> >> KVM causes a guest exit to enable QEMU to build and pass the
> >> error to the guest in the PAPR defined rtas error log format.
> >>
> >> This patch builds the rtas error log, copies it to the rtas_addr
> >> and then invokes the guest registered machine check handler. The
> >> handler in the guest takes suitable action(s) depending on the type
> >> and criticality of the error. For example, if an error is
> >> unrecoverable memory corruption in an application inside the
> >> guest, then the guest kernel sends a SIGBUS to the application.
> >> For recoverable errors, the guest performs recovery actions and
> >> logs the error.
> >>
> >> Signed-off-by: Aravinda Prasad <address@hidden>
[...]
> >> +
> >> +static void spapr_mce_dispatch_elog(PowerPCCPU *cpu, bool recovered)
> >> +{
> >> + SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> >> + CPUState *cs = CPU(cpu);
> >> + uint64_t rtas_addr;
> >> + CPUPPCState *env = &cpu->env;
> >> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
> >> + target_ulong msr = 0;
> >> + struct rtas_error_log log;
> >> + struct mc_extended_log *ext_elog;
> >> + uint32_t summary;
> >> +
> >> + /*
> >> + * Properly set bits in MSR before we invoke the handler.
> >> + * SRR0/1, DAR and DSISR are properly set by KVM
> >> + */
> >> + if (!(*pcc->interrupts_big_endian)(cpu)) {
> >> + msr |= (1ULL << MSR_LE);
> >> + }
> >> +
> >> + if (env->msr & (1ULL << MSR_SF)) {
> >> + msr |= (1ULL << MSR_SF);
> >> + }
> >> +
> >> + msr |= (1ULL << MSR_ME);
> >> +
> >> + ext_elog = g_malloc0(sizeof(*ext_elog));
> >
> > g_new0() is preferred for this sort of thing.
>
> I feel g_malloc0() is used to allocate extended logs in other places in
> this file, so I think g_malloc0() should be fine. Please let me know.
>
CODING_STYLE indeed promotes the use of g_new0() but it accepts
the g_malloc(sizeof(*foo)) syntax:
Declarations like
.. code-block:: c
T *v = g_malloc(sizeof(*v))
are acceptable, though.
- [Qemu-ppc] [PATCH v14 0/7] target-ppc/spapr: Add FWNMI support in QEMU for PowerKVM guests, Aravinda Prasad, 2019/09/18
- [Qemu-ppc] [PATCH v14 6/7] migration: Include migration support for machine check handling, Aravinda Prasad, 2019/09/18
- [Qemu-ppc] [PATCH v14 5/7] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls, Aravinda Prasad, 2019/09/18
- [Qemu-ppc] [PATCH v14 7/7] ppc: spapr: Activate the FWNMI functionality, Aravinda Prasad, 2019/09/18
- [Qemu-ppc] [PATCH v14 1/7] Wrapper function to wait on condition for the main loop mutex, Aravinda Prasad, 2019/09/18