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

Re: [Xen-devel] [v10][PATCH 06/16] hvmloader/pci: Try to avoid placing BARs in RMRRs



On 07/20/2015 03:06 PM, Chen, Tiejun wrote:
>>>> +/* Find the lowest RMRR higher than base. */
>>>> +static int find_next_rmrr(uint32_t base)
>>>> +{
>>>> +    unsigned int i;
>>>> +    int next_rmrr = -1;
>>>> +    uint64_t min_base = (1ull << 32);
>>>> +
>>>> +    for ( i = 0; i < memory_map.nr_map ; i++ )
>>>> +    {
>>>> +        if ( memory_map.map[i].type == E820_RESERVED &&
>>>> +             memory_map.map[i].addr > base &&
>>>> +             memory_map.map[i].addr < min_base )
>>>> +        {
>>>> +            next_rmrr = i;
>>>> +            min_base = memory_map.map[i].addr;
>>>> +        }
>>>> +    }
>>>> +    return next_rmrr;
>>>> +}
>>>
>>> Considering _both_ callers, I think the function should actually return
>>> the lowest RMRR higher than or equal to base.
>>
>> You mean instead of strictly greater than the base.
>>
>>> Or wait - we actually
>>> need to find the lowest RMRR the _end_ of which is higher than base.
>>
>> Yes, you're right: there's always a risk that pci_mem_start will *start*
>> in the middle of a range.  Looking for the next *end* is more robust.
>>
> 
> Sorry this is not very clear to me so are you saying something like this?
> 
>     for ( i = 0; i < memory_map.nr_map ; i++ )
>     {
>         end = memory_map.map[i].addr + memory_map.map[i].size;
> 
>         if ( memory_map.map[i].type == E820_RESERVED &&
>              end > base &&
>              memory_map.map[i].addr < min_base )
>         {
>             next_rmrr = i;
>             min_base = memory_map.map[i].addr;
>         }
>     }

I think replace min_base with min_end:

         if ( memory_map.map[i].type == E820_RESERVED &&
              end > base &&
              end < min_end )
         {
             next_rmrr = i;
             min_end = end;
         }

Hmm... although I suppose that doesn't catch the possibility of a memory
range crossing the 4G boundary.

 -George

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


 


Rackspace

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