From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id JcUWLlLrX2opGSIAWB0awg (envelope-from ) for ; Tue, 21 Jul 2026 17:57:38 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ToG8dAMR; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A44451E033; Tue, 21 Jul 2026 17:57:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id EB15A1E033 for ; Tue, 21 Jul 2026 17:57:37 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 483944BA2E0B for ; Tue, 21 Jul 2026 21:57:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 483944BA2E0B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ToG8dAMR Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id C53874BA543C for ; Tue, 21 Jul 2026 21:57:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C53874BA543C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C53874BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784671027; cv=none; b=ZYeHMYddC5Z5yQtPELW5ttC1JN3yWlryJNaMnADDGxYt13CdAVlkbAUeTkPWG59sjOu8ITzNJszcYPZPPmtK+ZnY547jGnsWHAhMIPWcICMgubkJdriyrCU1BtVudwpfZc4AxVP9KzBgtq7WyRlBSWTpTGjOBt9gi/iUgx879b4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784671027; c=relaxed/simple; bh=RNKD/dpaDJ2TD4ouamJdRnKtpFApT480ad1xCsUCwJ0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=bc340Mr2DPlzB03PauMNJCNoar+wVnUIgwWKUhFrXj6d0Z9xI+i9DzIbYEjv4jBtc+udikrZ9lJeuZmEFw6+Xa3oIKoBdSALmJ9UvkNR9c3/6FveoiM4z+sxx283fDWCHu55gWIgOogNBKFGZNwW7dLYWsFtFRAILLMED2BiK6g= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ToG8dAMR DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C53874BA543C Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4956242332dso20537675e9.2 for ; Tue, 21 Jul 2026 14:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784671026; x=1785275826; darn=sourceware.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=nm+Vfy8KOMahbYS+DnWXtKSTGxWwKvgLGc70/SFJfR4=; b=ToG8dAMRNX5+gQ7PI/GprALGm4i6rvLd5mcOa0EBUvVYAhbbsGiCEF1MpUYX8P+tUQ kuc9IdlpFBkAe7SbVLLFXTWi8Q2vp08Z94rDkfcdzcmtPiPMWFgztH2xEM+LA97qhmh+ v9rAKvh0c7tkOULE8LQPifmdXbKR+ynrAJdeFkOEypJWNJqAm1Lf58g0i8fJPWbO7ipv jidTjy816vWs6Q0rGL5PDl7XpgSUqrYPhKbctcQ2MdFjRPqQF3LF0xRu98e5el5Ezex5 bRDV5HRodpN8leoiae1twO7YvSuvobgGyqUG0EFX5+TqYKcM0cR434frJfXq6lq160kt BlnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784671026; x=1785275826; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nm+Vfy8KOMahbYS+DnWXtKSTGxWwKvgLGc70/SFJfR4=; b=FjVPqdsdFOkMsTy2ItZ6S3Vrj4BnJwt4wY4IoOjcGJF3ubF//9XqKgcuWnJEdjvSyM xJg2m9Zvif8ePNI6H6jFCuYRshFPHjnQELlmt8CwkNV4r3kwI8oSkrcEfVR0KdlZ9din tZHCj0AGVL26fdIpaa+5Zf2YqtQo/juhXsEs6yhgeL8+uwakaN7Y+wyMXYly/nLhYIyM oxcyDYooM3/lwY9Pv18qrPM8yuXUcQ7UfKdDhHLhrxb2S0bhG4ZNzmiaglDvFeHoIsI/ dZqXWCs2OHnmYf+6VAT+pAqhg8YkBRQLPbdhiSXH1q/Xq/cOebYVfTkvwReCG0sVVUJy UEEQ== X-Forwarded-Encrypted: i=1; AHgh+Ro07lkd1LJFERGd9mMgYK+N7gi4dkrVZ+HUAujEUTTdouehr8irlhthlDjsmWrbvGFctvzPIAo+fOb3KA==@sourceware.org X-Gm-Message-State: AOJu0Yy77p6tSYupZanPPy4Yt62u+6vnO6GKA3a5nXAhh+1kxXN3SCnA 1KdvhEmHq+S4NyKUyzCK849GL7wo4GnJvfyXl7n7Hjq98b5swmHAMbVV X-Gm-Gg: AfdE7cn+Dy2NSFi9wKM7LLya3UDUS9PckdT6KYJ3F3BaasNX21/syvxrFcTBmDoHd7Z flGY98PuGrnC3oP1AoCSZDVVZ0l8uU1a+9JA5MHBMIo2tLqfN5QaTc1NxUwaLfx4GfDNt6pQC7L PbpJsJuDdz+GxNTZWiXiDEgAxQX68bA6nAdVyPDwofuXu7eH7rLfdFPBMveJy47r/3E02gm1IJA c1/LHZGRIe613Pyejims934gv3bu7H/KH+ig1X8Dmoh+xzr+MIFv4m+FfFKCI8u8wcvQMuxqki8 WXjxYQAGAH6i5XqzIz7eAaQGhAGBaVqr/DAtMSeOOn1T1Q5RomhsUX8pjn/fassyHflc1p4xRq1 RQI3n5gtTiomNXLsnOs1KREq2Pw5IyQRzPJaYCErH3YLH4WOVn2tnxIN2jEUbjAhB/54IZyX/9b tsjCiK1zWMuu1+gr4= X-Received: by 2002:a05:600c:a42:b0:493:eed4:7210 with SMTP id 5b1f17b1804b1-4954a3ef700mr230782455e9.11.1784671025631; Tue, 21 Jul 2026 14:57:05 -0700 (PDT) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4956537c7desm130114675e9.7.2026.07.21.14.57.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2026 14:57:05 -0700 (PDT) Message-ID: <637710f5-382f-4120-8cc5-23f132e92592@gmail.com> Date: Tue, 21 Jul 2026 22:57:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 09/10] gdb/linux-tdep: parse ProtectionKey in /proc/PID/smaps Content-Language: en-US To: Matthieu Longo , gdb-patches@sourceware.org Cc: Luis Machado , Andrew Burgess , Yury Khrustalev , Pedro Alves , Tom Tromey References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-10-matthieu.longo@arm.com> From: Luis In-Reply-To: <20260707154900.94542-10-matthieu.longo@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Drive-by review. On 07/07/2026 16:48, Matthieu Longo wrote: > Memory Protection Keys provide a mechanism for enforcing page-based > protections without requiring modification of the page tables > when an application changes protection domains. [1] > > The "ProtectionKey" field may be present in /proc/PID/smaps x86_64 > and AArch64 systems since Linux 4.9, when the kernel is built with > Memory Protection Keys support. > > Add a new 'pkey' field to `struct smaps_data', and populate it when > the "ProtectionKey" field is present. > > This prepares for displaying the protection key in 'info proc mappings'. > > [1]: https://docs.kernel.org/core-api/protection-keys.html, > https://lkml.iu.edu/1512.0/03058.html > --- > gdb/linux-tdep.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c > index dbc69a5a7fc..d89c5ae8504 100644 > --- a/gdb/linux-tdep.c > +++ b/gdb/linux-tdep.c > @@ -124,6 +124,7 @@ struct smaps_data > > ULONGEST rss; > ULONGEST swap; > + std::optional pkey; > }; > > /* Whether to take the /proc/PID/coredump_filter into account when > @@ -1553,6 +1554,7 @@ parse_smaps_data (const file_reader_t &freader) > int mapping_file_p; > ULONGEST rss = -1; > ULONGEST swap = -1; > + int pkey = -1; > > memset (&v, 0, sizeof (v)); > struct mapping m = read_mapping (line); > @@ -1653,6 +1655,16 @@ parse_smaps_data (const file_reader_t &freader) > mapping_anon_p = 1; > } > } > + > + if (streq (keyword, "ProtectionKey:")) > + { > + if (sscanf (line, "%*s%d", &pkey) != 1) > + { > + warning (_("Error parsing %s's value in {s,}maps file '%s'"), > + keyword, freader.c_filepath ()); If keyword has the trailing colon this will read... Error parsing ProtectionKey:'s value ... right? > + break; > + } > + } > } > /* Save the smaps entry to the vector. */ > struct smaps_data map; > @@ -1672,6 +1684,7 @@ parse_smaps_data (const file_reader_t &freader) > map.inode = m.inode; > map.rss = rss; > map.swap = swap; > + map.pkey.emplace (pkey); Are we always unconditionally adding a key by design, even when no keys were found? Then we add the sentinel -1. Or am I missing something? > > smaps.emplace_back (map); > } And I agree with Thiago. This patch should live alongside Srinath's series.