* [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
@ 2010-05-19 9:54 Gerd Hoffmann
2010-05-19 9:54 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-24 12:32 ` [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Paul Brook
0 siblings, 2 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-19 9:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ioport.c | 5 +++++
ioport.h | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ioport.c b/ioport.c
index 53dd87a..b718047 100644
--- a/ioport.c
+++ b/ioport.c
@@ -190,6 +190,11 @@ void isa_unassign_ioport(pio_addr_t start, int length)
}
}
+int is_ioport_assigned(pio_addr_t addr)
+{
+ return ioport_opaque[addr] != NULL;
+}
+
/***********************************************************/
void cpu_outb(pio_addr_t addr, uint8_t val)
diff --git a/ioport.h b/ioport.h
index 3d3c8a3..46fbfa8 100644
--- a/ioport.h
+++ b/ioport.h
@@ -41,6 +41,7 @@ int register_ioport_read(pio_addr_t start, int length, int size,
int register_ioport_write(pio_addr_t start, int length, int size,
IOPortWriteFunc *func, void *opaque);
void isa_unassign_ioport(pio_addr_t start, int length);
+int is_ioport_assigned(pio_addr_t addr);
void cpu_outb(pio_addr_t addr, uint8_t val);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-19 9:54 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
@ 2010-05-19 9:54 ` Gerd Hoffmann
2010-05-24 12:32 ` [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Paul Brook
1 sibling, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-19 9:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Try to pci hotplug a vga card, watch qemu die with hw_error().
This patch fixes it.
[v2: code style fixes]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 4 ++++
hw/vga-pci.c | 4 ++++
hw/vmware_vga.c | 4 ++++
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9f61a01..977abd2 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3189,6 +3189,10 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
uint8_t *pci_conf = d->dev.config;
int device_id = CIRRUS_ID_CLGD5446;
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
/* setup VGA */
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, device_id, 1);
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c8d260c..9fa0bfb 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -79,6 +79,10 @@ static int pci_vga_initfn(PCIDevice *dev)
VGACommonState *s = &d->vga;
uint8_t *pci_conf = d->dev.config;
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 4e7a75d..7a8cec0 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1232,6 +1232,10 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
struct pci_vmsvga_state_s *s =
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
+ if (is_ioport_assigned(0x3c0)) {
+ return -1;
+ }
+
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
2010-05-19 9:54 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
2010-05-19 9:54 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
@ 2010-05-24 12:32 ` Paul Brook
2010-05-25 9:41 ` Gerd Hoffmann
1 sibling, 1 reply; 10+ messages in thread
From: Paul Brook @ 2010-05-24 12:32 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
> +int is_ioport_assigned(pio_addr_t addr)
Shouldn't we move this into register_ioport_{read,write}, and have that fail
if the port has already been assigned?
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
2010-05-24 12:32 ` [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Paul Brook
@ 2010-05-25 9:41 ` Gerd Hoffmann
2010-05-26 7:05 ` Markus Armbruster
0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-25 9:41 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On 05/24/10 14:32, Paul Brook wrote:
>> +int is_ioport_assigned(pio_addr_t addr)
>
> Shouldn't we move this into register_ioport_{read,write}, and have that fail
> if the port has already been assigned?
It already checks and fails with hw_error(). Problem with that is that
this kills qemu in case you try to pci hot-plug a vga card. So I've
added a way to check before-hand, so we can fail gracefully in the few
places where we need it (see second patch of the series).
cheers,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
2010-05-25 9:41 ` Gerd Hoffmann
@ 2010-05-26 7:05 ` Markus Armbruster
0 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2010-05-26 7:05 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Paul Brook, qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> On 05/24/10 14:32, Paul Brook wrote:
>>> +int is_ioport_assigned(pio_addr_t addr)
>>
>> Shouldn't we move this into register_ioport_{read,write}, and have that fail
>> if the port has already been assigned?
>
> It already checks and fails with hw_error(). Problem with that is
> that this kills qemu in case you try to pci hot-plug a vga card. So
> I've added a way to check before-hand, so we can fail gracefully in
> the few places where we need it (see second patch of the series).
If we needed in more than a few places, then a solution like the one we
adopted for qdev_init() could make sense: have register_ioport_FOO()
return an error, convert all users that don't want to check it to
register_ioport_FOO_nofail(), which hw_error()s out.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not
@ 2010-05-11 20:43 Gerd Hoffmann
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-11 20:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ioport.c | 5 +++++
ioport.h | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ioport.c b/ioport.c
index 53dd87a..b718047 100644
--- a/ioport.c
+++ b/ioport.c
@@ -190,6 +190,11 @@ void isa_unassign_ioport(pio_addr_t start, int length)
}
}
+int is_ioport_assigned(pio_addr_t addr)
+{
+ return ioport_opaque[addr] != NULL;
+}
+
/***********************************************************/
void cpu_outb(pio_addr_t addr, uint8_t val)
diff --git a/ioport.h b/ioport.h
index 3d3c8a3..46fbfa8 100644
--- a/ioport.h
+++ b/ioport.h
@@ -41,6 +41,7 @@ int register_ioport_read(pio_addr_t start, int length, int size,
int register_ioport_write(pio_addr_t start, int length, int size,
IOPortWriteFunc *func, void *opaque);
void isa_unassign_ioport(pio_addr_t start, int length);
+int is_ioport_assigned(pio_addr_t addr);
void cpu_outb(pio_addr_t addr, uint8_t val);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 Gerd Hoffmann
@ 2010-05-11 20:43 ` Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
0 siblings, 2 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-11 20:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Try to pci hotplug a vga card, watch qemu die with hw_error().
This patch fixes it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/cirrus_vga.c | 3 +++
hw/vga-pci.c | 3 +++
hw/vmware_vga.c | 3 +++
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 9f61a01..2f50e86 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3189,6 +3189,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
uint8_t *pci_conf = d->dev.config;
int device_id = CIRRUS_ID_CLGD5446;
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
/* setup VGA */
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, device_id, 1);
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index c8d260c..2ef3278 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -79,6 +79,9 @@ static int pci_vga_initfn(PCIDevice *dev)
VGACommonState *s = &d->vga;
uint8_t *pci_conf = d->dev.config;
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 4e7a75d..cd0eb57 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1232,6 +1232,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
struct pci_vmsvga_state_s *s =
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
+ if (is_ioport_assigned(0x3c0))
+ return -1;
+
pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
@ 2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
1 sibling, 0 replies; 10+ messages in thread
From: Blue Swirl @ 2010-05-12 18:59 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
On 5/11/10, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Try to pci hotplug a vga card, watch qemu die with hw_error().
> This patch fixes it.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/cirrus_vga.c | 3 +++
> hw/vga-pci.c | 3 +++
> hw/vmware_vga.c | 3 +++
> 3 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
> index 9f61a01..2f50e86 100644
> --- a/hw/cirrus_vga.c
> +++ b/hw/cirrus_vga.c
> @@ -3189,6 +3189,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
> uint8_t *pci_conf = d->dev.config;
> int device_id = CIRRUS_ID_CLGD5446;
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
-ECODING_STYLE.
> /* setup VGA */
> vga_common_init(&s->vga, VGA_RAM_SIZE);
> cirrus_init_common(s, device_id, 1);
> diff --git a/hw/vga-pci.c b/hw/vga-pci.c
> index c8d260c..2ef3278 100644
> --- a/hw/vga-pci.c
> +++ b/hw/vga-pci.c
> @@ -79,6 +79,9 @@ static int pci_vga_initfn(PCIDevice *dev)
> VGACommonState *s = &d->vga;
> uint8_t *pci_conf = d->dev.config;
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
> // vga + console init
> vga_common_init(s, VGA_RAM_SIZE);
> vga_init(s);
> diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> index 4e7a75d..cd0eb57 100644
> --- a/hw/vmware_vga.c
> +++ b/hw/vmware_vga.c
> @@ -1232,6 +1232,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
> struct pci_vmsvga_state_s *s =
> DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
>
> + if (is_ioport_assigned(0x3c0))
> + return -1;
> +
> pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
> pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
> s->card.config[PCI_COMMAND] = PCI_COMMAND_IO |
>
> --
> 1.6.6.1
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
@ 2010-05-18 12:33 ` Markus Armbruster
2010-05-18 12:45 ` Gerd Hoffmann
1 sibling, 1 reply; 10+ messages in thread
From: Markus Armbruster @ 2010-05-18 12:33 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> Try to pci hotplug a vga card, watch qemu die with hw_error().
> This patch fixes it.
Looks good.
Are there any other hot-pluggable devices that acquire single-use
resources such as fixed I/O ports?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-18 12:33 ` Markus Armbruster
@ 2010-05-18 12:45 ` Gerd Hoffmann
2010-05-18 14:06 ` Markus Armbruster
0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2010-05-18 12:45 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On 05/18/10 14:33, Markus Armbruster wrote:
> Gerd Hoffmann<kraxel@redhat.com> writes:
>
>> Try to pci hotplug a vga card, watch qemu die with hw_error().
>> This patch fixes it.
>
> Looks good.
>
> Are there any other hot-pluggable devices that acquire single-use
> resources such as fixed I/O ports?
Any PCI device doing ISA compatibility stuff I'd guess, which makes IDE
a candidate. Checking ...
Yes (hw/ide/piix.c):
ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->bus[1], 0x170, 0x376);
Those are tagged with "no-user" though due to being hard-coded in pc.c,
so any attempt to hot-plug one of those should fail way before it
attempts to grab the I/O ports.
cheers,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken
2010-05-18 12:45 ` Gerd Hoffmann
@ 2010-05-18 14:06 ` Markus Armbruster
0 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2010-05-18 14:06 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann <kraxel@redhat.com> writes:
> On 05/18/10 14:33, Markus Armbruster wrote:
>> Gerd Hoffmann<kraxel@redhat.com> writes:
>>
>>> Try to pci hotplug a vga card, watch qemu die with hw_error().
>>> This patch fixes it.
>>
>> Looks good.
>>
>> Are there any other hot-pluggable devices that acquire single-use
>> resources such as fixed I/O ports?
>
> Any PCI device doing ISA compatibility stuff I'd guess, which makes
> IDE a candidate. Checking ...
>
> Yes (hw/ide/piix.c):
>
> ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
> ide_init_ioport(&d->bus[1], 0x170, 0x376);
>
> Those are tagged with "no-user" though due to being hard-coded in
> pc.c, so any attempt to hot-plug one of those should fail way before
> it attempts to grab the I/O ports.
So a more general mechanism than you ad hoc is_ioport_assigned() check
doesn't seem to be justified.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-05-26 7:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19 9:54 [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Gerd Hoffmann
2010-05-19 9:54 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-24 12:32 ` [Qemu-devel] [PATCH 1/2] ioport: add function to check whenever a port is assigned or not Paul Brook
2010-05-25 9:41 ` Gerd Hoffmann
2010-05-26 7:05 ` Markus Armbruster
-- strict thread matches above, loose matches on Subject: below --
2010-05-11 20:43 Gerd Hoffmann
2010-05-11 20:43 ` [Qemu-devel] [PATCH 2/2] all vga: fail graicefully when vga ports are taken Gerd Hoffmann
2010-05-12 18:59 ` Blue Swirl
2010-05-18 12:33 ` Markus Armbruster
2010-05-18 12:45 ` Gerd Hoffmann
2010-05-18 14:06 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).