qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, paulus@ozlabs.org,
	qemu-ppc@nongnu.org, ganeshgr@linux.ibm.com,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v14 4/7] target/ppc: Build rtas error log upon an MCE
Date: Wed, 25 Sep 2019 08:16:54 +0200	[thread overview]
Message-ID: <20190925081654.2d970842@bahia.lan> (raw)
In-Reply-To: <3282d800-46d5-d270-542c-bcf8bd937944@linux.vnet.ibm.com>

On Wed, 25 Sep 2019 11:31:30 +0530
Aravinda Prasad <aravinda@linux.vnet.ibm.com> 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 <aravinda@linux.vnet.ibm.com>

[...]

> >> +
> >> +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.



  reply	other threads:[~2019-09-25  6:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18  8:12 [Qemu-devel] [PATCH v14 0/7] target-ppc/spapr: Add FWNMI support in QEMU for PowerKVM guests Aravinda Prasad
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 1/7] Wrapper function to wait on condition for the main loop mutex Aravinda Prasad
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 2/7] ppc: spapr: Introduce FWNMI capability Aravinda Prasad
2019-09-25  1:12   ` David Gibson
2019-09-25  5:42     ` Aravinda Prasad
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 3/7] target/ppc: Handle NMI guest exit Aravinda Prasad
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 4/7] target/ppc: Build rtas error log upon an MCE Aravinda Prasad
2019-09-25  1:30   ` David Gibson
2019-09-25  6:01     ` Aravinda Prasad
2019-09-25  6:16       ` Greg Kurz [this message]
2019-09-25  6:48       ` David Gibson
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 5/7] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls Aravinda Prasad
2019-09-25  1:33   ` David Gibson
2019-09-25  6:04     ` Aravinda Prasad
2019-09-18  8:12 ` [Qemu-devel] [PATCH v14 6/7] migration: Include migration support for machine check handling Aravinda Prasad
2019-09-25  1:39   ` David Gibson
2019-09-25  6:12     ` Aravinda Prasad
2019-09-18  8:13 ` [Qemu-devel] [PATCH v14 7/7] ppc: spapr: Activate the FWNMI functionality Aravinda Prasad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190925081654.2d970842@bahia.lan \
    --to=groug@kaod.org \
    --cc=aik@ozlabs.ru \
    --cc=aravinda@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=ganeshgr@linux.ibm.com \
    --cc=paulus@ozlabs.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).