From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v7][PATCH 07/16] hvmloader/e820: construct guest e820 table Date: Thu, 16 Jul 2015 09:58:49 +0800 Message-ID: <55A70FD9.1050704@intel.com> References: <1436420047-25356-1-git-send-email-tiejun.chen@intel.com> <1436420047-25356-8-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: George Dunlap Cc: Keir Fraser , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , "xen-devel@lists.xen.org" , Jan Beulich , Wei Liu List-Id: xen-devel@lists.xenproject.org > I think I would say: > > -- > Now use the hypervisor-supplied memory map to build our final e820 table: > * Add regions for BIOS ranges and other special mappings not in the > hypervisor map > * Add in the hypervisor regions > * Adjust the lowmem and highmem regions if we've had to relocate > memory (adding a highmem region if necessary) > * Sort all the ranges so that they appear in memory order. > -- I'll update this and thanks a lot. > >> >> CC: Keir Fraser >> CC: Jan Beulich >> CC: Andrew Cooper >> CC: Ian Jackson >> CC: Stefano Stabellini >> CC: Ian Campbell >> CC: Wei Liu >> Signed-off-by: Tiejun Chen >> --- [snip] >> + /* Low RAM goes here. Reserve space for special pages. */ >> + BUG_ON(low_mem_end < (2u << 20)); > > Won't this BUG if the guest was actually given less than 2GiB of RAM? 2u << 20 = 0x200000, so this is 2M, not 2G :) > >> + >> + /* >> + * We may need to adjust real lowmem end since we may >> + * populate RAM to get enough MMIO previously. >> + */ [snip] >> + >> + /* >> + * And then we also need to adjust highmem. >> + */ >> + if ( add_high_mem ) >> + { >> + for ( i = 0; i < memory_map.nr_map; i++ ) >> + { >> + if ( e820[i].type == E820_RAM && >> + e820[i].addr > (1ull << 32)) >> + e820[i].size += add_high_mem; >> + } >> + } > > What if there was originally no high memory, but resizing the pci hole > meant we had to create a high memory region? > You're right. We need to consider this case. Thanks Tiejun