[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 1/2] exec: add qemu_get_ram_hpagesize
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 1/2] exec: add qemu_get_ram_hpagesize |
Date: |
Thu, 24 Oct 2013 19:11:59 -0200 |
User-agent: |
quilt/0.60-1 |
Add helper to retrieve page size of RAM backing, when hugetlbfs
is used.
Signed-off-by: Marcelo Tosatti <address@hidden>
Index: git/qemu/exec.c
===================================================================
--- qemu.orig/exec.c
+++ qemu/exec.c
@@ -961,8 +961,27 @@ static void *file_ram_alloc(RAMBlock *bl
return (NULL);
}
block->fd = fd;
+ block->hpagesize = hpagesize;
return area;
}
+
+uint32_t qemu_get_ram_hpagesize(ram_addr_t addr)
+{
+ RAMBlock *block;
+
+ QTAILQ_FOREACH(block, &ram_list.blocks, next) {
+ if (addr - block->offset < block->length) {
+ return block->hpagesize;
+ }
+ }
+
+ fprintf(stderr, "%s: Bad ram offset %" PRIx64 "\n", __func__,
+ (uint64_t)addr);
+ abort();
+
+ return 0;
+}
+
#else
static void *file_ram_alloc(RAMBlock *block,
ram_addr_t memory,
Index: qemu/include/exec/cpu-all.h
===================================================================
--- qemu.orig/include/exec/cpu-all.h
+++ qemu/include/exec/cpu-all.h
@@ -448,6 +448,7 @@ typedef struct RAMBlock {
ram_addr_t offset;
ram_addr_t length;
uint32_t flags;
+ uint32_t hpagesize;
char idstr[256];
/* Reads can take either the iothread or the ramlist lock.
* Writes must take both locks.
Index: git/qemu/include/exec/cpu-common.h
===================================================================
--- qemu.orig/include/exec/cpu-common.h
+++ qemu/include/exec/cpu-common.h
@@ -54,6 +54,9 @@ void qemu_ram_remap(ram_addr_t addr, ram
/* This should not be used by devices. */
MemoryRegion *qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr);
void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev);
+#ifdef __linux__
+uint32_t qemu_get_ram_hpagesize(ram_addr_t addr);
+#endif
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
int len, int is_write);
- [Qemu-devel] [patch 0/2] align >4GB guest RAM to a 1GB boundary, in case of 1GB-sized hugetlbfs, Marcelo Tosatti, 2013/10/24
- [Qemu-devel] [patch 1/2] exec: add qemu_get_ram_hpagesize,
Marcelo Tosatti <=
- [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Marcelo Tosatti, 2013/10/24
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Peter Maydell, 2013/10/24
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Paolo Bonzini, 2013/10/24
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Marcelo Tosatti, 2013/10/25
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Paolo Bonzini, 2013/10/25
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Marcelo Tosatti, 2013/10/25
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Paolo Bonzini, 2013/10/25
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Gerd Hoffmann, 2013/10/30
- Re: [Qemu-devel] [patch 2/2] i386: pc: align gpa<->hpa on 1GB boundary, Paolo Bonzini, 2013/10/30