From patchwork Sun Jun 19 00:15:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Pearson X-Patchwork-Id: 9185921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C8376075E for ; Sun, 19 Jun 2016 00:21:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D04E269B2 for ; Sun, 19 Jun 2016 00:21:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7129D27AC2; Sun, 19 Jun 2016 00:21:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 14E97269B2 for ; Sun, 19 Jun 2016 00:21:38 +0000 (UTC) Received: from localhost ([::1]:36921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEQUb-000737-4c for patchwork-qemu-devel@patchwork.kernel.org; Sat, 18 Jun 2016 20:21:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEQOW-0001FN-BP for qemu-devel@nongnu.org; Sat, 18 Jun 2016 20:15:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEQOU-0004Ys-2k for qemu-devel@nongnu.org; Sat, 18 Jun 2016 20:15:19 -0400 Received: from pearsoncomputing.net ([192.119.205.242]:16674 helo=mail.pearsoncomputing.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEQOT-0004Ym-Pr for qemu-devel@nongnu.org; Sat, 18 Jun 2016 20:15:18 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.pearsoncomputing.net (Postfix) with ESMTP id 7A0BA640CB6 for ; Sat, 18 Jun 2016 19:15:17 -0500 (CDT) Received: from mail.pearsoncomputing.net ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 11S9GjLwYi6V for ; Sat, 18 Jun 2016 19:15:17 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.pearsoncomputing.net (Postfix) with ESMTP id F1F71640E6E for ; Sat, 18 Jun 2016 19:15:16 -0500 (CDT) DKIM-Filter: OpenDKIM Filter v2.9.2 mail.pearsoncomputing.net F1F71640E6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1466295317; bh=W6F4FlmxHopneP72hoJXjVDerXDFQCl3yLRs2nBeNYI=; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding; b=ompvPVDaC2ln4TFfh0DtRmMCTrB7d2hnVHIkBOP3pXoh9ERJLCmHUq1qsWvrNrMSU xldb+GF8xHYBipzqo6DUwZCwWdrqUDNOt6Tv5/tD4oDXFmJgtaqQPlisUPOZl8jXEA /KYFdOHIQt3cvNbBBAWNV09vRve5nNJTQpQZP918= X-Virus-Scanned: amavisd-new at pearsoncomputing.net Received: from mail.pearsoncomputing.net ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xvw4HfcJ3IsO for ; Sat, 18 Jun 2016 19:15:16 -0500 (CDT) Received: from vali.starlink.edu (vali.starlink.edu [192.168.3.21]) by mail.pearsoncomputing.net (Postfix) with ESMTP id BFD03640CB6 for ; Sat, 18 Jun 2016 19:15:16 -0500 (CDT) Date: Sat, 18 Jun 2016 19:15:16 -0500 (CDT) From: Timothy Pearson To: qemu-devel@nongnu.org Message-ID: <1841580212.1359461.1466295316691.JavaMail.zimbra@raptorengineeringinc.com> MIME-Version: 1.0 X-Originating-IP: [192.168.3.54] X-Mailer: Zimbra 8.5.0_GA_3042 (ZimbraWebClient - FF3.6 (Linux)/8.5.0_GA_3042) Thread-Topic: QEMU does not currently support host pages that are larger than guest pages, likely due to glibc using fixed mmap requests. Thread-Index: fMizhJWzqUeO0JQ2OJMeMiesLVuwvg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 192.119.205.242 Subject: [Qemu-devel] [PATCH 2/7] QEMU does not currently support host pages that are larger than guest pages, likely due to glibc using fixed mmap requests. 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Attempting to use host pages larger than the guest leads to alignment errors during ELF load in the best case, and an initialization failure inside NPTL in the worst case, causing all fork() requests inside the guest to fail. Warn when thread space cannot be set up, and suggest reducing host page size if applicable. Signed-off-by: Timothy Pearson --- linux-user/syscall.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1c17b74..2968b57 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5482,8 +5482,13 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, /* Wait for the child to initialize. */ pthread_cond_wait(&info.cond, &info.mutex); ret = info.tid; - if (flags & CLONE_PARENT_SETTID) - put_user_u32(ret, parent_tidptr); + if (flags & CLONE_PARENT_SETTID) { + if (put_user_u32(ret, parent_tidptr)) { + fprintf(stderr, "do_fork: put_user_u32() failed, child process state invalid\n"); + if (qemu_real_host_page_size > TARGET_PAGE_SIZE) + fprintf(stderr, "do_fork: host page size > target page size; reduce host page size and try again\n"); + } + } } else { ret = -1; } @@ -5514,10 +5519,20 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, (not implemented) or having *_tidptr to point at a shared memory mapping. We can't repeat the spinlock hack used above because the child process gets its own copy of the lock. */ - if (flags & CLONE_CHILD_SETTID) - put_user_u32(gettid(), child_tidptr); - if (flags & CLONE_PARENT_SETTID) - put_user_u32(gettid(), parent_tidptr); + if (flags & CLONE_CHILD_SETTID) { + if (put_user_u32(gettid(), child_tidptr)) { + fprintf(stderr, "do_fork: put_user_u32() failed, child process state invalid\n"); + if (qemu_real_host_page_size > TARGET_PAGE_SIZE) + fprintf(stderr, "do_fork: host page size > target page size; reduce host page size and try again\n"); + } + } + if (flags & CLONE_PARENT_SETTID) { + if (put_user_u32(gettid(), parent_tidptr)) { + fprintf(stderr, "do_fork: put_user_u32() failed, child process state invalid\n"); + if (qemu_real_host_page_size > TARGET_PAGE_SIZE) + fprintf(stderr, "do_fork: host page size > target page size; reduce host page size and try again\n"); + } + } ts = (TaskState *)cpu->opaque; if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls);