From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 1/2] kvm tools: Add memory gap for larger RAM sizes Date: Wed, 11 May 2011 09:21:16 +0300 Message-ID: <1305094876.2249.2.camel@sasha> References: <1305061513-28360-1-git-send-email-levinsasha928@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: mingo@elte.hu, asias.hejun@gmail.com, prasadjoshi124@gmail.com, avi@redhat.com, gorcunov@gmail.com, kvm@vger.kernel.org To: Pekka Enberg Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:45841 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169Ab1EKR0G (ORCPT ); Wed, 11 May 2011 13:26:06 -0400 Received: by wya21 with SMTP id 21so556365wya.19 for ; Wed, 11 May 2011 10:26:05 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 2011-05-11 at 08:37 +0300, 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. I've wanted to avoid actually allocating that gap (which is currently 512MB) and instead take the hit in guest_flat_to_host(). If you feel the 512MB vs guest_flat_to_host() trade-off is worth it, I'll change it to work that way. -- Sasha.