From patchwork Mon Jun 18 15:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139021 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4091728lji; Mon, 18 Jun 2018 08:33:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzu8fH6sDf6oaPim+7BYKncbbXN78Age7hdX09rGeqlqXlJAr7a0NnciPNHGOfJ48Gvwqk X-Received: by 2002:aa7:d299:: with SMTP id w25-v6mr11479491edq.13.1529336006850; Mon, 18 Jun 2018 08:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529336006; cv=none; d=google.com; s=arc-20160816; b=XdyyS0LMljqyJlC5J+p0xm2yqByhVnuvWifhyb7DsYXHUcxEAojJns1A7dYCJtExcS DUzGF7ujQD3+Wp8Nwj2VaLOifVNKJGb/+9DmuxcI849kSEh4E2zI8AhAMfTAKEyYoZwz 6yNKcqodJdAUoOATDtjiGwNtQSA4VhPECB8G6Lx3WSmQIGPkhBWBDBj5UpXRkm1MGRjV VxfkwuBMEaY9tbeJaWS/LHyOiv86sjuaqWP2vqArb3Bm7j3t0kMk7Bng1J8cdKEECbOR qUOQQdEAt7eu4e4Lnxzt9A0isPPM3u2VL3tJWq6wRd92/ip5OmEr8p+BrVXFco0BEh/i Z1Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=bDHdEMkPPh9PPgrQg4wWBVK2ZLTkrsdQGlRWEaiRVFY=; b=Ekos0LAUXnr1YaB4is6Emdocqr/cAaHoMAGa/GZYpq8FqPgg7LC0XLyz3TIyPMf3cN MnaWZhHRlqpwwoeis93QjpxHgrGky3fnVxL6aO8Rk+EEfY1MeikKzOwzPlAW6JyNzDnf iMm7c09rVzHLA8RIF57p8PUvIhL/9SarGBgWG35INac3mr1KxvBcBpewB0M98jfrBBt8 bBHmw5KCeTci1trErLPDEvFyXfkIM9EB/rWQcor/sUecDeQ+K09lWoEqPrKZbNGJWa40 hrrHner/TmdP4CtqNL02Y+zK6Fug3ystYp6kfbhJIE6HT4+XW9B7u9+BrXzN0Ykdmjw1 TcXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f24-v6si8850356edm.12.2018.06.18.08.33.26; Mon, 18 Jun 2018 08:33:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 7F93AC21F2B; Mon, 18 Jun 2018 15:28:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A143DC21F71; Mon, 18 Jun 2018 15:23:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5BC72C21E70; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 14AF1C21EB1 for ; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7CF4DAF85; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:14 +0200 Message-Id: <20180618152315.34233-21-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 20/21] sandbox: Always allocate aligned buffers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In some code paths we check whether host virtual addresses are sane. That only works if at least alignments between host and U-Boot address spaces match. So let's always map U-Boot addresses with 64kb alignment. That should be enough to ensure that the actual RAM ends up in a different page from the header on all architectures. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 9fa79a8843..4dc6483922 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -143,14 +143,15 @@ void os_tty_raw(int fd, bool allow_sigs) void *os_malloc(size_t length) { struct os_mem_hdr *hdr; + size_t alloc_length = length + (64 * 1024); - hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE, + hdr = mmap(NULL, alloc_length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hdr == MAP_FAILED) return NULL; hdr->length = length; - return hdr + 1; + return (void*)hdr + (64 * 1024); } void os_free(void *ptr)