mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
cpus: Have cpu_class_init_props() per user / system emulation
Rather than maintaining a mix of system / user code for CPU class properties, move system properties to cpu-system.c and user ones to the new cpu-user.c unit. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250123234415.59850-18-philmd@linaro.org>
This commit is contained in:
parent
530c7139f6
commit
e3a575f560
5 changed files with 72 additions and 59 deletions
|
@ -3791,6 +3791,7 @@ Overall usermode emulation
|
||||||
M: Riku Voipio <riku.voipio@iki.fi>
|
M: Riku Voipio <riku.voipio@iki.fi>
|
||||||
S: Maintained
|
S: Maintained
|
||||||
F: accel/tcg/user-exec*.c
|
F: accel/tcg/user-exec*.c
|
||||||
|
F: hw/core/cpu-user.c
|
||||||
F: include/user/
|
F: include/user/
|
||||||
F: common-user/
|
F: common-user/
|
||||||
|
|
||||||
|
|
58
cpu-target.c
58
cpu-target.c
|
@ -19,15 +19,12 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "hw/qdev-core.h"
|
|
||||||
#include "hw/qdev-properties.h"
|
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/qemu-print.h"
|
#include "qemu/qemu-print.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
#include "hw/core/sysemu-cpu-ops.h"
|
#include "hw/core/sysemu-cpu-ops.h"
|
||||||
#include "exec/address-spaces.h"
|
#include "exec/address-spaces.h"
|
||||||
#include "exec/memory.h"
|
|
||||||
#endif
|
#endif
|
||||||
#include "system/accel-ops.h"
|
#include "system/accel-ops.h"
|
||||||
#include "system/cpus.h"
|
#include "system/cpus.h"
|
||||||
|
@ -178,61 +175,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)
|
||||||
accel_cpu_common_unrealize(cpu);
|
accel_cpu_common_unrealize(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This can't go in hw/core/cpu.c because that file is compiled only
|
|
||||||
* once for both user-mode and system builds.
|
|
||||||
*/
|
|
||||||
static const Property cpu_common_props[] = {
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
|
||||||
/*
|
|
||||||
* Create a property for the user-only object, so users can
|
|
||||||
* adjust prctl(PR_SET_UNALIGN) from the command-line.
|
|
||||||
* Has no effect if the target does not support the feature.
|
|
||||||
*/
|
|
||||||
DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState,
|
|
||||||
prctl_unalign_sigbus, false),
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Create a memory property for system CPU object, so users can
|
|
||||||
* wire up its memory. The default if no link is set up is to use
|
|
||||||
* the system address space.
|
|
||||||
*/
|
|
||||||
DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
|
|
||||||
MemoryRegion *),
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
|
||||||
static bool cpu_get_start_powered_off(Object *obj, Error **errp)
|
|
||||||
{
|
|
||||||
CPUState *cpu = CPU(obj);
|
|
||||||
return cpu->start_powered_off;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp)
|
|
||||||
{
|
|
||||||
CPUState *cpu = CPU(obj);
|
|
||||||
cpu->start_powered_off = value;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void cpu_class_init_props(DeviceClass *dc)
|
|
||||||
{
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
|
||||||
ObjectClass *oc = OBJECT_CLASS(dc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We can't use DEFINE_PROP_BOOL in the Property array for this
|
|
||||||
* property, because we want this to be settable after realize.
|
|
||||||
*/
|
|
||||||
object_class_property_add_bool(oc, "start-powered-off",
|
|
||||||
cpu_get_start_powered_off,
|
|
||||||
cpu_set_start_powered_off);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
device_class_set_props(dc, cpu_common_props);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_exec_initfn(CPUState *cpu)
|
void cpu_exec_initfn(CPUState *cpu)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
|
|
|
@ -20,7 +20,10 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
#include "exec/memory.h"
|
||||||
#include "exec/tswap.h"
|
#include "exec/tswap.h"
|
||||||
|
#include "hw/qdev-core.h"
|
||||||
|
#include "hw/qdev-properties.h"
|
||||||
#include "hw/core/sysemu-cpu-ops.h"
|
#include "hw/core/sysemu-cpu-ops.h"
|
||||||
|
|
||||||
bool cpu_paging_enabled(const CPUState *cpu)
|
bool cpu_paging_enabled(const CPUState *cpu)
|
||||||
|
@ -147,3 +150,40 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const Property cpu_system_props[] = {
|
||||||
|
/*
|
||||||
|
* Create a memory property for system CPU object, so users can
|
||||||
|
* wire up its memory. The default if no link is set up is to use
|
||||||
|
* the system address space.
|
||||||
|
*/
|
||||||
|
DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
|
||||||
|
MemoryRegion *),
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool cpu_get_start_powered_off(Object *obj, Error **errp)
|
||||||
|
{
|
||||||
|
CPUState *cpu = CPU(obj);
|
||||||
|
return cpu->start_powered_off;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp)
|
||||||
|
{
|
||||||
|
CPUState *cpu = CPU(obj);
|
||||||
|
cpu->start_powered_off = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_class_init_props(DeviceClass *dc)
|
||||||
|
{
|
||||||
|
ObjectClass *oc = OBJECT_CLASS(dc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't use DEFINE_PROP_BOOL in the Property array for this
|
||||||
|
* property, because we want this to be settable after realize.
|
||||||
|
*/
|
||||||
|
object_class_property_add_bool(oc, "start-powered-off",
|
||||||
|
cpu_get_start_powered_off,
|
||||||
|
cpu_set_start_powered_off);
|
||||||
|
|
||||||
|
device_class_set_props(dc, cpu_system_props);
|
||||||
|
}
|
||||||
|
|
27
hw/core/cpu-user.c
Normal file
27
hw/core/cpu-user.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* QEMU CPU model (user specific)
|
||||||
|
*
|
||||||
|
* Copyright (c) Linaro, Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "hw/qdev-core.h"
|
||||||
|
#include "hw/qdev-properties.h"
|
||||||
|
#include "hw/core/cpu.h"
|
||||||
|
|
||||||
|
static const Property cpu_user_props[] = {
|
||||||
|
/*
|
||||||
|
* Create a property for the user-only object, so users can
|
||||||
|
* adjust prctl(PR_SET_UNALIGN) from the command-line.
|
||||||
|
* Has no effect if the target does not support the feature.
|
||||||
|
*/
|
||||||
|
DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState,
|
||||||
|
prctl_unalign_sigbus, false),
|
||||||
|
};
|
||||||
|
|
||||||
|
void cpu_class_init_props(DeviceClass *dc)
|
||||||
|
{
|
||||||
|
device_class_set_props(dc, cpu_user_props);
|
||||||
|
}
|
|
@ -46,4 +46,7 @@ system_ss.add(files(
|
||||||
'vm-change-state-handler.c',
|
'vm-change-state-handler.c',
|
||||||
'clock-vmstate.c',
|
'clock-vmstate.c',
|
||||||
))
|
))
|
||||||
user_ss.add(files('qdev-user.c'))
|
user_ss.add(files(
|
||||||
|
'cpu-user.c',
|
||||||
|
'qdev-user.c',
|
||||||
|
))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue