From nobody Tue Nov 26 15:34:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707188861; cv=none; d=zohomail.com; s=zohoarc; b=LXoBf0ptPbfUpgIexNpVgo+A1THJ32JBKi4R4AV6YxW4OkkNpELkYENsMlAAGLPW4+FDCS08PbdjjGRSjkj/H/KggeD2PiIeVk8PuCgDwNPtwUpdJVzh6y3ReGFODMLrs7u28Wv6EOhPFQ04Z3QTpDAJsDKo3WdzVmVDUuWqYJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707188861; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E6bw+vo5JatBKfHw3dI0irsDkK5JENn8mMxMtSK3thY=; b=jBLkLAQ+DiNtT6NH3jG8DOKWk0iu/ZYq2cZEDGQAFQ1Luxs7Wq9tKcglRzIm2ww09C/NOPS59d3RDf1jZDYUa+MnSfK3O8/RTfojvBNhZDotlclglsyIqToId0McLeW2CQXexPfR2e4KdFJeq4kAPbc9WN1lAQx/6bTF01uz5yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17071888618358.800491695705432; Mon, 5 Feb 2024 19:07:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXBmT-0006tJ-8t; Mon, 05 Feb 2024 22:05:53 -0500 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 1rXBmR-0006sW-Kt for qemu-devel@nongnu.org; Mon, 05 Feb 2024 22:05:51 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXBmC-0003Ci-Tf for qemu-devel@nongnu.org; Mon, 05 Feb 2024 22:05:51 -0500 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e04fd5e05aso106874b3a.0 for ; Mon, 05 Feb 2024 19:05:36 -0800 (PST) Received: from stoup.. ([43.252.112.200]) by smtp.gmail.com with ESMTPSA id r14-20020a62e40e000000b006e025030700sm627478pfh.190.2024.02.05.19.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707188735; x=1707793535; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E6bw+vo5JatBKfHw3dI0irsDkK5JENn8mMxMtSK3thY=; b=ztsMqqUa5uQOI/phLa1S4y1yJ8B/sxXDQ0fwHY+8IfAtNMyeLVMjGpEW7leDPCCM7i iFRz5K7V49sNzyI4DY8tw5ED1zdsB/6pNefdEN1SGu7WwkgTl2cYK9ZRCiVC1kf7wrZx vIk2p0x6BkoXaZN0mXGX1I+1cA5qfolptwl5jZ8PnsKPw9KmJcOw5+xy1bzdx0gDmMHx l0Kbx+bqcLkuNhX0veSJod7Dk4g2tKA+Y7/Y+xRVMcdncrYohZ2+bD+IFu0X0+9Z9aiC 22PgSyXipKjCdpkKkscSa9bkKRouAHqC2ENeMGAw9GkDA6Wc1Ykp19oWrDLj38I3xoIi duKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707188735; x=1707793535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E6bw+vo5JatBKfHw3dI0irsDkK5JENn8mMxMtSK3thY=; b=vPpPYY0gfpQG1xQncAWmGU+IlQnf6oTR1WY535OWms/z8OczvlPWqARPZs4p7X0wa9 irhDHLJmrzHUJiIvXT3eWJ77N7Tsz9+qvXD81OXvbQMf1IGpb6D8pmXD93R7/rDcybhO YSjsLl/0bfPdeWv3DIXPp+yKTLBOcxNR6gqPzoKHt9Oxo2KEIgGOkbHq+b/Jh3Gt1IVT W/Kx23I4ZcDfXcUaBo/WqP7x/SqTJXZQGyrc8CtLcoqWz+NhNGIIDqyXLkJIRmTojF0O iahDBJPp2uaAtVjetjJOg7JS+OGhkltpDRr4E0nFsBCmb3LY3lT9CTBL4Gp8j1PjhECW YaLg== X-Gm-Message-State: AOJu0Yyv8PyUaVhowoH1g23q3bImnUqYhEgHrhTqinKOdI3o2l+mGttx CnD/m9ngaYqVF8iuUDWPwThEckgu/k9DkgOoiWvUz81ic4hdOB4dHHWWIXbYMBeGVu7WwKfjwk5 AQJ4= X-Google-Smtp-Source: AGHT+IEgwbuGzWpy/YdZa8EljsI/4VDjTE9Yc8g3HOugDVw6I6xUAeU8bhJglrLA/0a0OI8Ope2j3g== X-Received: by 2002:a62:e405:0:b0:6da:bcea:4cd4 with SMTP id r5-20020a62e405000000b006dabcea4cd4mr2011390pfh.16.1707188735655; Mon, 05 Feb 2024 19:05:35 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV0nu4hV+42c5XWycC7UIfEGNXkD17R62Y7zKc7Qm/ASx7oHtrMviJt830t6SVB19nHbpf6SJiZvUcpqxMiH2SnX0a54qyuQ4rd From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, gustavo.romero@linaro.org Subject: [PATCH v2 1/6] linux-user/aarch64: Extend PR_SET_TAGGED_ADDR_CTRL for FEAT_MTE3 Date: Tue, 6 Feb 2024 13:05:22 +1000 Message-Id: <20240206030527.169147-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206030527.169147-1-richard.henderson@linaro.org> References: <20240206030527.169147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707188864019100001 Content-Type: text/plain; charset="utf-8" When MTE3 is supported, the kernel maps PR_MTE_TCF_ASYNC | PR_MTE_TCF_SYNC to MTE_CTRL_TCF_ASYMM and from there to SCTLR_EL1.TCF0 =3D 3 There is no error reported for setting ASYNC | SYNC when MTE3 is not supported; the kernel simply selects the ASYNC behavior of TCF0=3D2. Signed-off-by: Richard Henderson Reviewed-by: Gustavo Romero --- linux-user/aarch64/target_prctl.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_= prctl.h index 5067e7d731..49bd16aa95 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -173,21 +173,22 @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArch= State *env, abi_long arg2) env->tagged_addr_enable =3D arg2 & PR_TAGGED_ADDR_ENABLE; =20 if (cpu_isar_feature(aa64_mte, cpu)) { - switch (arg2 & PR_MTE_TCF_MASK) { - case PR_MTE_TCF_NONE: - case PR_MTE_TCF_SYNC: - case PR_MTE_TCF_ASYNC: - break; - default: - return -EINVAL; - } - /* * Write PR_MTE_TCF to SCTLR_EL1[TCF0]. - * Note that the syscall values are consistent with hw. + * Note that SYNC | ASYNC -> ASYMM with FEAT_MTE3, + * otherwise mte_update_sctlr_user chooses ASYNC. */ - env->cp15.sctlr_el[1] =3D - deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHI= FT); + unsigned tcf =3D 0; + if (arg2 & PR_MTE_TCF_ASYNC) { + if ((arg2 & PR_MTE_TCF_SYNC) && cpu_isar_feature(aa64_mte3, cp= u)) { + tcf =3D 3; + } else { + tcf =3D 2; + } + } else if (arg2 & PR_MTE_TCF_SYNC) { + tcf =3D 1; + } + env->cp15.sctlr_el[1] =3D deposit64(env->cp15.sctlr_el[1], 38, 2, = tcf); =20 /* * Write PR_MTE_TAG to GCR_EL1[Exclude]. --=20 2.34.1