From: Ingo Molnar Subject: Re: [PATCH 1/2] kvm tools: Add memory gap for larger RAM sizes Date: Wed, 11 May 2011 10:44:02 +0200 Message-ID: <20110511084402.GB7112@elte.hu> References: <1305061513-28360-1-git-send-email-levinsasha928@gmail.com> <4DCA4917.9020802@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Pekka Enberg , Sasha Levin , asias.hejun@gmail.com, prasadjoshi124@gmail.com, gorcunov@gmail.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from fallback.mail.elte.hu ([157.181.151.13]:37477 "EHLO fallback.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756305Ab1EKP5m (ORCPT ); Wed, 11 May 2011 11:57:42 -0400 Received: from mx3.mail.elte.hu ([157.181.1.138]) by fallback.mail.elte.hu with esmtp (Exim) id 1QK5As-0006zJ-89 from for ; Wed, 11 May 2011 10:53:42 +0200 Content-Disposition: inline In-Reply-To: <4DCA4917.9020802@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: * Avi Kivity wrote: > On 05/11/2011 08:37 AM, Pekka Enberg wrote: > >On Wed, May 11, 2011 at 12:05 AM, Sasha Levin wrote: > >> + if (kvm->ram_size< 0xe0000000) { > > > >Please use the ULL postfix for constants to ensure the types are sane. > >Also, please come up with a sane name for these. > > > >> @@ -60,7 +60,14 @@ static inline u32 segment_to_flat(u16 selector, u16 offset) > >> > >> static inline void *guest_flat_to_host(struct kvm *self, unsigned long offset) > >> { > >> - return self->ram_start + offset; > >> + /* > >> + * We have a gap between 0xe0000000 and 0x100000000. > >> + * Consider it when translating an address above 0x100000000. > >> + */ > >> + if (offset< 0xe0000000) > >> + return self->ram_start + offset; > >> + else > >> + return self->ram_start + 0xe0000000 + (offset - 0x100000000); > >> } > > > >Would it not be simpler to mmap() a "ram_size + gap_size" contiguous > >region and mprotect(PROT_NONE) the gap? We'd still tell KVM and E820 > >maps about two separate regions but guest_flat_to_host() would > >work-as-is. > > It doesn't work in general - if you have a PCI device with a BAR > (like a video card framebuffer), then you need allocations for main > memory (0+) and pci (0xe000000+). You can't have a contiguous > mapping on i386 containing both. I think in tools/kvm/ we can ignore i386 hosts that would like to map more RAM than they have virtual address space for ... Guests up to 1-2 gigs of RAM will still work fine. Thanks, Ingo