* [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets
2023-10-03 7:04 [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
@ 2023-10-03 7:04 ` Philippe Mathieu-Daudé
2023-10-12 18:49 ` Daniel Henrique Barboza
2023-10-03 7:04 ` [PATCH v2 2/4] hw/ppc/e500: Restrict ppce500_init_mpic_kvm() to KVM Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 7:04 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, David Gibson, Paolo Bonzini, kvm,
Richard Henderson, Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin, 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,
reduce its scope.
Rename using the 'kvmppc_' prefix following other declarations
from target/ppc/kvm_ppc.h.
Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/sysemu/kvm.h | 1 -
target/ppc/kvm.c | 4 ++--
2 files changed, 2 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.c b/target/ppc/kvm.c
index 51112bd367..19fe6d2d00 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)
+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) {
/*
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets
2023-10-03 7:04 ` [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets Philippe Mathieu-Daudé
@ 2023-10-12 18:49 ` Daniel Henrique Barboza
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Henrique Barboza @ 2023-10-12 18:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: David Gibson, Paolo Bonzini, kvm, Richard Henderson,
Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin
On 10/3/23 04:04, Philippe Mathieu-Daudé wrote:
> 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.
>
> Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> include/sysemu/kvm.h | 1 -
> target/ppc/kvm.c | 4 ++--
> 2 files changed, 2 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.c b/target/ppc/kvm.c
> index 51112bd367..19fe6d2d00 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)
> +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) {
> /*
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] hw/ppc/e500: Restrict ppce500_init_mpic_kvm() to KVM
2023-10-03 7:04 [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
2023-10-03 7:04 ` [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets Philippe Mathieu-Daudé
@ 2023-10-03 7:04 ` Philippe Mathieu-Daudé
2023-10-03 7:04 ` [PATCH v2 3/4] target/ppc: Restrict KVM objects to system emulation Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 7:04 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, David Gibson, Paolo Bonzini, kvm,
Richard Henderson, Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin, Philippe Mathieu-Daudé
Inline and guard the single call to kvm_openpic_connect_vcpu()
allows to remove kvm-stub.c.
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index d5b6820d1d..d0e199fb2c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -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,
diff --git a/target/ppc/kvm-stub.c b/target/ppc/kvm-stub.c
deleted file mode 100644
index b98e1d404f..0000000000
--- a/target/ppc/kvm-stub.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * QEMU KVM PPC specific function stubs
- *
- * Copyright Freescale Inc. 2013
- *
- * Author: Alexander Graf <agraf@suse.de>
- *
- * 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;
-}
diff --git a/target/ppc/meson.build b/target/ppc/meson.build
index 4c2635039e..0bff3e39e5 100644
--- a/target/ppc/meson.build
+++ b/target/ppc/meson.build
@@ -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()
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] target/ppc: Restrict KVM objects to system emulation
2023-10-03 7:04 [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
2023-10-03 7:04 ` [PATCH v2 1/4] sysemu/kvm: Restrict kvmppc_get_radix_page_info() to ppc targets Philippe Mathieu-Daudé
2023-10-03 7:04 ` [PATCH v2 2/4] hw/ppc/e500: Restrict ppce500_init_mpic_kvm() to KVM Philippe Mathieu-Daudé
@ 2023-10-03 7:04 ` Philippe Mathieu-Daudé
2023-10-03 7:04 ` [PATCH v2 4/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
2023-10-12 18:42 ` [PATCH v2 0/4] " Philippe Mathieu-Daudé
4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 7:04 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, David Gibson, Paolo Bonzini, kvm,
Richard Henderson, Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin, 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.
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/ppc/meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/ppc/meson.build b/target/ppc/meson.build
index 0bff3e39e5..44462f95cd 100644
--- a/target/ppc/meson.build
+++ b/target/ppc/meson.build
@@ -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',
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] target/ppc: Prohibit target specific KVM prototypes on user emulation
2023-10-03 7:04 [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-10-03 7:04 ` [PATCH v2 3/4] target/ppc: Restrict KVM objects to system emulation Philippe Mathieu-Daudé
@ 2023-10-03 7:04 ` Philippe Mathieu-Daudé
2023-10-12 18:42 ` [PATCH v2 0/4] " Philippe Mathieu-Daudé
4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 7:04 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, David Gibson, Paolo Bonzini, kvm,
Richard Henderson, Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin, 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).
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/kvm_ppc.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 6a4dd9c560..1975fb5ee6 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation
2023-10-03 7:04 [PATCH v2 0/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-10-03 7:04 ` [PATCH v2 4/4] target/ppc: Prohibit target specific KVM prototypes on user emulation Philippe Mathieu-Daudé
@ 2023-10-12 18:42 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-12 18:42 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, David Gibson, Paolo Bonzini, kvm,
Richard Henderson, Cédric Le Goater, qemu-ppc, Kevin Wolf,
Daniel Henrique Barboza, Michael Tokarev, Greg Kurz,
Nicholas Piggin
On 3/10/23 09:04, Philippe Mathieu-Daudé wrote:
> 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
Ping?
^ permalink raw reply [flat|nested] 7+ messages in thread