From patchwork Sat Nov 5 09:44:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Vanek X-Patchwork-Id: 59991 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D7163857BBB for ; Sat, 5 Nov 2022 09:45:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp00.avonet.cz (smtp00.avonet.cz [217.112.162.55]) by sourceware.org (Postfix) with ESMTP id 6D5EB3858418 for ; Sat, 5 Nov 2022 09:45:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D5EB3858418 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=fbl.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=fbl.cz Received: from ktus.lan (217-115-245-101.cust.avonet.cz [217.115.245.101]) by smtp00.avonet.cz (Postfix) with ESMTP id 4N4CK96zz1z1xqS; Sat, 5 Nov 2022 10:45:17 +0100 (CET) From: Tomas Vanek To: gdb-patches@sourceware.org Subject: [RFC PATCH 1/5] gdb/arm: Introduce control_s and control_ns registers Date: Sat, 5 Nov 2022 10:44:32 +0100 Message-Id: <1667641476-31602-1-git-send-email-vanekt@fbl.cz> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_FAIL, SPF_HELO_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomas Vanek Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The M-profile security extension registers will be used for stack selection in FNC_RETURN and return from secure to non-secure state. The presence of the registers is optional. If one or both are missing the security extension profile is accepted. The code using the registers must check m_profile_control_[n]?s_regnum for -1. Signed-off-by: Tomas Vanek --- gdb/arm-tdep.c | 20 ++++++++++++++++++++ gdb/arm-tdep.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 3105543..564ee43 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9996,6 +9996,8 @@ enum arm_vfp_cprc_base_type int m_profile_psp_ns_regnum = -1; int m_profile_msp_s_regnum = -1; int m_profile_psp_s_regnum = -1; + int m_profile_control_s_regnum = -1; + int m_profile_control_ns_regnum = -1; int tls_regnum = 0; /* If we have an object to base this architecture on, try to determine @@ -10473,6 +10475,22 @@ enum arm_vfp_cprc_base_type } m_profile_psp_s_regnum = register_count++; + /* Regard the control_s and control_ns registers optional, + * accept the security extension feature even without them */ + valid_p = tdesc_numbered_register (feature, tdesc_data.get (), + register_count, "control_s"); + if (!valid_p) + warning (_("M-profile secext feature is missing required register control_s.")); + else + m_profile_control_s_regnum = register_count++; + + valid_p = tdesc_numbered_register (feature, tdesc_data.get (), + register_count, "control_ns"); + if (!valid_p) + warning (_("M-profile secext feature is missing required register control_ns.")); + else + m_profile_control_ns_regnum = register_count++; + have_sec_ext = true; } @@ -10553,6 +10571,8 @@ enum arm_vfp_cprc_base_type tdep->m_profile_psp_ns_regnum = m_profile_psp_ns_regnum; tdep->m_profile_msp_s_regnum = m_profile_msp_s_regnum; tdep->m_profile_psp_s_regnum = m_profile_psp_s_regnum; + tdep->m_profile_control_s_regnum = m_profile_control_s_regnum; + tdep->m_profile_control_ns_regnum = m_profile_control_ns_regnum; } arm_register_g_packet_guesses (gdbarch); diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h index bcd7e08..11670e9 100644 --- a/gdb/arm-tdep.h +++ b/gdb/arm-tdep.h @@ -133,6 +133,8 @@ struct arm_gdbarch_tdep : gdbarch_tdep_base int m_profile_psp_ns_regnum = ARM_SP_REGNUM; /* M-profile PSP_NS register number. */ int m_profile_msp_s_regnum = ARM_SP_REGNUM; /* M-profile MSP_S register number. */ int m_profile_psp_s_regnum = ARM_SP_REGNUM; /* M-profile PSP_S register number. */ + int m_profile_control_s_regnum = -1; /* M-profile CONTROL_S register number. */ + int m_profile_control_ns_regnum = -1; /* M-profile CONTROL_NS register number. */ int tls_regnum = 0; /* Number of the tpidruro register. */