diff mbox series

[02/25] ppc/xics: assign of the CPU 'intc' pointer under the core

Message ID 20171123132955.1261-3-clg@kaod.org
State New
Headers show
Series spapr: Guest exploitation of the XIVE interrupt controller (POWER9) | expand

Commit Message

Cédric Le Goater Nov. 23, 2017, 1:29 p.m. UTC
The 'intc' pointer of the CPU references the interrupt presenter in
the XICS interrupt mode. When the XIVE interrupt mode is available and
activated, the machine will need to reassign this pointer to reflect
the change.

Moving this assignment under the realize routine of the CPU will ease
the process when the interrupt mode is toggled.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics.c          | 1 -
 hw/ppc/pnv_core.c       | 2 +-
 hw/ppc/spapr_cpu_core.c | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

Comments

David Gibson Nov. 24, 2017, 2:57 a.m. UTC | #1
On Thu, Nov 23, 2017 at 02:29:32PM +0100, Cédric Le Goater wrote:
> The 'intc' pointer of the CPU references the interrupt presenter in
> the XICS interrupt mode. When the XIVE interrupt mode is available and
> activated, the machine will need to reassign this pointer to reflect
> the change.
> 
> Moving this assignment under the realize routine of the CPU will ease
> the process when the interrupt mode is toggled.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/intc/xics.c          | 1 -
>  hw/ppc/pnv_core.c       | 2 +-
>  hw/ppc/spapr_cpu_core.c | 2 +-
>  3 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index e4ccdff8f577..0f2e7273bc8f 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -334,7 +334,6 @@ static void icp_realize(DeviceState *dev, Error **errp)
>      }
>  
>      cpu = POWERPC_CPU(obj);
> -    cpu->intc = OBJECT(icp);
>      icp->cs = CPU(obj);
>  
>      env = &cpu->env;
> diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
> index a066736846f8..90acaac45889 100644
> --- a/hw/ppc/pnv_core.c
> +++ b/hw/ppc/pnv_core.c
> @@ -133,7 +133,7 @@ static void pnv_core_realize_child(Object *child, XICSFabric *xi, Error **errp)
>          return;
>      }
>  
> -    icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
> +    cpu->intc = icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
>      if (local_err) {
>          error_propagate(errp, local_err);
>          return;
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index f8a520a2fa2d..f7cc74512481 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -122,7 +122,7 @@ static void spapr_cpu_core_realize_child(Object *child,
>          goto error;
>      }
>  
> -    icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
> +    cpu->intc = icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
>      if (local_err) {
>          goto error;
>      }
Greg Kurz Nov. 24, 2017, 9:21 a.m. UTC | #2
On Thu, 23 Nov 2017 14:29:32 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> The 'intc' pointer of the CPU references the interrupt presenter in
> the XICS interrupt mode. When the XIVE interrupt mode is available and
> activated, the machine will need to reassign this pointer to reflect
> the change.
> 
> Moving this assignment under the realize routine of the CPU will ease
> the process when the interrupt mode is toggled.
> 

No surprise since this was violating CPU internals actually :)

> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  hw/intc/xics.c          | 1 -
>  hw/ppc/pnv_core.c       | 2 +-
>  hw/ppc/spapr_cpu_core.c | 2 +-
>  3 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index e4ccdff8f577..0f2e7273bc8f 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -334,7 +334,6 @@ static void icp_realize(DeviceState *dev, Error **errp)
>      }
>  
>      cpu = POWERPC_CPU(obj);
> -    cpu->intc = OBJECT(icp);
>      icp->cs = CPU(obj);
>  
>      env = &cpu->env;
> diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
> index a066736846f8..90acaac45889 100644
> --- a/hw/ppc/pnv_core.c
> +++ b/hw/ppc/pnv_core.c
> @@ -133,7 +133,7 @@ static void pnv_core_realize_child(Object *child, XICSFabric *xi, Error **errp)
>          return;
>      }
>  
> -    icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
> +    cpu->intc = icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
>      if (local_err) {
>          error_propagate(errp, local_err);
>          return;
> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index f8a520a2fa2d..f7cc74512481 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -122,7 +122,7 @@ static void spapr_cpu_core_realize_child(Object *child,
>          goto error;
>      }
>  
> -    icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
> +    cpu->intc = icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
>      if (local_err) {
>          goto error;
>      }
diff mbox series

Patch

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index e4ccdff8f577..0f2e7273bc8f 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -334,7 +334,6 @@  static void icp_realize(DeviceState *dev, Error **errp)
     }
 
     cpu = POWERPC_CPU(obj);
-    cpu->intc = OBJECT(icp);
     icp->cs = CPU(obj);
 
     env = &cpu->env;
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index a066736846f8..90acaac45889 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -133,7 +133,7 @@  static void pnv_core_realize_child(Object *child, XICSFabric *xi, Error **errp)
         return;
     }
 
-    icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
+    cpu->intc = icp_create(cs, TYPE_PNV_ICP, xi, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index f8a520a2fa2d..f7cc74512481 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -122,7 +122,7 @@  static void spapr_cpu_core_realize_child(Object *child,
         goto error;
     }
 
-    icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
+    cpu->intc = icp_create(cs, spapr->icp_type, XICS_FABRIC(spapr), &local_err);
     if (local_err) {
         goto error;
     }