diff mbox

Fix typo in i400FX chipset init code

Message ID 1330479314.29508.7.camel@nzhmlwks0057.ad.endace.com
State New
Headers show

Commit Message

Alexey Korolev Feb. 29, 2012, 1:35 a.m. UTC
Hi,

There is a typo in i440FX init code. This is causing problems when
somebody wants to access 64bit PCI range.


Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
---

 hw/piix_pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Alexey Korolev March 21, 2012, 5:26 a.m. UTC | #1
> Hi,
> 
> There is a typo in i440FX init code. This is causing problems when
> somebody wants to access 64bit PCI range.
> 
> 
> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
> ---
> 
>  hw/piix_pci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
> index 3ed3d90..aab8188 100644
> --- a/hw/piix_pci.c
> +++ b/hw/piix_pci.c
> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>                             address_space_mem, address_space_io, ram_size,
>                             pci_hole_start, pci_hole_size,
> -                           pci_hole64_size, pci_hole64_size,
> +                           pci_hole64_start, pci_hole64_size,
>                             pci_memory, ram_memory);
>      return b;
>  }
> 
> 
> 
Hi there,

Any chance that someone could have a look and commit this?
Markus Armbruster March 21, 2012, 12:28 p.m. UTC | #2
Alexey Korolev <alexey.korolev@endace.com> writes:

>> Hi,
>> 
>> There is a typo in i440FX init code. This is causing problems when
>> somebody wants to access 64bit PCI range.
>> 
>> 
>> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
>> ---
>> 
>>  hw/piix_pci.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
>> index 3ed3d90..aab8188 100644
>> --- a/hw/piix_pci.c
>> +++ b/hw/piix_pci.c
>> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>>                             address_space_mem, address_space_io, ram_size,
>>                             pci_hole_start, pci_hole_size,
>> -                           pci_hole64_size, pci_hole64_size,
>> +                           pci_hole64_start, pci_hole64_size,
>>                             pci_memory, ram_memory);
>>      return b;
>>  }
>> 
>> 
>> 
> Hi there,
>
> Any chance that someone could have a look and commit this?

Stefan, would you like to take this through your trivial queue?
Andreas Färber March 21, 2012, 12:32 p.m. UTC | #3
Hi,

Am 21.03.2012 06:26, schrieb Alexey Korolev:
>> Hi,
>>
>> There is a typo in i440FX init code. This is causing problems when
>> somebody wants to access 64bit PCI range.
>>
>>
>> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
>> ---
>>
>>  hw/piix_pci.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
>> index 3ed3d90..aab8188 100644
>> --- a/hw/piix_pci.c
>> +++ b/hw/piix_pci.c
>> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>>                             address_space_mem, address_space_io, ram_size,
>>                             pci_hole_start, pci_hole_size,
>> -                           pci_hole64_size, pci_hole64_size,
>> +                           pci_hole64_start, pci_hole64_size,
>>                             pci_memory, ram_memory);
>>      return b;
>>  }
>>
>>
>>
> Hi there,
> 
> Any chance that someone could have a look and commit this?

A patch should never start with "Hi,", it should have a commit message
that can be applied unmodified to git, describing what area it touches,
what it changes and why. So, the the subject should start with, e.g.,
"i440fx: Fix start of 64-bit hole" and go on to explain where exactly
that is and what it affects (does this resolve some guest-visible bug?
when was it introduced? i.e., does it need to be backported?). Repeating
"typo" again and again is not helpful to understand the impact of a
commit when bisecting later on without seeing the code.

You forgot to cc the PCI maintainer.

Andreas
Andreas Färber March 21, 2012, 12:35 p.m. UTC | #4
Am 21.03.2012 13:28, schrieb Markus Armbruster:
> Alexey Korolev <alexey.korolev@endace.com> writes:
> 
>>> Hi,
>>>
>>> There is a typo in i440FX init code. This is causing problems when
>>> somebody wants to access 64bit PCI range.
>>>
>>>
>>> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
>>> ---
>>>
>>>  hw/piix_pci.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
>>> index 3ed3d90..aab8188 100644
>>> --- a/hw/piix_pci.c
>>> +++ b/hw/piix_pci.c
>>> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>>>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>>>                             address_space_mem, address_space_io, ram_size,
>>>                             pci_hole_start, pci_hole_size,
>>> -                           pci_hole64_size, pci_hole64_size,
>>> +                           pci_hole64_start, pci_hole64_size,
>>>                             pci_memory, ram_memory);
>>>      return b;
>>>  }
>>>
>>>
>>>
>> Hi there,
>>
>> Any chance that someone could have a look and commit this?
> 
> Stefan, would you like to take this through your trivial queue?

Not without fixing up the commit message, please. CC'ing mst since this
is a PCI issue and not some random unmaintained area of code.

Andreas
Michael S. Tsirkin March 21, 2012, 12:59 p.m. UTC | #5
On Wed, Feb 29, 2012 at 02:35:14PM +1300, Alexey Korolev wrote:
> Hi,
> 
> There is a typo in i440FX init code. This is causing problems when
> somebody wants to access 64bit PCI range.
> 
> 
> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>

I've fixed the commit message and applied.
How does one trigger the problem?
I'd like to know so I can test for it.

> ---
> 
>  hw/piix_pci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
> index 3ed3d90..aab8188 100644
> --- a/hw/piix_pci.c
> +++ b/hw/piix_pci.c
> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>                             address_space_mem, address_space_io, ram_size,
>                             pci_hole_start, pci_hole_size,
> -                           pci_hole64_size, pci_hole64_size,
> +                           pci_hole64_start, pci_hole64_size,
>                             pci_memory, ram_memory);
>      return b;
>  }
> 
> 
> 
>
Michael S. Tsirkin March 21, 2012, 1:07 p.m. UTC | #6
On Wed, Mar 21, 2012 at 01:32:44PM +0100, Andreas Färber wrote:
> Hi,
> 
> Am 21.03.2012 06:26, schrieb Alexey Korolev:
> >> Hi,
> >>
> >> There is a typo in i440FX init code. This is causing problems when
> >> somebody wants to access 64bit PCI range.
> >>
> >>
> >> Signed-off-by: Alexey Korolev <alexey.korolev@endace.com>
> >> ---
> >>
> >>  hw/piix_pci.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
> >> index 3ed3d90..aab8188 100644
> >> --- a/hw/piix_pci.c
> >> +++ b/hw/piix_pci.c
> >> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
> >>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
> >>                             address_space_mem, address_space_io, ram_size,
> >>                             pci_hole_start, pci_hole_size,
> >> -                           pci_hole64_size, pci_hole64_size,
> >> +                           pci_hole64_start, pci_hole64_size,
> >>                             pci_memory, ram_memory);
> >>      return b;
> >>  }
> >>
> >>
> >>
> > Hi there,
> > 
> > Any chance that someone could have a look and commit this?
> 
> A patch should never start with "Hi,", it should have a commit message
> that can be applied unmodified to git, describing what area it touches,
> what it changes and why. So, the the subject should start with, e.g.,
> "i440fx: Fix start of 64-bit hole" and go on to explain where exactly
> that is and what it affects (does this resolve some guest-visible bug?
> when was it introduced? i.e., does it need to be backported?). Repeating
> "typo" again and again is not helpful to understand the impact of a
> commit when bisecting later on without seeing the code.
> 
> You forgot to cc the PCI maintainer.
> 
> Andreas

Yes I'd like to see an explanation on how to trigger a bug too.
OTOH the fix is clearly right, and it's not submitter's
work to dig through history to find where was the bug
added, that is too much to ask IMO.

> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Alexey Korolev March 21, 2012, 11:08 p.m. UTC | #7
> On Wed, Feb 29, 2012 at 02:35:14PM +1300, Alexey Korolev wrote:
> I've fixed the commit message and applied. 
Thank you!
> How does one trigger the problem?
> I'd like to know so I can test for it.

The i440fx_init() function is called from pc_init code.
The call looks like that:
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
                               system_memory, system_io, ram_size,
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l200>                              
below_4g_mem_size,
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l201>                              
0x100000000ULL - below_4g_mem_size,
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l202>                              
0x100000000ULL + above_4g_mem_size,
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l203>                              
(sizeof(target_phys_addr_t) == 4
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l204>                               
? 0
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l205>                               
: ((uint64_t)1 << 62)),
<http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/pc_piix.c;hb=a27726650ecc89b4a518a9a5d256de852894b3a2#l206>                              
pci_memory, ram_memory);

So we have

pci_hole64_size = 1 << 62

and because of typo  we also have 

pci_hole64_start = 1 << 62

The pci_hole64_start & pci_hole64_size are used to build memory regions access ranges.
Since 64bit PCI regions must be below 1<<40 and pci_hole64_start is 1 << 62, we have situations when all
64bit PCI regions are inaccessible.

For how to test it:
Convert device to use 64bit PCI BARs (ivshmem.c for example).
Apply patches for 64 bit support in seabios:
http://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg00018.html.

Try to access the content of 64bit PCI memory. It will fail!


P/s:
IMHO it makes sence to update pc_iix.c code as well.
The pci_hole64_size value is incorrect anyway.


>> ---
>>
>>  hw/piix_pci.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
>> index 3ed3d90..aab8188 100644
>> --- a/hw/piix_pci.c
>> +++ b/hw/piix_pci.c
>> @@ -353,7 +353,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
>>      b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
>>                             address_space_mem, address_space_io, ram_size,
>>                             pci_hole_start, pci_hole_size,
>> -                           pci_hole64_size, pci_hole64_size,
>> +                           pci_hole64_start, pci_hole64_size,
>>                             pci_memory, ram_memory);
>>      return b;
>>  }
>>
>>
>>
>>
diff mbox

Patch

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 3ed3d90..aab8188 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -353,7 +353,7 @@  PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic,
                            address_space_mem, address_space_io, ram_size,
                            pci_hole_start, pci_hole_size,
-                           pci_hole64_size, pci_hole64_size,
+                           pci_hole64_start, pci_hole64_size,
                            pci_memory, ram_memory);
     return b;
 }