public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com, jan.kiszka@web.de, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 5/6] introduce qemu_ram_map
Date: Mon, 03 May 2010 19:48:24 -0300	[thread overview]
Message-ID: <20100503224905.894980453@amt.cnet> (raw)
In-Reply-To: 20100503224819.773169076@amt.cnet

[-- Attachment #1: qemu-ram-mmap --]
[-- Type: text/plain, Size: 1650 bytes --]

Which allows drivers to register an mmap region into ram block mappings.
To be used by device assignment driver.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm/cpu-common.h
===================================================================
--- qemu-kvm.orig/cpu-common.h
+++ qemu-kvm/cpu-common.h
@@ -40,6 +40,7 @@ static inline void cpu_register_physical
 }
 
 ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr);
+ram_addr_t qemu_ram_map(ram_addr_t size, void *host);
 ram_addr_t qemu_ram_alloc(ram_addr_t);
 void qemu_ram_free(ram_addr_t addr);
 /* This should only be used for ram local to a device.  */
Index: qemu-kvm/exec.c
===================================================================
--- qemu-kvm.orig/exec.c
+++ qemu-kvm/exec.c
@@ -2805,6 +2805,34 @@ static void *file_ram_alloc(ram_addr_t m
 }
 #endif
 
+ram_addr_t qemu_ram_map(ram_addr_t size, void *host)
+{
+    RAMBlock *new_block;
+
+    size = TARGET_PAGE_ALIGN(size);
+    new_block = qemu_malloc(sizeof(*new_block));
+
+    new_block->host = host;
+
+    new_block->offset = last_ram_offset;
+    new_block->length = size;
+
+    new_block->next = ram_blocks;
+    ram_blocks = new_block;
+
+    phys_ram_dirty = qemu_realloc(phys_ram_dirty,
+        (last_ram_offset + size) >> TARGET_PAGE_BITS);
+    memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS),
+           0xff, size >> TARGET_PAGE_BITS);
+
+    last_ram_offset += size;
+
+    if (kvm_enabled())
+        kvm_setup_guest_memory(new_block->host, size);
+
+    return new_block->offset;
+}
+
 ram_addr_t qemu_ram_alloc(ram_addr_t size)
 {
     RAMBlock *new_block;



  parent reply	other threads:[~2010-05-03 22:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 22:48 [patch 0/6] qemu-kvm: use upstream memslot code Marcelo Tosatti
2010-05-03 22:48 ` [patch 1/6] remove alias support Marcelo Tosatti
2010-05-03 22:48 ` [patch 2/6] remove support for !KVM_CAP_SET_TSS_ADDR Marcelo Tosatti
2010-05-03 22:48 ` [patch 3/6] remove unused kvm_get_dirty_pages Marcelo Tosatti
2010-05-03 22:48 ` [patch 4/6] remove unused kvm_dirty_bitmap array Marcelo Tosatti
2010-05-03 22:48 ` Marcelo Tosatti [this message]
2010-05-03 22:48 ` [patch 6/6] use upstream memslot management code Marcelo Tosatti
2010-05-05  8:49 ` [patch 0/6] qemu-kvm: use upstream memslot code Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100503224905.894980453@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox