[PATCH v2 05/14] spapr: nested: register nested-hv api hcalls only for cap-nested-hv

Harsh Prateek Bora posted 14 patches 2 years, 4 months ago
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>
There is a newer version of this series
[PATCH v2 05/14] spapr: nested: register nested-hv api hcalls only for cap-nested-hv
Posted by Harsh Prateek Bora 2 years, 4 months ago
Since cap-nested-hv and cap-nested-papr are mutually exclusive, now it
makes sense to register api specfic hcalls only when respective
capability is enabled, hence this change.

Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
---
 hw/ppc/spapr_caps.c  | 1 +
 hw/ppc/spapr_hcall.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 9b53f19ec8..ed3e638334 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -456,6 +456,7 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
 
     if (!spapr->nested.api) {
         spapr->nested.api = NESTED_API_KVM_HV;
+        spapr_register_nested();
     } else {
         error_setg(errp, "Nested-HV APIs are mutually exclusive/incompatible");
         error_append_hint(errp, "Please use either cap-nested-hv or "
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 522a2396c7..8ae55087ec 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1635,8 +1635,6 @@ static void hypercall_register_types(void)
     spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);
 
     spapr_register_hypercall(KVMPPC_H_UPDATE_DT, h_update_dt);
-
-    spapr_register_nested();
 }
 
 type_init(hypercall_register_types)
-- 
2.39.3
Re: [PATCH v2 05/14] spapr: nested: register nested-hv api hcalls only for cap-nested-hv
Posted by Nicholas Piggin 2 years, 2 months ago
On Thu Oct 12, 2023 at 8:49 PM AEST, Harsh Prateek Bora wrote:
> Since cap-nested-hv and cap-nested-papr are mutually exclusive, now it
> makes sense to register api specfic hcalls only when respective
> capability is enabled, hence this change.
>
> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

I think this basically makes sense anyway since if you don't enable
cap-nested-hv, then no need to register the hcalls. This patch could
be pulled to the front of the series.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> ---
>  hw/ppc/spapr_caps.c  | 1 +
>  hw/ppc/spapr_hcall.c | 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index 9b53f19ec8..ed3e638334 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -456,6 +456,7 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr,
>  
>      if (!spapr->nested.api) {
>          spapr->nested.api = NESTED_API_KVM_HV;
> +        spapr_register_nested();
>      } else {
>          error_setg(errp, "Nested-HV APIs are mutually exclusive/incompatible");
>          error_append_hint(errp, "Please use either cap-nested-hv or "
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 522a2396c7..8ae55087ec 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1635,8 +1635,6 @@ static void hypercall_register_types(void)
>      spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);
>  
>      spapr_register_hypercall(KVMPPC_H_UPDATE_DT, h_update_dt);
> -
> -    spapr_register_nested();
>  }
>  
>  type_init(hypercall_register_types)