spapr: Make the nested code TCG only
v2 cover spapr: Make the nested code TCG only
The spapr virtual hypervisor implementation of the nested KVM API depends on the first level guest to be emulated by TCG. So move the whole code under CONFIG_TCG.
v2:
- Created hypercall_register_nested instead of reusing hypercall_register_softmmu;
- Rearranged the ifdef a bit to keep the hypercall_register_* functions closer;
- Dropped the more paranoid patch that checked for KVM at every call. I couldn't convince myself anymore that it was necessary.
v1:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-03/msg00412.html
Fabiano Rosas (2):
spapr: Move hypercall_register_softmmu
spapr: Move nested KVM hypercalls under a TCG only config.
hw/ppc/spapr_hcall.c | 74 ++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 30 deletions(-)
Signature · 1 line
2.35.1
PATCH v2 1/2 spapr: Move hypercall_register_softmmu
I'm moving this because next patch will add more code under the ifdef and it will be cleaner if we keep them together.
Also switch the ifdef branches to make it more convenient to add code under CONFIG_TCG in the next patch.
--- hw/ppc/spapr_hcall.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
hw/ppc/spapr_hcall.c +25 -25
@@ -1473,31 +1473,6 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode,return H_FUNCTION ; } -#ifndef CONFIG_TCG -static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr, -target_ulong opcode,target_ulong *args) -{ -g_assert_not_reached (); -} - -static void hypercall_register_softmmu (void ) -{ -/* hcall-pft */ -spapr_register_hypercall (H_ENTER , h_softmmu); -spapr_register_hypercall (H_REMOVE , h_softmmu); -spapr_register_hypercall (H_PROTECT , h_softmmu); -spapr_register_hypercall (H_READ , h_softmmu); - -/* hcall-bulk */ -spapr_register_hypercall (H_BULK_REMOVE , h_softmmu); -} -#else -static void hypercall_register_softmmu (void ) -{ -/* DO NOTHING */ -} -#endif -/* TCG only */ #define PRTS_MASK 0x1f
@@ -1825,6 +1800,31 @@ out_restore_l1: spapr_cpu->nested_host_state =NULL ; } +#ifdef CONFIG_TCG +static void hypercall_register_softmmu (void ) +{ +/* DO NOTHING */ +} +#else +static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr, +target_ulong opcode,target_ulong *args) +{ +g_assert_not_reached (); +} + +static void hypercall_register_softmmu (void ) +{ +/* hcall-pft */ +spapr_register_hypercall (H_ENTER , h_softmmu); +spapr_register_hypercall (H_REMOVE , h_softmmu); +spapr_register_hypercall (H_PROTECT , h_softmmu); +spapr_register_hypercall (H_READ , h_softmmu); + +/* hcall-bulk */ +spapr_register_hypercall (H_BULK_REMOVE , h_softmmu); +} +#endif +static void hypercall_register_types (void ) {hypercall_register_softmmu ();
Signature · 1 line
2.35.1
Re: [PATCH v2 1/2] spapr: Move hypercall_register_softmmu
Excerpts from Fabiano Rosas's message of March 26, 2022 8:11 am:
Quoted 5 lines
I'm moving this because next patch will add more code under the ifdef and it will be cleaner if we keep them together.
Also switch the ifdef branches to make it more convenient to add code under
CONFIG_TCGin the next patch.
Quoted 78 lines
Signed-off-by Fabiano Rosas <[email protected]>--- hw/ppc/spapr_hcall.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-)hw/ppc/spapr_hcall.c +25
-25@@ -1473,31 +1473,6 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode,return H_FUNCTION ; } -#ifndef CONFIG_TCG -static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr, -target_ulong opcode,target_ulong *args) -{ -g_assert_not_reached (); -} - -static void hypercall_register_softmmu (void ) -{ -/* hcall-pft */ -spapr_register_hypercall (H_ENTER , h_softmmu); -spapr_register_hypercall (H_REMOVE , h_softmmu); -spapr_register_hypercall (H_PROTECT , h_softmmu); -spapr_register_hypercall (H_READ , h_softmmu); - -/* hcall-bulk */ -spapr_register_hypercall (H_BULK_REMOVE , h_softmmu); -} -#else -static void hypercall_register_softmmu (void ) -{ -/* DO NOTHING */ -} -#endif -/* TCG only */ #define PRTS_MASK 0x1f@@ -1825,6 +1800,31 @@ out_restore_l1: spapr_cpu->nested_host_state =NULL ; } +#ifdef CONFIG_TCG +static void hypercall_register_softmmu (void ) +{ +/* DO NOTHING */ +} +#else +static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr, +target_ulong opcode,target_ulong *args) +{ +g_assert_not_reached (); +} + +static void hypercall_register_softmmu (void ) +{ +/* hcall-pft */ +spapr_register_hypercall (H_ENTER , h_softmmu); +spapr_register_hypercall (H_REMOVE , h_softmmu); +spapr_register_hypercall (H_PROTECT , h_softmmu); +spapr_register_hypercall (H_READ , h_softmmu); + +/* hcall-bulk */ +spapr_register_hypercall (H_BULK_REMOVE , h_softmmu); +} +#endif +static void hypercall_register_types (void ) {hypercall_register_softmmu ();Signature · 1 line
2.35.1
PATCH v2 2/2 spapr: Move nested KVM hypercalls under a TCG only config.
In reply to Fabiano RosasThese are the spapr virtual hypervisor implementation of the nested KVM API. They only make sense when running with TCG.
--- hw/ppc/spapr_hcall.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
hw/ppc/spapr_hcall.c +20 -6
@@ -1473,7 +1473,7 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode,return H_FUNCTION ; } -/* TCG only */ +#ifdef CONFIG_TCG #define PRTS_MASK 0x1f static target_ulong h_set_ptbl(PowerPCCPU *cpu,
@@ -1800,18 +1800,35 @@ out_restore_l1: spapr_cpu->nested_host_state = NULL; } -#ifdef CONFIG_TCG +static void hypercall_register_nested (void ) +{ +spapr_register_hypercall (KVMPPC_H_SET_PARTITION_TABLE , h_set_ptbl); +spapr_register_hypercall (KVMPPC_H_ENTER_NESTED , h_enter_nested); +spapr_register_hypercall (KVMPPC_H_TLB_INVALIDATE , h_tlb_invalidate); +spapr_register_hypercall (KVMPPC_H_COPY_TOFROM_GUEST , h_copy_tofrom_guest); +} +static void hypercall_register_softmmu (void ) {/* DO NOTHING */ }#else +void spapr_exit_nested (PowerPCCPU *cpu,int excp) +{ +g_assert_not_reached (); +} +static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr,target_ulong opcode,target_ulong *args) {g_assert_not_reached (); } +static void hypercall_register_nested (void ) +{ +/* DO NOTHING */ +} +static void hypercall_register_softmmu (void ) {/* hcall-pft */
@@ -1881,10 +1898,7 @@ static void hypercall_register_types(void)spapr_register_hypercall (KVMPPC_H_UPDATE_DT , h_update_dt); -spapr_register_hypercall (KVMPPC_H_SET_PARTITION_TABLE , h_set_ptbl); -spapr_register_hypercall (KVMPPC_H_ENTER_NESTED , h_enter_nested); -spapr_register_hypercall (KVMPPC_H_TLB_INVALIDATE , h_tlb_invalidate); -spapr_register_hypercall (KVMPPC_H_COPY_TOFROM_GUEST , h_copy_tofrom_guest); +hypercall_register_nested (); }type_init (hypercall_register_types)
Signature · 1 line
2.35.1
Re: [PATCH v2 2/2] spapr: Move nested KVM hypercalls under a TCG only config.
Excerpts from Fabiano Rosas's message of March 26, 2022 8:11 am:
Quoted 2 lines
These are the spapr virtual hypervisor implementation of the nested KVM API. They only make sense when running with TCG.
Quoted 72 lines
Signed-off-by Fabiano Rosas <[email protected]>--- hw/ppc/spapr_hcall.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)hw/ppc/spapr_hcall.c +20
-6@@ -1473,7 +1473,7 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode,return H_FUNCTION ; } -/* TCG only */ +#ifdef CONFIG_TCG #define PRTS_MASK 0x1f static target_ulong h_set_ptbl(PowerPCCPU *cpu,@@ -1800,18 +1800,35 @@ out_restore_l1: spapr_cpu->nested_host_state = NULL; } -#ifdef CONFIG_TCG +static void hypercall_register_nested (void ) +{ +spapr_register_hypercall (KVMPPC_H_SET_PARTITION_TABLE , h_set_ptbl); +spapr_register_hypercall (KVMPPC_H_ENTER_NESTED , h_enter_nested); +spapr_register_hypercall (KVMPPC_H_TLB_INVALIDATE , h_tlb_invalidate); +spapr_register_hypercall (KVMPPC_H_COPY_TOFROM_GUEST , h_copy_tofrom_guest); +} +static void hypercall_register_softmmu (void ) {/* DO NOTHING */ }#else +void spapr_exit_nested (PowerPCCPU *cpu,int excp) +{ +g_assert_not_reached (); +} +static target_ulong h_softmmu (PowerPCCPU *cpu,SpaprMachineState *spapr,target_ulong opcode,target_ulong *args) {g_assert_not_reached (); } +static void hypercall_register_nested (void ) +{ +/* DO NOTHING */ +} +static void hypercall_register_softmmu (void ) {/* hcall-pft */ @@ -1881,10 +1898,7 @@ static void hypercall_register_types(void)spapr_register_hypercall (KVMPPC_H_UPDATE_DT , h_update_dt); -spapr_register_hypercall (KVMPPC_H_SET_PARTITION_TABLE , h_set_ptbl); -spapr_register_hypercall (KVMPPC_H_ENTER_NESTED , h_enter_nested); -spapr_register_hypercall (KVMPPC_H_TLB_INVALIDATE , h_tlb_invalidate); -spapr_register_hypercall (KVMPPC_H_COPY_TOFROM_GUEST , h_copy_tofrom_guest); +hypercall_register_nested (); }type_init (hypercall_register_types)Signature · 1 line
2.35.1
Daniel Henrique Barboza
AppliedQueued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,
Daniel
Quoted 25 lines · Fabiano Rosas
The spapr virtual hypervisor implementation of the nested KVM API depends on the first level guest to be emulated by TCG. So move the whole code under
CONFIG_TCG.v2:
- Created
hypercall_register_nestedinstead of reusinghypercall_register_softmmu;- Rearranged the ifdef a bit to keep the hypercall_register_* functions closer;
- Dropped the more paranoid patch that checked for KVM at every call. I couldn't convince myself anymore that it was necessary.
v1:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-03/msg00412.htmlFabiano Rosas (2):
spapr: Movehypercall_register_softmmu
spapr: Move nested KVM hypercalls under a TCG only config.hw/ppc/spapr_hcall.c | 74 ++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 30 deletions(-)