qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] xics/spapr: Only emulated XICS should use RTAS/hypercalls emulation
Date: Tue, 18 Jun 2019 22:18:39 +1000	[thread overview]
Message-ID: <20190618121839.GE3673@umbus.BigPond> (raw)
In-Reply-To: <156077253666.424706.6104557911104491047.stgit@bahia.lan>

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

On Mon, Jun 17, 2019 at 01:55:36PM +0200, Greg Kurz wrote:
> Checking that we're not using the in-kernel XICS is ok with the "xics"
> interrupt controller mode, but it is definitely not enough with the
> other modes since the guest could be using XIVE.
> 
> Ensure XIVE is not in use when emulated XICS RTAS/hypercalls are
> called.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied, thanks.

> ---
>  hw/intc/xics_spapr.c |   53 +++++++++++++++++++++++++-------------------------
>  1 file changed, 27 insertions(+), 26 deletions(-)
> 
> diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> index 8d605b68a7a0..7cd3c93d719f 100644
> --- a/hw/intc/xics_spapr.c
> +++ b/hw/intc/xics_spapr.c
> @@ -41,22 +41,23 @@
>   * Guest interfaces
>   */
>  
> -static bool check_in_kernel_xics(const char *func)
> +static bool check_emulated_xics(SpaprMachineState *spapr, const char *func)
>  {
> -    if (kvm_irqchip_in_kernel()) {
> -        error_report("pseries: %s must never be called for in-kernel XICS",
> +    if (spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT) ||
> +        kvm_irqchip_in_kernel()) {
> +        error_report("pseries: %s must only be called for emulated XICS",
>                       func);
> -        return true;
> +        return false;
>      }
>  
> -    return false;
> +    return true;
>  }
>  
> -#define CHECK_IN_KERNEL_XICS_HCALL              \
> -    do {                                        \
> -        if (check_in_kernel_xics(__func__)) {   \
> -            return H_HARDWARE;                  \
> -        }                                       \
> +#define CHECK_EMULATED_XICS_HCALL(spapr)               \
> +    do {                                               \
> +        if (!check_emulated_xics((spapr), __func__)) { \
> +            return H_HARDWARE;                         \
> +        }                                              \
>      } while (0)
>  
>  static target_ulong h_cppr(PowerPCCPU *cpu, SpaprMachineState *spapr,
> @@ -64,7 +65,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  {
>      target_ulong cppr = args[0];
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      icp_set_cppr(spapr_cpu_state(cpu)->icp, cppr);
>      return H_SUCCESS;
> @@ -76,7 +77,7 @@ static target_ulong h_ipi(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      target_ulong mfrr = args[1];
>      ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), args[0]);
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      if (!icp) {
>          return H_PARAMETER;
> @@ -91,7 +92,7 @@ static target_ulong h_xirr(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  {
>      uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      args[0] = xirr;
>      return H_SUCCESS;
> @@ -102,7 +103,7 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  {
>      uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      args[0] = xirr;
>      args[1] = cpu_get_host_ticks();
> @@ -114,7 +115,7 @@ static target_ulong h_eoi(PowerPCCPU *cpu, SpaprMachineState *spapr,
>  {
>      target_ulong xirr = args[0];
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      icp_eoi(spapr_cpu_state(cpu)->icp, xirr);
>      return H_SUCCESS;
> @@ -127,7 +128,7 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      uint32_t mfrr;
>      uint32_t xirr;
>  
> -    CHECK_IN_KERNEL_XICS_HCALL;
> +    CHECK_EMULATED_XICS_HCALL(spapr);
>  
>      if (!icp) {
>          return H_PARAMETER;
> @@ -141,12 +142,12 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      return H_SUCCESS;
>  }
>  
> -#define CHECK_IN_KERNEL_XICS_RTAS(rets)                 \
> -    do {                                                \
> -        if (check_in_kernel_xics(__func__)) {           \
> -            rtas_st((rets), 0, RTAS_OUT_HW_ERROR);      \
> -            return;                                     \
> -        }                                               \
> +#define CHECK_EMULATED_XICS_RTAS(spapr, rets)          \
> +    do {                                               \
> +        if (!check_emulated_xics((spapr), __func__)) { \
> +            rtas_st((rets), 0, RTAS_OUT_HW_ERROR);     \
> +            return;                                    \
> +        }                                              \
>      } while (0)
>  
>  static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
> @@ -157,7 +158,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      ICSState *ics = spapr->ics;
>      uint32_t nr, srcno, server, priority;
>  
> -    CHECK_IN_KERNEL_XICS_RTAS(rets);
> +    CHECK_EMULATED_XICS_RTAS(spapr, rets);
>  
>      if ((nargs != 3) || (nret != 1)) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> @@ -192,7 +193,7 @@ static void rtas_get_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      ICSState *ics = spapr->ics;
>      uint32_t nr, srcno;
>  
> -    CHECK_IN_KERNEL_XICS_RTAS(rets);
> +    CHECK_EMULATED_XICS_RTAS(spapr, rets);
>  
>      if ((nargs != 1) || (nret != 3)) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> @@ -224,7 +225,7 @@ static void rtas_int_off(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      ICSState *ics = spapr->ics;
>      uint32_t nr, srcno;
>  
> -    CHECK_IN_KERNEL_XICS_RTAS(rets);
> +    CHECK_EMULATED_XICS_RTAS(spapr, rets);
>  
>      if ((nargs != 1) || (nret != 1)) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> @@ -257,7 +258,7 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr,
>      ICSState *ics = spapr->ics;
>      uint32_t nr, srcno;
>  
> -    CHECK_IN_KERNEL_XICS_RTAS(rets);
> +    CHECK_EMULATED_XICS_RTAS(spapr, rets);
>  
>      if ((nargs != 1) || (nret != 1)) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> 

-- 
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: 833 bytes --]

      parent reply	other threads:[~2019-06-19  2:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 11:55 [Qemu-devel] [PATCH] xics/spapr: Only emulated XICS should use RTAS/hypercalls emulation Greg Kurz
2019-06-18  7:09 ` Cédric Le Goater
2019-06-18 12:18 ` 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=20190618121839.GE3673@umbus.BigPond \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.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).