From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +VrsAQtDT2oQTC0AWB0awg (envelope-from ) for ; Thu, 09 Jul 2026 02:43:23 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M9LmG0UQ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0367A1E04F; Thu, 09 Jul 2026 02:43:23 -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,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 441A91E04F for ; Thu, 09 Jul 2026 02:43:22 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77CF44BA23D5 for ; Thu, 9 Jul 2026 06:43:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77CF44BA23D5 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M9LmG0UQ Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id C7EBF4BA2E35 for ; Thu, 9 Jul 2026 06:42:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7EBF4BA2E35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C7EBF4BA2E35 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783579376; cv=none; b=Wxkma7sECLhCQEZiultenw+0s67Jd9pj3oycejgf8S7ucx2YWLQYyqoSxfFKTcLoLCyp9AHAD9muSPVSE/YHATk6RCchJahnBffRTdaO21ZT2ikLzaP39B+CB7eK4//5wmx99ON3imV0u8iXI121Pqd8IjsL38KYRJU7C2Mo0ZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783579376; c=relaxed/simple; bh=24XE1T4ZSd8T4cJty23jYDqOaDNd2DhsotMZ9gkGAHs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mqfwp5cbPd6G+RupoO8zkVJesQpYJccs2M+s1DkzwQ/J3HUEfTeTokip/4eQ5ihsyFLCffxsILxfNLO6eLk74302tIaVCGVHCFceXh2qPoeGAzfwQLn6kAH6ZJYF1zMvxvhOG/icREJL1TI2C6fBp0ya741mdl8EcHRmbGCXiac= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M9LmG0UQ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7EBF4BA2E35 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-8051ad12d23so17417327b3.3 for ; Wed, 08 Jul 2026 23:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783579376; x=1784184176; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=2r9TSFNfvSvDjLYKBNd0ai0sxQlYRDXn46CfftkSsp8=; b=M9LmG0UQJlQm6ZK3JiK5jpJzgklwx4r0PC2q1rKPj1U4fhYT0LcbV276SdtvZw7Vvp AXaYJ1nkZmg93OlQhFvUtH+WvJYB249YGY/u1fF2Tjp5tlUS/ynnYbJd0lnoTk5Uhycg J5lDSVuYDF1QauHhe0bQTfnzeXP4sfgsp+JUjy6mF5+730q+/kaWMvDj/GXGE6DdDYFg a2DMeBgvCRpkBcKwRyRkY8CFi2filuPL+rem9GZHius9gikLC6EXJTTp1agqVGwXZ2ca txNDeZDjtQL8D3pUT+KQO7dyTMraOgS09rmI1uzB5ktPdfQ3onj9tXImBx3TIGFiJUAA m/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783579376; x=1784184176; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=2r9TSFNfvSvDjLYKBNd0ai0sxQlYRDXn46CfftkSsp8=; b=Qq+5GgXOqzuwhwY1doqoFIjANaVnuUBxo7UtdkL9zooT/8JgheOx8dBfn0feuhdK+F HI/GN+CzbAAi9GWuYBpMHLtj+6hseztOVwwurVE0MNcTB+jhFz6FNgxiLQZllqOwINAj BCUQUdsI9qWYm/8QMIVzNJlVx8Lw62V3xDZDP3Bxl4pPVw/nLhvaRWz3xrA2wCJcBx/5 OuU0pgD+nxDLZM+POCStEn6NPm8t041so8LOCweB7FHR60RTHE3v0cNAalPblAlWCJ/h 9g6Ig5R2lasbRtbmis28XnGFdRxy2A6A3OFRP4wpTKru9Db8bTLGknbAqCoWDd3PpTr5 XKbA== X-Gm-Message-State: AOJu0Yyf2Z/2QPPAZEEII1tFAfBn818n1MbjgVSoF7aAh929ayELFlrk bU1DWe/11TwAR+EoHEz25l+kxUmUwIbM13XBfClW1oQcL88VX/N0X9tMBGpdm0PIDw0M1xukA7v BwBqh1E0= X-Gm-Gg: AfdE7clRbkf6DRup77uEB49C77RcmvwMgACWzhmlQBaRVbJVJTPN4DL5y0WKJjtemUZ 8M1CkrGwvttbvPeMdjXo8deDDKrp55TatKYZQ4r+jlv2pQaIlvZBOM/XMQZW6QVS+/zSUNLmf7K DRY/eeM3Go+ModpnqBP1zqFgdUtRnWRQvc28c01N1qK0B9/g9PutOW+DO9vJX2UKxoS8vJYJikw vU/EOcmkmhBIzexbGw7oWjEH26/Y5dmWAaUxJhAZr8IDGY3bEMYYIXMjapFD5CiAFjfN1iNEjDx UgAXwQ20rk+JtNwXRBfEHaLdNELdtVlYlcf9QekaN7ucMLs2vciv63FEty84hJfBb2CRrc5L7uF oXpvTazqjzO41iOu+hivkn7p6E+U6wq0LQgzNa/xY01YLyOzYxA67KO3AacBDXsvoq87DGBfhAn 7MVx0Pug386FXFqzoQwOGDIZ0= X-Received: by 2002:a05:690c:6c8b:b0:80c:85c6:897a with SMTP id 00721157ae682-81dc1632c6amr43275277b3.57.1783579376070; Wed, 08 Jul 2026 23:42:56 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81e6c245d12sm10432627b3.48.2026.07.08.23.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 23:42:55 -0700 (PDT) From: Thiago Jung Bauermann To: Matthieu Longo Cc: , Luis Machado , Luis Machado , Andrew Burgess , "Yury Khrustalev" , Pedro Alves , "Tom Tromey" Subject: Re: [PATCH v1 09/10] gdb/linux-tdep: parse ProtectionKey in /proc/PID/smaps In-Reply-To: <20260707154900.94542-10-matthieu.longo@arm.com> (Matthieu Longo's message of "Tue, 7 Jul 2026 16:48:59 +0100") References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-10-matthieu.longo@arm.com> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Thu, 09 Jul 2026 06:42:52 +0000 Message-ID: <87qzlczms3.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Matthieu Longo writes: > 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. /me from a previous life would feel the need to point out that it may also be present on POWER systems. :) > 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 I suggest linking to the commit that went upstream instead of the mailing list patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c1192f842841 > --- > 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; There's nothing in this patch series that uses the parsed pkey, so IMHO (other maintainers may disagree) it makes more sense if this patch is committed together with a patch that makes use of the field. > }; > > /* 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 ()); > + 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); Shouldn't map.pkey be set only if pkey != -1? > > smaps.emplace_back (map); > } -- Thiago (he/him)