* [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
@ 2012-01-04 14:28 Avi Kivity
2012-01-04 14:47 ` Michael S. Tsirkin
0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2012-01-04 14:28 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel
Commit d0ed8076cbdc261 converted the PCI config access to the memory
API, but also inadvertantly changed it to accept unaligned writes,
and corrupt the index register in the process. This causes a regression
booting NetBSD.
Fix by ignoring unaligned or non-dword writes.
https://bugs.launchpad.net/qemu/+bug/897771
Reported-by: Andreas Gustafsson <gson@gson.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
hw/pci_host.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..8041778 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -101,6 +101,9 @@ static void pci_host_config_write(void *opaque, target_phys_addr_t addr,
PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
__func__, addr, len, val);
+ if (addr != 0 || len != 4) {
+ return;
+ }
s->config_reg = val;
}
--
1.7.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-04 14:28 [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write Avi Kivity
@ 2012-01-04 14:47 ` Michael S. Tsirkin
2012-01-04 15:34 ` Alexander Graf
2012-01-05 15:14 ` Stefan Weil
0 siblings, 2 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2012-01-04 14:47 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel
On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
> Commit d0ed8076cbdc261 converted the PCI config access to the memory
> API, but also inadvertantly changed it to accept unaligned writes,
> and corrupt the index register in the process. This causes a regression
> booting NetBSD.
>
> Fix by ignoring unaligned or non-dword writes.
>
> https://bugs.launchpad.net/qemu/+bug/897771
>
> Reported-by: Andreas Gustafsson <gson@gson.org>
> Signed-off-by: Avi Kivity <avi@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> hw/pci_host.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci_host.c b/hw/pci_host.c
> index 44c6c20..8041778 100644
> --- a/hw/pci_host.c
> +++ b/hw/pci_host.c
> @@ -101,6 +101,9 @@ static void pci_host_config_write(void *opaque, target_phys_addr_t addr,
>
> PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
> __func__, addr, len, val);
> + if (addr != 0 || len != 4) {
> + return;
> + }
> s->config_reg = val;
> }
>
> --
> 1.7.7.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-04 14:47 ` Michael S. Tsirkin
@ 2012-01-04 15:34 ` Alexander Graf
2012-01-05 15:14 ` Stefan Weil
1 sibling, 0 replies; 10+ messages in thread
From: Alexander Graf @ 2012-01-04 15:34 UTC (permalink / raw)
To: Michael S.Tsirkin
Cc: qemu-stable, Avi Kivity, qemu-devel@nongnu.org Developers
On 04.01.2012, at 15:47, Michael S. Tsirkin wrote:
> On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
>> Commit d0ed8076cbdc261 converted the PCI config access to the memory
>> API, but also inadvertantly changed it to accept unaligned writes,
>> and corrupt the index register in the process. This causes a regression
>> booting NetBSD.
>>
>> Fix by ignoring unaligned or non-dword writes.
>>
>> https://bugs.launchpad.net/qemu/+bug/897771
>>
>> Reported-by: Andreas Gustafsson <gson@gson.org>
>> Signed-off-by: Avi Kivity <avi@redhat.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
CC'ing qemu-stable.
Alex
>
>> ---
>>
>> hw/pci_host.c | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/pci_host.c b/hw/pci_host.c
>> index 44c6c20..8041778 100644
>> --- a/hw/pci_host.c
>> +++ b/hw/pci_host.c
>> @@ -101,6 +101,9 @@ static void pci_host_config_write(void *opaque, target_phys_addr_t addr,
>>
>> PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
>> __func__, addr, len, val);
>> + if (addr != 0 || len != 4) {
>> + return;
>> + }
>> s->config_reg = val;
>> }
>>
>> --
>> 1.7.7.1
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-04 14:47 ` Michael S. Tsirkin
2012-01-04 15:34 ` Alexander Graf
@ 2012-01-05 15:14 ` Stefan Weil
2012-01-08 9:17 ` Michael S. Tsirkin
1 sibling, 1 reply; 10+ messages in thread
From: Stefan Weil @ 2012-01-05 15:14 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel, Michael S. Tsirkin
Am 04.01.2012 15:47, schrieb Michael S. Tsirkin:
> On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
>> Commit d0ed8076cbdc261 converted the PCI config access to the memory
>> API, but also inadvertantly changed it to accept unaligned writes,
>> and corrupt the index register in the process. This causes a regression
>> booting NetBSD.
>>
>> Fix by ignoring unaligned or non-dword writes.
>>
>> https://bugs.launchpad.net/qemu/+bug/897771
>>
>> Reported-by: Andreas Gustafsson <gson@gson.org>
>> Signed-off-by: Avi Kivity <avi@redhat.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
>> ---
>>
>> hw/pci_host.c | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/pci_host.c b/hw/pci_host.c
>> index 44c6c20..8041778 100644
>> --- a/hw/pci_host.c
>> +++ b/hw/pci_host.c
>> @@ -101,6 +101,9 @@ static void pci_host_config_write(void *opaque,
>> target_phys_addr_t addr,
>>
>> PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
>> __func__, addr, len, val);
>> + if (addr != 0 || len != 4) {
>> + return;
>> + }
>> s->config_reg = val;
>> }
>>
>> --
>> 1.7.7.1
Non dword writes are quite common. I get them with Linux kernels, too.
Do you really want to ignore them?
And the check for unaligned writes is, well, unusual :-)
Regards,
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-05 15:14 ` Stefan Weil
@ 2012-01-08 9:17 ` Michael S. Tsirkin
2012-01-08 10:02 ` Avi Kivity
0 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2012-01-08 9:17 UTC (permalink / raw)
To: Stefan Weil; +Cc: Avi Kivity, qemu-devel
On Thu, Jan 05, 2012 at 04:14:29PM +0100, Stefan Weil wrote:
> Am 04.01.2012 15:47, schrieb Michael S. Tsirkin:
> >On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
> >>Commit d0ed8076cbdc261 converted the PCI config access to the memory
> >>API, but also inadvertantly changed it to accept unaligned writes,
> >>and corrupt the index register in the process. This causes a regression
> >>booting NetBSD.
> >>
> >>Fix by ignoring unaligned or non-dword writes.
> >>
> >>https://bugs.launchpad.net/qemu/+bug/897771
> >>
> >>Reported-by: Andreas Gustafsson <gson@gson.org>
> >>Signed-off-by: Avi Kivity <avi@redhat.com>
> >
> >Acked-by: Michael S. Tsirkin <mst@redhat.com>
> >
> >>---
> >>
> >>hw/pci_host.c | 3 +++
> >>1 files changed, 3 insertions(+), 0 deletions(-)
> >>
> >>diff --git a/hw/pci_host.c b/hw/pci_host.c
> >>index 44c6c20..8041778 100644
> >>--- a/hw/pci_host.c
> >>+++ b/hw/pci_host.c
> >>@@ -101,6 +101,9 @@ static void pci_host_config_write(void
> >>*opaque, target_phys_addr_t addr,
> >>
> >>PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
> >>__func__, addr, len, val);
> >>+ if (addr != 0 || len != 4) {
> >>+ return;
> >>+ }
> >>s->config_reg = val;
> >>}
> >>
> >>--
> >>1.7.7.1
>
> Non dword writes are quite common. I get them with Linux kernels, too.
> Do you really want to ignore them?
Are you sure?
Note this is an io write at cf8. Not an unaligned config write.
> And the check for unaligned writes is, well, unusual :-)
This seems to be how memory API behaves ... right, Avi?
Maybe this should be documented somewhere.
> Regards,
> Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-08 9:17 ` Michael S. Tsirkin
@ 2012-01-08 10:02 ` Avi Kivity
2012-01-08 10:12 ` Michael S. Tsirkin
0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2012-01-08 10:02 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Stefan Weil, qemu-devel
On 01/08/2012 11:17 AM, Michael S. Tsirkin wrote:
> On Thu, Jan 05, 2012 at 04:14:29PM +0100, Stefan Weil wrote:
> > Am 04.01.2012 15:47, schrieb Michael S. Tsirkin:
> > >On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
> > >>Commit d0ed8076cbdc261 converted the PCI config access to the memory
> > >>API, but also inadvertantly changed it to accept unaligned writes,
> > >>and corrupt the index register in the process. This causes a regression
> > >>booting NetBSD.
> > >>
> > >>Fix by ignoring unaligned or non-dword writes.
> > >>
> > >>https://bugs.launchpad.net/qemu/+bug/897771
> > >>
> > >>Reported-by: Andreas Gustafsson <gson@gson.org>
> > >>Signed-off-by: Avi Kivity <avi@redhat.com>
> > >
> > >Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > >
> > >>---
> > >>
> > >>hw/pci_host.c | 3 +++
> > >>1 files changed, 3 insertions(+), 0 deletions(-)
> > >>
> > >>diff --git a/hw/pci_host.c b/hw/pci_host.c
> > >>index 44c6c20..8041778 100644
> > >>--- a/hw/pci_host.c
> > >>+++ b/hw/pci_host.c
> > >>@@ -101,6 +101,9 @@ static void pci_host_config_write(void
> > >>*opaque, target_phys_addr_t addr,
> > >>
> > >>PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
> > >>__func__, addr, len, val);
> > >>+ if (addr != 0 || len != 4) {
> > >>+ return;
> > >>+ }
> > >>s->config_reg = val;
> > >>}
> > >>
> > >>--
> > >>1.7.7.1
> >
> > Non dword writes are quite common. I get them with Linux kernels, too.
> > Do you really want to ignore them?
>
> Are you sure?
> Note this is an io write at cf8. Not an unaligned config write.
>
> > And the check for unaligned writes is, well, unusual :-)
What's unusual?
> This seems to be how memory API behaves ... right, Avi?
> Maybe this should be documented somewhere.
Document what?
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-08 10:02 ` Avi Kivity
@ 2012-01-08 10:12 ` Michael S. Tsirkin
2012-01-08 10:48 ` Avi Kivity
0 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2012-01-08 10:12 UTC (permalink / raw)
To: Avi Kivity; +Cc: Stefan Weil, qemu-devel
On Sun, Jan 08, 2012 at 12:02:35PM +0200, Avi Kivity wrote:
> On 01/08/2012 11:17 AM, Michael S. Tsirkin wrote:
> > On Thu, Jan 05, 2012 at 04:14:29PM +0100, Stefan Weil wrote:
> > > Am 04.01.2012 15:47, schrieb Michael S. Tsirkin:
> > > >On Wed, Jan 04, 2012 at 04:28:42PM +0200, Avi Kivity wrote:
> > > >>Commit d0ed8076cbdc261 converted the PCI config access to the memory
> > > >>API, but also inadvertantly changed it to accept unaligned writes,
> > > >>and corrupt the index register in the process. This causes a regression
> > > >>booting NetBSD.
> > > >>
> > > >>Fix by ignoring unaligned or non-dword writes.
> > > >>
> > > >>https://bugs.launchpad.net/qemu/+bug/897771
> > > >>
> > > >>Reported-by: Andreas Gustafsson <gson@gson.org>
> > > >>Signed-off-by: Avi Kivity <avi@redhat.com>
> > > >
> > > >Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > > >
> > > >>---
> > > >>
> > > >>hw/pci_host.c | 3 +++
> > > >>1 files changed, 3 insertions(+), 0 deletions(-)
> > > >>
> > > >>diff --git a/hw/pci_host.c b/hw/pci_host.c
> > > >>index 44c6c20..8041778 100644
> > > >>--- a/hw/pci_host.c
> > > >>+++ b/hw/pci_host.c
> > > >>@@ -101,6 +101,9 @@ static void pci_host_config_write(void
> > > >>*opaque, target_phys_addr_t addr,
> > > >>
> > > >>PCI_DPRINTF("%s addr " TARGET_FMT_plx " len %d val %"PRIx64"\n",
> > > >>__func__, addr, len, val);
> > > >>+ if (addr != 0 || len != 4) {
> > > >>+ return;
> > > >>+ }
> > > >>s->config_reg = val;
> > > >>}
> > > >>
> > > >>--
> > > >>1.7.7.1
> > >
> > > Non dword writes are quite common. I get them with Linux kernels, too.
> > > Do you really want to ignore them?
> >
> > Are you sure?
> > Note this is an io write at cf8. Not an unaligned config write.
> >
> > > And the check for unaligned writes is, well, unusual :-)
>
> What's unusual?
>
>
> > This seems to be how memory API behaves ... right, Avi?
> > Maybe this should be documented somewhere.
>
> Document what?
That address passed to callbacks is in fact an offset
from start of the region.
> --
> error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-08 10:12 ` Michael S. Tsirkin
@ 2012-01-08 10:48 ` Avi Kivity
2012-01-08 12:45 ` Michael S. Tsirkin
0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2012-01-08 10:48 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Stefan Weil, qemu-devel
On 01/08/2012 12:12 PM, Michael S. Tsirkin wrote:
> > >
> > > > And the check for unaligned writes is, well, unusual :-)
> >
> > What's unusual?
> >
> >
> > > This seems to be how memory API behaves ... right, Avi?
> > > Maybe this should be documented somewhere.
> >
> > Document what?
>
> That address passed to callbacks is in fact an offset
> from start of the region.
>
It's documented already (and it's not new - since 8da3ff18097, Dec 2008).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-08 10:48 ` Avi Kivity
@ 2012-01-08 12:45 ` Michael S. Tsirkin
2012-01-08 12:53 ` Avi Kivity
0 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2012-01-08 12:45 UTC (permalink / raw)
To: Avi Kivity; +Cc: Stefan Weil, qemu-devel
On Sun, Jan 08, 2012 at 12:48:05PM +0200, Avi Kivity wrote:
> On 01/08/2012 12:12 PM, Michael S. Tsirkin wrote:
> > > >
> > > > > And the check for unaligned writes is, well, unusual :-)
> > >
> > > What's unusual?
> > >
> > >
> > > > This seems to be how memory API behaves ... right, Avi?
> > > > Maybe this should be documented somewhere.
> > >
> > > Document what?
> >
> > That address passed to callbacks is in fact an offset
> > from start of the region.
> >
>
> It's documented already (and it's not new - since 8da3ff18097, Dec 2008).
True, memory.h explicitly says:
@addr is relative to @mr
But now that's mentioned, I have a question:
we could also specify min access size and disable
unaligned access in ops.valid structure.
That would trigger machine checks on access errors
instead of ignoring them as we do now.
Anyone knows offhand what does real hardware do?
> --
> error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write
2012-01-08 12:45 ` Michael S. Tsirkin
@ 2012-01-08 12:53 ` Avi Kivity
0 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2012-01-08 12:53 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Stefan Weil, qemu-devel
On 01/08/2012 02:45 PM, Michael S. Tsirkin wrote:
> On Sun, Jan 08, 2012 at 12:48:05PM +0200, Avi Kivity wrote:
> > On 01/08/2012 12:12 PM, Michael S. Tsirkin wrote:
> > > > >
> > > > > > And the check for unaligned writes is, well, unusual :-)
> > > >
> > > > What's unusual?
> > > >
> > > >
> > > > > This seems to be how memory API behaves ... right, Avi?
> > > > > Maybe this should be documented somewhere.
> > > >
> > > > Document what?
> > >
> > > That address passed to callbacks is in fact an offset
> > > from start of the region.
> > >
> >
> > It's documented already (and it's not new - since 8da3ff18097, Dec 2008).
>
> True, memory.h explicitly says:
> @addr is relative to @mr
>
> But now that's mentioned, I have a question:
> we could also specify min access size and disable
> unaligned access in ops.valid structure.
> That would trigger machine checks on access errors
> instead of ignoring them as we do now.
> Anyone knows offhand what does real hardware do?
It depends on the actual hardware. qemu has some #ifdefs deep down that
control this.
Ultimately this should be local to the bus rather than global; for
example a bus can intercept unaligned writes and invoke some bus
specific behaviour even though the cpu allows those accesses.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-01-08 12:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-04 14:28 [Qemu-devel] [PATCH master/stable-1.0] pci: fix corrupted pci conf index register by unaligned write Avi Kivity
2012-01-04 14:47 ` Michael S. Tsirkin
2012-01-04 15:34 ` Alexander Graf
2012-01-05 15:14 ` Stefan Weil
2012-01-08 9:17 ` Michael S. Tsirkin
2012-01-08 10:02 ` Avi Kivity
2012-01-08 10:12 ` Michael S. Tsirkin
2012-01-08 10:48 ` Avi Kivity
2012-01-08 12:45 ` Michael S. Tsirkin
2012-01-08 12:53 ` Avi Kivity
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.