From patchwork Wed Aug 16 18:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714058 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2497177wrp; Wed, 16 Aug 2023 11:16:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERCS7xWCrNhN9JU7A86NfL2oVuPehsAhESqtA+j5BLyJdw/UYZmB3vjuKINk6BWqfaD9vn X-Received: by 2002:a05:620a:40d2:b0:76c:d05f:99f5 with SMTP id g18-20020a05620a40d200b0076cd05f99f5mr3428985qko.52.1692209764112; Wed, 16 Aug 2023 11:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209764; cv=none; d=google.com; s=arc-20160816; b=hu0T8/7YalAhbATSBdtyQYnjlug3Ab70CpL8aycduh0JkhMFd8SgaLC5vNx9u8FBjs YaEIK8OR8Q+SCVI/u3yDx5M5eCeWGet70nwSHNjNwI8uJS+oxa5o8N/++5uGrOQnDDvy +vhHfv79w1Ap/TC1PU7cjdsq7U4uOou6j2blKOND7fCHve8KoLGz1O9BuZqpTH5Po97v c6xfIINSUUwSM6NxXmG8Rbez7EhsT/rRQxia+icr/yR562IjvRRsnYPW/l5+VXWpYfRq K6rT9d3HUo6z7ItYNwcAj0M8db+AKPY49rRswvZB6MPfDYI/hmBX2VYHjd6zy+1zyMeh EdYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9k/dj6N9E+0jkaseus+SrmWswgP+JZzh/61nYmUDIMo=; fh=tvl0UihGnCNMZ5cda0Gq4mk/HXi+Z25jes+ecZ856eA=; b=qtqeRwRHB8CINn3nF0wqbh2zMjnoNf6kp91Q+Ew49zc1dMeqZt22SSiI6tFCvw5q42 l+nasd4HYXaUQ/HaX2p++Vsp4RKghYjCWb+KnQg2tnNrTIYleVwVH+AHeBnTuUpcVCCm 2Y1fEZze39a9kGszJkS9LkxBh0mAAIXaTlRLvPadSg/8cgmAuVA2UCif9YWyx7N4S7gY GDtGkvtSUpkhnyyvCsO63TQluaELwk2TH/Rx9DKmfcVaSS3S1mi73WR0dyfMTIlttIRr hPnB9KToyQVS+8APT82zMdnz4UDFDiZ7p7dyWmMgOnQSkDLyl3NiBzxDmG27I5hNlRog iq3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xsavGthW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s18-20020a05620a29d200b0076cad668927si9609441qkp.295.2023.08.16.11.16.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:16:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xsavGthW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2d-0002LH-93; Wed, 16 Aug 2023 14:14:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2b-0002Km-3o for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:45 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2X-0003gC-K8 for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:44 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bdcb800594so26909765ad.1 for ; Wed, 16 Aug 2023 11:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209680; x=1692814480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9k/dj6N9E+0jkaseus+SrmWswgP+JZzh/61nYmUDIMo=; b=xsavGthWJfPmf7wY17BG/sRbOU/PcrmVAX5O/SkOpAQVfbqz1tOd8FvHVLzKWTQ8+E KKKDYv/yxSpADkDEeiYoRpcjZWNhxiAfDREjAUjfsPHFaA6/T+9m01br8EIi+8Bk6HxH cmkbve2JpA6j5SMtrLxzs7LhwQw47hFo++cZyk4YHmrnb7Ylbnx1he8nmca28uECPsla kV+aCkbKCyclZ2qNXNHg6ge3Q7o/q+MRIhyIn95A8u4nhrEHuwMmnMryUgPO/yusMtbm Q8hICjUje4umNTgO3IVv8eHYCTmuyev/Hd7U79ABxx+b1ETdTtgQJbWK+0ZCpKfhWkbx rPBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209680; x=1692814480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9k/dj6N9E+0jkaseus+SrmWswgP+JZzh/61nYmUDIMo=; b=XyDUZafpcRLADUvZQq7PBEq/3hELoD4OO6o47gvAplnwPqw0qK8dCoFbcLCRqU4lyC byW9vDA4Qj9PnJegpsBkP1r71EvCmbEVDVyEGgnqfOhDeG2mQ2kq5FXxvxP651C/KKjr z8pEfA0ddlAlC1GhBx0pd5b8IoDChKL35Ei8iDk5zsx/p3sg7JeFQSxFgABYP85JLoPj RefzbzXyCT//XG/ucwLyaijiileyQUnjtNXUCQVG/oMsmPDZ4lIBdsD85aAj/LsmppDV yQhFx2eMWdkqIgdrBzu7097govLypdT5bJKfd2J8kSWmPJoeeprlGUmrAnS7W8VNEAER ydYQ== X-Gm-Message-State: AOJu0YygPh5qpZ0Ii4oZnz4d+2aqhT3LpYe4nBY5AvCblVt4Xei3XzzU /4MbEWPA3rUS48tLE5ylwzOrGDTEKhOeq9V1eSo= X-Received: by 2002:a17:903:246:b0:1be:3d5:ef6e with SMTP id j6-20020a170903024600b001be03d5ef6emr3134272plh.32.1692209680376; Wed, 16 Aug 2023 11:14:40 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de Subject: [PATCH 1/6] util/selfmap: Use dev_t and ino_t in MapInfo Date: Wed, 16 Aug 2023 11:14:32 -0700 Message-Id: <20230816181437.572997-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 Use dev_t instead of a string, and ino_t instead of uint64_t. The latter is likely to be identical on modern systems but is more type-correct for usage. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/selfmap.h | 4 ++-- linux-user/syscall.c | 6 ++++-- util/selfmap.c | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/qemu/selfmap.h b/include/qemu/selfmap.h index 7d938945cb..1690a74f4b 100644 --- a/include/qemu/selfmap.h +++ b/include/qemu/selfmap.h @@ -20,10 +20,10 @@ typedef struct { bool is_exec; bool is_priv; + dev_t dev; + ino_t inode; uint64_t offset; - uint64_t inode; const char *path; - char dev[]; } MapInfo; /** diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9353268cc1..074262b3ac 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8160,13 +8160,15 @@ static int open_self_maps_1(CPUArchState *cpu_env, int fd, bool smaps) } count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr - " %c%c%c%c %08" PRIx64 " %s %"PRId64, + " %c%c%c%c %08" PRIx64 " %02x:%02x %"PRId64, h2g(min), h2g(max - 1) + 1, (flags & PAGE_READ) ? 'r' : '-', (flags & PAGE_WRITE_ORG) ? 'w' : '-', (flags & PAGE_EXEC) ? 'x' : '-', e->is_priv ? 'p' : 's', - (uint64_t) e->offset, e->dev, e->inode); + (uint64_t)e->offset, + major(e->dev), minor(e->dev), + (uint64_t)e->inode); if (path) { dprintf(fd, "%*s%s\n", 73 - count, "", path); } else { diff --git a/util/selfmap.c b/util/selfmap.c index 4db5b42651..483cb617e2 100644 --- a/util/selfmap.c +++ b/util/selfmap.c @@ -30,19 +30,21 @@ IntervalTreeRoot *read_self_maps(void) if (nfields > 4) { uint64_t start, end, offset, inode; + unsigned dev_maj, dev_min; int errors = 0; const char *p; errors |= qemu_strtou64(fields[0], &p, 16, &start); errors |= qemu_strtou64(p + 1, NULL, 16, &end); errors |= qemu_strtou64(fields[2], NULL, 16, &offset); + errors |= qemu_strtoui(fields[3], &p, 16, &dev_maj); + errors |= qemu_strtoui(p + 1, NULL, 16, &dev_min); errors |= qemu_strtou64(fields[4], NULL, 10, &inode); if (!errors) { - size_t dev_len, path_len; + size_t path_len; MapInfo *e; - dev_len = strlen(fields[3]) + 1; if (nfields == 6) { p = fields[5]; p += strspn(p, " "); @@ -52,11 +54,12 @@ IntervalTreeRoot *read_self_maps(void) path_len = 0; } - e = g_malloc0(sizeof(*e) + dev_len + path_len); + e = g_malloc0(sizeof(*e) + path_len); e->itree.start = start; e->itree.last = end - 1; e->offset = offset; + e->dev = makedev(dev_maj, dev_min); e->inode = inode; e->is_read = fields[1][0] == 'r'; @@ -64,9 +67,8 @@ IntervalTreeRoot *read_self_maps(void) e->is_exec = fields[1][2] == 'x'; e->is_priv = fields[1][3] == 'p'; - memcpy(e->dev, fields[3], dev_len); if (path_len) { - e->path = memcpy(e->dev + dev_len, p, path_len); + e->path = memcpy(e + 1, p, path_len); } interval_tree_insert(&e->itree, root); From patchwork Wed Aug 16 18:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714055 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2496889wrp; Wed, 16 Aug 2023 11:15:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFl7gr2KxGUE3w7JU5meNl8L47TYEb/b+L4CFqw5DX2aYk+iDfKmFGgmwu2wljES1ELCXHU X-Received: by 2002:a0c:f001:0:b0:643:1027:ac41 with SMTP id z1-20020a0cf001000000b006431027ac41mr2577674qvk.9.1692209730524; Wed, 16 Aug 2023 11:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209730; cv=none; d=google.com; s=arc-20160816; b=EH3i5KaR5IFwNwV61dl4dy7rVOuWPNnAxcQFBoDtoD51wKaV9tWkYTtmixIwSmYin2 BimKhXTpr5PGj3RoosUKPM9gP3vFZSWTQKQqxk5sd/AqKil8N/MdkmqsDYVCQidbJMgm MD8uNg1k4/hyi6Ykh7Axp4CjJ1Tgm0RDPB9/ITJN/XPnza/fewxJrN2MBv8EO9vEEhQ9 BHuLap1q8TV6ei79IwBKlfE3GsUQ1Ff0g4OlwWUmA7t3LIPqvCpR8rEuZSY0u00siXRK 7QZeB5shwNZ23MZRgmVdNQ30GpDZ+Ph5NerIaMxQN16W5K5KvgseZ5ft0cwDCaI6pq99 v/5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dW/vtLNEGLKE5B9LCkZvKX3qKtEgOxcnhubyDt3ZcGY=; fh=tvl0UihGnCNMZ5cda0Gq4mk/HXi+Z25jes+ecZ856eA=; b=TG0IPhHGEdRgc+aVQ4d+QUd6mvg7DWsfBXLISqvwnhaBSV14uAzaLqgP5ZeOXU1AMv ZgCUuLuoHqsWdspL4VSc9+rN86g37qKu60XowJRBNoM3Ho2IDQvot44PKPn9hPIUXrCW e33QlDkXMSAwPFsaUul/P6Vvn7GnxtkYkr5N1N4AYBUDxGIQwsVTZBFyL+YaKxv+2N9+ zQKPacIOKvbYpSLh938l3IcotQbpSzzYCGqFUhc2DVO8BIOYdlQkTu3u7Ss6JVfukevV Mmqk9Moinj6tE10F9pith8j8B9a+JHDsTQIfb8C+mnu4gDvUAoI5xTK3h599hX2C37m2 GmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yg9mzqq1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j17-20020a0cf511000000b00646fb9f6eb7si5960151qvm.74.2023.08.16.11.15.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:15:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yg9mzqq1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2f-0002Le-2C; Wed, 16 Aug 2023 14:14:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2d-0002L1-3E for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:47 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2a-0003gM-5i for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:46 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bdb7b0c8afso32663755ad.3 for ; Wed, 16 Aug 2023 11:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209681; x=1692814481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dW/vtLNEGLKE5B9LCkZvKX3qKtEgOxcnhubyDt3ZcGY=; b=yg9mzqq10jDjdr0LrevN5wTFkBJnNPVY14w+AYINCf8VbCVCvDJWpkHUI9eJUFfppF QflU7YymYDLowKHedvvueKDKs9KQkL6cwsVvDQKTBBGOHYGm8zoKnu63B77qeAe+vvbT 5jiz2qhHk97WN4LZZAf8myvxs6V4c1nANvpvuncCeATHT/82juLWWXlmqmZQRSBLpkzN Rd4I01fHXtempTiKYeWsDwFobIaJzkY2X3E7CjBKm1uml2BG1QLLeohLUc4zucYSXb17 fKQEMSOivsLXMPp4ioGx3SX5c+7h5uUWgebyUGhdrT1h5y4jvDvnt8cnVp1slrLil9BC +Ckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209681; x=1692814481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dW/vtLNEGLKE5B9LCkZvKX3qKtEgOxcnhubyDt3ZcGY=; b=DJivG256heah+nfW1fYuBRc7hjWsyepwHd8iJBJBpnWtNWFgeMUlutLAer/CB2V8GN z4j2QOmWlT8fve6E1ZNdHHkMy1t+ifACNli3Tfs2nr4WG865GDhCFl6OxCtyO6Ddr/lg R3EpOXdIZ/iRXap5cv6o+ik23UJdQN9eQm/nPU5pPNe9IKS2sHi8wJQkNXWcJl4/9hjH 2N5GZjlpgcDBazRMee6ReDzjVo//gvBwcRC3P/jydMUQumRpizDoO5mfZ/Piar3f1Ejv Ybuqzn2D7KPKIEK6491VJQZDfI+eN9+7bUUvaYkSN8jfLgFgKW6CGEueEJVFnDY4C+07 WJCQ== X-Gm-Message-State: AOJu0YxrRft8lePNkXjy1sRfAxtTUAWKPM1FM6AQR3xEG0RSbUg65dnu AWM+tYHjS3JYwPmATzhfjWnNx/WKrQQkbh0Oke8= X-Received: by 2002:a17:902:be08:b0:1bc:6dd9:82c3 with SMTP id r8-20020a170902be0800b001bc6dd982c3mr2378382pls.37.1692209681487; Wed, 16 Aug 2023 11:14:41 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de Subject: [PATCH 2/6] linux-user: Use walk_memory_regions for open_self_maps Date: Wed, 16 Aug 2023 11:14:33 -0700 Message-Id: <20230816181437.572997-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 Replace the by-hand method of region identification with the official user-exec interface. Cross-check the region provided to the callback with the interval tree from read_self_maps(). Signed-off-by: Richard Henderson --- linux-user/syscall.c | 192 ++++++++++++++++++++++++++----------------- 1 file changed, 115 insertions(+), 77 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 074262b3ac..658c276e39 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8095,12 +8095,66 @@ static int open_self_cmdline(CPUArchState *cpu_env, int fd) return 0; } -static void show_smaps(int fd, unsigned long size) -{ - unsigned long page_size_kb = TARGET_PAGE_SIZE >> 10; - unsigned long size_kb = size >> 10; +struct open_self_maps_data { + TaskState *ts; + IntervalTreeRoot *host_maps; + int fd; + bool smaps; +}; - dprintf(fd, "Size: %lu kB\n" +/* + * Subroutine to output one line of /proc/self/maps, + * or one region of /proc/self/smaps. + */ + +#ifdef TARGET_HPPA +# define test_stack(S, E, L) (E == L) +#else +# define test_stack(S, E, L) (S == L) +#endif + +static void open_self_maps_4(const struct open_self_maps_data *d, + const MapInfo *mi, abi_ptr start, + abi_ptr end, unsigned flags) +{ + const struct image_info *info = d->ts->info; + const char *path = mi->path; + uint64_t offset; + int fd = d->fd; + int count; + + if (test_stack(start, end, info->stack_limit)) { + path = "[stack]"; + } + + /* Except null device (MAP_ANON), adjust offset for this fragment. */ + offset = mi->offset; + if (mi->dev) { + uintptr_t hstart = (uintptr_t)g2h_untagged(start); + offset += hstart - mi->itree.start; + } + + count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr + " %c%c%c%c %08" PRIx64 " %02x:%02x %"PRId64, + start, end, + (flags & PAGE_READ) ? 'r' : '-', + (flags & PAGE_WRITE_ORG) ? 'w' : '-', + (flags & PAGE_EXEC) ? 'x' : '-', + mi->is_priv ? 'p' : 's', + offset, major(mi->dev), minor(mi->dev), + (uint64_t)mi->inode); + if (path) { + dprintf(fd, "%*s%s\n", 73 - count, "", path); + } else { + dprintf(fd, "\n"); + } + + if (d->smaps) { + unsigned long size = end - start; + unsigned long page_size_kb = TARGET_PAGE_SIZE >> 10; + unsigned long size_kb = size >> 10; + + dprintf(fd, "Size: %lu kB\n" "KernelPageSize: %lu kB\n" "MMUPageSize: %lu kB\n" "Rss: 0 kB\n" @@ -8121,91 +8175,75 @@ static void show_smaps(int fd, unsigned long size) "Swap: 0 kB\n" "SwapPss: 0 kB\n" "Locked: 0 kB\n" - "THPeligible: 0\n", size_kb, page_size_kb, page_size_kb); + "THPeligible: 0\n" + "VmFlags:%s%s%s%s%s%s%s%s\n", + size_kb, page_size_kb, page_size_kb, + (flags & PAGE_READ) ? " rd" : "", + (flags & PAGE_WRITE_ORG) ? " wr" : "", + (flags & PAGE_EXEC) ? " ex" : "", + mi->is_priv ? "" : " sh", + (flags & PAGE_READ) ? " mr" : "", + (flags & PAGE_WRITE_ORG) ? " mw" : "", + (flags & PAGE_EXEC) ? " me" : "", + mi->is_priv ? "" : " ms"); + } } -static int open_self_maps_1(CPUArchState *cpu_env, int fd, bool smaps) +/* + * Callback for walk_memory_regions, when read_self_maps() fails. + * Proceed without the benefit of host /proc/self/maps cross-check. + */ +static int open_self_maps_3(void *opaque, target_ulong guest_start, + target_ulong guest_end, unsigned long flags) { - CPUState *cpu = env_cpu(cpu_env); - TaskState *ts = cpu->opaque; - IntervalTreeRoot *map_info = read_self_maps(); - IntervalTreeNode *s; - int count; + static const MapInfo mi = { .is_priv = true }; - for (s = interval_tree_iter_first(map_info, 0, -1); s; - s = interval_tree_iter_next(s, 0, -1)) { - MapInfo *e = container_of(s, MapInfo, itree); + open_self_maps_4(opaque, &mi, guest_start, guest_end, flags); + return 0; +} - if (h2g_valid(e->itree.start)) { - unsigned long min = e->itree.start; - unsigned long max = e->itree.last + 1; - int flags = page_get_flags(h2g(min)); - const char *path; +/* + * Callback for walk_memory_regions, when read_self_maps() succeeds. + */ +static int open_self_maps_2(void *opaque, target_ulong guest_start, + target_ulong guest_end, unsigned long flags) +{ + const struct open_self_maps_data *d = opaque; + uintptr_t host_start = (uintptr_t)g2h_untagged(guest_start); + uintptr_t host_last = (uintptr_t)g2h_untagged(guest_end - 1); - max = h2g_valid(max - 1) ? - max : (uintptr_t) g2h_untagged(GUEST_ADDR_MAX) + 1; + while (1) { + IntervalTreeNode *n = + interval_tree_iter_first(d->host_maps, host_start, host_start); + MapInfo *mi = container_of(n, MapInfo, itree); + uintptr_t this_hlast = MIN(host_last, n->last); + target_ulong this_gend = h2g(this_hlast) + 1; - if (!page_check_range(h2g(min), max - min, flags)) { - continue; - } + open_self_maps_4(d, mi, guest_start, this_gend, flags); -#ifdef TARGET_HPPA - if (h2g(max) == ts->info->stack_limit) { -#else - if (h2g(min) == ts->info->stack_limit) { -#endif - path = "[stack]"; - } else { - path = e->path; - } - - count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr - " %c%c%c%c %08" PRIx64 " %02x:%02x %"PRId64, - h2g(min), h2g(max - 1) + 1, - (flags & PAGE_READ) ? 'r' : '-', - (flags & PAGE_WRITE_ORG) ? 'w' : '-', - (flags & PAGE_EXEC) ? 'x' : '-', - e->is_priv ? 'p' : 's', - (uint64_t)e->offset, - major(e->dev), minor(e->dev), - (uint64_t)e->inode); - if (path) { - dprintf(fd, "%*s%s\n", 73 - count, "", path); - } else { - dprintf(fd, "\n"); - } - if (smaps) { - show_smaps(fd, max - min); - dprintf(fd, "VmFlags:%s%s%s%s%s%s%s%s\n", - (flags & PAGE_READ) ? " rd" : "", - (flags & PAGE_WRITE_ORG) ? " wr" : "", - (flags & PAGE_EXEC) ? " ex" : "", - e->is_priv ? "" : " sh", - (flags & PAGE_READ) ? " mr" : "", - (flags & PAGE_WRITE_ORG) ? " mw" : "", - (flags & PAGE_EXEC) ? " me" : "", - e->is_priv ? "" : " ms"); - } + if (this_hlast == host_last) { + return 0; } + host_start = this_hlast + 1; + guest_start = h2g(host_start); } +} - free_self_maps(map_info); +static int open_self_maps_1(CPUArchState *env, int fd, bool smaps) +{ + struct open_self_maps_data d = { + .ts = env_cpu(env)->opaque, + .host_maps = read_self_maps(), + .fd = fd, + .smaps = smaps + }; -#ifdef TARGET_VSYSCALL_PAGE - /* - * We only support execution from the vsyscall page. - * This is as if CONFIG_LEGACY_VSYSCALL_XONLY=y from v5.3. - */ - count = dprintf(fd, TARGET_FMT_lx "-" TARGET_FMT_lx - " --xp 00000000 00:00 0", - TARGET_VSYSCALL_PAGE, TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE); - dprintf(fd, "%*s%s\n", 73 - count, "", "[vsyscall]"); - if (smaps) { - show_smaps(fd, TARGET_PAGE_SIZE); - dprintf(fd, "VmFlags: ex\n"); + if (d.host_maps) { + walk_memory_regions(&d, open_self_maps_2); + free_self_maps(d.host_maps); + } else { + walk_memory_regions(&d, open_self_maps_3); } -#endif - return 0; } From patchwork Wed Aug 16 18:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714054 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2496890wrp; Wed, 16 Aug 2023 11:15:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECsWfI3SOEF/vGI3QeeFQ5UfHmTfX1dRaiGyyRMTm+IKNdkFjwOs4ZzQfQ1tEvzeNTMzaQ X-Received: by 2002:a05:620a:394c:b0:767:797b:4115 with SMTP id qs12-20020a05620a394c00b00767797b4115mr3028383qkn.60.1692209730555; Wed, 16 Aug 2023 11:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209730; cv=none; d=google.com; s=arc-20160816; b=WtrlroN27DYTzBhWvLzNKN6VUWfoxhcR9RrKR5ZB6Qs0Noy0jvIgftkttIFmTuPOQI 1Z6KFK5f4v4jsmPhmUrCkDB96B6KmsztNMvbVUI8BPT+NJhk/5okPP1+tpHDuHfjzOya xQxJF/RZLntxp0+HtVActn+1Ivdx0rUZxfRrfhKV7WfDNyRkquUjnbUnQN0KNXkP8+Zx rYXiKwXuIIYLnnBvc7Xn3w9VrQCPMa6HDPa1xlKfNcAtGnd3GugLRRpD7k2tRzBDXSuY xZ1jgn7MF4RTbKDuZi/3cXFk8R0tKPIc4BcQyNjDsQcNMo1Vy+dPE2NKjrGO0Bn3y5Ve LKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ALV9YoDASQh3INUMqfrZ/39T3j4UWNqGdyGzg6ZT7es=; fh=1/RPLmiPOKxI3K0Tth0t1XLamI3BfJwfFXnlXaMnevA=; b=WWoyp5Ni3FRRlexzstQAa4HWvPGCSX5Q0IwAP2ujkaf1QPBcOWYb02zaNxoeG7+HjQ QXQdUcU83IJdzE+g8VoUqDn0GFlPjg3XPkVCsXha72tFosVYE7bnajImd+dmNUcddJBw C+Y76XGlprxYmPE1boKK95q55MXMC713SFgeOLmwWJp9XA2UcEx8ANZOZgqR/ObAvAwL 1udSFLU/R0byrSt1IjnD4HW6dIp5uiZLUqBF3C1Sybp1TL4+PrEk4gkQM91qIenBm01B c2DoPOAoZkIMBkJRWSRl/FLBS2lSj5Es/dc6qn5XWaeZXy8QPdUWzc7RepsNeZL3hlsc 9eZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XqGZnj0+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n9-20020a05620a294900b00767cd737259si9544075qkp.251.2023.08.16.11.15.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:15:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XqGZnj0+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2e-0002Ld-Fx; Wed, 16 Aug 2023 14:14:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2c-0002Kx-Vd for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:46 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2a-0003gb-JI for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:46 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bdaeb0f29aso39059465ad.2 for ; Wed, 16 Aug 2023 11:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209682; x=1692814482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ALV9YoDASQh3INUMqfrZ/39T3j4UWNqGdyGzg6ZT7es=; b=XqGZnj0+813xTIZc5J1fYjjgVKDKyL8mEikF6j0n+FswP53tFYFH3HXVSdC4L/YUz2 t6z0AVSm1DMrVqe5bI6woeAU0AkXGDEC35JnvKHQA5j4+D7oisi3BeB2FSAhpihI3EsL bYQnKAjLM1fB7Ln834NwRZ9yCxV6VMC9PtcNnU612hW9arkOd8QfIFAzf+0rXSlgP/IA NFSes4aRwrNG3IFOKV7MGXiSPtto4YvIFnDS4FJaIaQst39tsrrmEUz+8Cr+3W1a1ScU ZQMSyz3f6ySGM+iiaea3wtFZ/vVsVCvLXidzQn3Nhs5DMZvbqTfwN846kfxDZD7tL8a+ 9LMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209682; x=1692814482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ALV9YoDASQh3INUMqfrZ/39T3j4UWNqGdyGzg6ZT7es=; b=YcHA+FfvSwOd5g/pehCMDdTHsFwPSgp1KRu4cBcP84IuUS8aljusPVWmN/P1gujZmC R6DiVdlry/jxfB7BwEPUgnynsFMmZ/1+48QqTM37BdPrPEk92A/HCpLn5+kiKqV922AB /Wo4TV4o+3NKeV9nW0ilD45Dz3lgDkPfpJzJr/mIa7aXaPn6dAJ+tPdzqs6W8Lt8qAFW yQXhQ5F7d4sC4rebvKkxmHoL5PiWvOjMXxCd+WDWCQqlo/M+nkDGUicolPKKLP42bj0f rb/4jlNSb5zxolh0Lq3HdjDs1Al3p7EoEi9D4khwx9j20LOn0TPfUKffJVby+0fBwqPM kCSA== X-Gm-Message-State: AOJu0YxgfEa8gHygyeib9lZbs7MQ3ZUFsmm6sDtKOvvkCpH6kRSYreFm nj6CrIUZ3FVrw4+Dsmyu/borhRKvUf6F+ElG32U= X-Received: by 2002:a17:902:7e83:b0:1bc:8748:8bbf with SMTP id z3-20020a1709027e8300b001bc87488bbfmr2262512pla.52.1692209682381; Wed, 16 Aug 2023 11:14:42 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de, qemu-stable@nongnu.org Subject: [PATCH 3/6] linux-user: Adjust brk for load_bias Date: Wed, 16 Aug 2023 11:14:34 -0700 Message-Id: <20230816181437.572997-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 PIE executables are usually linked at offset 0 and are relocated somewhere during load. The hiaddr needs to be adjusted to keep the brk next to the executable. Cc: qemu-stable@nongnu.org Fixes: 1f356e8c013 ("linux-user: Adjust initial brk when interpreter is close to executable") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ccfbf82836..ab11f141c3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3278,7 +3278,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src, info->start_data = -1; info->end_data = 0; /* Usual start for brk is after all sections of the main executable. */ - info->brk = TARGET_PAGE_ALIGN(hiaddr); + info->brk = TARGET_PAGE_ALIGN(hiaddr + load_bias); info->elf_flags = ehdr->e_flags; prot_exec = PROT_EXEC; From patchwork Wed Aug 16 18:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714059 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2497188wrp; Wed, 16 Aug 2023 11:16:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoOxf+F5CGY0/wqsmAqws4ChgXc0Of+fBuFayFaIbQMTWM/MQDF+kDzx1qMyndbUzf5i73 X-Received: by 2002:a05:620a:1908:b0:76c:5715:b45f with SMTP id bj8-20020a05620a190800b0076c5715b45fmr3229925qkb.14.1692209765583; Wed, 16 Aug 2023 11:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209765; cv=none; d=google.com; s=arc-20160816; b=Or76gcQfEBdtWyKcO768a8c4EXkxPvEZjc6lP23fwCOJoc+85eZg4S8tmZUD3asoY/ PQbbtRbvYMmNk3nU7BDYsMgXW+4qCq5TQ+4j02+NO0y/cXD215T6pxLKPrHVC+iczW4O knEZogA2tUgdBUrrRuT0o1ZZkVyChV8tVopzYLxdpaOU/REM8W8sRJGTxrgh/vTR21VQ N+/SrpvI52OmURshX1q6Gee9LCQQN16IXIXN4Ak+VtfM7IVh4Kwq6XE7HF/ERGRhGF17 y8YqGbEEoZO6t9KEp/AIhd8eutbgIqIre+YN+lUNZ2eHNvDLRkhV/50CfFfJZqJkvHKr wnow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=902iWhbQP4VzMfSuKMj7bvmHlg0vdFaz5xqxGaNOCL4=; fh=tvl0UihGnCNMZ5cda0Gq4mk/HXi+Z25jes+ecZ856eA=; b=TyDfPd4jkHe13vJV/c8HfFZuWlmFwGSZ+m1zO0LKZVcZl/vx/p5qVOZ8TpngP7g7+p wlBb7ZeXq8/vx+uAqOZhggx8ANVw9cyuMJl/4Hr0do7lfXPplt0Syuuh0HRC3MHODhdw KtMM4GKbdw2EaS5yqU384Zv3uwc8Oj1MfIp7eFOkUrEIEGAW1iO5kLI2bRgXyhjeSnAX jUiXjl6DzljQNpJgoFF7wbVKQUn59Ihktoqn56zt1gcms2HfLg0CLUJlkiHev78QxGoj BEVgvej8THb2WwuMuZHGa9fw5WaqJfOYRvVW0tcLDxvlojTMeg9U1DxmXQiZP0VoFQtD C6nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IIfTeJgj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m19-20020a05620a291300b0076aeff30307si9402319qkp.312.2023.08.16.11.16.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IIfTeJgj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2f-0002Lj-E2; Wed, 16 Aug 2023 14:14:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2d-0002L2-3W for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:47 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2a-0003gr-PW for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:46 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bc3d94d40fso57609005ad.3 for ; Wed, 16 Aug 2023 11:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209683; x=1692814483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=902iWhbQP4VzMfSuKMj7bvmHlg0vdFaz5xqxGaNOCL4=; b=IIfTeJgjkyJXi8sDe/KAAuiQmw9g7A9YVPabjQkksqfts6OmyZ+ubPderDa2iQioU6 JPDyBU1QBbUgmK5uYq12rC9T/q84wL6mUNTNBnTEje/ENyQH9OBoVQoOn6yBPUcH2oRp tN6X1shHFCcXdKqY/alMZCAzbDzKqQokgoWhc9r9tI0quStHoas2SEhQaN4LKOj/Z3MU 3/ZJpVqz7+9BtIeccfEHeVIBHZrFUJPW/7hD9Y4ZeQ2QPNuuJM7/9zC6XbBkqHY0NaMU NEyx7oepV6ibfiNqzBhAF+fJa6eRru2vL5OKVT2CZjyuh8lcdDGh+EoiAIgKAcdkKRL1 yDnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209683; x=1692814483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=902iWhbQP4VzMfSuKMj7bvmHlg0vdFaz5xqxGaNOCL4=; b=hFUjvBX1sCXQixbMMJFD5Bcjv3mutj1B5Rp7KWycu8GpUzjxtpUKtIiJj7LO2gXCok jBS1Ad+iCqzTFGgq8MWIm5mghxZNgYe/q/IhXmDqiHZNofJAUNywJKcJ3Ubn13o1kAKV o5zNXYTk/DaskyH8GQXsqXyHW9sbGdwUKtm+Y0phQUE2mDJYeWVbTVvIsOzvhRKserO7 cLYHPsqwXQS5uJRoZNAiNFvzqqEV0dqEXa6mnT+S1FKN8ARvSw2GiWHqFjHvcF3mqaos 10E/Xa464em5dNOEU8t/51rA6BPPKIRLgZ/IhIp9bZBoveZYD7ETPDTb/tM3ZUYa0m4C f8oA== X-Gm-Message-State: AOJu0Ywfjwefer7Ry9fKS9i3+IxgGj5A1Tpi1frciqJy+lveCF5DB+6X yUTwWvrMfkc25Zevp4fReCOtQ+WoBiMkrSP4Nac= X-Received: by 2002:a17:902:db0e:b0:1b9:de75:d5bb with SMTP id m14-20020a170902db0e00b001b9de75d5bbmr3343345plx.7.1692209683425; Wed, 16 Aug 2023 11:14:43 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de Subject: [PATCH 4/6] linux-user: Show heap address in /proc/pid/maps Date: Wed, 16 Aug 2023 11:14:35 -0700 Message-Id: <20230816181437.572997-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 658c276e39..5c0fb20e19 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8125,6 +8125,8 @@ static void open_self_maps_4(const struct open_self_maps_data *d, if (test_stack(start, end, info->stack_limit)) { path = "[stack]"; + } else if (start == info->brk) { + path = "[heap]"; } /* Except null device (MAP_ANON), adjust offset for this fragment. */ From patchwork Wed Aug 16 18:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714057 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2497122wrp; Wed, 16 Aug 2023 11:15:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzER2hwZatBYnynZw7yPFr4+uQFin7Uxd1fR2opSpwoXTdl8o75aEWd2jLP51SsJ58/eRz X-Received: by 2002:a0c:f147:0:b0:63c:f72d:1124 with SMTP id y7-20020a0cf147000000b0063cf72d1124mr2427455qvl.48.1692209758332; Wed, 16 Aug 2023 11:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209758; cv=none; d=google.com; s=arc-20160816; b=BFHUtcq9Mz4HZSqi6Ff3t6midPMR31l6u7y9h9Hvwn+iy8HhCH7hDCGXDmUPoSg+rf Nltdl6Z5HfmHXlz8Oh4GIiOSChoqd7aeus1QYFgu7zTlsO6SmRRsMmuK6hx/weh+PrZz 0hyr0hFYsKv54kyQ5QR3DO0MNJ9VbPTR+oTG2dpLB/8UvN9rPvniMmKhlAo0Io6/x+sH LL/C/LviGJcUDLDY+WtbrSOKHv4/0qUdsh60D0wct2hvI0O4cqHK0hRy3n7fKBphGqYP 9TpPMOJ/fl8PyAkwMZDRy1rQ9UbWHAYIas7oLsFFHH//8BZ19s3jP8sFTUK3EnEa+DuT dAvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N/VrLavYNm2qSqY+s/daJnb3lPDtmWM2XHscaFIHocI=; fh=tvl0UihGnCNMZ5cda0Gq4mk/HXi+Z25jes+ecZ856eA=; b=zVN9td6DMGRBjM6Uqd45TEm7kdGq00l65Tm+jX0a/V29qYUa6DD0dkmJLdXXWG18ru mAHUKAsj3+uls0K+FEsC3X+Tazwp1F1+Hj8ItVze7KzEmdlMC/Azvfn4pOkvVDAw1AHQ uR2KCyfGFMOpuiIMTo0zpmB2AvugynlOXz29uWeF9nwMQdhrutJLWrbHjBOAuVLF+8yl /2zp6Ei1Z7yf6zTO2kz9Us9qW2D5r4qCZP4z4fbPlL7AYXjnXWoDNw40MGI15xClpq06 JpJjmLs940gQcby0ALtptQPiWUTJ8eogRSOAijoc+NVlcf/5rGhfo49nRttctU51/iUx kGuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I+X/sp58"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dt21-20020a05620a479500b0076d72d7c916si921730qkb.524.2023.08.16.11.15.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I+X/sp58"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2h-0002NC-69; Wed, 16 Aug 2023 14:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2f-0002Lg-6g for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:49 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2c-0003gz-Ne for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:48 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bdc243d62bso32209085ad.3 for ; Wed, 16 Aug 2023 11:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209684; x=1692814484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N/VrLavYNm2qSqY+s/daJnb3lPDtmWM2XHscaFIHocI=; b=I+X/sp58mJC0uRA/4OZpX+sQctDJxQpB4HPP0uOxflAjGy9ncHI6XXgD+F4lJDsg+p HuuAGcPkTrdBEBogQ1imRmpDdMChFAgiTcn9JBcB0dwCzeern84bG1XHlO0qgc70uRFu Dxyq/vXOo5BjHxOmv67XVsDn9Ouugm2AVApT/t0uv91FbkiRhCkeOo/MHHY+kc22IC0p 2EYpZfDSp117ikX1u78BMpuIqbwBZmwzg9FSVcpp7eI4pdikJE6JNc3xgoUnMjsoHiNi gKi0w9SfzWZbb0YbRj/mhDcDcuKL00+4a15DLuleMxGGSNW6hm6QRCpvcepWRGmAOQZK ysBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209684; x=1692814484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N/VrLavYNm2qSqY+s/daJnb3lPDtmWM2XHscaFIHocI=; b=aw/Tt5fUQeHA3HIyBFXfUfoV33XMIfny08cvU/adoOAtBQO67GJtMaUIRTDatMrwBX 9GC6brUKs+bG2HG8TyFqDZ6XKy1CXOb+t6WLrrBk3bo+OvurejkRhPvCanfchtRaygAM h5G3RJpInUvyJh5cZFj/y7yWCBRSNVdpfePRcq4nAY8Gm1WoHap74sDqSIj/sW7KXmjg 3jMOY1zfYFddCuSlq+9qyEhffHUg2quR+27uGyR6rgXVC1oMgoDajWKRi8ekVquO1NY6 m36fRSyYqt0debPdyoQnQ3MCATVJ4VPcX/jQO+KJ3r5kaOYuGvfskCPj4f02e8X6Bdg0 etuA== X-Gm-Message-State: AOJu0YzKsk5effT79/HjHTMw/HXrCj3vu1aPyDRiDHKckWB6ESerdwQ7 fLXC/harLzxD9Frdl87gpJgAa9wAaNG1VTVJKZw= X-Received: by 2002:a17:902:680e:b0:1b6:6c32:59a8 with SMTP id h14-20020a170902680e00b001b66c3259a8mr2479897plk.36.1692209684356; Wed, 16 Aug 2023 11:14:44 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de Subject: [PATCH 5/6] linux-user: Remove ELF_START_MMAP and image_info.start_mmap Date: Wed, 16 Aug 2023 11:14:36 -0700 Message-Id: <20230816181437.572997-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 The start_mmap value is write-only. Remove the field and the defines that populated it. Logically, this has been replaced by task_unmapped_base. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/qemu.h | 1 - linux-user/elfload.c | 38 -------------------------------------- 2 files changed, 39 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4f8b55e2fb..12f638336a 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -30,7 +30,6 @@ struct image_info { abi_ulong start_data; abi_ulong end_data; abi_ulong brk; - abi_ulong start_mmap; abi_ulong start_stack; abi_ulong stack_limit; abi_ulong entry; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ab11f141c3..a670a7817a 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -156,8 +156,6 @@ static uint32_t get_elf_hwcap(void) } #ifdef TARGET_X86_64 -#define ELF_START_MMAP 0x2aaaaab000ULL - #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_X86_64 @@ -234,8 +232,6 @@ static bool init_guest_commpage(void) #endif #else -#define ELF_START_MMAP 0x80000000 - /* * This is used to ensure we don't load something for the wrong architecture. */ @@ -333,8 +329,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en #ifndef TARGET_AARCH64 /* 32 bit ARM definitions */ -#define ELF_START_MMAP 0x80000000 - #define ELF_ARCH EM_ARM #define ELF_CLASS ELFCLASS32 #define EXSTACK_DEFAULT true @@ -606,7 +600,6 @@ static const VdsoImageInfo *vdso_image_info(void) #else /* 64 bit ARM definitions */ -#define ELF_START_MMAP 0x80000000 #define ELF_ARCH EM_AARCH64 #define ELF_CLASS ELFCLASS64 @@ -802,7 +795,6 @@ static uint32_t get_elf_hwcap2(void) #ifdef TARGET_SPARC #ifdef TARGET_SPARC64 -#define ELF_START_MMAP 0x80000000 #define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ | HWCAP_SPARC_MULDIV | HWCAP_SPARC_V9) #ifndef TARGET_ABI32 @@ -814,7 +806,6 @@ static uint32_t get_elf_hwcap2(void) #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_SPARCV9 #else -#define ELF_START_MMAP 0x80000000 #define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ | HWCAP_SPARC_MULDIV) #define ELF_CLASS ELFCLASS32 @@ -836,7 +827,6 @@ static inline void init_thread(struct target_pt_regs *regs, #ifdef TARGET_PPC #define ELF_MACHINE PPC_ELF_MACHINE -#define ELF_START_MMAP 0x80000000 #if defined(TARGET_PPC64) @@ -1048,8 +1038,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en #ifdef TARGET_LOONGARCH64 -#define ELF_START_MMAP 0x80000000 - #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_LOONGARCH #define EXSTACK_DEFAULT true @@ -1144,8 +1132,6 @@ static uint32_t get_elf_hwcap(void) #ifdef TARGET_MIPS -#define ELF_START_MMAP 0x80000000 - #ifdef TARGET_MIPS64 #define ELF_CLASS ELFCLASS64 #else @@ -1303,8 +1289,6 @@ static uint32_t get_elf_hwcap(void) #ifdef TARGET_MICROBLAZE -#define ELF_START_MMAP 0x80000000 - #define elf_check_arch(x) ( (x) == EM_MICROBLAZE || (x) == EM_MICROBLAZE_OLD) #define ELF_CLASS ELFCLASS32 @@ -1345,8 +1329,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env #ifdef TARGET_NIOS2 -#define ELF_START_MMAP 0x80000000 - #define elf_check_arch(x) ((x) == EM_ALTERA_NIOS2) #define ELF_CLASS ELFCLASS32 @@ -1442,8 +1424,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #ifdef TARGET_OPENRISC -#define ELF_START_MMAP 0x08000000 - #define ELF_ARCH EM_OPENRISC #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2MSB @@ -1480,8 +1460,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #ifdef TARGET_SH4 -#define ELF_START_MMAP 0x80000000 - #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_SH @@ -1562,8 +1540,6 @@ static uint32_t get_elf_hwcap(void) #ifdef TARGET_CRIS -#define ELF_START_MMAP 0x80000000 - #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_CRIS @@ -1579,8 +1555,6 @@ static inline void init_thread(struct target_pt_regs *regs, #ifdef TARGET_M68K -#define ELF_START_MMAP 0x80000000 - #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_68K @@ -1630,8 +1604,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e #ifdef TARGET_ALPHA -#define ELF_START_MMAP (0x30000000000ULL) - #define ELF_CLASS ELFCLASS64 #define ELF_ARCH EM_ALPHA @@ -1649,8 +1621,6 @@ static inline void init_thread(struct target_pt_regs *regs, #ifdef TARGET_S390X -#define ELF_START_MMAP (0x20000000000ULL) - #define ELF_CLASS ELFCLASS64 #define ELF_DATA ELFDATA2MSB #define ELF_ARCH EM_S390 @@ -1763,7 +1733,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #ifdef TARGET_RISCV -#define ELF_START_MMAP 0x80000000 #define ELF_ARCH EM_RISCV #ifdef TARGET_RISCV32 @@ -1803,7 +1772,6 @@ static inline void init_thread(struct target_pt_regs *regs, #ifdef TARGET_HPPA -#define ELF_START_MMAP 0x80000000 #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_PARISC #define ELF_PLATFORM "PARISC" @@ -1859,8 +1827,6 @@ static bool init_guest_commpage(void) #ifdef TARGET_XTENSA -#define ELF_START_MMAP 0x20000000 - #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_XTENSA @@ -1926,8 +1892,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, #ifdef TARGET_HEXAGON -#define ELF_START_MMAP 0x20000000 - #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_HEXAGON @@ -3684,8 +3648,6 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) interp_info.fp_abi = MIPS_ABI_FP_UNKNOWN; #endif - info->start_mmap = (abi_ulong)ELF_START_MMAP; - load_elf_image(bprm->filename, &bprm->src, info, &ehdr, &elf_interpreter); /* Do this so that we can load the interpreter, if need be. We will From patchwork Wed Aug 16 18:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714056 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp2497049wrp; Wed, 16 Aug 2023 11:15:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzkMd86fzzA059UdOFLHBPmsVHCP3hadURgmMxV/kJ/36BRPvy678mJ8vA1q19z8eja4C4 X-Received: by 2002:a37:ad10:0:b0:766:fe00:7df with SMTP id f16-20020a37ad10000000b00766fe0007dfmr2367644qkm.42.1692209750085; Wed, 16 Aug 2023 11:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692209750; cv=none; d=google.com; s=arc-20160816; b=Yns/UkTJE9ohUBsOVEZzGZQURS46gLL9dx2TKYaVUkIL/Djf2DqJ0TjfDYWGw0ojj8 VbPR6l3vEOjzEtY272S/Vkn4oGRlk1aevCKNdId3Kmbw7XQyIl0leKkBxZRwjIiRPZFT cAWmqmHXhjcPSH3cKOxYBZSyW9QRxWfZFF5XW1QWnorlg93YWJFfdsaftdSmnAfbnG7O LC5w9feIIDLsyRfRMGHLE7t/LwcSGhQDfLpisOOB91EJVtZfcx/j1RrhCcvevN3C3tTQ SY72P8NqQj84oOsrjXQ4/JqCu+mJ9FlZjnWJ3RclZP29O9dL0b554GbssrF8tNZlbekm u3fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VvfERpWnA//CSNMU9sCRk6rxPVpfXMYFa3j/mN7uLKY=; fh=tvl0UihGnCNMZ5cda0Gq4mk/HXi+Z25jes+ecZ856eA=; b=jSiz/dswC1cnRs9ie8Xcyaxtc22vAMWfRAQJqhlPJble9ZGVrmEQlns+qW3kzQabP4 7+PMl2oEMTw/iAypdMRiml/2IS18SRNxaX4vQP1KzmaIzb8PioldJEjqtnLyk+dRfU4H /rR9HReDFKx5fdpCUCezmcZ8oNZbnqewTnXQSzOhnSrYVskwSDurZKkaXmcz8sxxL3Ff T1vT/KXEdSi+IH1ZlD5XheCm3kMfx/EPfOXXzWSyrnh6VsGnfH8IF2BDA2d9mX/h/Wbz Gwkhazm7YRsBTE7i3LtI/NqFXN9N7ptThJNwI8Zwyg9Rs8VH/zl3B5Z3iIN2lXUhhg+r /gdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WWZaKad3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id px8-20020a05620a870800b00763b522ef39si9074200qkn.749.2023.08.16.11.15.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Aug 2023 11:15:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WWZaKad3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWL2g-0002Mq-Lc; Wed, 16 Aug 2023 14:14:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWL2f-0002Lf-6U for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:49 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWL2c-0003hD-OE for qemu-devel@nongnu.org; Wed, 16 Aug 2023 14:14:48 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bc3d94d40fso57609275ad.3 for ; Wed, 16 Aug 2023 11:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692209685; x=1692814485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VvfERpWnA//CSNMU9sCRk6rxPVpfXMYFa3j/mN7uLKY=; b=WWZaKad3FFfnbwyNKiYhKhMfZGQAYvFctIXGdCwHD3xlu0HgdAzcQhgKNmq3uDaEPb 3PS6ctymeobik/f07N/HaeLork4P42RZxABUVHZfWo35m/XVVAbjVjxpRSxpv1W2K4Kq 1FAiqJDW/ldaUtw0atnuCnPoZwJZAfuG3ltzPgzCAjdIttavH4NmmvlA3ayQWmqXfMhH W71/0UdzPNtJxq4PLYSGXTEEDRn75g2kN/WpKnsrhBxcx8WLI2cL9yON5XYfnw74+5xj oB9jD7nq3Bkn5NuNKko3vEhAA61MncsN4U0oec7Xap3fM7mE/ya88jGHax5x20t1J6jX w66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692209685; x=1692814485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VvfERpWnA//CSNMU9sCRk6rxPVpfXMYFa3j/mN7uLKY=; b=dJxqIwHh0iHt4dfGwr5/2BUmfXffsVSAv1y6cNIW7Ae0kyDWL2ZWz/tF6qHVA6WHyc myuEVgEUO69VG0Jm6eJ4nRuMMpatnfvxFG5oTA2JKLef1GN7biO42A+TSPw//f8von5y /b+/h1ab/6R+b0NbFK/DYgdPeM38WDULAMjIvC3AQm6L5swZCExAHD72hTgO4rep7lGA FP2wq0dPBw/F9UstlY4kUrBb3lzISZ+6rSL0T4qDsjFP68eqzLw1ReL40ejjpy/tNMB9 qyEw7WLSsWf+D6+I84GTgBny1YrYrxSI1EQ/5BvXYJHFI+CdBBtClAqhGNpSeTHWJ1jT 5I9g== X-Gm-Message-State: AOJu0Yw6YH8bSXpkgVRlQWbgJN+06654gW+AgMWBSUeF2WjLlwjZRmSF E9zYym/iE6vypWVZM8oabulOG6ID0xrYUN74fPk= X-Received: by 2002:a17:902:7789:b0:1bc:2d43:c747 with SMTP id o9-20020a170902778900b001bc2d43c747mr2707972pll.38.1692209685202; Wed, 16 Aug 2023 11:14:45 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:a064:e3f9:a812:973b]) by smtp.gmail.com with ESMTPSA id g14-20020a170902868e00b001b9dab0397bsm13423563plo.29.2023.08.16.11.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 11:14:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, deller@gmx.de Subject: [PATCH 6/6] linux-user: Show vdso address in /proc/pid/maps Date: Wed, 16 Aug 2023 11:14:37 -0700 Message-Id: <20230816181437.572997-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816181437.572997-1-richard.henderson@linaro.org> References: <20230816181437.572997-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/qemu.h | 1 + linux-user/elfload.c | 1 + linux-user/syscall.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 12f638336a..4de9ec783f 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -32,6 +32,7 @@ struct image_info { abi_ulong brk; abi_ulong start_stack; abi_ulong stack_limit; + abi_ulong vdso; abi_ulong entry; abi_ulong code_offset; abi_ulong data_offset; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a670a7817a..12285eae82 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3726,6 +3726,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) const VdsoImageInfo *vdso = vdso_image_info(); if (vdso) { load_elf_vdso(&vdso_info, vdso); + info->vdso = vdso_info.load_bias; } else if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) { abi_long tramp_page = target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_WRITE, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5c0fb20e19..c85cf6ffb9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8127,6 +8127,8 @@ static void open_self_maps_4(const struct open_self_maps_data *d, path = "[stack]"; } else if (start == info->brk) { path = "[heap]"; + } else if (start == info->vdso) { + path = "[vdso]"; } /* Except null device (MAP_ANON), adjust offset for this fragment. */