From patchwork Wed Feb 21 08:20:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774502 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp308466wrw; Wed, 21 Feb 2024 07:28:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXfsFfyO5ne9MIToU5OT2proVaUNiX7pO5F1IzQ8WJAhTc2YQnH5qzfOy9/p/B/HEFzXg8sY1D7ICyvPNTtKOCF X-Google-Smtp-Source: AGHT+IFhaYl0DVXgKc+ZxL1ZE8nQnfmJZfmfLFMPt8JbEtxU+kAZdeKma62jf/9kltRN4PT29a3l X-Received: by 2002:a05:620a:559a:b0:785:d776:2202 with SMTP id vq26-20020a05620a559a00b00785d7762202mr20543191qkn.77.1708529289739; Wed, 21 Feb 2024 07:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708529289; cv=none; d=google.com; s=arc-20160816; b=b/+sh3X/fph3uOyfLcaDwxXwbiyOhS8r2QOLlpZkPajvyYi7ri0kPAcEZXTWbzbNjr 55em8rX6m7o+Imd6zyD5E3AmPh2pccV+rPRYnaBQT8ihdSaYEC8HctziqTnPG++qlNGr Uyfz3N4sxK1sej+CRoWV7600Z6ML55xpyPencyG+L69dRfCmlwe020y8VaZRGIKdqJe6 +TabymHwcd4RJPlVnNRPnjR5hRbxBxGV6BkZLbA7hZTLM3wIOFLoo3YmR1UuDsCRMBpe luen5gyJW01E+on8rXuKbhZI5kW1zMqF3uE7vUh/c03qS+2sFOw51duP5ELUlhwaKXbA 1G0w== 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=GAZG1miXgWSwbptKmsQvMkHxdo8O9bWPg+qBolHy+V0=; fh=Mfp+ztHun75jr+I+HJ3gu9b5WkI1iGjp+6yuuqdwzx0=; b=ySEHPnSFONNJX8eXYflAuYBd26hgy7D4jydV17We1uyzH1Ohca2xhMJDqU/58z7OHE mgMCtBBiwPIxeQHuhaBvLYxP6rPfEnRToTTl/O9AcSAr33u8JBonhmaN7+G+vOrSTgM8 Y+1m1dleW9rNyjQvQHVdvnQfhzVp19pcmeiZSPtHLc8CGS7p/8cmYaIoTJU8zEftx27A Ft4qpxCYLYw8RO+w4BZi3k0N1t4aO48X8geDU+PqLqgvlpRzkqpaYTw6JMuiNJDqPPgD DOxZK2QUrAFI3Af2TZxTQSdDaKGtXNWGl+3rakBhZEQIkda05wYPqNCPBTmzspcZV+dz tGeQ==; 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 vu28-20020a05620a561c00b0078738465c99si10801475qkn.495.2024.02.21.07.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 07:28:09 -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 1rcoJE-0000ji-A2; Wed, 21 Feb 2024 10:14:56 -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 1rchu5-0000w1-2o; Wed, 21 Feb 2024 03:24:33 -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 1rchu3-0002fb-5Z; Wed, 21 Feb 2024 03:24:32 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 9ED754F3E6; Wed, 21 Feb 2024 11:21:22 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 69C8C860C5; Wed, 21 Feb 2024 11:21:01 +0300 (MSK) Received: (nullmailer pid 2142109 invoked by uid 1000); Wed, 21 Feb 2024 08:20:58 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Gustavo Romero , Peter Maydell , Michael Tokarev Subject: [Stable-8.2.2 40/60] linux-user/aarch64: Choose SYNC as the preferred MTE mode Date: Wed, 21 Feb 2024 11:20:28 +0300 Message-Id: <20240221082058.2141850-40-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, 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+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 5067e7d731..aa8e203c15 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -173,21 +173,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].