From patchwork Thu Aug 24 01:02:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 716493 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1091631wrp; Wed, 23 Aug 2023 18:04:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHbDjIZp9AwAFzQPS2WqqpvOREIeVgtyXIOl8NgNskHNCHon3sa38KMDo1FzTqJt8Zuza1 X-Received: by 2002:a05:620a:280c:b0:76c:ba9d:3ec7 with SMTP id f12-20020a05620a280c00b0076cba9d3ec7mr16897493qkp.6.1692839085956; Wed, 23 Aug 2023 18:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692839085; cv=none; d=google.com; s=arc-20160816; b=ZfsDDZ9TrHNyslJn54fK6XO6YJQde7NJP3sVGQg5jb8tdE7gLkX+ORbSgRYuL95T/m bzxVIg96fQ8JdT8NDnS7YbS19Bt288rhdSKD3BoWO1BhDExmNAPEVTrTkUEEVv3+4zWj bRrpHGwbp4/Ql7YrFAec3XmvVBoINYZeQwa+QaQ3HR9oKGcnL7ckYBeSN3Sm6jH6AmHi LlBAat3h/CpMyo/8Zf4t5iV5zZLjACwaEhuPtzxmJyIpThm2wpLK8ioSe2xDwlN2PFq8 WtFCl6P+W5YUhBQ+sKA90JdAzJuY2t3ghItMwGc68woT/ANitJrDbdlhlNHYnKjcBpD2 HagQ== 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=4DWAv0bR3QBWPP10gPMl5GXU+szn3XnQPYnLcaRRAHU=; fh=WpTNcOBxl+ViqVJ027hc6uh8MPmhfO3NWsuNb69FM0w=; b=k+iXTdNoVs3xQi+T/+E3hkNy4whw8F3n/nICXV1XPaP1bWhz+cXwRBhuql0kfoq9mK ky9SRmMJT3N/dLX0Gw0MwWfKUxuxxoRFIlZU4M2/QdrpQrvjIYSH4YoHw4vCBt1mjwkJ /XWnQ50EqyadHMkptSs95PM0WIsa4IcgOMS2O80dHx3te5/FAJEVuhEwtEExXomwBLIB ZbgHsK4yKN/zk6Lh2xWxsk1cTFs9s7iIfrax1oBehio7Qqnl/KdG/BdicjEO2yUesC9F dcw/Cn8Ovn3aghfuUcSktsFMZ8r2rObD72W1rSnpNggcl53uKPlBKBDOoDuvmoHcL1s6 vCOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WNsMtT+D; 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 bp7-20020a05620a458700b0076da8e6727dsi783187qkb.677.2023.08.23.18.04.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2023 18:04:45 -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=WNsMtT+D; 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 1qYykN-0000AM-AT; Wed, 23 Aug 2023 21:02: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 1qYykI-00005f-5c for qemu-devel@nongnu.org; Wed, 23 Aug 2023 21:02:46 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYykF-0000QY-OP for qemu-devel@nongnu.org; Wed, 23 Aug 2023 21:02:45 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68a3082c771so308910b3a.0 for ; Wed, 23 Aug 2023 18:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692838962; x=1693443762; 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=4DWAv0bR3QBWPP10gPMl5GXU+szn3XnQPYnLcaRRAHU=; b=WNsMtT+Dl7h1fwXfuMFloPrYZBORVbvIgxnhVdjSjstjonL/yWgOMuFoZGpoHX0NND J7QXzH1OJnrR6/0Ca4fBvXJ0ehvn60ibk42oWNH86slV7r5sHZ3sDkCMTq+/GpfyEyhG KKq/xJqLOek/AHjMDHswg4YFIeHtL+VqvZyRT6xb4NxtPT0geR3b4aFEG4TTqU/YyCTj +7qTJG8WMMYRYxNeKJTGR6HxWpvEwI2cLp9jKsSssfZc6wFOmwc143fZgUlt/edmCWpi SQHEn9qdk4knYyqbPrJOwNCutplOsnqlb44xE9T1GvqboMtgofHRefhFF4qPSoQuidfh 9KPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692838962; x=1693443762; 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=4DWAv0bR3QBWPP10gPMl5GXU+szn3XnQPYnLcaRRAHU=; b=UUwA36OJvQcb+GzcRKiVHldIT0HcSBJCE86SgWnkKLjeIh9G5DVRKXeXn7/E3piFDI aW129DbgPZT3JLYH3yUDEDY0G0nX7oodATLY4x6rc+vQKPnJAYhfOYufz8tN67A2XvfO 6gHQ611TvMAPqTdKT2CXAYJQV9wQGFxYytkxZwPdpP709OyAPeW05tdEybkPLryTCuXX s28VJXcwLei3oqTKsuHiCWT2Uc0T83WgNDdK3QS1zK6WYYL48/Dtnaal81obhf3WLhdW oub+CvBc8PhZO5symiMMcl3O3UnH1IRZrL447pQzNkZzw6FLZUt08rCBY51IQ7FbU1eY 28LQ== X-Gm-Message-State: AOJu0YzZDtdVKcg0aF1wq7CA9jewzxdSYJQcn7nYoYxLte2YaO4AghbT EbIhE52JLdOrtkYQGj5uT7V1je34Pscbl3WXLME= X-Received: by 2002:a05:6a00:2808:b0:68a:6e26:a918 with SMTP id bl8-20020a056a00280800b0068a6e26a918mr7996046pfb.8.1692838962388; Wed, 23 Aug 2023 18:02:42 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:72f0:1ea7:85d2:141e]) by smtp.gmail.com with ESMTPSA id c10-20020aa78c0a000000b006875df4773fsm2050789pfd.163.2023.08.23.18.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 18:02:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller , Ilya Leoshkevich , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 04/13] util/selfmap: Use dev_t and ino_t in MapInfo Date: Wed, 23 Aug 2023 18:02:28 -0700 Message-Id: <20230824010237.1379735-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824010237.1379735-1-richard.henderson@linaro.org> References: <20230824010237.1379735-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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. Tested-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 faad3a56df..a562920a84 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);