From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zang Hongyong Subject: Re: [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size. Date: Thu, 05 Jan 2012 11:34:28 +0800 Message-ID: <4F051A44.8060205@huawei.com> References: <1324261621-19862-1-git-send-email-zanghongyong@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7BIT Cc: kvm@vger.kernel.org, xiaowei.yang@huawei.com, hanweidong@huawei.com, wusongwei@huawei.com, kongbo@huawei.com, Sasha Levin , Lai Jiangshan , Ingo Molnar To: Pekka Enberg Return-path: Received: from szxga04-in.huawei.com ([119.145.14.67]:60283 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752763Ab2AEDgH (ORCPT ); Wed, 4 Jan 2012 22:36:07 -0500 Received: from huawei.com (szxga04-in [172.24.2.12]) by szxga04-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LXB00LMR3AC4M@szxga04-in.huawei.com> for kvm@vger.kernel.org; Thu, 05 Jan 2012 11:35:00 +0800 (CST) Received: from szxrg02-dlp.huawei.com ([172.24.2.119]) by szxga04-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LXB004BD3ACGL@szxga04-in.huawei.com> for kvm@vger.kernel.org; Thu, 05 Jan 2012 11:35:00 +0800 (CST) In-reply-to: Sender: kvm-owner@vger.kernel.org List-ID: Pekka Enberg wrote: > On Mon, Dec 19, 2011 at 4:27 AM, wrote: >> From: Hongyong Zang >> >> If a guest's ram_size exceeds KVM_32BIT_GAP_START, the corresponding kvm tool's >> virtual address size should be (ram_size + KVM_32BIT_GAP_SIZE), rather than ram_size. >> >> Signed-off-by: Hongyong Zang > Please CC me on patches if you want me to apply them. OK. >> --- >> tools/kvm/x86/bios.c | 2 +- >> tools/kvm/x86/kvm.c | 12 ++++++------ >> 2 files changed, 7 insertions(+), 7 deletions(-) >> >> diff --git a/tools/kvm/x86/bios.c b/tools/kvm/x86/bios.c >> index ded0717..06ec708 100644 >> --- a/tools/kvm/x86/bios.c >> +++ b/tools/kvm/x86/bios.c >> @@ -93,7 +93,7 @@ static void e820_setup(struct kvm *kvm) >> }; >> mem_map[i++] = (struct e820entry) { >> .addr = 0x100000000ULL, >> - .size = kvm->ram_size - KVM_32BIT_GAP_START, >> + .size = kvm->ram_size - 0x100000000ULL, >> .type = E820_RAM, >> }; >> } >> diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c >> index d2fbbe2..11a726e 100644 >> --- a/tools/kvm/x86/kvm.c >> +++ b/tools/kvm/x86/kvm.c >> @@ -111,7 +111,7 @@ void kvm__init_ram(struct kvm *kvm) >> /* Second RAM range from 4GB to the end of RAM: */ >> >> phys_start = 0x100000000ULL; > Can we please turn this "0x100000000ULL" magic number into a constant? Sure. How about define this magic number as follow? #define KVM_32BIT_MAX_MEM_SIZE (1ULL << 32) Hongyong >> - phys_size = kvm->ram_size - phys_size; >> + phys_size = kvm->ram_size - phys_start; >> host_mem = kvm->ram_start + phys_start; >> >> kvm__register_mem(kvm, phys_start, phys_size, host_mem); >> @@ -156,12 +156,12 @@ void kvm__arch_init(struct kvm *kvm, const char *kvm_dev, const char *hugetlbfs_ >> if (ret< 0) >> die_perror("KVM_CREATE_PIT2 ioctl"); >> >> - kvm->ram_size = ram_size; >> - >> - if (kvm->ram_size< KVM_32BIT_GAP_START) { >> - kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size); >> + if (ram_size< KVM_32BIT_GAP_START) { >> + kvm->ram_size = ram_size; >> + kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, kvm->ram_size); >> } else { >> - kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE); >> + kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE; >> + kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, kvm->ram_size); >> if (kvm->ram_start != MAP_FAILED) >> /* >> * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that >> -- >> 1.7.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > . >