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

Re: [Xen-devel] [v8][PATCH 10/17] hvmloader/mem_hole_alloc: skip any overlap with reserved device memory



On Mon, Dec 01, 2014 at 05:24:28PM +0800, Tiejun Chen wrote:
> In some cases like igd_opregion_pgbase, guest will use mem_hole_alloc
> to allocate some memory to use in runtime cycle, so we alsoe need to

s/cycle//

s/alsoe/also

> make sure all reserved device memory don't overlap such a region.

s/such a/with such/
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx>
> ---
>  tools/firmware/hvmloader/util.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
> index 8767897..f3723c7 100644
> --- a/tools/firmware/hvmloader/util.c
> +++ b/tools/firmware/hvmloader/util.c
> @@ -416,9 +416,29 @@ static uint32_t alloc_down = RESERVED_MEMORY_DYNAMIC_END;
>  
>  xen_pfn_t mem_hole_alloc(uint32_t nr_mfns)
>  {
> +    unsigned int i, num = hvm_get_reserved_device_memory_map();
> +    uint64_t rdm_start, rdm_end;
> +    uint32_t alloc_start, alloc_end;
> +
>      alloc_down -= nr_mfns << PAGE_SHIFT;
> +    alloc_start = alloc_down;
> +    alloc_end = alloc_start + (nr_mfns << PAGE_SHIFT);
> +    for ( i = 0; i < num; i++ )
> +    {
> +        rdm_start = (uint64_t)rdm_map[i].start_pfn << PAGE_SHIFT;
> +        rdm_end = rdm_start + ((uint64_t)rdm_map[i].nr_pages << PAGE_SHIFT);
> +        if ( check_rdm_hole_conflict((uint64_t)alloc_start,
> +                                     (uint64_t)alloc_end,
> +                                     rdm_start, rdm_end - rdm_start) )
> +        {
> +            alloc_end = rdm_start;
> +            alloc_start = alloc_end - (nr_mfns << PAGE_SHIFT);
> +            BUG_ON(alloc_up >= alloc_start);
> +        }
> +    }
> +
>      BUG_ON(alloc_up >= alloc_down);
> -    return alloc_down >> PAGE_SHIFT;
> +    return alloc_start >> PAGE_SHIFT;
>  }
>  
>  void *mem_alloc(uint32_t size, uint32_t align)
> -- 
> 1.9.1
> 

_______________________________________________
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®.