From patchwork Wed Feb 21 21:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774537 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469510wrw; Wed, 21 Feb 2024 13:49:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXEtPIRldOexnhUS/tMHr97hEU7yMNUGF+LU92IkpM3KlZjNskFlOJTvVVDFQ4w2HENCBF+b+r6fhMm8PsilY41 X-Google-Smtp-Source: AGHT+IHF4ywdvKaehD6t/Ha2h33oHTqjE5ZuVYayuaDeMGdRbXDTEdmqS+mmAy0ihqS9vx1Ge3E+ X-Received: by 2002:a5d:47a9:0:b0:33d:3a06:acbc with SMTP id 9-20020a5d47a9000000b0033d3a06acbcmr9486073wrb.70.1708552169693; Wed, 21 Feb 2024 13:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552169; cv=none; d=google.com; s=arc-20160816; b=ZLcIGkSwR0BiYkkecNmB+x1gBAJ4g39muJkJnszxCEVsy7B0cYni+lVdeMDr3gGJzR NWGeGdIB19Vr84tGCKjGfwPoMz0gcOFrqDNwVATKkITT4MnYF0bllhRLdFXwsuxZk6du lXr8YeN01rSgbFniczUFDsaGmMrD/Dtp27AsQUB9vjzLJRaozV/VEcTWYgWIvOKK07Ci AG60RC1TP+xgACfiVGUl2R4cVbG9ao/hRxSW+Mk0L3MjKx6fJc1tfAX5FgxChC6rJIY7 mmBWv3G8VYYX0kJNw+BaqbAFyeQy+s621BWwFzvaNT8QrgbgIRPuGSwP2P8CHZhwIkjw DHFw== 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:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5XO64HjlvT8wYk/rChPRMvR1OdumJgiebOLrnFZT6jM=; fh=Mfp+ztHun75jr+I+HJ3gu9b5WkI1iGjp+6yuuqdwzx0=; b=qNLOJELscIBG4CZy6vPzI4Fa3spEzC+BXPMP3v/rj+bhBv0RTHqOoGr0b4MoZI0m6Y tDmSNlYFGoYOXvnwMaZdIagm6DUbLgPXVev+jLP1ccdHxqaofTxhTY5G/GKFW5p+BWj3 ELb3eOdbyPi7zIzneFGTIkIB2BU6psi9I82/3/xXO1Btx4CSyLGAB6wVQOqwlUeMfIDk peBFUUtWv1qQ35ehgnV2/tki8wM4v1A0XHNfjse5H693v4XpPBhBSstJLCT2s+uFgrf5 HhKZMif2C+VdRedSzlWhVzLlO6wHzmkiVrBPHavhS6fn62Azaa5+nRfutQN3fEx2PRy+ rw3w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r11-20020adff10b000000b0033cf938ad18si6923961wro.594.2024.02.21.13.49.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:49:29 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcuST-0005PD-Dd; Wed, 21 Feb 2024 16:48: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 1rcuSQ-0005Ad-C1; Wed, 21 Feb 2024 16:48:50 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcuSL-0007XU-Cu; Wed, 21 Feb 2024 16:48:50 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 42EBE4F86F; Thu, 22 Feb 2024 00:47:47 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E0545869F0; Thu, 22 Feb 2024 00:47:24 +0300 (MSK) Received: (nullmailer pid 2339880 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Gustavo Romero , Peter Maydell , Michael Tokarev Subject: [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode Date: Thu, 22 Feb 2024 00:47:02 +0300 Message-Id: <20240221214723.2339742-19-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson The API does not generate an error for setting ASYNC | SYNC; that merely constrains the selection vs the per-cpu default. For qemu linux-user, choose SYNC as the default. Cc: qemu-stable@nongnu.org Reported-by: Gustavo Romero Signed-off-by: Richard Henderson Tested-by: Gustavo Romero Message-id: 20240207025210.8837-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 681dfc0d552963d4d598350d26097a692900b408) Signed-off-by: Michael Tokarev diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h index 907c314146..d9f6648e27 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -171,21 +171,26 @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2) env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE; 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. + * + * The kernel has a per-cpu configuration for the sysadmin, + * /sys/devices/system/cpu/cpu/mte_tcf_preferred, + * which qemu does not implement. + * + * Because there is no performance difference between the modes, and + * because SYNC is most useful for debugging MTE errors, choose SYNC + * as the preferred mode. With this preference, and the way the API + * uses only two bits, there is no way for the program to select + * ASYMM mode. */ - env->cp15.sctlr_el[1] = - deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT); + unsigned tcf = 0; + if (arg2 & PR_MTE_TCF_SYNC) { + tcf = 1; + } else if (arg2 & PR_MTE_TCF_ASYNC) { + tcf = 2; + } + env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf); /* * Write PR_MTE_TAG to GCR_EL1[Exclude].