Merge remote-tracking branch 'afaerber/qom-cpu' into staging
* afaerber/qom-cpu: target-i386: Postpone cpuid_level update to realize time target-i386: Use define for cpuid vendor string size target-i386: Separate feature string parsing from CPU model lookup target-i386/cpu.c: Coding style fixes qdev: qdev_create(): use error_report() instead of hw_error() sysemu.h: Include qemu-types.h instead of qemu-common.h Create qemu-types.h for struct typedefs qlist.h: Do not include qemu-common.h qga/channel-posix.c: Include headers it needs qapi/qmp-registry.c: Include headers it needs ui/vnc-palette.c: Include headers it needs user: Rename qemu-types.h to qemu-user-types.h user: Move *-user/qemu-types.h to main directory Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
commit
1c97e303d4
@ -1,24 +0,0 @@
|
||||
#ifndef QEMU_TYPES_H
|
||||
#define QEMU_TYPES_H
|
||||
#include "cpu.h"
|
||||
|
||||
#ifdef TARGET_ABI32
|
||||
typedef uint32_t abi_ulong;
|
||||
typedef int32_t abi_long;
|
||||
#define TARGET_ABI_FMT_lx "%08x"
|
||||
#define TARGET_ABI_FMT_ld "%d"
|
||||
#define TARGET_ABI_FMT_lu "%u"
|
||||
#define TARGET_ABI_BITS 32
|
||||
#else
|
||||
typedef target_ulong abi_ulong;
|
||||
typedef target_long abi_long;
|
||||
#define TARGET_ABI_FMT_lx TARGET_FMT_lx
|
||||
#define TARGET_ABI_FMT_ld TARGET_FMT_ld
|
||||
#define TARGET_ABI_FMT_lu TARGET_FMT_lu
|
||||
#define TARGET_ABI_BITS TARGET_LONG_BITS
|
||||
/* for consistency, define ABI32 too */
|
||||
#if TARGET_ABI_BITS == 32
|
||||
#define TARGET_ABI32 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
@ -11,7 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#endif /* DEBUG_REMAP */
|
||||
|
||||
#include "qemu-types.h"
|
||||
#include "qemu-user-types.h"
|
||||
|
||||
enum BSDType {
|
||||
target_freebsd,
|
||||
|
@ -180,7 +180,7 @@ static inline void tswap64s(uint64_t *s)
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#include <assert.h>
|
||||
#include "qemu-types.h"
|
||||
#include "qemu-user-types.h"
|
||||
|
||||
/* On some host systems the guest address space is reserved on the host.
|
||||
* This allows the guest address space to be offset to a convenient location.
|
||||
|
@ -3,20 +3,11 @@
|
||||
|
||||
#include "qemu-queue.h"
|
||||
#include "qemu-option.h"
|
||||
#include "qemu-types.h"
|
||||
#include "qemu/object.h"
|
||||
#include "hw/irq.h"
|
||||
#include "error.h"
|
||||
|
||||
typedef struct Property Property;
|
||||
|
||||
typedef struct PropertyInfo PropertyInfo;
|
||||
|
||||
typedef struct CompatProperty CompatProperty;
|
||||
|
||||
typedef struct BusState BusState;
|
||||
|
||||
typedef struct BusClass BusClass;
|
||||
|
||||
enum DevState {
|
||||
DEV_STATE_CREATED = 1,
|
||||
DEV_STATE_INITIALIZED,
|
||||
|
@ -109,10 +109,12 @@ DeviceState *qdev_create(BusState *bus, const char *name)
|
||||
dev = qdev_try_create(bus, name);
|
||||
if (!dev) {
|
||||
if (bus) {
|
||||
hw_error("Unknown device '%s' for bus '%s'\n", name,
|
||||
object_get_typename(OBJECT(bus)));
|
||||
error_report("Unknown device '%s' for bus '%s'\n", name,
|
||||
object_get_typename(OBJECT(bus)));
|
||||
abort();
|
||||
} else {
|
||||
hw_error("Unknown device '%s' for default sysbus\n", name);
|
||||
error_report("Unknown device '%s' for default sysbus\n", name);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#endif /* DEBUG_REMAP */
|
||||
|
||||
#include "qemu-types.h"
|
||||
#include "qemu-user-types.h"
|
||||
|
||||
#include "thunk.h"
|
||||
#include "syscall_defs.h"
|
||||
|
@ -12,6 +12,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include "qapi/qmp-core.h"
|
||||
|
||||
static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "compiler.h"
|
||||
#include "config-host.h"
|
||||
#include "qemu-types.h"
|
||||
|
||||
#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)
|
||||
#define WORDS_ALIGNED
|
||||
@ -21,15 +22,6 @@
|
||||
|
||||
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
|
||||
|
||||
typedef struct QEMUTimer QEMUTimer;
|
||||
typedef struct QEMUFile QEMUFile;
|
||||
typedef struct QEMUBH QEMUBH;
|
||||
typedef struct DeviceState DeviceState;
|
||||
|
||||
struct Monitor;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct MigrationParams MigrationParams;
|
||||
|
||||
/* we put basic includes here to avoid repeating them in device drivers */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -258,48 +250,6 @@ struct ParallelIOArg {
|
||||
|
||||
typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
|
||||
|
||||
/* A load of opaque types so that device init declarations don't have to
|
||||
pull in all the real definitions. */
|
||||
typedef struct NICInfo NICInfo;
|
||||
typedef struct HCIInfo HCIInfo;
|
||||
typedef struct AudioState AudioState;
|
||||
typedef struct BlockDriverState BlockDriverState;
|
||||
typedef struct DriveInfo DriveInfo;
|
||||
typedef struct DisplayState DisplayState;
|
||||
typedef struct DisplayChangeListener DisplayChangeListener;
|
||||
typedef struct DisplaySurface DisplaySurface;
|
||||
typedef struct PixelFormat PixelFormat;
|
||||
typedef struct QemuConsole QemuConsole;
|
||||
typedef struct CharDriverState CharDriverState;
|
||||
typedef struct MACAddr MACAddr;
|
||||
typedef struct NetClientState NetClientState;
|
||||
typedef struct i2c_bus i2c_bus;
|
||||
typedef struct ISABus ISABus;
|
||||
typedef struct ISADevice ISADevice;
|
||||
typedef struct SMBusDevice SMBusDevice;
|
||||
typedef struct PCIHostState PCIHostState;
|
||||
typedef struct PCIExpressHost PCIExpressHost;
|
||||
typedef struct PCIBus PCIBus;
|
||||
typedef struct PCIDevice PCIDevice;
|
||||
typedef struct PCIExpressDevice PCIExpressDevice;
|
||||
typedef struct PCIBridge PCIBridge;
|
||||
typedef struct PCIEAERMsg PCIEAERMsg;
|
||||
typedef struct PCIEAERLog PCIEAERLog;
|
||||
typedef struct PCIEAERErr PCIEAERErr;
|
||||
typedef struct PCIEPort PCIEPort;
|
||||
typedef struct PCIESlot PCIESlot;
|
||||
typedef struct MSIMessage MSIMessage;
|
||||
typedef struct SerialState SerialState;
|
||||
typedef struct PCMCIACardState PCMCIACardState;
|
||||
typedef struct MouseTransformInfo MouseTransformInfo;
|
||||
typedef struct uWireSlave uWireSlave;
|
||||
typedef struct I2SCodec I2SCodec;
|
||||
typedef struct SSIBus SSIBus;
|
||||
typedef struct EventNotifier EventNotifier;
|
||||
typedef struct VirtIODevice VirtIODevice;
|
||||
typedef struct QEMUSGList QEMUSGList;
|
||||
typedef struct SHPCDevice SHPCDevice;
|
||||
|
||||
typedef uint64_t pcibus_t;
|
||||
|
||||
typedef enum LostTickPolicy {
|
||||
|
61
qemu-types.h
Normal file
61
qemu-types.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef QEMU_TYPEDEFS_H
|
||||
#define QEMU_TYPEDEFS_H
|
||||
|
||||
/* A load of opaque types so that device init declarations don't have to
|
||||
pull in all the real definitions. */
|
||||
typedef struct QEMUTimer QEMUTimer;
|
||||
typedef struct QEMUFile QEMUFile;
|
||||
typedef struct QEMUBH QEMUBH;
|
||||
|
||||
struct Monitor;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct MigrationParams MigrationParams;
|
||||
|
||||
typedef struct Property Property;
|
||||
typedef struct PropertyInfo PropertyInfo;
|
||||
typedef struct CompatProperty CompatProperty;
|
||||
typedef struct DeviceState DeviceState;
|
||||
typedef struct BusState BusState;
|
||||
typedef struct BusClass BusClass;
|
||||
|
||||
typedef struct NICInfo NICInfo;
|
||||
typedef struct HCIInfo HCIInfo;
|
||||
typedef struct AudioState AudioState;
|
||||
typedef struct BlockDriverState BlockDriverState;
|
||||
typedef struct DriveInfo DriveInfo;
|
||||
typedef struct DisplayState DisplayState;
|
||||
typedef struct DisplayChangeListener DisplayChangeListener;
|
||||
typedef struct DisplaySurface DisplaySurface;
|
||||
typedef struct PixelFormat PixelFormat;
|
||||
typedef struct QemuConsole QemuConsole;
|
||||
typedef struct CharDriverState CharDriverState;
|
||||
typedef struct MACAddr MACAddr;
|
||||
typedef struct NetClientState NetClientState;
|
||||
typedef struct i2c_bus i2c_bus;
|
||||
typedef struct ISABus ISABus;
|
||||
typedef struct ISADevice ISADevice;
|
||||
typedef struct SMBusDevice SMBusDevice;
|
||||
typedef struct PCIHostState PCIHostState;
|
||||
typedef struct PCIExpressHost PCIExpressHost;
|
||||
typedef struct PCIBus PCIBus;
|
||||
typedef struct PCIDevice PCIDevice;
|
||||
typedef struct PCIExpressDevice PCIExpressDevice;
|
||||
typedef struct PCIBridge PCIBridge;
|
||||
typedef struct PCIEAERMsg PCIEAERMsg;
|
||||
typedef struct PCIEAERLog PCIEAERLog;
|
||||
typedef struct PCIEAERErr PCIEAERErr;
|
||||
typedef struct PCIEPort PCIEPort;
|
||||
typedef struct PCIESlot PCIESlot;
|
||||
typedef struct MSIMessage MSIMessage;
|
||||
typedef struct SerialState SerialState;
|
||||
typedef struct PCMCIACardState PCMCIACardState;
|
||||
typedef struct MouseTransformInfo MouseTransformInfo;
|
||||
typedef struct uWireSlave uWireSlave;
|
||||
typedef struct I2SCodec I2SCodec;
|
||||
typedef struct SSIBus SSIBus;
|
||||
typedef struct EventNotifier EventNotifier;
|
||||
typedef struct VirtIODevice VirtIODevice;
|
||||
typedef struct QEMUSGList QEMUSGList;
|
||||
typedef struct SHPCDevice SHPCDevice;
|
||||
|
||||
#endif /* QEMU_TYPEDEFS_H */
|
@ -1,5 +1,10 @@
|
||||
#include <glib.h>
|
||||
#include <termios.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include "osdep.h"
|
||||
#include "qemu_socket.h"
|
||||
#include "qga/channel.h"
|
||||
|
||||
|
1
qlist.h
1
qlist.h
@ -15,7 +15,6 @@
|
||||
|
||||
#include "qobject.h"
|
||||
#include "qemu-queue.h"
|
||||
#include "qemu-common.h"
|
||||
#include "qemu-queue.h"
|
||||
|
||||
typedef struct QListEntry {
|
||||
|
2
sysemu.h
2
sysemu.h
@ -2,7 +2,7 @@
|
||||
#define SYSEMU_H
|
||||
/* Misc. things related to the system emulator. */
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "qemu-types.h"
|
||||
#include "qemu-option.h"
|
||||
#include "qemu-queue.h"
|
||||
#include "qemu-timer.h"
|
||||
|
@ -1106,13 +1106,13 @@ static char *x86_cpuid_get_vendor(Object *obj, Error **errp)
|
||||
char *value;
|
||||
int i;
|
||||
|
||||
value = (char *)g_malloc(12 + 1);
|
||||
value = (char *)g_malloc(CPUID_VENDOR_SZ + 1);
|
||||
for (i = 0; i < 4; i++) {
|
||||
value[i ] = env->cpuid_vendor1 >> (8 * i);
|
||||
value[i + 4] = env->cpuid_vendor2 >> (8 * i);
|
||||
value[i + 8] = env->cpuid_vendor3 >> (8 * i);
|
||||
}
|
||||
value[12] = '\0';
|
||||
value[CPUID_VENDOR_SZ] = '\0';
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -1123,7 +1123,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,
|
||||
CPUX86State *env = &cpu->env;
|
||||
int i;
|
||||
|
||||
if (strlen(value) != 12) {
|
||||
if (strlen(value) != CPUID_VENDOR_SZ) {
|
||||
error_set(errp, QERR_PROPERTY_VALUE_BAD, "",
|
||||
"vendor", value);
|
||||
return;
|
||||
@ -1208,14 +1208,33 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
|
||||
cpu->env.tsc_khz = value / 1000;
|
||||
}
|
||||
|
||||
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
|
||||
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
x86_def_t *def;
|
||||
|
||||
char *s = g_strdup(cpu_model);
|
||||
char *featurestr, *name = strtok(s, ",");
|
||||
/* Features to be added*/
|
||||
for (def = x86_defs; def; def = def->next) {
|
||||
if (name && !strcmp(name, def->name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (kvm_enabled() && name && strcmp(name, "host") == 0) {
|
||||
kvm_cpu_fill_host(x86_cpu_def);
|
||||
} else if (!def) {
|
||||
return -1;
|
||||
} else {
|
||||
memcpy(x86_cpu_def, def, sizeof(*def));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse "+feature,-feature,feature=foo" CPU feature string
|
||||
*/
|
||||
static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features)
|
||||
{
|
||||
unsigned int i;
|
||||
char *featurestr; /* Single 'key=value" string being parsed */
|
||||
/* Features to be added */
|
||||
uint32_t plus_features = 0, plus_ext_features = 0;
|
||||
uint32_t plus_ext2_features = 0, plus_ext3_features = 0;
|
||||
uint32_t plus_kvm_features = kvm_default_features, plus_svm_features = 0;
|
||||
@ -1227,22 +1246,11 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
|
||||
uint32_t minus_7_0_ebx_features = 0;
|
||||
uint32_t numvalue;
|
||||
|
||||
for (def = x86_defs; def; def = def->next)
|
||||
if (name && !strcmp(name, def->name))
|
||||
break;
|
||||
if (kvm_enabled() && name && strcmp(name, "host") == 0) {
|
||||
kvm_cpu_fill_host(x86_cpu_def);
|
||||
} else if (!def) {
|
||||
goto error;
|
||||
} else {
|
||||
memcpy(x86_cpu_def, def, sizeof(*def));
|
||||
}
|
||||
|
||||
add_flagname_to_bitmaps("hypervisor", &plus_features,
|
||||
&plus_ext_features, &plus_ext2_features, &plus_ext3_features,
|
||||
&plus_kvm_features, &plus_svm_features, &plus_7_0_ebx_features);
|
||||
|
||||
featurestr = strtok(NULL, ",");
|
||||
featurestr = features ? strtok(features, ",") : NULL;
|
||||
|
||||
while (featurestr) {
|
||||
char *val;
|
||||
@ -1373,14 +1381,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
|
||||
if (kvm_check_features_against_host(x86_cpu_def) && enforce_cpuid)
|
||||
goto error;
|
||||
}
|
||||
if (x86_cpu_def->cpuid_7_0_ebx_features && x86_cpu_def->level < 7) {
|
||||
x86_cpu_def->level = 7;
|
||||
}
|
||||
g_free(s);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
g_free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1490,11 +1493,25 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
|
||||
CPUX86State *env = &cpu->env;
|
||||
x86_def_t def1, *def = &def1;
|
||||
Error *error = NULL;
|
||||
char *name, *features;
|
||||
gchar **model_pieces;
|
||||
|
||||
memset(def, 0, sizeof(*def));
|
||||
|
||||
if (cpu_x86_find_by_name(def, cpu_model) < 0)
|
||||
return -1;
|
||||
model_pieces = g_strsplit(cpu_model, ",", 2);
|
||||
if (!model_pieces[0]) {
|
||||
goto error;
|
||||
}
|
||||
name = model_pieces[0];
|
||||
features = model_pieces[1];
|
||||
|
||||
if (cpu_x86_find_by_name(def, name) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (cpu_x86_parse_featurestr(def, features) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (def->vendor1) {
|
||||
env->cpuid_vendor1 = def->vendor1;
|
||||
env->cpuid_vendor2 = def->vendor2;
|
||||
@ -1551,9 +1568,14 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
|
||||
if (error) {
|
||||
fprintf(stderr, "%s\n", error_get_pretty(error));
|
||||
error_free(error);
|
||||
return -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_strfreev(model_pieces);
|
||||
return 0;
|
||||
error:
|
||||
g_strfreev(model_pieces);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
@ -1835,17 +1857,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
|
||||
}
|
||||
break;
|
||||
case 0x8000000A:
|
||||
if (env->cpuid_ext3_features & CPUID_EXT3_SVM) {
|
||||
*eax = 0x00000001; /* SVM Revision */
|
||||
*ebx = 0x00000010; /* nr of ASIDs */
|
||||
*ecx = 0;
|
||||
*edx = env->cpuid_svm_features; /* optional features */
|
||||
} else {
|
||||
*eax = 0;
|
||||
*ebx = 0;
|
||||
*ecx = 0;
|
||||
*edx = 0;
|
||||
}
|
||||
if (env->cpuid_ext3_features & CPUID_EXT3_SVM) {
|
||||
*eax = 0x00000001; /* SVM Revision */
|
||||
*ebx = 0x00000010; /* nr of ASIDs */
|
||||
*ecx = 0;
|
||||
*edx = env->cpuid_svm_features; /* optional features */
|
||||
} else {
|
||||
*eax = 0;
|
||||
*ebx = 0;
|
||||
*ecx = 0;
|
||||
*edx = 0;
|
||||
}
|
||||
break;
|
||||
case 0xC0000000:
|
||||
*eax = env->cpuid_xlevel2;
|
||||
@ -2049,6 +2071,11 @@ static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)
|
||||
void x86_cpu_realize(Object *obj, Error **errp)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(obj);
|
||||
CPUX86State *env = &cpu->env;
|
||||
|
||||
if (env->cpuid_7_0_ebx_features && env->cpuid_level < 7) {
|
||||
env->cpuid_level = 7;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
qemu_register_reset(x86_cpu_machine_reset_cb, cpu);
|
||||
|
@ -510,6 +510,8 @@
|
||||
#define CPUID_7_0_EBX_ADX (1 << 19)
|
||||
#define CPUID_7_0_EBX_SMAP (1 << 20)
|
||||
|
||||
#define CPUID_VENDOR_SZ 12
|
||||
|
||||
#define CPUID_VENDOR_INTEL_1 0x756e6547 /* "Genu" */
|
||||
#define CPUID_VENDOR_INTEL_2 0x49656e69 /* "ineI" */
|
||||
#define CPUID_VENDOR_INTEL_3 0x6c65746e /* "ntel" */
|
||||
|
@ -27,6 +27,8 @@
|
||||
*/
|
||||
|
||||
#include "vnc-palette.h"
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
static VncPaletteEntry *palette_find(const VncPalette *palette,
|
||||
uint32_t color, unsigned int hash)
|
||||
|
Loading…
Reference in New Issue
Block a user