Patchwork [for-1.7,v2,7/8] pc: s/INT64_MAX/UINT64_MAX/

login
register
mail settings
Submitter Marcel Apfelbaum
Date Nov. 7, 2013, 10:41 a.m.
Message ID <1383820884-29596-8-git-send-email-marcel.a@redhat.com>
Download mbox | patch
Permalink /patch/289285/
State New
Headers show

Comments

Marcel Apfelbaum - Nov. 7, 2013, 10:41 a.m.
From: Paolo Bonzini <pbonzini@redhat.com>

It doesn't make sense for a region to be INT64_MAX in size:
memory core uses UINT64_MAX as a special value meaning
"all 64 bit" this is what was meant here.

While this should never affect the PC system which at the moment always
has < 63 bit size, this makes us hit all kind of corner case bugs with
sub-pages, so users are probably better off if we just use UINT64_MAX
instead.

Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
Tested-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/pc_piix.c | 2 +-
 hw/i386/pc_q35.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Paolo Bonzini - Nov. 19, 2013, 11:44 a.m.
Il 07/11/2013 11:41, Marcel Apfelbaum ha scritto:
> From: Paolo Bonzini <pbonzini@redhat.com>
> 
> It doesn't make sense for a region to be INT64_MAX in size:
> memory core uses UINT64_MAX as a special value meaning
> "all 64 bit" this is what was meant here.
> 
> While this should never affect the PC system which at the moment always
> has < 63 bit size, this makes us hit all kind of corner case bugs with
> sub-pages, so users are probably better off if we just use UINT64_MAX
> instead.
> 
> Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
> Tested-by: Luiz Capitulino <lcapitulino@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Michael, is this patch (and 8/8: spapr_pci: s/INT64_MAX/UINT64_MAX/)
queued for 1.7 and/or 1.8?

Paolo

> ---
>  hw/i386/pc_piix.c | 2 +-
>  hw/i386/pc_q35.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 4fdb7b6..8e8d354 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -115,7 +115,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
>  
>      if (pci_enabled) {
>          pci_memory = g_new(MemoryRegion, 1);
> -        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
> +        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
>          rom_memory = pci_memory;
>      } else {
>          pci_memory = NULL;
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 4c191d3..ca44e05 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -102,7 +102,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
>      /* pci enabled */
>      if (pci_enabled) {
>          pci_memory = g_new(MemoryRegion, 1);
> -        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
> +        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
>          rom_memory = pci_memory;
>      } else {
>          pci_memory = NULL;
>
Michael S. Tsirkin - Nov. 19, 2013, 12:04 p.m.
On Tue, Nov 19, 2013 at 12:44:42PM +0100, Paolo Bonzini wrote:
> Il 07/11/2013 11:41, Marcel Apfelbaum ha scritto:
> > From: Paolo Bonzini <pbonzini@redhat.com>
> > 
> > It doesn't make sense for a region to be INT64_MAX in size:
> > memory core uses UINT64_MAX as a special value meaning
> > "all 64 bit" this is what was meant here.
> > 
> > While this should never affect the PC system which at the moment always
> > has < 63 bit size, this makes us hit all kind of corner case bugs with
> > sub-pages, so users are probably better off if we just use UINT64_MAX
> > instead.
> > 
> > Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
> > Tested-by: Luiz Capitulino <lcapitulino@redhat.com>
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> Michael, is this patch (and 8/8: spapr_pci: s/INT64_MAX/UINT64_MAX/)
> queued for 1.7 and/or 1.8?
> 
> Paolo

I queued this for 1.8 - I don't think it fixes any known specific bugs.
You can see my queue at
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci

> > ---
> >  hw/i386/pc_piix.c | 2 +-
> >  hw/i386/pc_q35.c  | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> > index 4fdb7b6..8e8d354 100644
> > --- a/hw/i386/pc_piix.c
> > +++ b/hw/i386/pc_piix.c
> > @@ -115,7 +115,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
> >  
> >      if (pci_enabled) {
> >          pci_memory = g_new(MemoryRegion, 1);
> > -        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
> > +        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
> >          rom_memory = pci_memory;
> >      } else {
> >          pci_memory = NULL;
> > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> > index 4c191d3..ca44e05 100644
> > --- a/hw/i386/pc_q35.c
> > +++ b/hw/i386/pc_q35.c
> > @@ -102,7 +102,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
> >      /* pci enabled */
> >      if (pci_enabled) {
> >          pci_memory = g_new(MemoryRegion, 1);
> > -        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
> > +        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
> >          rom_memory = pci_memory;
> >      } else {
> >          pci_memory = NULL;
> >

Patch

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 4fdb7b6..8e8d354 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -115,7 +115,7 @@  static void pc_init1(QEMUMachineInitArgs *args,
 
     if (pci_enabled) {
         pci_memory = g_new(MemoryRegion, 1);
-        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
+        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
         rom_memory = pci_memory;
     } else {
         pci_memory = NULL;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 4c191d3..ca44e05 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -102,7 +102,7 @@  static void pc_q35_init(QEMUMachineInitArgs *args)
     /* pci enabled */
     if (pci_enabled) {
         pci_memory = g_new(MemoryRegion, 1);
-        memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
+        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
         rom_memory = pci_memory;
     } else {
         pci_memory = NULL;