From patchwork Tue Jan 31 09:29:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 138724 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 D4AA11007D5 for ; Tue, 31 Jan 2012 20:30:02 +1100 (EST) Received: from localhost ([::1]:36288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsA2K-0004cC-Fp for incoming@patchwork.ozlabs.org; Tue, 31 Jan 2012 04:30:00 -0500 Received: from eggs.gnu.org ([140.186.70.92]:58145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsA1s-0004F8-Ig for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsA1q-0002ap-GI for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:32 -0500 Received: from afflict.kos.to ([92.243.29.197]:37229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsA1q-0002aP-BI for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:30 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id 81CDB26531; Tue, 31 Jan 2012 09:29:28 +0000 (UTC) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 31 Jan 2012 11:29:13 +0200 Message-Id: <15c7871080452614abd450f73a365ae7ae98790b.1328001769.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 92.243.29.197 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 04/19] 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 From: Alexander Graf 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 Signed-off-by: Riku Voipio --- 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 e100025..1864d7f 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 } };