From nobody Thu Nov 28 11:34:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1692839086; cv=none; d=zohomail.com; s=zohoarc; b=kjtRBjulHv0es7M0BGZQ1HoxOeFYNwClPV/zcqjjZqnau36TSiZ8z9eN6SqqbtGt3987ssXeUFcOVK/J5QwhxNX2p4C7GC/gvzGQL2IXYnnm1Y1Tp8GvoVQKU/JE5hDUnohtFvrfOA2C1dhPCuXgP/gIffgUa52lehvnKmdpp3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692839086; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4DWAv0bR3QBWPP10gPMl5GXU+szn3XnQPYnLcaRRAHU=; b=f4D8bglHgO3oF0P6aQfLDc/i3mKyhOUdbU1ZhaUhgy28/rMz+LjmKUVDU3TEAn9Dv5WeOWiey4ABJon4z0ApdyHwruPt6oDAvFVGGc+vwdrLHwGoL1Y97Ztbm83pbW6CFVBFaygSudbsc7/C+u0dr7TIrVscJSe4LVQ+Ff6dVWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692839086306714.959514842785; Wed, 23 Aug 2023 18:04:46 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IH+BFd6Ik1Qv/vy/RAbvcd6Jd7wKZZc7fypQHkgyl6FPV7yjyG+TB5xPrrZfl4tZPHiIlRn/w== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller , Ilya Leoshkevich , =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1692839087345100001 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=C3=A9 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; =20 + dev_t dev; + ino_t inode; uint64_t offset; - uint64_t inode; const char *path; - char dev[]; } MapInfo; =20 /** 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) } =20 count =3D 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) =20 if (nfields > 4) { uint64_t start, end, offset, inode; + unsigned dev_maj, dev_min; int errors =3D 0; const char *p; =20 errors |=3D qemu_strtou64(fields[0], &p, 16, &start); errors |=3D qemu_strtou64(p + 1, NULL, 16, &end); errors |=3D qemu_strtou64(fields[2], NULL, 16, &offset); + errors |=3D qemu_strtoui(fields[3], &p, 16, &dev_maj); + errors |=3D qemu_strtoui(p + 1, NULL, 16, &dev_min); errors |=3D qemu_strtou64(fields[4], NULL, 10, &inode); =20 if (!errors) { - size_t dev_len, path_len; + size_t path_len; MapInfo *e; =20 - dev_len =3D strlen(fields[3]) + 1; if (nfields =3D=3D 6) { p =3D fields[5]; p +=3D strspn(p, " "); @@ -52,11 +54,12 @@ IntervalTreeRoot *read_self_maps(void) path_len =3D 0; } =20 - e =3D g_malloc0(sizeof(*e) + dev_len + path_len); + e =3D g_malloc0(sizeof(*e) + path_len); =20 e->itree.start =3D start; e->itree.last =3D end - 1; e->offset =3D offset; + e->dev =3D makedev(dev_maj, dev_min); e->inode =3D inode; =20 e->is_read =3D fields[1][0] =3D=3D 'r'; @@ -64,9 +67,8 @@ IntervalTreeRoot *read_self_maps(void) e->is_exec =3D fields[1][2] =3D=3D 'x'; e->is_priv =3D fields[1][3] =3D=3D 'p'; =20 - memcpy(e->dev, fields[3], dev_len); if (path_len) { - e->path =3D memcpy(e->dev + dev_len, p, path_len); + e->path =3D memcpy(e + 1, p, path_len); } =20 interval_tree_insert(&e->itree, root); --=20 2.34.1