[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH-not-for-5.1? v2] hw/isa/isa-bus: Ensure ISA I/O regions a
From: |
Michael S. Tsirkin |
Subject: |
Re: [RFC PATCH-not-for-5.1? v2] hw/isa/isa-bus: Ensure ISA I/O regions are 8/16-bit accessible |
Date: |
Wed, 22 Jul 2020 07:17:14 -0400 |
On Mon, Jul 20, 2020 at 08:57:58PM +0200, Philippe Mathieu-Daudé wrote:
> Since commit 5d971f9e67 we don't accept mismatching sizes
> in memory_region_access_valid(). This gives troubles when
> a device is on an ISA bus, because the CPU is free to use
> 8/16-bit accesses on the bus (or up to 32-bit on EISA bus),
> regardless what range is valid for the device.
Right, but I am not sure device is guaranteed to do something
sensible if the CPU does it.
Any examples where that is the case?
> Add a check to ensure devices plugged on the ISA bus can
> accept 8/16-bits accesses.
>
> Related bug reports:
>
> -
> https://lore.kernel.org/xen-devel/20200630170913.123646-1-anthony.perard@citrix.com/T/
> - https://bugs.debian.org/964793
> - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964247
> - https://bugs.launchpad.net/bugs/1886318
These all have to do with ACPI that Michael fixed, right?
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> MST: I really don't like this approach, I think the ISA bus
> should adjust the access.
>
> since v1: only 8/16-bit accesses enforced
> ---
> hw/isa/isa-bus.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
> index 58fde178f9..e142eeef06 100644
> --- a/hw/isa/isa-bus.c
> +++ b/hw/isa/isa-bus.c
> @@ -132,6 +132,20 @@ static inline void isa_init_ioport(ISADevice *dev,
> uint16_t ioport)
>
> void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start)
> {
> + if (io->ops->valid.min_access_size > 1) {
> + /*
> + * To be backward compatible with IBM-PC bus, ISA bus must accept
> + * 8-bit accesses.
> + */
> + error_report("ISA device '%s' requires I/O min_access_size of 1
> (byte)",
> + object_get_typename(OBJECT(dev)));
> + exit(1);
> + } else if (io->ops->valid.max_access_size < 2) {
> + /* ISA bus must accept 16-bit accesses (EISA accepts 32-bit) */
> + error_report("ISA device '%s' requires I/O max_access_size of "
> + "at least 2 (bytes)", object_get_typename(OBJECT(dev)));
> + exit(1);
> + }
> memory_region_add_subregion(isabus->address_space_io, start, io);
> isa_init_ioport(dev, start);
> }
> --
> 2.21.3