From: Anthony Liguori Subject: [PATCH 1/3] Make to round memory to next page Date: Wed, 5 Sep 2007 10:35:00 -0500 Message-ID: <118900650250-git-send-email-aliguori@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , Avi Kivity To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org In general, the BIOS, VGA BIOS, and option ROMs are not required to be multiple of page sizes. This means that phys_ram_size may not be a multiple of page. Address this at the kvm_create() level to make things simplier for future callers. Signed-off-by: Anthony Liguori diff --git a/user/kvmctl.c b/user/kvmctl.c index 846aac9..035ff43 100644 --- a/user/kvmctl.c +++ b/user/kvmctl.c @@ -40,6 +40,7 @@ static int kvm_abi = EXPECTED_KVM_API_VERSION; #define PAGE_SIZE 4096ul +#define PAGE_MASK (~(PAGE_SIZE - 1)) /* FIXME: share this number with kvm */ /* FIXME: or dynamically alloc/realloc regions */ @@ -232,11 +233,12 @@ int kvm_create_vcpu(kvm_context_t kvm, int slot) return 0; } -int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem) +int kvm_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem) { unsigned long dosmem = 0xa0000; unsigned long exmem = 0xc0000; unsigned long pcimem = 0xf0000000; + unsigned long memory = (phys_mem_bytes + PAGE_SIZE - 1) & PAGE_MASK; int fd = kvm->fd; int zfd; int r; ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/