From patchwork Wed Nov 2 19:23:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 123318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7C35EB6F99 for ; Thu, 3 Nov 2011 06:24:07 +1100 (EST) Received: from localhost ([::1]:51519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLgPs-0006Sv-HV for incoming@patchwork.ozlabs.org; Wed, 02 Nov 2011 15:24:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLgPQ-0005Kw-IZ for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLgPO-0005MB-Uf for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53009 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLgPO-0005Lx-72 for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:34 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id B7FC98ADF6; Wed, 2 Nov 2011 20:23:33 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Date: Wed, 2 Nov 2011 20:23:24 +0100 Message-Id: <1320261806-13194-4-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1320261806-13194-3-git-send-email-agraf@suse.de> References: <1320261806-13194-1-git-send-email-agraf@suse.de> <1320261806-13194-2-git-send-email-agraf@suse.de> <1320261806-13194-3-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: adrian@suse.de, riku.voipio@iki.fi Subject: [Qemu-devel] [PATCH 3/5] linux-user: fake /proc/self/maps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org glibc's pthread_attr_getstack tries to find the stack range from /proc/self/maps. Unfortunately, /proc is usually the host's /proc which means linux-user guests see qemu's stack there. Fake the file with a constructed maps entry that exposes the guest's stack range. Signed-off-by: Alexander Graf --- linux-user/syscall.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 38953ba..a51b457 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4600,6 +4600,20 @@ int get_osversion(void) return osversion; } + +static int open_self_maps(void *cpu_env, int fd) +{ + TaskState *ts = ((CPUState *)cpu_env)->opaque; + + dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n", + (unsigned long long)ts->info->stack_limit, + (unsigned long long)(ts->stack_base + (TARGET_PAGE_SIZE - 1)) + & TARGET_PAGE_MASK, + (unsigned long long)ts->stack_base); + + return 0; +} + static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) { struct fake_open { @@ -4608,6 +4622,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) }; const struct fake_open *fake_open; static const struct fake_open fakes[] = { + { "/proc/self/maps", open_self_maps }, { NULL, NULL } };