All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size.
@ 2011-12-19  2:27 zanghongyong
  2012-01-03 11:04 ` Pekka Enberg
  0 siblings, 1 reply; 4+ messages in thread
From: zanghongyong @ 2011-12-19  2:27 UTC (permalink / raw)
  To: kvm; +Cc: xiaowei.yang, hanweidong, wusongwei, kongbo, Hongyong Zang

From: Hongyong Zang <zanghongyong@huawei.com>

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 <zanghongyong@huawei.com>
---
 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;
-		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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size.
  2011-12-19  2:27 [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size zanghongyong
@ 2012-01-03 11:04 ` Pekka Enberg
  2012-01-05  3:34   ` Zang Hongyong
  0 siblings, 1 reply; 4+ messages in thread
From: Pekka Enberg @ 2012-01-03 11:04 UTC (permalink / raw)
  To: zanghongyong
  Cc: kvm, xiaowei.yang, hanweidong, wusongwei, kongbo, Sasha Levin,
	Lai Jiangshan, Ingo Molnar

On Mon, Dec 19, 2011 at 4:27 AM,  <zanghongyong@huawei.com> wrote:
> From: Hongyong Zang <zanghongyong@huawei.com>
>
> 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 <zanghongyong@huawei.com>

Please CC me on patches if you want me to apply them.

> ---
>  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?

> -               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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size.
  2012-01-03 11:04 ` Pekka Enberg
@ 2012-01-05  3:34   ` Zang Hongyong
  2012-01-05  6:25     ` Pekka Enberg
  0 siblings, 1 reply; 4+ messages in thread
From: Zang Hongyong @ 2012-01-05  3:34 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: kvm, xiaowei.yang, hanweidong, wusongwei, kongbo, Sasha Levin,
	Lai Jiangshan, Ingo Molnar

Pekka Enberg wrote:
> On Mon, Dec 19, 2011 at 4:27 AM,<zanghongyong@huawei.com>  wrote:
>> From: Hongyong Zang<zanghongyong@huawei.com>
>>
>> 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<zanghongyong@huawei.com>
> 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
> .
>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size.
  2012-01-05  3:34   ` Zang Hongyong
@ 2012-01-05  6:25     ` Pekka Enberg
  0 siblings, 0 replies; 4+ messages in thread
From: Pekka Enberg @ 2012-01-05  6:25 UTC (permalink / raw)
  To: Zang Hongyong
  Cc: kvm, xiaowei.yang, hanweidong, wusongwei, kongbo, Sasha Levin,
	Lai Jiangshan, Ingo Molnar

On Thu, 5 Jan 2012, Zang Hongyong wrote:
>>>   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)

I'm OK with that.

 			Pekka

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-05  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-19  2:27 [PATCH v2] kvm tool: Change kvm->ram_size to real mapped size zanghongyong
2012-01-03 11:04 ` Pekka Enberg
2012-01-05  3:34   ` Zang Hongyong
2012-01-05  6:25     ` Pekka Enberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.