From patchwork Thu May 23 14:43:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 165027 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2291154ili; Thu, 23 May 2019 07:46:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyr7Btpy/pO/fHvmjgY7s/EPagHAtz7UrmrX85M+Ie/Ud/aPRFvPU3VlvCjpApHUt4RJGwe X-Received: by 2002:a17:906:68c4:: with SMTP id y4mr64732991ejr.198.1558622812288; Thu, 23 May 2019 07:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558622812; cv=none; d=google.com; s=arc-20160816; b=Td7vJEBWoHXYfHs8XZyIudunqjKQc/qcY9wn20BeEQXk5qb8CXApx8y3oUiLGivyDL zOB7oW5y94BZvG0tTpgOvsbPpc44Vrqr6IBxhPcywtTT6A6hCvXSFPF1iDL0sQMP0LA2 YN7gl9ibQhIKLOBy0xFLJ/fj10EEca2SkjfOTTbuvt0LsZtkcjrlPZ0LalqxhBrLoQJS g5Yx0evvCwOVpHQLyiK2ZThnfhPUPMY3STSK/NEaJAJRzOB75MWjRUBvg6e46AVO42nz i7cXOJHcO739hfxDipzP/GDeiFcqizm1Aflx5YRLpYpFLEIE5iGNImeJMyY60P20NN1Q dktg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=zzDWv75tx3vBBNjEGBPM/qHXvgfTq7p0ug/j2OJvEBY=; b=g4W9gr7kUlAND8GI/Uzecv8R8E2DCHkELbSq/GSXxjEo9gCha7QK/awFJG2adu7PGm idZA1exWX1mlFqc1VcSPxE3X/Ep4MYjljW1AzYhN78pk86RvjqvCHLUsy6Q6u9arzyIY 25JsDDEwJvu4TpUhnWs6MHqSEEkVwxjRnG98UvO0EYg/1jIME1GVnBPFhMUgBvWeuP3f RrsGo3fEod5gDJFdJOMd7iWieKXb3q6NNbzKZPABdd3j1lBMSmAPv7xVQTDfQJtvV8yC V5UOeZ7m4SDcqlhBZsbxF8/vZElXg5mbW+UKZAbmUKZcvj5u8iPnNZyo8ddObZ7k/3DO hnMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v1si1599528ejk.50.2019.05.23.07.46.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 23 May 2019 07:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:38059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTozb-0007Fc-4d for patch@linaro.org; Thu, 23 May 2019 10:46:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTox1-0004Kq-0p for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTowz-0006Me-DT for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:10 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:53799) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTowz-0006Lj-49 for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:09 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N17l4-1gVmX23mPq-012bag; Thu, 23 May 2019 16:43:47 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 16:43:34 +0200 Message-Id: <20190523144336.13960-9-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523144336.13960-1-laurent@vivier.eu> References: <20190523144336.13960-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:RfUqtwaq+SNTjIfAEcu3U45jOpyRrW+Lr1Rq/nN6AvmHsV2Av3x 3DhBtn7CdObLTJ2Sput6MQwePPrgXLX6+uwTfdRA0BemS98RAyA9R9DIoQvheYPPy4sSA59 MdApKaTjGjLeGHwqKeoWPla5pAMQn8UABonv8pXYnhsx3AmWUvIqssSUxfy8GtAKm6GtwhC bIT6L1bNxB/OSE9gwgREg== X-UI-Out-Filterresults: notjunk:1; V03:K0:F+deb7E1NZ4=:Tq+MUOeXS9AUMRBpdloGWo v5389u/hF2NDXvxJfbDY6S4qZfagoo3YfPpvHlj6yvuuC3f+AKSWIPpsl3MuKMpBFPq29WiUZ HD6a5NuzLwIPA/eiN7PMV90ljhDpRtbe+dE9JK5Oy0rfxrdcPW7NS/wryJQqDPcJTuBrfVfRj g5tfAZjhE29BU0Ag9/YmRznmIUQoHWEJsg7fB3AF50Lw96PcV+TB72tnlQJ1SLa7D42QZJ15T Pei+N7lUttiGZCUE6ITOW7UX+BBUYUbjP63zTQ6ZEya4AZhkj6aK61qQ409vgKCPlLOxWn4ik ZntBJ2BNGV25JBmIJNHDPbNBCTC4Ia+8Cuem1qXrDxGmLktObbYaG/AbomPYMRyF0euhYx+VQ WripoieG3pc4T3mEWkVyaPwLIhi9TONMh8LInPkpAKatYAvnnIJHkXrfaU8CNDnmFUkIbe6uw bivqG8nrIbXi/tzYJS0RQychaPt4j/Ior+0rH0npGNuSupomZ9wcMrJE/HRKJwD8FIHX21oJ5 fo134AqQabYf1mhui4+x744ER0hAwVSsgJwCxTUDNwGfb7+W38SREAhlsC4JnXZ29HXRJGF8K /sXwAk0fK51RKwWOpkwwJDeuKygsCtTu2G3YLlzSS9xwXR9GdYXL54wOAcb+/MSgAMBuWlfz+ ztQBDjOE7DYTvaNOXV/yaBJsNd0naNcADJ570seQxDP8DI11zoeeDruW1Y6FhluhAB1Tmtz99 gJdOVN4NCnTHXp/E+4070nOMzz5hsxjX6AQRMQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 Subject: [Qemu-devel] [PULL 08/10] linux-user: Fix shmat emulation by honoring host SHMLBA X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , Riku Voipio , Richard Henderson , Laurent Vivier , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson For those hosts with SHMLBA > getpagesize, we don't automatically select a guest address that is compatible with the host. We can achieve this by boosting the alignment of guest_base and by adding an extra alignment argument to mmap_find_vma. Signed-off-by: Richard Henderson Message-Id: <20190519201953.20161-13-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 17 ++++++----- linux-user/mmap.c | 70 +++++++++++++++++++++++--------------------- linux-user/qemu.h | 2 +- linux-user/syscall.c | 3 +- 4 files changed, 50 insertions(+), 42 deletions(-) -- 2.20.1 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 02832adfbc0c..a23aa4493e72 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3,6 +3,7 @@ #include #include +#include #include "qemu.h" #include "disas/disas.h" @@ -2012,6 +2013,8 @@ unsigned long init_guest_space(unsigned long host_start, unsigned long guest_start, bool fixed) { + /* In order to use host shmat, we must be able to honor SHMLBA. */ + unsigned long align = MAX(SHMLBA, qemu_host_page_size); unsigned long current_start, aligned_start; int flags; @@ -2029,7 +2032,7 @@ unsigned long init_guest_space(unsigned long host_start, } /* Setup the initial flags and start address. */ - current_start = host_start & qemu_host_page_mask; + current_start = host_start & -align; flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; if (fixed) { flags |= MAP_FIXED; @@ -2065,8 +2068,8 @@ unsigned long init_guest_space(unsigned long host_start, return (unsigned long)-1; } munmap((void *)real_start, host_full_size); - if (real_start & ~qemu_host_page_mask) { - /* The same thing again, but with an extra qemu_host_page_size + if (real_start & (align - 1)) { + /* The same thing again, but with extra * so that we can shift around alignment. */ unsigned long real_size = host_full_size + qemu_host_page_size; @@ -2079,7 +2082,7 @@ unsigned long init_guest_space(unsigned long host_start, return (unsigned long)-1; } munmap((void *)real_start, real_size); - real_start = HOST_PAGE_ALIGN(real_start); + real_start = ROUND_UP(real_start, align); } current_start = real_start; } @@ -2106,7 +2109,7 @@ unsigned long init_guest_space(unsigned long host_start, } /* Ensure the address is properly aligned. */ - if (real_start & ~qemu_host_page_mask) { + if (real_start & (align - 1)) { /* Ideally, we adjust like * * pages: [ ][ ][ ][ ][ ] @@ -2134,7 +2137,7 @@ unsigned long init_guest_space(unsigned long host_start, if (real_start == (unsigned long)-1) { return (unsigned long)-1; } - aligned_start = HOST_PAGE_ALIGN(real_start); + aligned_start = ROUND_UP(real_start, align); } else { aligned_start = real_start; } @@ -2171,7 +2174,7 @@ unsigned long init_guest_space(unsigned long host_start, * because of trouble with ARM commpage setup. */ munmap((void *)real_start, real_size); - current_start += qemu_host_page_size; + current_start += align; if (host_start == current_start) { /* Theoretically possible if host doesn't have any suitably * aligned areas. Normally the first mmap will fail. diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e0249efe4fed..10796b37ac7b 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -202,49 +202,52 @@ unsigned long last_brk; /* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk of guest address space. */ -static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size) +static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, + abi_ulong align) { - abi_ulong addr; - abi_ulong end_addr; + abi_ulong addr, end_addr, incr = qemu_host_page_size; int prot; - int looped = 0; + bool looped = false; if (size > reserved_va) { return (abi_ulong)-1; } - size = HOST_PAGE_ALIGN(size); + /* Note that start and size have already been aligned by mmap_find_vma. */ + end_addr = start + size; - if (end_addr > reserved_va) { - end_addr = reserved_va; + if (start > reserved_va - size) { + /* Start at the top of the address space. */ + end_addr = ((reserved_va - size) & -align) + size; + looped = true; } - addr = end_addr - qemu_host_page_size; + /* Search downward from END_ADDR, checking to see if a page is in use. */ + addr = end_addr; while (1) { + addr -= incr; if (addr > end_addr) { if (looped) { + /* Failure. The entire address space has been searched. */ return (abi_ulong)-1; } - end_addr = reserved_va; - addr = end_addr - qemu_host_page_size; - looped = 1; - continue; - } - prot = page_get_flags(addr); - if (prot) { - end_addr = addr; - } - if (addr && addr + size == end_addr) { - break; + /* Re-start at the top of the address space. */ + addr = end_addr = ((reserved_va - size) & -align) + size; + looped = true; + } else { + prot = page_get_flags(addr); + if (prot) { + /* Page in use. Restart below this page. */ + addr = end_addr = ((addr - size) & -align) + size; + } else if (addr && addr + size == end_addr) { + /* Success! All pages between ADDR and END_ADDR are free. */ + if (start == mmap_next_start) { + mmap_next_start = addr; + } + return addr; + } } - addr -= qemu_host_page_size; } - - if (start == mmap_next_start) { - mmap_next_start = addr; - } - - return addr; } /* @@ -253,7 +256,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size) * It must be called with mmap_lock() held. * Return -1 if error. */ -abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) +abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { void *ptr, *prev; abi_ulong addr; @@ -265,11 +268,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) } else { start &= qemu_host_page_mask; } + start = ROUND_UP(start, align); size = HOST_PAGE_ALIGN(size); if (reserved_va) { - return mmap_find_vma_reserved(start, size); + return mmap_find_vma_reserved(start, size, align); } addr = start; @@ -299,7 +303,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) if (h2g_valid(ptr + size - 1)) { addr = h2g(ptr); - if ((addr & ~TARGET_PAGE_MASK) == 0) { + if ((addr & (align - 1)) == 0) { /* Success. */ if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) { mmap_next_start = addr + size; @@ -313,12 +317,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) /* Assume the result that the kernel gave us is the first with enough free space, so start again at the next higher target page. */ - addr = TARGET_PAGE_ALIGN(addr); + addr = ROUND_UP(addr, align); break; case 1: /* Sometimes the kernel decides to perform the allocation at the top end of memory instead. */ - addr &= TARGET_PAGE_MASK; + addr &= -align; break; case 2: /* Start over at low memory. */ @@ -416,7 +420,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, if (!(flags & MAP_FIXED)) { host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); - start = mmap_find_vma(real_start, host_len); + start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; goto fail; @@ -710,7 +714,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, } else if (flags & MREMAP_MAYMOVE) { abi_ulong mmap_start; - mmap_start = mmap_find_vma(0, new_size); + mmap_start = mmap_find_vma(0, new_size, TARGET_PAGE_SIZE); if (mmap_start == -1) { errno = ENOMEM; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ef400cb78ac6..82d33d7e93d5 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -443,7 +443,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_ulong new_addr); extern unsigned long last_brk; extern abi_ulong mmap_next_start; -abi_ulong mmap_find_vma(abi_ulong, abi_ulong); +abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong); void mmap_fork_start(void); void mmap_fork_end(int child); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a0c2bf7db43c..e43255c29e56 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3935,7 +3935,8 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, else { abi_ulong mmap_start; - mmap_start = mmap_find_vma(0, shm_info.shm_segsz); + /* In order to use the host shmat, we need to honor host SHMLBA. */ + mmap_start = mmap_find_vma(0, shm_info.shm_segsz, MAX(SHMLBA, shmlba)); if (mmap_start == -1) { errno = ENOMEM; From patchwork Thu May 23 14:43:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 165028 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2299427ili; Thu, 23 May 2019 07:53:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMM5eKgjoZd6EphsXKnK53lFTESmJOsI+QH2u68qOVQMNRd44sN7mUtwN7BqOYN3GS+Qe1 X-Received: by 2002:a17:906:6a90:: with SMTP id p16mr16068127ejr.75.1558623202614; Thu, 23 May 2019 07:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558623202; cv=none; d=google.com; s=arc-20160816; b=LR5OyZWJCCjT2BAYPHiZ/x2WkL42iqnuojdcT44iHr8OmenJb2j+5S77X6fY3Bqxzd Ka9bnTIfTntbAa4IdGhAhN4Eoa4aIi0JBKwRvLdztQQtAvliy9qPJh364AxgnKDdsmmr rna9+YlLNE980/W2u45lbZ/kCXqLCzLS0htrQM/yvS91Q9LKXngYr56e7IKUj34Gwfgs Yy9h6VgMAxrWVZMmjHjxVLxuYlAf6466AvNo1jQfM7a9+Cj7vrk2d2rl8WqkiPgk9tQY OQXbKkuO7J+10aUKnTi6ruqLq95Rlgg0pr30nGqC6WbajxUOqqUuZvta58w6oUvlDbZO buQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=598f44TGDuB7IZvCNYslfKPq6sNaQzuRh2yw82YelaU=; b=jxnywi61EFYZQp6B0Yke0kmbOrnDQBI6L9y7mN+yt+Qy8+hayYy0Cl9YsgN/pMVrQG 4IZ/y+YBYNRCSQPPxSdIZuZKmVhB7bc9yRNgG9WeN+XLhgcHGf7c/ogRtetlbb1FsTLT OViYH26psC3Wp4qS4osm4qF0fWrZFU9oPUafJypKjWF+Tx3kK9u2XIj17w7zKRipfpKI dL6zq0fmwdy7fe44LCm90dtCLp99RLl+chap3VPSBDnTIBOccldql83CAYkANfp9Zd1z rK76DwF5hSJOnjk91Y9FMgfxfHbPaFasfZUIp49c8xFmMBIm2kzxND8zAtF7eLfdDCM9 Hvhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w54si6725342edd.124.2019.05.23.07.53.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 23 May 2019 07:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:38181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTp5t-0003Ly-It for patch@linaro.org; Thu, 23 May 2019 10:53:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTowv-0004E7-Tt for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTowv-0006EE-0V for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:05 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:51857) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTowu-0006Ct-Mc for qemu-devel@nongnu.org; Thu, 23 May 2019 10:44:04 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MtwEO-1ge4H12l8m-00uK7E; Thu, 23 May 2019 16:43:47 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 16:43:35 +0200 Message-Id: <20190523144336.13960-10-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523144336.13960-1-laurent@vivier.eu> References: <20190523144336.13960-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:cs5dL+X0+zasUeXQvoPJVHhfkw/EwMe1R2voizKI35ZRlKPrz33 91yv08yz56F4EgYkfgadCkW+//Hf1Lj+n6l7znXrazaElkDBqPszz+q89EGpqeQDbMGHXqY D0Vtsi7X4y5t7k2lLJuUXnZSlEtd8OTkl/IvzC5TAj1xd0zHOkb0z5iWYEeAJHsLxsypbwV KiBnTwg+B5m1Mbnc7v0hQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:hUXmpm1N3uw=:VpozkE213P2bVP2P5vnXey r+tdpGI0VLHOAtyCdieEoe440MKAoaD9AuO7GTQBntGxUJN1/u9Imip9dtkKF+EsB9my6uN4+ 2oJEiZl1SZOsUofyf+EtphgcteF++sJscd3bhAbgasvLPmT+/M1T5P8yUStX2+psg5abWA6IU edMrvnhT9l47uZoQQgPsjOr4iMP10VVJoXUKoY1j+noPNF0VQOhlMxzqAK3fjhdUBBXfrHyEV BolUuyQMWg3rET5ncGuFkjVZSLyalHximClmhEVOMS5Jx0MBEeBB2csNRduJDoGdVXvLGkZPy gY22Vl9OCz56GJZ7PJliS5bbnzoyg/4ImNtXPqlIca+4tfZ6PuOdgjAvBGzIUeu3dluz7ww8f iIYd/kzygePbsG4Qa+t5bqp3hOsGntW1CNBe2wtM2GYrrS+PBoYjU+LhAzMVPWZsUfhOwSJaP zXMUaUnSSmOyHQr/0svRJRmvn4sJR9uUxmNV/QEqxmGls7tIPeBGBp/LRVNOoAglFBGVpT6+4 t7TIaoMT6L/P7RmH6S3hZ2aWDK12xIfHh98hG9RKmpsZvIwp0s8aX5X+/w60r8vFKJGiL+112 uPMqomiDQ3ppCVk3lTJvuzm+PvWzUgRcH4QDpt2PzmR+WucV11hf6ic8QKJ9JkrDyjrBG/jNt XIV43X6CXvN97aJI+qfOVJifao5DZrND6gCY6favGwtFq8+0Unv4ia9pbxC/GxKEZvezMv1ut +rg9udD7ir7ERr2Dvh5HtBGtHwYkR3zj3wvZTQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.187 Subject: [Qemu-devel] [PULL 09/10] linux-user: Align mmap_find_vma to host page size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , Riku Voipio , Richard Henderson , Laurent Vivier , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This can avoid stack allocation failures for i386 guest on ppc64 (64k page) host. Suggested-by: Laurent Vivier Signed-off-by: Richard Henderson Message-Id: <20190519201953.20161-14-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 10796b37ac7b..af41339d576b 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -262,6 +262,8 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) abi_ulong addr; int wrapped, repeat; + align = MAX(align, qemu_host_page_size); + /* If 'start' == 0, then a default start address is used. */ if (start == 0) { start = mmap_next_start;