[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v1] hvmloader, pci: Don't try to relocate memory if 64-bit BAR is bigger than 4GB



>>> On 06.07.16 at 20:16, <konrad.wilk@xxxxxxxxxx> wrote:
> @@ -269,8 +269,19 @@ void pci_setup(void)
>              if ( ((bar_data & PCI_BASE_ADDRESS_SPACE) ==
>                    PCI_BASE_ADDRESS_SPACE_MEMORY) ||
>                   (bar_reg == PCI_ROM_ADDRESS) )
> -                mmio_total += bar_sz;
> -

Please retain this blank line (below your addition).

> +            {
> +                /* If bigger than 4GB, don't try to put under 4GB. */
> +                if ( is_64bar && bar_sz > (1ull<<32) )

Clearly at the very least this should be >=. However, even when
it's a 2Gb BAR, we won't be able to fit it (as it can't go at address
zero, nor at address 0x80000000, both for different reasons).

> +                {
> +                    mmio_64bit_total += bar_sz;
> +                    /*
> +                     * As this may not trigger now that mmio_total could be
> +                     * less than 2GB, so force it.
> +                     */
> +                    bar64_relocate = 1;
> +                } else

Coding style.

> @@ -431,7 +442,7 @@ void pci_setup(void)
>           * Should either of those two conditions change, this code will 
> break.
>           */
>          using_64bar = bars[i].is_64bar && bar64_relocate
> -            && (mmio_total > (mem_resource.max - mem_resource.base));
> +            && (mmio_total + mmio_64bit_total > (mem_resource.max - 
> mem_resource.base));

Please retain consistent parenthesization: Either drop the ones
around the operands of - or add a pair around the operands of +.

> @@ -451,7 +462,10 @@ void pci_setup(void)
>                  resource = &mem_resource;
>                  bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
>              }
> -            mmio_total -= bar_sz;
> +            if ( bars[i].is_64bar && bar_sz > (1ull<<32) )

Now that you use this constant a second time, it clearly needs to
become a #define.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.