From patchwork Fri Aug 22 13:24: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: 35796 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5358020540 for ; Fri, 22 Aug 2014 13:26:19 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf24439364ieb.2 for ; Fri, 22 Aug 2014 06:26:18 -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=m1LBZMRapRKiBBliilNn8cNyhgPDJ+vDJzO65Dc0Wg9YWfcRxA9xrOXNJoHARhk1+J 6L0wu3XLr5kP2hEfKwHpuaeb6oCDB6AE87SUV4mLtpkX5yVilWE/e8wzaanElfvRzyCh k4SV3ONl78ooC12GlriSLdSU8bd1nu8zzBFDltFqhEej7NVdmbAVuxW4nqVqWPkwaNSY wFtupWV8aieLTl2qyXBZqVW20gVjOwfKgKdg8p7ywrCK6HCjrEaJE/sPS3f7hH4UssMO 9GAlGimqzPvvuTAgJ5DfspaTqXZEwoEnfIb4FDsJPn5YQPo3WVK4mioS71NDmq3405cV mvzQ== X-Gm-Message-State: ALoCoQlIBBFyV0hokC/UQVqbJaJQC5aFsNsnA+lJYxQX+d3gaPcwVmeGsJZOihFCBUr+u6w1x1Uk X-Received: by 10.50.65.99 with SMTP id w3mr4503101igs.7.1408713978854; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.18 with SMTP id z18ls1118831qge.0.gmail; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) X-Received: by 10.52.88.74 with SMTP id be10mr145683vdb.54.1408713978562; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id do1si7421170vdb.61.2014.08.22.06.26.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:26:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so12266922vcb.19 for ; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) X-Received: by 10.52.190.71 with SMTP id go7mr3458092vdc.28.1408713978479; Fri, 22 Aug 2014 06:26:18 -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.45.67 with SMTP id uj3csp16729vcb; Fri, 22 Aug 2014 06:26:18 -0700 (PDT) X-Received: by 10.140.80.167 with SMTP id c36mr7483643qgd.52.1408713977382; Fri, 22 Aug 2014 06:26:17 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m89si42242791qge.51.2014.08.22.06.26.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:26:17 -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]:37061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKor8-0007lh-3i for patch@linaro.org; Fri, 22 Aug 2014 09:26:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopm-0006Up-D7 for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKopf-0002B0-OL for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:50 -0400 Received: from afflict.kos.to ([92.243.29.197]:39293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopf-0002A6-HM for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:43 -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 5C8DB264D6; Fri, 22 Aug 2014 15:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:19 +0300 Message-Id: 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: 92.243.29.197 Cc: Mikhail Ilyin Subject: [Qemu-devel] [PULL v3 01/22] 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.174 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; }