accel/nvmm: Expose nvmm_enabled() to common code

Currently nvmm_enabled() is restricted to target-specific code.
By defining CONFIG_NVMM_IS_POSSIBLE we allow its use anywhere.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20250703173248.44995-25-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2025-06-16 10:39:09 +02:00
parent 60c9cec12c
commit b6637bd556
5 changed files with 27 additions and 18 deletions

View file

@ -586,6 +586,7 @@ NetBSD Virtual Machine Monitor (NVMM) CPU support
M: Reinoud Zandijk <reinoud@netbsd.org> M: Reinoud Zandijk <reinoud@netbsd.org>
S: Maintained S: Maintained
F: include/system/nvmm.h F: include/system/nvmm.h
F: accel/stubs/nvmm-stub.c
F: target/i386/nvmm/ F: target/i386/nvmm/
Hosts Hosts

View file

@ -3,5 +3,6 @@ system_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c')) system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
system_stubs_ss.add(when: 'CONFIG_NVMM', if_false: files('nvmm-stub.c'))
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss) specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)

12
accel/stubs/nvmm-stub.c Normal file
View file

@ -0,0 +1,12 @@
/*
* NVMM stubs for QEMU
*
* Copyright (c) Linaro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "system/nvmm.h"
bool nvmm_allowed;

View file

@ -13,17 +13,18 @@
#define QEMU_NVMM_H #define QEMU_NVMM_H
#ifdef COMPILING_PER_TARGET #ifdef COMPILING_PER_TARGET
# ifdef CONFIG_NVMM
#ifdef CONFIG_NVMM # define CONFIG_NVMM_IS_POSSIBLE
# endif /* !CONFIG_NVMM */
int nvmm_enabled(void); #else
# define CONFIG_NVMM_IS_POSSIBLE
#else /* CONFIG_NVMM */
#define nvmm_enabled() (0)
#endif /* CONFIG_NVMM */
#endif /* COMPILING_PER_TARGET */ #endif /* COMPILING_PER_TARGET */
#ifdef CONFIG_NVMM_IS_POSSIBLE
extern bool nvmm_allowed;
#define nvmm_enabled() (nvmm_allowed)
#else /* !CONFIG_NVMM_IS_POSSIBLE */
#define nvmm_enabled() 0
#endif /* !CONFIG_NVMM_IS_POSSIBLE */
#endif /* QEMU_NVMM_H */ #endif /* QEMU_NVMM_H */

View file

@ -46,7 +46,7 @@ struct qemu_machine {
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
static bool nvmm_allowed; bool nvmm_allowed;
static struct qemu_machine qemu_mach; static struct qemu_machine qemu_mach;
static struct nvmm_machine * static struct nvmm_machine *
@ -1192,12 +1192,6 @@ nvmm_accel_init(MachineState *ms)
return 0; return 0;
} }
int
nvmm_enabled(void)
{
return nvmm_allowed;
}
static void static void
nvmm_accel_class_init(ObjectClass *oc, const void *data) nvmm_accel_class_init(ObjectClass *oc, const void *data)
{ {