WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

Re: [PATCH] check memory descriptor over lap in dom_fw_init() (was Re: [

To: Alex Williamson <alex.williamson@xxxxxx>
Subject: Re: [PATCH] check memory descriptor over lap in dom_fw_init() (was Re: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.)
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Fri, 2 Jun 2006 15:28:58 +0900
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 01 Jun 2006 23:29:12 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1149189542.5480.34.camel@lappy>
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <9FBCE015AF479F46B3B410499F3AE05B011EC67C@pdsmsx405> <1149127842.12367.50.camel@lappy> <20060601024642.GE13854%yamahata@xxxxxxxxxxxxx> <1149189542.5480.34.camel@lappy>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.2.1i
Hi Alex.

You're right. It could be simplified. It had also a bug.
The new patch is attached. please find it.

Thanks.

On Thu, Jun 01, 2006 at 01:19:02PM -0600, Alex Williamson wrote:
> Hi Isaku,
> 
>    I like this idea, this should really help creating dom0s with large
> memory (the swiotlb doesn't like it when we don't put any memory below
> 4GB).  I'm having trouble with the loop below though, it seems overly
> complicated, but maybe I'm missing something important.  We're just
> looking for gaps in the MDT above the hypercall areas, right?  Could the
> original be simplified as something like this (untested):
> 
>     for (j = 0; j < num_mds; j++) {
>             efi_memory_desc_t* next_md;
>             unsigned long end;
> 
>             md = &efi_memmap[j];
>             end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
>             if (maxmem < start)
>                     break;
> 
>             // Avoid "legacy" low memory addresses and the
>             // HYPERCALL patch area.
>             if (md->phys_addr < HYPERCALL_END) {
>                     BUG_ON(end > HYPERCALL_START);
>                     continue;
>             }
> 
>             if (j + 1 == num_mds && end < maxmem) {
>                     // End of list, map memory
>                     MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
>                             end, maxmem, 0);
>                     continue;
>             }
> 
>             next_md = &efi_memmap[j + 1];
> 
>             if (next_md->phys_addr > end) {
>                     // Found a gap, insert memory.
>                     // Should we look for some minimum sized gap?
>                     MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
>                             end, min(next_md->phys_addr, maxmem), 0);
>                     continue;
>             } else if (next_md->phys_addr < end) {
>                     // Bad, overlapping MDT ranges
>                     BUG_ON(next_md->phys_addr < end);
>             }
>     }
> 
> The MDT we're parsing is already sorted, so there's no reason to look
> further than j + 1 for the next gap.  I'm not sure I follow all of the
> tests at the end of the original loop, but I think I've captured them
> above.  Does this look right?  Thanks,
> 
>       Alex
> 
> On Thu, 2006-06-01 at 11:46 +0900, Isaku Yamahata wrote:
> > +#ifdef CONFIG_XEN_IA64_DOM0_VP
> > +        // simple
> > +        // MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
> > +        //         HYPERCALL_END, maxmem, 0);
> > +        // is not good. Check overlap.
> > +        sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp,
> > NULL);
> > +
> > +        num_mds = i;
> > +        for (j = 0; j < num_mds; j++) {
> > +            unsigned long start;
> > +            unsigned long end;
> > +            unsigned long next_start;
> > +            int k;
> > +            
> > +            md = &efi_memmap[j];
> > +            start = md->phys_addr;
> > +            end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
> > +
> > +            if (maxmem < start)
> > +                break;
> > +
> > +            // find gap
> > +            next_start = maxmem;
> > +            for (k = j + 1; k < num_mds; k++) {
> > +                efi_memory_desc_t* next_md = &efi_memmap[k];
> > +
> > +                if (end != next_md->phys_addr) {
> > +                    next_start = next_md->phys_addr;
> > +                    break;
> > +                }
> > +                end = next_md->phys_addr +
> > +                    (next_md->num_pages << EFI_PAGE_SHIFT);
> > +            }
> > +
> > +            if (next_start < HYPERCALL_END)
> > +                continue;
> > +
> > +            if (end < HYPERCALL_END)
> > +                end = HYPERCALL_END;
> > +            if (next_start > maxmem)
> > +                next_start = maxmem;
> > +            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
> > +                    end, next_start, 0);
> > +        }
> > +#endif   
> -- 
> Alex Williamson                             HP Open Source & Linux Org.
> 
> 
> _______________________________________________
> Xen-ia64-devel mailing list
> Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-ia64-devel
> 

-- 
yamahata

Attachment: 10236:8036118ac726_assign_page_to_dom0_precisely.patch
Description: Text document

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>