From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /n5iKinQN2rQCRIAWB0awg (envelope-from ) for ; Sun, 21 Jun 2026 07:51:05 -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=NlYtEDWW; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9DD8C1E098; Sun, 21 Jun 2026 07:51:05 -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 7524F1E024 for ; Sun, 21 Jun 2026 07:51:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F2C54BA23C4 for ; Sun, 21 Jun 2026 11:51:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F2C54BA23C4 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=NlYtEDWW Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id B5BEA4BA2E0D for ; Sun, 21 Jun 2026 11:50:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5BEA4BA2E0D 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 B5BEA4BA2E0D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782042637; cv=none; b=VyS1dg82c9My0AHgf64tDE/16KXNQW4As0O2tRoWzMdWiaU2spY6Sa+4PxUFGkWKHdSq6XIwqfUdp4nxaeSTzPH3iLgilI/IDOds31VvjjzA/lwJE2x0DB/+Hd/C5B7f/xKqYxuYT+j4sZCejEBGY21L60wGczkGaRxrCvm7+Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782042637; c=relaxed/simple; bh=68yvJ9dHqAI0xQg3Ewpfn7o8WlEci7qzBSxZ3U/vxEQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=H1ZIDmQz4G1Guc34RIxLNN/cd/bn0JLdiv3N4ZK+8Q6YZSM2kbPpvEM832KTEU80eSX9W5ol9bIcbAfmehtErtjm9ZW5XQK7kQCOWiWuNJz75j5I+ftkT21MqKLfn6mhtfGv9VNnwgSVsrMLUES7oPt4IfTqMACpPfSJe57c+kM= 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=NlYtEDWW DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5BEA4BA2E0D Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4924f8db066so3218425e9.2 for ; Sun, 21 Jun 2026 04:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782042637; x=1782647437; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uJJ3kH2XhMU/prkA3a5PHPUG01H/frWNYnSD074Xo4o=; b=NlYtEDWWKBkSGo6gdmE697xaFyydudoj1yzJmYOvZUIzD7+nZVwJ6+rfX6wF15m9QE E8Joo+f6pFkjXTVeMRwhy2kRio2jOrW5optn/uC2Tl+vM3qnXbx+qioCbhU6DpEv5krO ofXOUD+w9BZnRhiEIwNXRRVarSyQqtG0gos0Tlz/CSsQcVcZ251QVVYPD9Wo2DSNU3t2 CmAkEwE2JFJTbZmMqf20T3UKDQUaNgfEVR8JEJOmMFImXFwAyYelW5iM0RC6/9mhMM6W 2fMZNPvKpH/5f5Uk+eLJK7Ow5V6K5h14T6varhhtJUNMgEnYIYCzOX6X3S8iJQ0dqrVn F3LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782042637; x=1782647437; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uJJ3kH2XhMU/prkA3a5PHPUG01H/frWNYnSD074Xo4o=; b=nqhhA7ZmbDoJRUN1F4CtiN7eolO9QNKEx1OMiBMw1QCl2muvP1jy8rITgTKtlIMOgZ uTLqyaNFnOz+HHGbm8NwYEjn3XQHr1nQ28FSookPRo6x2Ibsc1bZy4NrjYwDvU9sWoZV vSxOZe6AbzGj2rQg8zI1+mq45G7msgVDJK5/2PS6ey9pwktD4KlZ3x/Ch1yixD1aQizw w2H5DGxdmuRDPnUk5cHM0lHvgYSUsjon/LVCnNNzXqNySI1wsNrBgwXutzQAPUcsaoc6 hJt6MT1oZQTO1zAduwAcgaNm4vDY+0LztuYfrlzUzf+MPfHB7ewnKjK5JlbnLc7q9E60 avWw== X-Forwarded-Encrypted: i=1; AFNElJ+xhBwFb1paJUqtu48Ud1IXpBdvzAeZ2ZofDh17HVfn2CoFoyKfcHXdc3CXQ2O6WkWA3KSe+3cAk86ANA==@sourceware.org X-Gm-Message-State: AOJu0YzoLhQkuOLHQxTNN5EIHL2uwlftN5IOXre6bpmdzqhyBvzgW8ea b69g05T1O9ezAbJ1l79oyt5L9QGmC5NbT293gfdJZrH0o7cHvF0AA6fZWNtIFw== X-Gm-Gg: AfdE7cnjn3Siu24xX9Cl2vsrCooh8P/YWR93wn5q6RrFkpOPDfOMkKeVVp3q0XR0udN Gwiy3pfB3JBlpnXpjvT7GO6pNxGxgUrDsDNaPof+WFg8m2ebsEUsaO0fClx6NBgH3v07jx6lLZW u3EEhydfQ3nAAAZP9TFMXW5gnMA5GiwB0f4uzAnAnwArfuLJIzexSp4SBVxPGJX+X/hstnDljCs 7CMvqNIiQvYj8JAT0puDWuLIiss/pTxcJRQqnzmh4ihpI12erns+boTUAG89xjow2QfBpwfnnz4 /w3/PTcyBZxmVV3kCAQi48Achz3VjMo9fw2RruGIMDAMZF9Og/2QgskUVI6apyvhaRlDg8TVbuq JA4J53Hiusk8x3lDOMpl5+XM28b/NdZNIv2hgdEkH2OT+/T+72j5OO3dlpDYaHsAwVOLD0+6lIC eXm25SLRiqkkTnCuoLRMsGImQixA== X-Received: by 2002:a05:600c:820e:b0:490:d354:d151 with SMTP id 5b1f17b1804b1-49242571659mr136364615e9.18.1782042636501; Sun, 21 Jun 2026 04:50:36 -0700 (PDT) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4923fd33dafsm238709455e9.8.2026.06.21.04.50.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Jun 2026 04:50:35 -0700 (PDT) Message-ID: <9473f052-ab79-4e2c-897f-1f255873de06@gmail.com> Date: Sun, 21 Jun 2026 12:50:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] gdb/aarch64: Add support for FEAT_S1POE POR_EL0 register To: srinath.parvathaneni@arm.com, gdb-patches@sourceware.org Cc: guinevere@redhat.com, thiago.bauermann@linaro.org References: <20260617170003.1351479-1-srinath.parvathaneni@arm.com> Content-Language: en-US From: Luis In-Reply-To: <20260617170003.1351479-1-srinath.parvathaneni@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 On Wed, Jun 17, 2026 at 05:00:03PM +0000, srinath.parvathaneni@arm.com wrote: > From: Srinath Parvathaneni > > Hi, > > FEAT_S1POE introduces the POR_EL0 register. This patch adds > support for POR_EL0 in both native GDB and gdbserver using > NT_ARM_POE and HWCAP2_POE detection. Hi Srinath, Thanks for the patch. A few comments below (some might overlap with what Ezra and Matthieu already raised). > +/* Feature check for Permission Overlay Extension. */ Nit: FEAT_S1POE stands for Stage 1 Permission Overlay Enhancement, not Extension. Please fix the comment. > +#ifndef HWCAP2_POE > +#define AARCH64_HWCAP2_POE (1ULL << 63) > +#endif The #ifndef guard checks HWCAP2_POE but the macro being defined is AARCH64_HWCAP2_POE. If a system header has already provided HWCAP2_POE, AARCH64_HWCAP2_POE will silently remain undefined. #ifndef AARCH64_HWCAP2_POE #define AARCH64_HWCAP2_POE (1ULL << 63) #endif > +#ifndef AARCH64_SEGV_PKUERR > +#define AARCH64_SEGV_PKUERR 4 /* Protection overlay violation. */ > +#endif Make it more informative: /* Data or instruction abort caused by a POE violation. */ > +/* The POE regset consists of 1 64-bit register. */ > +#define AARCH64_LINUX_SIZEOF_POE_REGSET (8) Drop the parenthesis. > +#endif /* GDB_ARCH_AARCH64_POE_H */ Once the file is renamed the guard should become GDB_ARCH_AARCH64_POE_LINUX_H. > diff --git a/gdb/nat/aarch64-poe.h b/gdb/nat/aarch64-poe.h > new file mode 100644 > @@ -0,0 +1,49 @@ > +#ifndef HWCAP2_POE > +#define HWCAP2_POE (1ULL << 63) > +#endif defines this on kernels >= 6.9. Is this fallback needed, and if so, why? > +#ifndef NT_ARM_POE > +#define NT_ARM_POE 0x40f > +#endif Same question. This is in on recent kernels. > +struct user_poe > +{ > + uint64_t por_el0; > +}; Why a struct for a single scalar? A bare uint64_t works fine here. > diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h > @@ -208,6 +208,16 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base > return gcs_linux_reg_base != -1; > } > > + /* First POE register. This is -1 if no POE feature is available. */ > + int poe_regnum = -1; "First POE register" implies there may be more than one. Since there is exactly one, please use: /* Index of the POE register. This is -1 if POE is not supported. */ Upstream master now has comments for every other boolean in this struct. Please add a comment as well. > diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h > @@ -35,6 +35,7 @@ struct aarch64_features > bool pauth = false; > bool mte = false; > bool fpmr = false; > + bool poe = false; Missing comment. Please add: /* Whether the Permission Overlay Extension (FEAT_S1POE) is supported. */ > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > +/* Fill GDB's register array with the POE register value from the current > + thread. */ > + > +static void > +fetch_por_el0_from_thread (regcache *regcache) The convention for fetch functions in this file is to name them after the feature or register group, not the specific register: fetch_fpmr_from_thread fetch_gcsregs_from_thread fetch_tlsregs_from_thread Please rename to fetch_poereg_from_thread. > +{ > + aarch64_gdbarch_tdep *tdep > + = gdbarch_tdep (regcache->arch ()); > + > + gdb_assert (tdep->poe_regnum != -1); Please use: gdb_assert (tdep->has_poe ()); > + user_poe user_poe; > + iovec iovec; Letś not use a variable with the same name as the type. > + int tid = get_ptrace_pid (regcache->ptid ()); get_ptrace_pid here looks correct, as we have the regcache information. > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > +/* Convert a POR_EL0 Perm overlay permission encoding into rwx-style string. > + For example: > + 0b0011 -> "r-x" (3) > + 0b0101 -> "rw-" (5) > + 0b0111 -> "rwx" (7) > + 0b0000 -> "---" (0) > + Reserved encodings (0b1xxx) are returned as "???". */ > + > +static const char* > +aarch64_perm_overlay_decode (unsigned int perm) Missing space before *. > +/* For POE SEGSEGV, show additional information. */ Typo: SEGSEGV should be SIGSEGV. > + else if (si_code == AARCH64_SEGV_PKUERR && si_errno == 0) > + meaning = _("Protection overlay violation"); The si_errno == 0 condition is not meaningful for SEGV_PKUERR. si_errno is not used to qualify this signal code, is it? If so... else if (si_code == AARCH64_SEGV_PKUERR) meaning = _("Protection overlay violation"); > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > + if (features.poe) > + regnum = create_feature_aarch64_poe (tdesc.get (), regnum); Is identation off here? > diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc > +static void > +aarch64_store_por_el0_regset (struct regcache *regcache, const void *buf) > +{ > + const user_poe *regset = (const user_poe *) buf; > + int poe_regnum = find_regno (regcache->tdesc, "por_el0"); Single space before =. > + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_POE, > + 0, OPTIONAL_REGS, > + nullptr, aarch64_store_por_el0_regset }, Document/Add comment that we don´t support writing for now. Also document/add comment stating we lack core file support as well. Reviewed-By: Luis Machado