From patchwork Mon Oct 19 14:37:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 36384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 158C2B7B6F for ; Tue, 20 Oct 2009 01:54:09 +1100 (EST) Received: from localhost ([127.0.0.1]:47464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mztcc-00082q-D0 for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2009 10:54:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MztMw-0001ra-SE for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:37:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MztMq-0001ms-72 for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:37:53 -0400 Received: from [199.232.76.173] (port=41450 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MztMm-0001mA-Mf for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:37:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43857 helo=mx2.suse.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MztMm-0005Oy-6u for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:37:44 -0400 Received: from relay1.suse.de (mail2.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id 67AAD88B6C; Mon, 19 Oct 2009 16:37:40 +0200 (CEST) From: Alexander Graf To: qemu-devel Date: Mon, 19 Oct 2009 16:37:31 +0200 Message-Id: <1255963059-10298-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1255963059-10298-1-git-send-email-agraf@suse.de> References: <1255963059-10298-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Carsten Otte , hare@suse.de Subject: [Qemu-devel] [PATCH 1/9] Export function for VA defined ram allocation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org S390 requires vmas for guests to be < 256 GB. So we need to directly export mmaps "try to use this vma as start address" feature to not accidently get over that limit. Signed-off-by: Alexander Graf --- cpu-common.h | 1 + exec.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cpu-common.h b/cpu-common.h index 6302372..ecaf9e3 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -30,6 +30,7 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr); ram_addr_t qemu_ram_alloc(ram_addr_t); +ram_addr_t _qemu_ram_alloc(ram_addr_t size, void *map_at); void qemu_ram_free(ram_addr_t addr); /* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr(ram_addr_t addr); diff --git a/exec.c b/exec.c index 076d26b..36c26cd 100644 --- a/exec.c +++ b/exec.c @@ -2404,14 +2404,20 @@ void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size) kvm_uncoalesce_mmio_region(addr, size); } -ram_addr_t qemu_ram_alloc(ram_addr_t size) +ram_addr_t _qemu_ram_alloc(ram_addr_t size, void *map_at) { RAMBlock *new_block; size = TARGET_PAGE_ALIGN(size); new_block = qemu_malloc(sizeof(*new_block)); - new_block->host = qemu_vmalloc(size); + if (map_at) { + new_block->host = mmap(map_at, size, PROT_EXEC|PROT_READ|PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + + } else { + new_block->host = qemu_vmalloc(size); + } #ifdef MADV_MERGEABLE madvise(new_block->host, size, MADV_MERGEABLE); #endif @@ -2434,6 +2440,11 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) return new_block->offset; } +ram_addr_t qemu_ram_alloc(ram_addr_t size) +{ + return _qemu_ram_alloc(size, NULL); +} + void qemu_ram_free(ram_addr_t addr) { /* TODO: implement this. */