From patchwork Fri Jul 26 15:15:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 262187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 654872C0098 for ; Sat, 27 Jul 2013 01:16:03 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1V2jkN-0005Co-Mn; Fri, 26 Jul 2013 15:15:59 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1V2jjc-0005Ah-IO for fwts-devel@lists.ubuntu.com; Fri, 26 Jul 2013 15:15:12 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1V2jjc-0005cG-F5 for fwts-devel@lists.ubuntu.com; Fri, 26 Jul 2013 15:15:12 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_alloc: use plain old mmap on 32 bit machines (LP: #1204065) Date: Fri, 26 Jul 2013 16:15:12 +0100 Message-Id: <1374851712-29896-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King For 32 bit machines, we know that we're going to get a 32 bit mmap'd address, so there is no need to lark about with forcing a low 32 bit allocation. We only really need to fret about this for 64 bit systems. So, just do a normal mmap for 32 bit. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_alloc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/src/fwts_alloc.c b/src/lib/src/fwts_alloc.c index 5ea759a..667e8fd 100644 --- a/src/lib/src/fwts_alloc.c +++ b/src/lib/src/fwts_alloc.c @@ -122,10 +122,15 @@ void *fwts_low_calloc(const size_t nmemb, const size_t size) ret = mmap(NULL, n, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); #else - /* We don't have a native MAP_32BIT, so bodge our own */ - ret = fwts_low_mmap(n); + if (sizeof(void *) == 4) { + /* 32 bit mmap by default */ + ret = mmap(NULL, n, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + } else { + /* We don't have a native MAP_32BIT, so bodge our own */ + ret = fwts_low_mmap(n); + } #endif - if (ret == MAP_FAILED) return NULL;