Compare commits
18 Commits
rm-protoco
...
v0.15.0-rc
Author | SHA1 | Date | |
---|---|---|---|
|
9dc9f2b820 | ||
|
ef942b795a | ||
|
868aa386b8 | ||
|
7e10be8c74 | ||
|
9843621e3b | ||
|
ab640dbfc0 | ||
|
eaa8b2778c | ||
|
7ec7f28019 | ||
|
31b1308046 | ||
|
4ec648dd6e | ||
|
e961d129e1 | ||
|
8959459386 | ||
|
e2b40e003a | ||
|
1a39b0fcff | ||
|
4a97e18b87 | ||
|
f1ee0a0ebd | ||
|
3583bc031e | ||
|
2798b5e174 |
61
balloon.c
61
balloon.c
@@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* QEMU System Emulator
|
* Generic Balloon handlers and management
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003-2008 Fabrice Bellard
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
||||||
|
* Copyright (C) 2011 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2011 Amit Shah <amit.shah@redhat.com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -30,44 +32,53 @@
|
|||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
static QEMUBalloonEvent *balloon_event_fn;
|
||||||
|
static QEMUBalloonStatus *balloon_stat_fn;
|
||||||
|
static void *balloon_opaque;
|
||||||
|
|
||||||
static QEMUBalloonEvent *qemu_balloon_event;
|
int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
|
||||||
void *qemu_balloon_event_opaque;
|
QEMUBalloonStatus *stat_func, void *opaque)
|
||||||
|
|
||||||
void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque)
|
|
||||||
{
|
{
|
||||||
qemu_balloon_event = func;
|
if (balloon_event_fn || balloon_stat_fn || balloon_opaque) {
|
||||||
qemu_balloon_event_opaque = opaque;
|
/* We're already registered one balloon handler. How many can
|
||||||
|
* a guest really have?
|
||||||
|
*/
|
||||||
|
error_report("Another balloon device already registered");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
balloon_event_fn = event_func;
|
||||||
|
balloon_stat_fn = stat_func;
|
||||||
|
balloon_opaque = opaque;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque)
|
static int qemu_balloon(ram_addr_t target)
|
||||||
{
|
{
|
||||||
if (qemu_balloon_event) {
|
if (!balloon_event_fn) {
|
||||||
trace_balloon_event(qemu_balloon_event_opaque, target);
|
|
||||||
qemu_balloon_event(qemu_balloon_event_opaque, target, cb, opaque);
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
trace_balloon_event(balloon_opaque, target);
|
||||||
|
balloon_event_fn(balloon_opaque, target);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_balloon_status(MonitorCompletion cb, void *opaque)
|
static int qemu_balloon_status(MonitorCompletion cb, void *opaque)
|
||||||
{
|
{
|
||||||
if (qemu_balloon_event) {
|
if (!balloon_stat_fn) {
|
||||||
qemu_balloon_event(qemu_balloon_event_opaque, 0, cb, opaque);
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
balloon_stat_fn(balloon_opaque, cb, opaque);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_balloon_stat(const char *key, QObject *obj, void *opaque)
|
static void print_balloon_stat(const char *key, QObject *obj, void *opaque)
|
||||||
{
|
{
|
||||||
Monitor *mon = opaque;
|
Monitor *mon = opaque;
|
||||||
|
|
||||||
if (strcmp(key, "actual"))
|
if (strcmp(key, "actual")) {
|
||||||
monitor_printf(mon, ",%s=%" PRId64, key,
|
monitor_printf(mon, ",%s=%" PRId64, key,
|
||||||
qint_get_int(qobject_to_qint(obj)));
|
qint_get_int(qobject_to_qint(obj)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitor_print_balloon(Monitor *mon, const QObject *data)
|
void monitor_print_balloon(Monitor *mon, const QObject *data)
|
||||||
@@ -75,9 +86,9 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
|
|||||||
QDict *qdict;
|
QDict *qdict;
|
||||||
|
|
||||||
qdict = qobject_to_qdict(data);
|
qdict = qobject_to_qdict(data);
|
||||||
if (!qdict_haskey(qdict, "actual"))
|
if (!qdict_haskey(qdict, "actual")) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
monitor_printf(mon, "balloon: actual=%" PRId64,
|
monitor_printf(mon, "balloon: actual=%" PRId64,
|
||||||
qdict_get_int(qdict, "actual") >> 20);
|
qdict_get_int(qdict, "actual") >> 20);
|
||||||
qdict_iter(qdict, print_balloon_stat, mon);
|
qdict_iter(qdict, print_balloon_stat, mon);
|
||||||
@@ -129,6 +140,7 @@ int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
|
|||||||
int do_balloon(Monitor *mon, const QDict *params,
|
int do_balloon(Monitor *mon, const QDict *params,
|
||||||
MonitorCompletion cb, void *opaque)
|
MonitorCompletion cb, void *opaque)
|
||||||
{
|
{
|
||||||
|
int64_t target;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (kvm_enabled() && !kvm_has_sync_mmu()) {
|
if (kvm_enabled() && !kvm_has_sync_mmu()) {
|
||||||
@@ -136,7 +148,12 @@ int do_balloon(Monitor *mon, const QDict *params,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemu_balloon(qdict_get_int(params, "value"), cb, opaque);
|
target = qdict_get_int(params, "value");
|
||||||
|
if (target <= 0) {
|
||||||
|
qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ret = qemu_balloon(target);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
|
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
|
||||||
return -1;
|
return -1;
|
||||||
|
12
balloon.h
12
balloon.h
@@ -16,14 +16,12 @@
|
|||||||
|
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
|
||||||
typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target,
|
typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
|
||||||
MonitorCompletion cb, void *cb_data);
|
typedef void (QEMUBalloonStatus)(void *opaque, MonitorCompletion cb,
|
||||||
|
void *cb_data);
|
||||||
|
|
||||||
void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque);
|
int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
|
||||||
|
QEMUBalloonStatus *stat_func, void *opaque);
|
||||||
int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque);
|
|
||||||
|
|
||||||
int qemu_balloon_status(MonitorCompletion cb, void *opaque);
|
|
||||||
|
|
||||||
void monitor_print_balloon(Monitor *mon, const QObject *data);
|
void monitor_print_balloon(Monitor *mon, const QObject *data);
|
||||||
int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
|
int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Virtio Block Device
|
* Virtio Balloon Device
|
||||||
*
|
*
|
||||||
* Copyright IBM, Corp. 2008
|
* Copyright IBM, Corp. 2008
|
||||||
|
* Copyright (C) 2011 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2011 Amit Shah <amit.shah@redhat.com>
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Anthony Liguori <aliguori@us.ibm.com>
|
* Anthony Liguori <aliguori@us.ibm.com>
|
||||||
@@ -43,6 +45,7 @@ typedef struct VirtIOBalloon
|
|||||||
size_t stats_vq_offset;
|
size_t stats_vq_offset;
|
||||||
MonitorCompletion *stats_callback;
|
MonitorCompletion *stats_callback;
|
||||||
void *stats_opaque_callback_data;
|
void *stats_opaque_callback_data;
|
||||||
|
DeviceState *qdev;
|
||||||
} VirtIOBalloon;
|
} VirtIOBalloon;
|
||||||
|
|
||||||
static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
|
static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
|
||||||
@@ -199,18 +202,11 @@ static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_balloon_to_target(void *opaque, ram_addr_t target,
|
static void virtio_balloon_stat(void *opaque, MonitorCompletion cb,
|
||||||
MonitorCompletion cb, void *cb_data)
|
void *cb_data)
|
||||||
{
|
{
|
||||||
VirtIOBalloon *dev = opaque;
|
VirtIOBalloon *dev = opaque;
|
||||||
|
|
||||||
if (target > ram_size)
|
|
||||||
target = ram_size;
|
|
||||||
|
|
||||||
if (target) {
|
|
||||||
dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
|
|
||||||
virtio_notify_config(&dev->vdev);
|
|
||||||
} else {
|
|
||||||
/* For now, only allow one request at a time. This restriction can be
|
/* For now, only allow one request at a time. This restriction can be
|
||||||
* removed later by queueing callback and data pairs.
|
* removed later by queueing callback and data pairs.
|
||||||
*/
|
*/
|
||||||
@@ -219,16 +215,31 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target,
|
|||||||
}
|
}
|
||||||
dev->stats_callback = cb;
|
dev->stats_callback = cb;
|
||||||
dev->stats_opaque_callback_data = cb_data;
|
dev->stats_opaque_callback_data = cb_data;
|
||||||
if (ENABLE_GUEST_STATS && (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ))) {
|
|
||||||
|
if (ENABLE_GUEST_STATS
|
||||||
|
&& (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ))) {
|
||||||
virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
|
virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
|
||||||
virtio_notify(&dev->vdev, dev->svq);
|
virtio_notify(&dev->vdev, dev->svq);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Stats are not supported. Clear out any stale values that might
|
/* Stats are not supported. Clear out any stale values that might
|
||||||
* have been set by a more featureful guest kernel.
|
* have been set by a more featureful guest kernel.
|
||||||
*/
|
*/
|
||||||
reset_stats(dev);
|
reset_stats(dev);
|
||||||
complete_stats_request(dev);
|
complete_stats_request(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
|
||||||
|
{
|
||||||
|
VirtIOBalloon *dev = opaque;
|
||||||
|
|
||||||
|
if (target > ram_size) {
|
||||||
|
target = ram_size;
|
||||||
}
|
}
|
||||||
|
if (target) {
|
||||||
|
dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
|
||||||
|
virtio_notify_config(&dev->vdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +270,7 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
|
|||||||
VirtIODevice *virtio_balloon_init(DeviceState *dev)
|
VirtIODevice *virtio_balloon_init(DeviceState *dev)
|
||||||
{
|
{
|
||||||
VirtIOBalloon *s;
|
VirtIOBalloon *s;
|
||||||
|
int ret;
|
||||||
|
|
||||||
s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
|
s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
|
||||||
VIRTIO_ID_BALLOON,
|
VIRTIO_ID_BALLOON,
|
||||||
@@ -268,15 +280,29 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev)
|
|||||||
s->vdev.set_config = virtio_balloon_set_config;
|
s->vdev.set_config = virtio_balloon_set_config;
|
||||||
s->vdev.get_features = virtio_balloon_get_features;
|
s->vdev.get_features = virtio_balloon_get_features;
|
||||||
|
|
||||||
|
ret = qemu_add_balloon_handler(virtio_balloon_to_target,
|
||||||
|
virtio_balloon_stat, s);
|
||||||
|
if (ret < 0) {
|
||||||
|
virtio_cleanup(&s->vdev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
|
s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
|
||||||
s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
|
s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
|
||||||
s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);
|
s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);
|
||||||
|
|
||||||
reset_stats(s);
|
reset_stats(s);
|
||||||
qemu_add_balloon_handler(virtio_balloon_to_target, s);
|
|
||||||
|
|
||||||
|
s->qdev = dev;
|
||||||
register_savevm(dev, "virtio-balloon", -1, 1,
|
register_savevm(dev, "virtio-balloon", -1, 1,
|
||||||
virtio_balloon_save, virtio_balloon_load, s);
|
virtio_balloon_save, virtio_balloon_load, s);
|
||||||
|
|
||||||
return &s->vdev;
|
return &s->vdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void virtio_balloon_exit(VirtIODevice *vdev)
|
||||||
|
{
|
||||||
|
VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
|
||||||
|
unregister_savevm(s->qdev, "virtio-balloon", s);
|
||||||
|
virtio_cleanup(vdev);
|
||||||
|
}
|
||||||
|
@@ -788,10 +788,22 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
|
|||||||
VirtIODevice *vdev;
|
VirtIODevice *vdev;
|
||||||
|
|
||||||
vdev = virtio_balloon_init(&pci_dev->qdev);
|
vdev = virtio_balloon_init(&pci_dev->qdev);
|
||||||
|
if (!vdev) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
virtio_init_pci(proxy, vdev);
|
virtio_init_pci(proxy, vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
|
||||||
|
{
|
||||||
|
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
||||||
|
|
||||||
|
virtio_pci_stop_ioeventfd(proxy);
|
||||||
|
virtio_balloon_exit(proxy->vdev);
|
||||||
|
return virtio_exit_pci(pci_dev);
|
||||||
|
}
|
||||||
|
|
||||||
static PCIDeviceInfo virtio_info[] = {
|
static PCIDeviceInfo virtio_info[] = {
|
||||||
{
|
{
|
||||||
.qdev.name = "virtio-blk-pci",
|
.qdev.name = "virtio-blk-pci",
|
||||||
@@ -866,7 +878,7 @@ static PCIDeviceInfo virtio_info[] = {
|
|||||||
.qdev.alias = "virtio-balloon",
|
.qdev.alias = "virtio-balloon",
|
||||||
.qdev.size = sizeof(VirtIOPCIProxy),
|
.qdev.size = sizeof(VirtIOPCIProxy),
|
||||||
.init = virtio_balloon_init_pci,
|
.init = virtio_balloon_init_pci,
|
||||||
.exit = virtio_exit_pci,
|
.exit = virtio_balloon_exit_pci,
|
||||||
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
|
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
|
||||||
.device_id = PCI_DEVICE_ID_VIRTIO_BALLOON,
|
.device_id = PCI_DEVICE_ID_VIRTIO_BALLOON,
|
||||||
.revision = VIRTIO_PCI_ABI_VERSION,
|
.revision = VIRTIO_PCI_ABI_VERSION,
|
||||||
|
@@ -213,6 +213,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
|
|||||||
void virtio_net_exit(VirtIODevice *vdev);
|
void virtio_net_exit(VirtIODevice *vdev);
|
||||||
void virtio_blk_exit(VirtIODevice *vdev);
|
void virtio_blk_exit(VirtIODevice *vdev);
|
||||||
void virtio_serial_exit(VirtIODevice *vdev);
|
void virtio_serial_exit(VirtIODevice *vdev);
|
||||||
|
void virtio_balloon_exit(VirtIODevice *vdev);
|
||||||
|
|
||||||
#define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
|
#define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
|
||||||
DEFINE_PROP_BIT("indirect_desc", _state, _field, \
|
DEFINE_PROP_BIT("indirect_desc", _state, _field, \
|
||||||
|
@@ -374,6 +374,7 @@ enum arm_features {
|
|||||||
ARM_FEATURE_V4T,
|
ARM_FEATURE_V4T,
|
||||||
ARM_FEATURE_V5,
|
ARM_FEATURE_V5,
|
||||||
ARM_FEATURE_STRONGARM,
|
ARM_FEATURE_STRONGARM,
|
||||||
|
ARM_FEATURE_VAPA, /* cp15 VA to PA lookups */
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline int arm_feature(CPUARMState *env, int feature)
|
static inline int arm_feature(CPUARMState *env, int feature)
|
||||||
|
@@ -70,13 +70,24 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
|
|||||||
env->cp15.c0_cachetype = 0x1dd20d2;
|
env->cp15.c0_cachetype = 0x1dd20d2;
|
||||||
env->cp15.c1_sys = 0x00090078;
|
env->cp15.c1_sys = 0x00090078;
|
||||||
break;
|
break;
|
||||||
case ARM_CPUID_ARM1136_R2:
|
|
||||||
case ARM_CPUID_ARM1136:
|
case ARM_CPUID_ARM1136:
|
||||||
|
/* This is the 1136 r1, which is a v6K core */
|
||||||
|
set_feature(env, ARM_FEATURE_V6K);
|
||||||
|
/* Fall through */
|
||||||
|
case ARM_CPUID_ARM1136_R2:
|
||||||
|
/* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
|
||||||
|
* older core than plain "arm1136". In particular this does not
|
||||||
|
* have the v6K features.
|
||||||
|
*/
|
||||||
set_feature(env, ARM_FEATURE_V4T);
|
set_feature(env, ARM_FEATURE_V4T);
|
||||||
set_feature(env, ARM_FEATURE_V5);
|
set_feature(env, ARM_FEATURE_V5);
|
||||||
set_feature(env, ARM_FEATURE_V6);
|
set_feature(env, ARM_FEATURE_V6);
|
||||||
set_feature(env, ARM_FEATURE_VFP);
|
set_feature(env, ARM_FEATURE_VFP);
|
||||||
set_feature(env, ARM_FEATURE_AUXCR);
|
set_feature(env, ARM_FEATURE_AUXCR);
|
||||||
|
/* These ID register values are correct for 1136 but may be wrong
|
||||||
|
* for 1136_r2 (in particular r0p2 does not actually implement most
|
||||||
|
* of the ID registers).
|
||||||
|
*/
|
||||||
env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
|
env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
|
||||||
env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
|
env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
|
||||||
env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
|
env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
|
||||||
@@ -92,6 +103,7 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
|
|||||||
set_feature(env, ARM_FEATURE_V6K);
|
set_feature(env, ARM_FEATURE_V6K);
|
||||||
set_feature(env, ARM_FEATURE_VFP);
|
set_feature(env, ARM_FEATURE_VFP);
|
||||||
set_feature(env, ARM_FEATURE_AUXCR);
|
set_feature(env, ARM_FEATURE_AUXCR);
|
||||||
|
set_feature(env, ARM_FEATURE_VAPA);
|
||||||
env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
|
env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
|
||||||
env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
|
env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
|
||||||
env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
|
env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
|
||||||
@@ -222,6 +234,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
|
|||||||
cpu_abort(env, "Bad CPU ID: %x\n", id);
|
cpu_abort(env, "Bad CPU ID: %x\n", id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some features automatically imply others: */
|
||||||
|
if (arm_feature(env, ARM_FEATURE_V7)) {
|
||||||
|
set_feature(env, ARM_FEATURE_VAPA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_reset(CPUARMState *env)
|
void cpu_reset(CPUARMState *env)
|
||||||
@@ -1502,7 +1519,7 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
|
|||||||
goto bad_reg;
|
goto bad_reg;
|
||||||
}
|
}
|
||||||
/* No cache, so nothing to do except VA->PA translations. */
|
/* No cache, so nothing to do except VA->PA translations. */
|
||||||
if (arm_feature(env, ARM_FEATURE_V6K)) {
|
if (arm_feature(env, ARM_FEATURE_VAPA)) {
|
||||||
switch (crm) {
|
switch (crm) {
|
||||||
case 4:
|
case 4:
|
||||||
if (arm_feature(env, ARM_FEATURE_V7)) {
|
if (arm_feature(env, ARM_FEATURE_V7)) {
|
||||||
|
@@ -2498,12 +2498,6 @@ static int cp15_user_ok(CPUState *env, uint32_t insn)
|
|||||||
if (op == 2 || (op == 3 && (insn & ARM_CP_RW_BIT)))
|
if (op == 2 || (op == 3 && (insn & ARM_CP_RW_BIT)))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cpn == 7) {
|
|
||||||
/* ISB, DSB, DMB. */
|
|
||||||
if ((cpm == 5 && op == 4)
|
|
||||||
|| (cpm == 10 && (op == 4 || op == 5)))
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2579,39 +2573,60 @@ static int disas_cp15_insn(CPUState *env, DisasContext *s, uint32_t insn)
|
|||||||
/* cdp */
|
/* cdp */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (IS_USER(s) && !cp15_user_ok(env, insn)) {
|
/* We special case a number of cp15 instructions which were used
|
||||||
return 1;
|
* for things which are real instructions in ARMv7. This allows
|
||||||
}
|
* them to work in linux-user mode which doesn't provide functional
|
||||||
|
* get_cp15/set_cp15 helpers, and is more efficient anyway.
|
||||||
/* Pre-v7 versions of the architecture implemented WFI via coprocessor
|
|
||||||
* instructions rather than a separate instruction.
|
|
||||||
*/
|
*/
|
||||||
if ((insn & 0x0fff0fff) == 0x0e070f90) {
|
switch ((insn & 0x0fff0fff)) {
|
||||||
|
case 0x0e070f90:
|
||||||
/* 0,c7,c0,4: Standard v6 WFI (also used in some pre-v6 cores).
|
/* 0,c7,c0,4: Standard v6 WFI (also used in some pre-v6 cores).
|
||||||
* In v7, this must NOP.
|
* In v7, this must NOP.
|
||||||
*/
|
*/
|
||||||
|
if (IS_USER(s)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (!arm_feature(env, ARM_FEATURE_V7)) {
|
if (!arm_feature(env, ARM_FEATURE_V7)) {
|
||||||
/* Wait for interrupt. */
|
/* Wait for interrupt. */
|
||||||
gen_set_pc_im(s->pc);
|
gen_set_pc_im(s->pc);
|
||||||
s->is_jmp = DISAS_WFI;
|
s->is_jmp = DISAS_WFI;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
case 0x0e070f58:
|
||||||
|
|
||||||
if ((insn & 0x0fff0fff) == 0x0e070f58) {
|
|
||||||
/* 0,c7,c8,2: Not all pre-v6 cores implemented this WFI,
|
/* 0,c7,c8,2: Not all pre-v6 cores implemented this WFI,
|
||||||
* so this is slightly over-broad.
|
* so this is slightly over-broad.
|
||||||
*/
|
*/
|
||||||
if (!arm_feature(env, ARM_FEATURE_V6)) {
|
if (!IS_USER(s) && !arm_feature(env, ARM_FEATURE_V6)) {
|
||||||
/* Wait for interrupt. */
|
/* Wait for interrupt. */
|
||||||
gen_set_pc_im(s->pc);
|
gen_set_pc_im(s->pc);
|
||||||
s->is_jmp = DISAS_WFI;
|
s->is_jmp = DISAS_WFI;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Otherwise fall through to handle via helper function.
|
/* Otherwise continue to handle via helper function.
|
||||||
* In particular, on v7 and some v6 cores this is one of
|
* In particular, on v7 and some v6 cores this is one of
|
||||||
* the VA-PA registers.
|
* the VA-PA registers.
|
||||||
*/
|
*/
|
||||||
|
break;
|
||||||
|
case 0x0e070f3d:
|
||||||
|
/* 0,c7,c13,1: prefetch-by-MVA in v6, NOP in v7 */
|
||||||
|
if (arm_feature(env, ARM_FEATURE_V6)) {
|
||||||
|
return IS_USER(s) ? 1 : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0e070f95: /* 0,c7,c5,4 : ISB */
|
||||||
|
case 0x0e070f9a: /* 0,c7,c10,4: DSB */
|
||||||
|
case 0x0e070fba: /* 0,c7,c10,5: DMB */
|
||||||
|
/* Barriers in both v6 and v7 */
|
||||||
|
if (arm_feature(env, ARM_FEATURE_V6)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_USER(s) && !cp15_user_ok(env, insn)) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rd = (insn >> 12) & 0xf;
|
rd = (insn >> 12) & 0xf;
|
||||||
@@ -3056,6 +3071,17 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
/* Source and destination the same. */
|
/* Source and destination the same. */
|
||||||
gen_mov_F0_vreg(dp, rd);
|
gen_mov_F0_vreg(dp, rd);
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
/* VCVTB, VCVTT: only present with the halfprec extension,
|
||||||
|
* UNPREDICTABLE if bit 8 is set (we choose to UNDEF)
|
||||||
|
*/
|
||||||
|
if (dp || !arm_feature(env, ARM_FEATURE_VFP_FP16)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* Otherwise fall through */
|
||||||
default:
|
default:
|
||||||
/* One source operand. */
|
/* One source operand. */
|
||||||
gen_mov_F0_vreg(dp, rm);
|
gen_mov_F0_vreg(dp, rm);
|
||||||
@@ -3152,24 +3178,18 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
gen_vfp_sqrt(dp);
|
gen_vfp_sqrt(dp);
|
||||||
break;
|
break;
|
||||||
case 4: /* vcvtb.f32.f16 */
|
case 4: /* vcvtb.f32.f16 */
|
||||||
if (!arm_feature(env, ARM_FEATURE_VFP_FP16))
|
|
||||||
return 1;
|
|
||||||
tmp = gen_vfp_mrs();
|
tmp = gen_vfp_mrs();
|
||||||
tcg_gen_ext16u_i32(tmp, tmp);
|
tcg_gen_ext16u_i32(tmp, tmp);
|
||||||
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
|
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
|
||||||
tcg_temp_free_i32(tmp);
|
tcg_temp_free_i32(tmp);
|
||||||
break;
|
break;
|
||||||
case 5: /* vcvtt.f32.f16 */
|
case 5: /* vcvtt.f32.f16 */
|
||||||
if (!arm_feature(env, ARM_FEATURE_VFP_FP16))
|
|
||||||
return 1;
|
|
||||||
tmp = gen_vfp_mrs();
|
tmp = gen_vfp_mrs();
|
||||||
tcg_gen_shri_i32(tmp, tmp, 16);
|
tcg_gen_shri_i32(tmp, tmp, 16);
|
||||||
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
|
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
|
||||||
tcg_temp_free_i32(tmp);
|
tcg_temp_free_i32(tmp);
|
||||||
break;
|
break;
|
||||||
case 6: /* vcvtb.f16.f32 */
|
case 6: /* vcvtb.f16.f32 */
|
||||||
if (!arm_feature(env, ARM_FEATURE_VFP_FP16))
|
|
||||||
return 1;
|
|
||||||
tmp = tcg_temp_new_i32();
|
tmp = tcg_temp_new_i32();
|
||||||
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
|
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
|
||||||
gen_mov_F0_vreg(0, rd);
|
gen_mov_F0_vreg(0, rd);
|
||||||
@@ -3180,8 +3200,6 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
gen_vfp_msr(tmp);
|
gen_vfp_msr(tmp);
|
||||||
break;
|
break;
|
||||||
case 7: /* vcvtt.f16.f32 */
|
case 7: /* vcvtt.f16.f32 */
|
||||||
if (!arm_feature(env, ARM_FEATURE_VFP_FP16))
|
|
||||||
return 1;
|
|
||||||
tmp = tcg_temp_new_i32();
|
tmp = tcg_temp_new_i32();
|
||||||
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
|
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
|
||||||
tcg_gen_shli_i32(tmp, tmp, 16);
|
tcg_gen_shli_i32(tmp, tmp, 16);
|
||||||
@@ -3382,17 +3400,18 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
VFP_DREG_D(rd, insn);
|
VFP_DREG_D(rd, insn);
|
||||||
else
|
else
|
||||||
rd = VFP_SREG_D(insn);
|
rd = VFP_SREG_D(insn);
|
||||||
if (s->thumb && rn == 15) {
|
|
||||||
addr = tcg_temp_new_i32();
|
|
||||||
tcg_gen_movi_i32(addr, s->pc & ~2);
|
|
||||||
} else {
|
|
||||||
addr = load_reg(s, rn);
|
|
||||||
}
|
|
||||||
if ((insn & 0x01200000) == 0x01000000) {
|
if ((insn & 0x01200000) == 0x01000000) {
|
||||||
/* Single load/store */
|
/* Single load/store */
|
||||||
offset = (insn & 0xff) << 2;
|
offset = (insn & 0xff) << 2;
|
||||||
if ((insn & (1 << 23)) == 0)
|
if ((insn & (1 << 23)) == 0)
|
||||||
offset = -offset;
|
offset = -offset;
|
||||||
|
if (s->thumb && rn == 15) {
|
||||||
|
/* This is actually UNPREDICTABLE */
|
||||||
|
addr = tcg_temp_new_i32();
|
||||||
|
tcg_gen_movi_i32(addr, s->pc & ~2);
|
||||||
|
} else {
|
||||||
|
addr = load_reg(s, rn);
|
||||||
|
}
|
||||||
tcg_gen_addi_i32(addr, addr, offset);
|
tcg_gen_addi_i32(addr, addr, offset);
|
||||||
if (insn & (1 << 20)) {
|
if (insn & (1 << 20)) {
|
||||||
gen_vfp_ld(s, dp, addr);
|
gen_vfp_ld(s, dp, addr);
|
||||||
@@ -3404,11 +3423,34 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
tcg_temp_free_i32(addr);
|
tcg_temp_free_i32(addr);
|
||||||
} else {
|
} else {
|
||||||
/* load/store multiple */
|
/* load/store multiple */
|
||||||
|
int w = insn & (1 << 21);
|
||||||
if (dp)
|
if (dp)
|
||||||
n = (insn >> 1) & 0x7f;
|
n = (insn >> 1) & 0x7f;
|
||||||
else
|
else
|
||||||
n = insn & 0xff;
|
n = insn & 0xff;
|
||||||
|
|
||||||
|
if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) {
|
||||||
|
/* P == U , W == 1 => UNDEF */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (n == 0 || (rd + n) > 32 || (dp && n > 16)) {
|
||||||
|
/* UNPREDICTABLE cases for bad immediates: we choose to
|
||||||
|
* UNDEF to avoid generating huge numbers of TCG ops
|
||||||
|
*/
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (rn == 15 && w) {
|
||||||
|
/* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->thumb && rn == 15) {
|
||||||
|
/* This is actually UNPREDICTABLE */
|
||||||
|
addr = tcg_temp_new_i32();
|
||||||
|
tcg_gen_movi_i32(addr, s->pc & ~2);
|
||||||
|
} else {
|
||||||
|
addr = load_reg(s, rn);
|
||||||
|
}
|
||||||
if (insn & (1 << 24)) /* pre-decrement */
|
if (insn & (1 << 24)) /* pre-decrement */
|
||||||
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
|
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
|
||||||
|
|
||||||
@@ -3428,7 +3470,7 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
|
|||||||
}
|
}
|
||||||
tcg_gen_addi_i32(addr, addr, offset);
|
tcg_gen_addi_i32(addr, addr, offset);
|
||||||
}
|
}
|
||||||
if (insn & (1 << 21)) {
|
if (w) {
|
||||||
/* writeback */
|
/* writeback */
|
||||||
if (insn & (1 << 24))
|
if (insn & (1 << 24))
|
||||||
offset = -offset * n;
|
offset = -offset * n;
|
||||||
|
Reference in New Issue
Block a user