From patchwork Wed Oct 21 09:24:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 36510 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 C6698B7B65 for ; Wed, 21 Oct 2009 20:33:10 +1100 (EST) Received: from localhost ([127.0.0.1]:46241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0XZ4-00061D-I2 for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 05:33:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0XRT-0003SQ-0F for qemu-devel@nongnu.org; Wed, 21 Oct 2009 05:25:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0XRN-0003Pu-Hk for qemu-devel@nongnu.org; Wed, 21 Oct 2009 05:25:14 -0400 Received: from [199.232.76.173] (port=55462 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0XRN-0003Pi-79 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 05:25:09 -0400 Received: from cantor.suse.de ([195.135.220.2]:43710 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N0XRM-0000vB-Mn for qemu-devel@nongnu.org; Wed, 21 Oct 2009 05:25:08 -0400 Received: from relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 0D0C793A00; Wed, 21 Oct 2009 11:25:07 +0200 (CEST) From: Alexander Graf To: qemu-devel Date: Wed, 21 Oct 2009 11:24:58 +0200 Message-Id: <1256117106-9475-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1256117106-9475-1-git-send-email-agraf@suse.de> References: <1256117106-9475-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 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. */