target/ppc: Prohibit target specific KVM prototypes on user emulation
Subsystems (2)
v2 cover target/ppc: Prohibit target specific KVM prototypes on user emulation
Since v1:
- Addressed Michael review comments,
- Added Daniel R-b tag.
Implement Kevin's suggestion to remove KVM declarations for user emulation builds, so if KVM prototype are used we directly get a compile failure.
Philippe Mathieu-Daudé (4):
sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets hw/ppc/e500: Restrict ppce500_init_mpic_kvm() to KVM target/ppc: Restrict KVM objects to system emulation target/ppc: Prohibit target specific KVM prototypes on user emulation
include/sysemu/kvm.h | 1 - target/ppc/kvm_ppc.h | 4 ++++ hw/ppc/e500.c | 4 ++++ target/ppc/kvm-stub.c | 19 ------------------- target/ppc/kvm.c | 4 ++-- target/ppc/meson.build | 2 +- 6 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 target/ppc/kvm-stub.c
Signature · 1 line
2.41.0
PATCH v2 1/4 sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets
kvm_get_radix_page_info() is only defined for ppc targets (in target/ppc/kvm.c). The declaration is not useful in other targets, reduce its scope.
Rename using the 'kvmppc_' prefix following other declarations from target/ppc/kvm_ppc.h.
--- include/sysemu/kvm.h | 1 - target/ppc/kvm.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
include/sysemu/kvm.h +0 -1
@@ -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. */
target/ppc/kvm.c +2 -2
@@ -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 ) +static 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 ) {/*
Signature · 1 line
2.41.0
Re: [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets
Quoted 9 lines · Philippe Mathieu-Daudé
kvm_get_radix_page_info()is only defined for ppc targets (intarget/ppc/kvm.c). The declaration is not useful in other targets, reduce its scope.
Rename using the 'kvmppc_' prefix following other declarations fromtarget/ppc/kvm_ppc.h.Suggested-by Michael Tokarev <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 38 lines
include/sysemu/kvm.h | 1 - target/ppc/kvm.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)include/sysemu/kvm.h +0
-1@@ -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. */ target/ppc/kvm.c +2
-2@@ -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 ) +static 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 ) {/*
PATCH v2 2/4 hw/ppc/e500: Restrict ppce500_init_mpic_kvm() to KVM
In reply to Philippe Mathieu-DaudéInline and guard the single call to kvm_openpic_connect_vcpu() allows to remove kvm-stub.c.
--- hw/ppc/e500.c | 4 ++++ target/ppc/kvm-stub.c | 19 ------------------- target/ppc/meson.build | 2 +- 3 files changed, 5 insertions(+), 20 deletions(-) delete mode 100644 target/ppc/kvm-stub.c
hw/ppc/e500.c +4 -0
@@ -834,6 +834,7 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,static DeviceState *ppce500_init_mpic_kvm (const PPCE500MachineClass *pmc,IrqLines *irqs,Error **errp) { +#ifdef CONFIG_KVM DeviceState *dev;CPUState *cs;
@@ -854,6 +855,9 @@ static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc, }return dev; +#else +g_assert_not_reached (); +#endif } static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
target/ppc/kvm-stub.c deleted +0 -19
@@ -1,19 +0,0 @@ -/* -* QEMU KVM PPC specific function stubs -* -* Copyright Freescale Inc. 2013 -* -* Author: Alexander Graf <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ -#include "qemu/osdep.h" -#include "cpu.h" -#include "hw/ppc/openpic_kvm.h" - -int kvm_openpic_connect_vcpu (DeviceState *d,CPUState *cs) -{ -return -EINVAL ; -}
target/ppc/meson.build +1 -1
@@ -30,7 +30,7 @@ gen = [ ] ppc_ss.add(when: 'CONFIG_TCG', if_true: gen) -ppc_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) +ppc_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) ppc_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user_only_helper.c')) ppc_system_ss = ss.source_set()
Signature · 1 line
2.41.0
PATCH v2 3/4 target/ppc: Restrict KVM objects to system emulation
In reply to Philippe Mathieu-DaudéCONFIG_KVM is always FALSE on user emulation, so 'kvm.c' won't be added to ppc_ss[] source set; direcly use the system specific ppc_system_ss[] source set.
--- target/ppc/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/meson.build +1 -1
@@ -30,7 +30,6 @@ gen = [ ] ppc_ss.add(when: 'CONFIG_TCG', if_true: gen) -ppc_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) ppc_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user_only_helper.c')) ppc_system_ss = ss.source_set()
@@ -46,6 +45,7 @@ ppc_system_ss.add(when: 'CONFIG_TCG', if_true: files( ), if_false: files( 'tcg-stub.c', )) +ppc_system_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) ppc_system_ss.add(when: 'TARGET_PPC64', if_true: files( 'compat.c',
Signature · 1 line
2.41.0
PATCH v2 4/4 target/ppc: Prohibit target specific KVM prototypes on user emulation
In reply to Philippe Mathieu-DaudéNone of these target-specific prototypes should be used by user emulation. Remove their declaration there, so we get a compile failure if ever used (instead of having to deal with linker and its possible optimizations, such dead code removal).
--- target/ppc/kvm_ppc.h | 4 ++++ 1 file changed, 4 insertions(+)
target/ppc/kvm_ppc.h +4 -0
@@ -13,6 +13,10 @@#include "exec/hwaddr.h" #include "cpu.h" +#ifdef CONFIG_USER_ONLY +#error Cannot include kvm_ppc.h from user emulation +#endif +#ifdef CONFIG_KVM uint32_t kvmppc_get_tbfreq (void );
Signature · 1 line
2.41.0
Quoted 8 lines · Philippe Mathieu-Daudé
Since v1:
- Addressed Michael review comments,
- Added Daniel R-b tag.Implement Kevin's suggestion to remove KVM declarations for user emulation builds, so if KVM prototype are used we directly get a compile failure.
Quoted 5 lines
Philippe Mathieu-Daudé (4):
sysemu/kvm: Restrictkvmppc_get_radix_page_info()to ppc targets hw/ppc/e500: Restrictppce500_init_mpic_kvm()to KVM target/ppc: Restrict KVM objects to system emulation target/ppc: Prohibit target specific KVM prototypes on user emulation
Ping?