From patchwork Fri Aug 15 11:01:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35448 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F8C2203C5 for ; Fri, 15 Aug 2014 11:14:03 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf17829738pad.6 for ; Fri, 15 Aug 2014 04:13:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=S4jdg4puYJ3ath8WbGxL3TQTLgAXcwvyquwCoQPCQTs=; b=DsPPVfKpqUCS7ODEqhkChRYwtc//KZkENq6YaLDixC/q77xm0GplfQyAtgQ1CNxGkK krHVqbryXsOSb/vZnxZI5yig1dMQIbC8W2RgnCSjTAbcRnTcQH6efqVurs2qvuWpWpnp SBEom50T00MRM2BfiROBOmkLByHVAn3naG7yFOJGesAWSCICIKgXC1qWQp8KpM61/sr+ 9E54HTYQ/w7O8Og6Mihbam8WI8YyzOvQaWo+KXiDsy7jpVWtsLLOfUWQgzJ8qfWckZen dOHBHbjEPB6SbH5brt+Fpm1dxiHbYD6mMKmXm0qI57/bkuP7jMZxaTeRmx6I7Ecf/pXW OMug== X-Gm-Message-State: ALoCoQksTxxJklgTAPcmRPZC05xJWs5rS2ZtdW0SfGuKHPF3TV7V3Zwo207t95jhB797KwzTtJV0 X-Received: by 10.69.31.75 with SMTP id kk11mr8939593pbd.8.1408101239111; Fri, 15 Aug 2014 04:13:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.166 with SMTP id z35ls1348155qgd.94.gmail; Fri, 15 Aug 2014 04:13:59 -0700 (PDT) X-Received: by 10.140.27.144 with SMTP id 16mr24659393qgx.18.1408101239023; Fri, 15 Aug 2014 04:13:59 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id l43si11366126qga.73.2014.08.15.04.13.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so2730422vcb.7 for ; Fri, 15 Aug 2014 04:13:58 -0700 (PDT) X-Received: by 10.52.137.2 with SMTP id qe2mr645585vdb.11.1408101238807; Fri, 15 Aug 2014 04:13:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp104666vcb; Fri, 15 Aug 2014 04:13:58 -0700 (PDT) X-Received: by 10.140.98.7 with SMTP id n7mr22825781qge.83.1408101237961; Fri, 15 Aug 2014 04:13:57 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p5si11366964qcc.10.2014.08.15.04.13.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFSH-00089j-H7 for patch@linaro.org; Fri, 15 Aug 2014 07:13:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGj-0004xr-9o for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGT-00070m-Sx for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:01 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=44476 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGT-00070U-Ls for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:45 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 4C64B26552; Fri, 15 Aug 2014 13:01:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:19 +0300 Message-Id: <9de06760fb5f153f827ecca7384baa3f0d3775a3.1408100160.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Mikhail Ilyin , Peter Maydell Subject: [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Mikhail Ilyin Build /proc/self/maps doing a match against guest memory translation table. Output only that map records which are valid for guest memory layout. Signed-off-by: Mikhail Ilyin Signed-off-by: Riku Voipio --- include/exec/cpu-all.h | 2 ++ linux-user/syscall.c | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index f91581f..f9d132f 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -198,6 +198,8 @@ extern unsigned long reserved_va; #define RESERVED_VA 0ul #endif +#define GUEST_ADDR_MAX (RESERVED_VA ? RESERVED_VA : \ + (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) #endif /* page related stuff */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a50229d..c8c2b4c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5092,10 +5092,8 @@ static int open_self_cmdline(void *cpu_env, int fd) static int open_self_maps(void *cpu_env, int fd) { -#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); TaskState *ts = cpu->opaque; -#endif FILE *fp; char *line = NULL; size_t len = 0; @@ -5118,13 +5116,18 @@ static int open_self_maps(void *cpu_env, int fd) if ((fields < 10) || (fields > 11)) { continue; } - if (!strncmp(path, "[stack]", 7)) { - continue; - } - if (h2g_valid(min) && h2g_valid(max)) { + if (h2g_valid(min)) { + int flags = page_get_flags(h2g(min)); + max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX); + if (page_check_range(h2g(min), max - min, flags) == -1) { + continue; + } + if (h2g(min) == ts->info->stack_limit) { + pstrcpy(path, sizeof(path), " [stack]"); + } dprintf(fd, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx " %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n", - h2g(min), h2g(max), flag_r, flag_w, + h2g(min), h2g(max - 1) + 1, flag_r, flag_w, flag_x, flag_p, offset, dev_maj, dev_min, inode, path[0] ? " " : "", path); } @@ -5133,14 +5136,6 @@ static int open_self_maps(void *cpu_env, int fd) free(line); fclose(fp); -#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) - dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n", - (unsigned long long)ts->info->stack_limit, - (unsigned long long)(ts->info->start_stack + - (TARGET_PAGE_SIZE - 1)) & TARGET_PAGE_MASK, - (unsigned long long)0); -#endif - return 0; }