[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5)
From: |
Igor Mammedov |
Subject: |
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5) |
Date: |
Tue, 12 Nov 2013 13:45:51 +0100 |
On Sun, 10 Nov 2013 18:47:53 -0200
Marcelo Tosatti <address@hidden> wrote:
[...]
> @@ -1177,10 +1182,50 @@ FWCfgState *pc_memory_init(MemoryRegion
> *system_memory,
> e820_add_entry(0, below_4g_mem_size, E820_RAM);
> if (above_4g_mem_size > 0) {
> ram_above_4g = g_malloc(sizeof(*ram_above_4g));
it is a memory leak when "ram-above-4g" is not created
> - memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
> - below_4g_mem_size, above_4g_mem_size);
> - memory_region_add_subregion(system_memory, 0x100000000ULL,
> + /*
> + *
> + * If 1GB hugepages are used to back guest RAM, map guest address
> + * space in the range [ramsize,ramsize+holesize] to the ram block
> + * range [holestart, 4GB]
> + *
> + * 0 h 4G
> [ramsize,ramsize+holesize]
> + *
> + * guest-addr-space [ ] [ ][xxx]
> + * /----------/
> + * contiguous-ram-block [ ][xxx][ ]
> + *
> + * So that memory beyond 4GB is aligned on a 1GB boundary,
> + * at the host physical address space.
> + *
> + */
> + if (guest_info->gb_align) {
> + uint64_t holesize = 0x100000000ULL - below_4g_mem_size;
> + uint64_t piecetwosize = holesize - align_offset;
> +
> + assert(piecetwosize <= holesize);
> +
> + if ((above_4g_mem_size - piecetwosize) > 0) {
here is integer overflow,
reproducable with: -mem-path /var/lib/hugetlbfs/global/pagesize-1GB -m 3600
> + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g",
> + ram, 0x100000000ULL,
> + above_4g_mem_size - piecetwosize);
> + memory_region_add_subregion(system_memory, 0x100000000ULL,
> + ram_above_4g);
> + }
> +
> + ram_above_4g_piecetwo = g_malloc(sizeof(*ram_above_4g_piecetwo));
> + memory_region_init_alias(ram_above_4g_piecetwo, NULL,
> + "ram-above-4g-piecetwo", ram,
> + 0x100000000ULL - holesize,
> piecetwosize);
> + memory_region_add_subregion(system_memory,
> + 0x100000000ULL +
> + above_4g_mem_size - piecetwosize,
is there a guaranty that "ram-above-4g-piecetwo" will be mapped immediately
after "ram-above-4g" without any gap?
if there is no then you might need to change how e820_add_entry() for high ram
is handled and possibly CMOS value as well.
> + ram_above_4g_piecetwo);
> + } else {
> + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram,
> + below_4g_mem_size, above_4g_mem_size);
> + memory_region_add_subregion(system_memory, 0x100000000ULL,
> ram_above_4g);
> + }
> e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
> }
[...]
--
Regards,
Igor
- Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v3), (continued)
[Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v4), Marcelo Tosatti, 2013/11/06
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v4), Igor Mammedov, 2013/11/07
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v4), Marcelo Tosatti, 2013/11/07
[Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5), Marcelo Tosatti, 2013/11/10
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5),
Igor Mammedov <=
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v5), Marcelo Tosatti, 2013/11/12
[Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Marcelo Tosatti, 2013/11/12
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Igor Mammedov, 2013/11/13
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Paolo Bonzini, 2013/11/13
Message not availableRe: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Marcelo Tosatti, 2013/11/13
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Paolo Bonzini, 2013/11/13
Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6), Michael S. Tsirkin, 2013/11/13