From: Marcelo Tosatti <marcelo@kvack.org>
To: Amit Shah <amit.shah@qumranet.com>
Cc: kvm-devel@lists.sourceforge.net, Avi Kivity <avik@qumranet.com>,
qemu-devel@nongnu.org
Subject: Re: [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic
Date: Tue, 18 Mar 2008 10:54:54 -0300 [thread overview]
Message-ID: <20080318135454.GA15188@dmt> (raw)
In-Reply-To: <200803181802.10575.amit.shah@qumranet.com>
On Tue, Mar 18, 2008 at 06:02:10PM +0530, Amit Shah wrote:
> This patch broke -no-kvm-irqchip:
>
> * On Wednesday 12 March 2008 01:42:08 Marcelo Tosatti wrote:
> > So drivers can clear their mem io table entries on exit back to unassigned
> > state.
> >
> > Also make the io mem index allocation dynamic.
> >
> > Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> >
> > Index: kvm-userspace.hotplug2/qemu/cpu-all.h
> > ===================================================================
> > --- kvm-userspace.hotplug2.orig/qemu/cpu-all.h
> > +++ kvm-userspace.hotplug2/qemu/cpu-all.h
> > @@ -837,6 +837,7 @@ int cpu_register_io_memory(int io_index,
> > CPUReadMemoryFunc **mem_read,
> > CPUWriteMemoryFunc **mem_write,
> > void *opaque);
> > +void cpu_unregister_io_memory(int table_address);
> > CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
> > CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
> >
> > Index: kvm-userspace.hotplug2/qemu/exec.c
> > ===================================================================
> > --- kvm-userspace.hotplug2.orig/qemu/exec.c
> > +++ kvm-userspace.hotplug2/qemu/exec.c
> > @@ -158,7 +158,7 @@ PhysPageDesc **l1_phys_map;
> > CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
> > CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
> > void *io_mem_opaque[IO_MEM_NB_ENTRIES];
> > -static int io_mem_nb;
> > +char io_mem_used[IO_MEM_NB_ENTRIES];
> > #if defined(CONFIG_SOFTMMU)
> > static int io_mem_watch;
> > #endif
> > @@ -2498,12 +2498,28 @@ static void *subpage_init (target_phys_a
> > return mmio;
> > }
> >
> > +static int get_free_io_mem_idx(void)
> > +{
> > + int i;
> > +
> > + for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
> > + if (!io_mem_used[i]) {
> > + io_mem_used[i] = 1;
> > + return i;
> > + }
> > +
> > + return -1;
> > +}
> > +
> > static void io_mem_init(void)
> > {
> > + int i;
> > +
> > cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read,
> > unassigned_mem_write, NULL); cpu_register_io_memory(IO_MEM_UNASSIGNED >>
> > IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
> > cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read,
> > notdirty_mem_write, NULL); - io_mem_nb = 5;
> > + for (i=0; i<5; i++)
> > + io_mem_used[i] = 0;
>
> The remaining bits (5..IO_MEM_NB_ENTRIES) aren't initialised.
>
> >
> > #if defined(CONFIG_SOFTMMU)
> > io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
> > @@ -2530,9 +2546,9 @@ int cpu_register_io_memory(int io_index,
> > int i, subwidth = 0;
> >
> > if (io_index <= 0) {
> > - if (io_mem_nb >= IO_MEM_NB_ENTRIES)
> > - return -1;
> > - io_index = io_mem_nb++;
> > + io_index = get_free_io_mem_idx();
> > + if (io_index == -1)
> > + return io_index;
>
> io_mem_nb was initialised to 5 earlier; we now trample over the first 0..4
> bits.
>
> This fixes the issue; please check for correctness.
>
> From: Amit Shah <amit.shah@qumranet.com>
> Date: Tue, 18 Mar 2008 18:01:05 +0530
> Subject: [PATCH] QEMU/KVM: fix initialization of IO memory regions
>
> Signed-off-by: Amit Shah <amit.shah@qumranet.com>
> ---
> qemu/exec.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qemu/exec.c b/qemu/exec.c
> index edeb21a..be15433 100644
> --- a/qemu/exec.c
> +++ b/qemu/exec.c
> @@ -2502,7 +2502,7 @@ static int get_free_io_mem_idx(void)
> {
> int i;
>
> - for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
> + for (i = 5; i<IO_MEM_NB_ENTRIES; i++)
> if (!io_mem_used[i]) {
> io_mem_used[i] = 1;
> return i;
> @@ -2518,7 +2518,7 @@ static void io_mem_init(void)
> cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read,
> unassigned_mem_write, NULL);
> cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT,
> unassigned_mem_read, unassigned_mem_write, NULL);
> cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read,
> notdirty_mem_write, NULL);
> - for (i=0; i<5; i++)
> + for (i=5; i<IO_MEM_NB_ENTRIES; i++)
> io_mem_used[i] = 0;
>
> #if defined(CONFIG_SOFTMMU)
Hi Amit,
There is no need to zero io_mem_used since its in the BSS. The loop in
io_mem_init() was meant to allocate the slots from 0 to 4, not free
them.
So does the following fix the problem?
diff --git a/qemu/exec.c b/qemu/exec.c
index edeb21a..e5199cf 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -2519,7 +2519,7 @@ static void io_mem_init(void)
cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_re cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, not for (i=0; i<5; i++)
- io_mem_used[i] = 0;
+ io_mem_used[i] = 1;
#if defined(CONFIG_SOFTMMU)
io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Tosatti <marcelo@kvack.org>
To: Amit Shah <amit.shah@qumranet.com>
Cc: kvm-devel@lists.sourceforge.net, Avi Kivity <avik@qumranet.com>,
qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [kvm-devel] [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic
Date: Tue, 18 Mar 2008 10:54:54 -0300 [thread overview]
Message-ID: <20080318135454.GA15188@dmt> (raw)
In-Reply-To: <200803181802.10575.amit.shah@qumranet.com>
On Tue, Mar 18, 2008 at 06:02:10PM +0530, Amit Shah wrote:
> This patch broke -no-kvm-irqchip:
>
> * On Wednesday 12 March 2008 01:42:08 Marcelo Tosatti wrote:
> > So drivers can clear their mem io table entries on exit back to unassigned
> > state.
> >
> > Also make the io mem index allocation dynamic.
> >
> > Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> >
> > Index: kvm-userspace.hotplug2/qemu/cpu-all.h
> > ===================================================================
> > --- kvm-userspace.hotplug2.orig/qemu/cpu-all.h
> > +++ kvm-userspace.hotplug2/qemu/cpu-all.h
> > @@ -837,6 +837,7 @@ int cpu_register_io_memory(int io_index,
> > CPUReadMemoryFunc **mem_read,
> > CPUWriteMemoryFunc **mem_write,
> > void *opaque);
> > +void cpu_unregister_io_memory(int table_address);
> > CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
> > CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
> >
> > Index: kvm-userspace.hotplug2/qemu/exec.c
> > ===================================================================
> > --- kvm-userspace.hotplug2.orig/qemu/exec.c
> > +++ kvm-userspace.hotplug2/qemu/exec.c
> > @@ -158,7 +158,7 @@ PhysPageDesc **l1_phys_map;
> > CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
> > CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
> > void *io_mem_opaque[IO_MEM_NB_ENTRIES];
> > -static int io_mem_nb;
> > +char io_mem_used[IO_MEM_NB_ENTRIES];
> > #if defined(CONFIG_SOFTMMU)
> > static int io_mem_watch;
> > #endif
> > @@ -2498,12 +2498,28 @@ static void *subpage_init (target_phys_a
> > return mmio;
> > }
> >
> > +static int get_free_io_mem_idx(void)
> > +{
> > + int i;
> > +
> > + for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
> > + if (!io_mem_used[i]) {
> > + io_mem_used[i] = 1;
> > + return i;
> > + }
> > +
> > + return -1;
> > +}
> > +
> > static void io_mem_init(void)
> > {
> > + int i;
> > +
> > cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read,
> > unassigned_mem_write, NULL); cpu_register_io_memory(IO_MEM_UNASSIGNED >>
> > IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
> > cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read,
> > notdirty_mem_write, NULL); - io_mem_nb = 5;
> > + for (i=0; i<5; i++)
> > + io_mem_used[i] = 0;
>
> The remaining bits (5..IO_MEM_NB_ENTRIES) aren't initialised.
>
> >
> > #if defined(CONFIG_SOFTMMU)
> > io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
> > @@ -2530,9 +2546,9 @@ int cpu_register_io_memory(int io_index,
> > int i, subwidth = 0;
> >
> > if (io_index <= 0) {
> > - if (io_mem_nb >= IO_MEM_NB_ENTRIES)
> > - return -1;
> > - io_index = io_mem_nb++;
> > + io_index = get_free_io_mem_idx();
> > + if (io_index == -1)
> > + return io_index;
>
> io_mem_nb was initialised to 5 earlier; we now trample over the first 0..4
> bits.
>
> This fixes the issue; please check for correctness.
>
> From: Amit Shah <amit.shah@qumranet.com>
> Date: Tue, 18 Mar 2008 18:01:05 +0530
> Subject: [PATCH] QEMU/KVM: fix initialization of IO memory regions
>
> Signed-off-by: Amit Shah <amit.shah@qumranet.com>
> ---
> qemu/exec.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qemu/exec.c b/qemu/exec.c
> index edeb21a..be15433 100644
> --- a/qemu/exec.c
> +++ b/qemu/exec.c
> @@ -2502,7 +2502,7 @@ static int get_free_io_mem_idx(void)
> {
> int i;
>
> - for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
> + for (i = 5; i<IO_MEM_NB_ENTRIES; i++)
> if (!io_mem_used[i]) {
> io_mem_used[i] = 1;
> return i;
> @@ -2518,7 +2518,7 @@ static void io_mem_init(void)
> cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read,
> unassigned_mem_write, NULL);
> cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT,
> unassigned_mem_read, unassigned_mem_write, NULL);
> cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read,
> notdirty_mem_write, NULL);
> - for (i=0; i<5; i++)
> + for (i=5; i<IO_MEM_NB_ENTRIES; i++)
> io_mem_used[i] = 0;
>
> #if defined(CONFIG_SOFTMMU)
Hi Amit,
There is no need to zero io_mem_used since its in the BSS. The loop in
io_mem_init() was meant to allocate the slots from 0 to 4, not free
them.
So does the following fix the problem?
diff --git a/qemu/exec.c b/qemu/exec.c
index edeb21a..e5199cf 100644
--- a/qemu/exec.c
+++ b/qemu/exec.c
@@ -2519,7 +2519,7 @@ static void io_mem_init(void)
cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_re cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, not for (i=0; i<5; i++)
- io_mem_used[i] = 0;
+ io_mem_used[i] = 1;
#if defined(CONFIG_SOFTMMU)
io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
next prev parent reply other threads:[~2008-03-18 13:54 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 20:11 [patch 00/24] QEMU ACPI PCI hotplug support Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 01/24] QEMU/KVM: add devices to represent PCI slots with _EJ0 method Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 02/24] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 03/24] QEMU/KVM: add pci_find_bus Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 04/24] QEMU/KVM: return PCIDevice on net device init and record devfn Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 05/24] QEMU/KVM: pci hotplug GPE support Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 06/24] QEMU/KVM: dynamic drive/drive_opt index allocation Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 07/24] QEMU/KVM: dynamic nic info " Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 08/24] QEMU/KVM: drive removal support Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 09/24] QEMU/KVM: record devfn on block driver instance Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 10/24] QEMU/KVM: move drives_opt for external use Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 11/24] QEMU/KVM: net/drive add/remove tweaks Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 12/24] QEMU/KVM: add net_client_uninit Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 13/24] QEMU/KVM: export get_param_value/check_params Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 14/24] QEMU/KVM: add pci_find_device Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 15/24] QEMU/KVM: virtio_blk_init return PCIDevice pointer Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 16/24] QEMU/KVM: device and disk hot-add Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-18 12:32 ` Amit Shah
2008-03-18 12:32 ` [Qemu-devel] Re: [kvm-devel] " Amit Shah
2008-03-18 13:54 ` Marcelo Tosatti [this message]
2008-03-18 13:54 ` Marcelo Tosatti
2008-03-18 14:13 ` Amit Shah
2008-03-18 14:13 ` [Qemu-devel] RE: [kvm-devel] " Amit Shah
2008-03-18 15:22 ` Avi Kivity
2008-03-18 15:22 ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
2008-03-11 20:12 ` [patch 18/24] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 19/24] QEMU/KVM: handle SEJ notifications Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 20/24] QEMU/KVM: add qemu_free_irqs Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 21/24] QEMU/KVM: add pci_unregister_device Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 22/24] QEMU/KVM: LSI SCSI and e1000 unregister callbacks Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 23/24] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 24/24] QEMU/KVM: device hot-remove Marcelo Tosatti
2008-03-11 20:12 ` [Qemu-devel] " Marcelo Tosatti
2008-03-16 12:30 ` [patch 00/24] QEMU ACPI PCI hotplug support Avi Kivity
2008-03-16 12:30 ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
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=20080318135454.GA15188@dmt \
--to=marcelo@kvack.org \
--cc=amit.shah@qumranet.com \
--cc=avik@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.