From patchwork Tue Mar 28 21:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 667873 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp18052wrt; Tue, 28 Mar 2023 14:25:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YFqmqvUdHN0b6flsjcJOffzgTF13ZL7wt4ciwi5Xum8/wiVpgzQ4AgsepS6BXcjIyZBYCj X-Received: by 2002:a05:6214:2409:b0:570:ccb9:a4d0 with SMTP id fv9-20020a056214240900b00570ccb9a4d0mr34617302qvb.16.1680038753777; Tue, 28 Mar 2023 14:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680038753; cv=none; d=google.com; s=arc-20160816; b=i3tMSvDUM8YZMytk/KzxhLZDFANqczRF2Y8KgMHmEqySMBzpAaiFypBbC9ZobU4kkm lqnC4fVbulB6RK/VcDx3lj0YRfBp9Ka8tBVERRcLEuHhKkwCGpGX5xmoZU28UVT5bIuz 9dr3/8PHBhLlHDfIf/f/drhUmMnz18yp5j9kVxxVobGYHb92THto85OyqWw96JXmxm7p BQHJ/BU2DYOzkGJWdLCmNTbpsBWRjmmRiRMBAj6Umd7z1b4W5MSrqFu5bzNn/vTtwPPa Pf/8/do6kB6Yy53OHnC3FB191f9delfnSyA3frtZkUQbvdVBHIvK5givvPYLpY/0FZgt gPvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=E3L0YvTAg6g+pvqy2IDkXobfjbifgoR5d+5WWMVGSjA=; b=cbnXy9YLZ04OQjuNb3kQiVvwxJSqKcjE+ZTsTPAOS5zOYfvbUr6wAAw7QsPf9aUcs1 YN1B78L2TEjNv17brVZskkgtE8uQFdOYCGGNZnUZVnyuqaes2nhCnhXLRNNI2M470odo JF2zVmqSTH5vpTehwbDVgtnONxHgjc6Kaj8fqmvlmXcbQWBv61YY30uiPE+ii+zhEMeK lCzP3ejxtS9yF0Rn+XLc5kSzYRBr1o38vlWkro34FlKyjYamfghrtmEOFDVULdSVfXmj ctrBZ/SWn+UxWtEZz4+/ELqarUnOBcTKk073Is4uvkx/FlGDbFbgRsSMaTysg8zUpHNZ McDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bv49Li2i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jo26-20020a056214501a00b005dda9d02286si9993084qvb.603.2023.03.28.14.25.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Mar 2023 14:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bv49Li2i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phGom-0007br-Kt; Tue, 28 Mar 2023 17:25:24 -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 1phGok-0007bH-M4 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 17:25:22 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phGoi-0007LD-Pj for qemu-devel@nongnu.org; Tue, 28 Mar 2023 17:25:22 -0400 Received: by mail-wm1-x334.google.com with SMTP id v20-20020a05600c471400b003ed8826253aso1391198wmo.0 for ; Tue, 28 Mar 2023 14:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680038719; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=E3L0YvTAg6g+pvqy2IDkXobfjbifgoR5d+5WWMVGSjA=; b=bv49Li2ipHy1cMxkX6WHvslBbEPnJ3y9dwwdiLKSpPyJJTgL9ZubdYWhuv8dJISqNS 3etfsZHTL2Y2BJYQlPF8PHVabyDWQBH0OWesmep62cm6r9FmjSa/G6IpRlwBMc7ToXE1 QxHTyFSB0TtxsVuxTr3RdQxeZ9wwA+CueZRUdvFn/qWW71Tb0QMArp4pMK4/u7Gc+X5t ajqaY3goblqz/v5SkagIf8XvOMigcBmAKQdSF+UclT3z0ivieaAJ2TT/TTD5yaZVLAeL n6y38l+ZiYGBSgGgp8B790ehV07C/IAVyyUeT9xSvUiiiChIBVIikKouMVC43ZizKgB5 kwvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680038719; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E3L0YvTAg6g+pvqy2IDkXobfjbifgoR5d+5WWMVGSjA=; b=JIr8d1/mKvQyot5yp/rxKYE/MtX9gX58v5uh0koJMnbEOZ/xRRI3bNekt47MAXvMgN 2q+/3aEKx1kvJnjwdjytdfl1wbydbiCE20LenaGTGCpYMlv24aIOBZOfqi4DmeFD6jXv QxckyTA5+QJMKD2z8jjjUzckl0WqbEim8QN2tVMtG+I2bQvASi7x2QK8civYtJp0B127 MQfnLcpf+CedjkxyHUjwhaeXmWRaXnI4bLtErwgX2X1ithO8bTXMj3/w1VzlkweHUuqQ WHESdFcMXMtWz4YN7lHreyaoJlUJZzLGhu/sxX0kDo4msWUd3r0kSE344J8nudYS92H/ nepA== X-Gm-Message-State: AO0yUKVM0s7WL9qdAt3x7gCZ+7xkHgmbtFppSQB0GSqNEwYKAyaGQVO5 WMhfAi22e5Ac9flWF1UmGdz9CsASX8H7wFGCqDY= X-Received: by 2002:a05:600c:2312:b0:3ee:b3bf:5f7c with SMTP id 18-20020a05600c231200b003eeb3bf5f7cmr13420456wmo.23.1680038719144; Tue, 28 Mar 2023 14:25:19 -0700 (PDT) Received: from localhost.localdomain ([176.187.210.212]) by smtp.gmail.com with ESMTPSA id m1-20020a05600c4f4100b003ee1e07a14asm13756569wmq.45.2023.03.28.14.25.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Mar 2023 14:25:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: qemu-arm@nongnu.org, Peter Maydell , Claudio Fontana , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-8.0 v3] target/arm: Fix non-TCG build failure by inlining pauth_ptr_mask() Date: Tue, 28 Mar 2023 23:25:16 +0200 Message-Id: <20230328212516.29592-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org aarch64_gdb_get_pauth_reg() -- although disabled since commit 5787d17a42 ("target/arm: Don't advertise aarch64-pauth.xml to gdb") is still compiled in. It calls pauth_ptr_mask() which is located in target/arm/tcg/pauth_helper.c, a TCG specific helper. To avoid a linking error when TCG is not enabled: Undefined symbols for architecture arm64: "_pauth_ptr_mask", referenced from: _aarch64_gdb_get_pauth_reg in target_arm_gdbstub64.c.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) - Inline pauth_ptr_mask() in aarch64_gdb_get_pauth_reg() (this is the single user), - Rename pauth_ptr_mask_internal() as pauth_ptr_mask() and inline it in "internals.h", Fixes: e995d5cce4 ("target/arm: Implement gdbstub pauth extension") Suggested-by: Richard Henderson Reviewed-by: Fabiano Rosas Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- Supersedes: <20230328133054.6553-1-philmd@linaro.org> Since v2: - Rebased (patch #1 merged) - Addressed rth's comments - Added R-b tags --- target/arm/internals.h | 16 +++++++--------- target/arm/gdbstub64.c | 7 +++++-- target/arm/tcg/pauth_helper.c | 18 +----------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 673519a24a..71f4c6d8a2 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1389,15 +1389,13 @@ int exception_target_el(CPUARMState *env); bool arm_singlestep_active(CPUARMState *env); bool arm_generate_debug_exceptions(CPUARMState *env); -/** - * pauth_ptr_mask: - * @env: cpu context - * @ptr: selects between TTBR0 and TTBR1 - * @data: selects between TBI and TBID - * - * Return a mask of the bits of @ptr that contain the authentication code. - */ -uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data); +static inline uint64_t pauth_ptr_mask(ARMVAParameters param) +{ + int bot_pac_bit = 64 - param.tsz; + int top_pac_bit = 64 - 8 * param.tbi; + + return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit); +} /* Add the cpreg definitions for debug related system registers */ void define_debug_regs(ARMCPU *cpu); diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index ec1e07f139..c1f7e8c934 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -230,8 +230,11 @@ int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg) { bool is_data = !(reg & 1); bool is_high = reg & 2; - uint64_t mask = pauth_ptr_mask(env, -is_high, is_data); - return gdb_get_reg64(buf, mask); + ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); + ARMVAParameters param; + + param = aa64_va_parameters(env, -is_high, mmu_idx, is_data); + return gdb_get_reg64(buf, pauth_ptr_mask(param)); } default: return 0; diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 20f347332d..de067fa716 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -339,17 +339,9 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, return pac | ext | ptr; } -static uint64_t pauth_ptr_mask_internal(ARMVAParameters param) -{ - int bot_pac_bit = 64 - param.tsz; - int top_pac_bit = 64 - 8 * param.tbi; - - return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit); -} - static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) { - uint64_t mask = pauth_ptr_mask_internal(param); + uint64_t mask = pauth_ptr_mask(param); /* Note that bit 55 is used whether or not the regime has 2 ranges. */ if (extract64(ptr, 55, 1)) { @@ -359,14 +351,6 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) } } -uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data) -{ - ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); - ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); - - return pauth_ptr_mask_internal(param); -} - static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data, int keynumber) {