All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Cédric Le Goater" <clg@fr.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	Greg Kurz <gkurz@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] spapr: compute interrupt vector address from LPCR
Date: Tue, 29 Mar 2016 15:35:48 +1100	[thread overview]
Message-ID: <20160329043548.GD15156@voom.fritz.box> (raw)
In-Reply-To: <1458833333-24103-1-git-send-email-clg@fr.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 4135 bytes --]

On Thu, Mar 24, 2016 at 04:28:53PM +0100, Cédric Le Goater wrote:
> This address is changed by the linux kernel using the H_SET_MODE hcall
> and needs to be migrated in order to restart a spapr VM running in
> TCG. This can be done using the AIL bits from the LPCR register.
> 
> The patch introduces a spapr_h_set_mode_resource_addr() helper to
> share some code with the H_SET_MODE hcall.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
>  hw/ppc/spapr.c         |   21 +++++++++++++++++++++
>  hw/ppc/spapr_hcall.c   |   13 ++-----------
>  include/hw/ppc/spapr.h |   14 ++++++++++++++
>  3 files changed, 37 insertions(+), 11 deletions(-)
> 
> Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr.c
> ===================================================================
> --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr.c
> +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr.c
> @@ -1244,6 +1244,24 @@ static bool spapr_vga_init(PCIBus *pci_b
>      }
>  }
>  
> +static int load_excp_prefix(void)
> +{
> +    CPUState *cs;
> +
> +    CPU_FOREACH(cs) {
> +        CPUPPCState *env = &POWERPC_CPU(cs)->env;
> +        int ail = (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT;
> +
> +        env->excp_prefix = spapr_h_set_mode_resource_addr(ail);
> +        if (env->excp_prefix == H_UNSUPPORTED_FLAG) {
> +            error_report("LPCR has an invalid AIL value");
> +            return -EINVAL;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  static int spapr_post_load(void *opaque, int version_id)
>  {
>      sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
> @@ -1257,6 +1275,9 @@ static int spapr_post_load(void *opaque,
>          err = spapr_rtc_import_offset(spapr->rtc, spapr->rtc_offset);
>      }
>  
> +    if (!err) {
> +        err = load_excp_prefix();
> +    }
>      return err;
>  }

As Greg says, it seems like this would make more sense in
cpu_post_load().


> Index: qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h
> ===================================================================
> --- qemu-dgibson-for-2.6.git.orig/include/hw/ppc/spapr.h
> +++ qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h
> @@ -561,6 +561,20 @@ struct sPAPREventLogEntry {
>      QTAILQ_ENTRY(sPAPREventLogEntry) next;
>  };
>  
> +static inline target_ulong spapr_h_set_mode_resource_addr(target_ulong mflags)
> +{
> +    switch (mflags) {
> +    case H_SET_MODE_ADDR_TRANS_NONE:
> +        return 0;
> +    case H_SET_MODE_ADDR_TRANS_0001_8000:
> +        return 0x18000;
> +    case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000:
> +        return 0xC000000000004000ULL;
> +    default:
> +        return H_UNSUPPORTED_FLAG;
> +    }
> +}

I'd like to see a different name for this function, and to move it
into target-ppc, since I imagine we'll want to re-use it for mtlpcr
(and/or mtmsr) once we do the powernv machine type.

>  void spapr_events_init(sPAPRMachineState *sm);
>  void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq);
>  int spapr_h_cas_compose_response(sPAPRMachineState *sm,
> Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c
> ===================================================================
> --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr_hcall.c
> +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c
> @@ -835,17 +835,8 @@ static target_ulong h_set_mode_resource_
>          return H_P4;
>      }
>  
> -    switch (mflags) {
> -    case H_SET_MODE_ADDR_TRANS_NONE:
> -        prefix = 0;
> -        break;
> -    case H_SET_MODE_ADDR_TRANS_0001_8000:
> -        prefix = 0x18000;
> -        break;
> -    case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000:
> -        prefix = 0xC000000000004000ULL;
> -        break;
> -    default:
> +    prefix = spapr_h_set_mode_resource_addr(mflags);
> +    if (prefix == H_UNSUPPORTED_FLAG) {
>          return H_UNSUPPORTED_FLAG;
>      }
>  
> 

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2016-03-29  4:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 15:28 [Qemu-devel] [PATCH] spapr: compute interrupt vector address from LPCR Cédric Le Goater
2016-03-25 11:45 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-03-29  7:13   ` Cédric Le Goater
2016-03-29  4:35 ` David Gibson [this message]

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=20160329043548.GD15156@voom.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@fr.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.