From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: [PATCH] qemu-kvm: Remove qemu_system_is_ready side-channel
Date: Mon, 25 Jul 2011 09:13:41 +0200 [thread overview]
Message-ID: <4E2D17A5.6090605@web.de> (raw)
From: Jan Kiszka <jan.kiszka@siemens.com>
kvm_add/remove_ioport_region need to know if the change is done during
init or while the system is running. We added qemu_system_is_ready for
this purpose which exported qemu_system_ready. The latter will be gone
soon, but we can also obtain the information "hot-plug or not" from the
callers of those services. They can retrieve it from the associated qdev
device state.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
cpus.c | 5 -----
cpus.h | 1 -
hw/device-assignment.c | 6 ++++--
qemu-kvm.c | 12 +++++++-----
qemu-kvm.h | 6 ++++--
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/cpus.c b/cpus.c
index 007345a..3035314 100644
--- a/cpus.c
+++ b/cpus.c
@@ -687,11 +687,6 @@ void qemu_main_loop_start(void)
qemu_cond_broadcast(&qemu_system_cond);
}
-bool qemu_system_is_ready(void)
-{
- return qemu_system_ready;
-}
-
void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
{
struct qemu_work_item wi;
diff --git a/cpus.h b/cpus.h
index f6d37af..f42b54e 100644
--- a/cpus.h
+++ b/cpus.h
@@ -7,7 +7,6 @@ void qemu_main_loop_start(void);
void resume_all_vcpus(void);
void pause_all_vcpus(void);
void cpu_stop_current(void);
-bool qemu_system_is_ready(void);
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 5c24c78..4a3e9b5 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -277,7 +277,8 @@ static void assigned_dev_ioport_map(PCIDevice *pci_dev, int region_num,
addr, region->u.r_baseport, type, size, region_num);
if (first_map && region->region->resource_fd < 0) {
- r = kvm_add_ioport_region(region->u.r_baseport, region->r_size);
+ r = kvm_add_ioport_region(region->u.r_baseport, region->r_size,
+ pci_dev->qdev.hotplugged);
if (r < 0) {
fprintf(stderr, "%s: failed to enable ioport access (%m)\n",
__func__);
@@ -676,7 +677,8 @@ static void free_assigned_device(AssignedDevice *dev)
}
if (pci_region->type & IORESOURCE_IO) {
if (pci_region->resource_fd < 0) {
- kvm_remove_ioport_region(region->u.r_baseport, region->r_size);
+ kvm_remove_ioport_region(region->u.r_baseport, region->r_size,
+ dev->dev.qdev.hotplugged);
}
} else if (pci_region->type & IORESOURCE_MEM) {
if (region->u.r_virtbase) {
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 80cc077..4a10616 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -589,7 +589,8 @@ static void do_set_ioport_access(void *data)
}
}
-int kvm_add_ioport_region(unsigned long start, unsigned long size)
+int kvm_add_ioport_region(unsigned long start, unsigned long size,
+ bool is_hot_plug)
{
KVMIOPortRegion *region = qemu_mallocz(sizeof(KVMIOPortRegion));
CPUState *env;
@@ -600,12 +601,12 @@ int kvm_add_ioport_region(unsigned long start, unsigned long size)
region->status = 1;
QLIST_INSERT_HEAD(&ioport_regions, region, entry);
- if (qemu_system_is_ready()) {
+ if (is_hot_plug) {
for (env = first_cpu; env != NULL; env = env->next_cpu) {
run_on_cpu(env, do_set_ioport_access, region);
if (region->status < 0) {
r = region->status;
- kvm_remove_ioport_region(start, size);
+ kvm_remove_ioport_region(start, size, is_hot_plug);
break;
}
}
@@ -613,7 +614,8 @@ int kvm_add_ioport_region(unsigned long start, unsigned long size)
return r;
}
-int kvm_remove_ioport_region(unsigned long start, unsigned long size)
+int kvm_remove_ioport_region(unsigned long start, unsigned long size,
+ bool is_hot_unplug)
{
KVMIOPortRegion *region, *tmp;
CPUState *env;
@@ -623,7 +625,7 @@ int kvm_remove_ioport_region(unsigned long start, unsigned long size)
if (region->start == start && region->size == size) {
region->status = 0;
}
- if (qemu_system_is_ready()) {
+ if (is_hot_unplug) {
for (env = first_cpu; env != NULL; env = env->next_cpu) {
run_on_cpu(env, do_set_ioport_access, region);
}
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 845880e..90bcca9 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -252,8 +252,10 @@ void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
int kvm_arch_init_irq_routing(void);
-int kvm_add_ioport_region(unsigned long start, unsigned long size);
-int kvm_remove_ioport_region(unsigned long start, unsigned long size);
+int kvm_add_ioport_region(unsigned long start, unsigned long size,
+ bool is_hot_plug);
+int kvm_remove_ioport_region(unsigned long start, unsigned long size,
+ bool is_hot_unplug);
int kvm_update_ioport_access(CPUState *env);
int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
--
1.7.3.4
next reply other threads:[~2011-07-25 7:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-25 7:13 Jan Kiszka [this message]
2011-08-01 15:42 ` [PATCH] qemu-kvm: Remove qemu_system_is_ready side-channel Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E2D17A5.6090605@web.de \
--to=jan.kiszka@web.de \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox