diff mbox series

[1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets

Message ID 20230912113027.63941-2-philmd@linaro.org
State New
Headers show
Series target/ppc: Prohibit target specific KVM prototypes on user emulation | expand

Commit Message

Philippe Mathieu-Daudé Sept. 12, 2023, 11:30 a.m. UTC
kvm_get_radix_page_info() is only defined for ppc targets (in
target/ppc/kvm.c). The declaration is not useful in other targets.
Rename using the 'kvmppc_' prefix following other declarations
from target/ppc/kvm_ppc.h.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/sysemu/kvm.h | 1 -
 target/ppc/kvm_ppc.h | 2 ++
 target/ppc/kvm.c     | 4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

Comments

Michael Tokarev Sept. 12, 2023, 12:32 p.m. UTC | #1
12.09.2023 14:30, Philippe Mathieu-Daudé:
> kvm_get_radix_page_info() is only defined for ppc targets (in
> target/ppc/kvm.c). The declaration is not useful in other targets.
> Rename using the 'kvmppc_' prefix following other declarations
> from target/ppc/kvm_ppc.h.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/sysemu/kvm.h | 1 -
>   target/ppc/kvm_ppc.h | 2 ++
>   target/ppc/kvm.c     | 4 ++--
>   3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index ee9025f8e9..3bcd8f45be 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -551,7 +551,6 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
>    * Returns: 0 on success, or a negative errno on failure.
>    */
>   int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
> -struct ppc_radix_page_info *kvm_get_radix_page_info(void);
>   int kvm_get_max_memslots(void);
>   
>   /* Notify resamplefd for EOI of specific interrupts. */
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 6a4dd9c560..440e93f923 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -89,6 +89,8 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
>   
>   int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
>   
> +struct ppc_radix_page_info *kvmppc_get_radix_page_info(void);
> +
>   #define kvmppc_eieio() \
>       do {                                          \
>           if (kvm_enabled()) {                          \
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 51112bd367..a58708cdfc 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -268,7 +268,7 @@ static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info, Error **errp)
>                        "KVM failed to provide the MMU features it supports");
>   }
>   
> -struct ppc_radix_page_info *kvm_get_radix_page_info(void)
> +struct ppc_radix_page_info *kvmppc_get_radix_page_info(void)
>   {
>       KVMState *s = KVM_STATE(current_accel());
>       struct ppc_radix_page_info *radix_page_info;
> @@ -2372,7 +2372,7 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)
>       }
>   
>   #if defined(TARGET_PPC64)
> -    pcc->radix_page_info = kvm_get_radix_page_info();
> +    pcc->radix_page_info = kvmppc_get_radix_page_info();
>   
>       if ((pcc->pvr & 0xffffff00) == CPU_POWERPC_POWER9_DD1) {
>           /*

I wonder, if it's defined and used in target/ppc/kvm.c only,
why it needs to be in an .h file to begin with, instead of being static?

/mjt
Philippe Mathieu-Daudé Sept. 12, 2023, 12:44 p.m. UTC | #2
On 12/9/23 14:32, Michael Tokarev wrote:
> 12.09.2023 14:30, Philippe Mathieu-Daudé:
>> kvm_get_radix_page_info() is only defined for ppc targets (in
>> target/ppc/kvm.c). The declaration is not useful in other targets.
>> Rename using the 'kvmppc_' prefix following other declarations
>> from target/ppc/kvm_ppc.h.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/sysemu/kvm.h | 1 -
>>   target/ppc/kvm_ppc.h | 2 ++
>>   target/ppc/kvm.c     | 4 ++--
>>   3 files changed, 4 insertions(+), 3 deletions(-)


> I wonder, if it's defined and used in target/ppc/kvm.c only,
> why it needs to be in an .h file to begin with, instead of being static?

Good point, I didn't noticed.
It is this way since it's introduction in commit c64abd1f9c
("spapr: Add ibm,processor-radix-AP-encodings to the device tree").

I'll respin after waiting for more review, thanks!

Phil.
diff mbox series

Patch

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index ee9025f8e9..3bcd8f45be 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -551,7 +551,6 @@  int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
  * Returns: 0 on success, or a negative errno on failure.
  */
 int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
-struct ppc_radix_page_info *kvm_get_radix_page_info(void);
 int kvm_get_max_memslots(void);
 
 /* Notify resamplefd for EOI of specific interrupts. */
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 6a4dd9c560..440e93f923 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -89,6 +89,8 @@  void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset);
 
 int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
 
+struct ppc_radix_page_info *kvmppc_get_radix_page_info(void);
+
 #define kvmppc_eieio() \
     do {                                          \
         if (kvm_enabled()) {                          \
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 51112bd367..a58708cdfc 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -268,7 +268,7 @@  static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info, Error **errp)
                      "KVM failed to provide the MMU features it supports");
 }
 
-struct ppc_radix_page_info *kvm_get_radix_page_info(void)
+struct ppc_radix_page_info *kvmppc_get_radix_page_info(void)
 {
     KVMState *s = KVM_STATE(current_accel());
     struct ppc_radix_page_info *radix_page_info;
@@ -2372,7 +2372,7 @@  static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)
     }
 
 #if defined(TARGET_PPC64)
-    pcc->radix_page_info = kvm_get_radix_page_info();
+    pcc->radix_page_info = kvmppc_get_radix_page_info();
 
     if ((pcc->pvr & 0xffffff00) == CPU_POWERPC_POWER9_DD1) {
         /*