From patchwork Fri Jul 19 01:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813362 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp544947wro; Thu, 18 Jul 2024 18:08:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGqr3xrxTxnS+UMLuynFQFqITGXL56fpxSnNZZC6jhQL6vUtypeag1l6elw0Dd+vbTOgfBM9K8h+vXo+oBydIW X-Google-Smtp-Source: AGHT+IFsmj0kQjE8pIx8LoNnHT/tUOj9Ap9PFdo0uy9+0rjE1GcOOlNcWhB+hZO3zc0hseJ2mkOK X-Received: by 2002:a05:6102:3e08:b0:48f:95c4:d534 with SMTP id ada2fe7eead31-4915975ecdbmr8165309137.3.1721351322283; Thu, 18 Jul 2024 18:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351322; cv=none; d=google.com; s=arc-20160816; b=nbI+onMIM34SnIs/dBWDo9xri79PbNAe5Gg0x+lrXrAxnssEpm9FJGNk6D1Z2E5mCm 9PxWt2iJmPeHH98/mpc043Gidzt3Xfw4ZxMC+lDhMi49Hxyly9rrzgvw8sn+M91jQ7OO oLG+hhebdDE0OVI2mYDSBvLyb8L/wVYTzi8jKBbg/updyEAeaGwDpeONHer56aBIxHR2 vcyTiSB0P6OT7n4WKGNIxMJriwgORKtLsV6jkl2FA49lAfkJT0vELDpbobqGEULbl2q+ yIJszBf1QGpqRgAfL6tPqTLzmaN/oNnKwE2m0a6sO4oReDcJyvnF5mJsBPFiOrDnERY7 X6Dw== 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:dkim-signature; bh=afR5Mh7AuJ+l97gjVcHTy2tuYfmOnsauTdcz7zi2zaI=; fh=qjFy40K+ZQaomz0djLvfgk0/gq57yB0/W8d5nzdAVZA=; b=WEgbok6RBAAuFEBxApICtIDVxZU3U16hHoEJH0CVea/g2SP6Wl4aTLHc8o9Mfvb+rg 7u6uDDiDpiewZ1Ug45Rd/5zauybA9bVUwqkY6Wy2fLyxl665ydp+3g4Gpw6RXr/n+5// omBGRY4LAEDluZ0gI/yUJ1Rg2H0B01jK9/8Tf/IjHLFGaXtFds+uGGhX5zTiR+ouG9Hb 1eQl7tvU1tl3pMu/aIiXU9PdT6I+fKaP8zoKB0iU8cMvZ1jyWducO8/9n1dXjY5bRB73 Ry08EehhbAzdqGF96yqLnDPcnP6bHqjZRe8+1j3Fu9dxQ4/PwiGepR/XRPq9zWhcnG+A G2ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G3tdhOtN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=fail header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac9b716csi4574176d6.334.2024.07.18.18.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:08:42 -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=fail header.i=@linaro.org header.s=google header.b=G3tdhOtN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=fail header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc66-0003Um-AL; Thu, 18 Jul 2024 21:07:47 -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 1sUc5i-0002oV-8f for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:23 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5f-0000iO-Pl for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:21 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70b4267ccfcso337600b3a.3 for ; Thu, 18 Jul 2024 18:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351238; x=1721956038; 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=afR5Mh7AuJ+l97gjVcHTy2tuYfmOnsauTdcz7zi2zaI=; b=G3tdhOtNah+qVrGYaT8h6SC2Kj/UFyjRvVJbmESmHs4vtAq0uXh1OKPBUw3my3tKPn gJI6OP4KBrXxcUeqdBVnyzq0LAVE3UQ0EpYf/xdfohB8EmAKGkoBWEzMYVg1nlwm1SJ4 MRsP43a94jhFSP5PQztMlIG17RrWAsJMMRKiwHhlDwl3BfqritYC7Uwtg1OCqU9VPVqD iMDEvL1RocXmdEuk3EEtUOkVC84/nAqChzYc48AeaS4mC2+goDPlWtuYQxnOtp1tnT+X DfJZ9E5s12hc810FcFP7umTaBn8dXhPPN0Kos0H74uSx2OB9MMU8uUyRnvd4pjb1zZ2p rGvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351238; x=1721956038; 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=afR5Mh7AuJ+l97gjVcHTy2tuYfmOnsauTdcz7zi2zaI=; b=rFHOqQZDW7sWqmnnQ8ROJ07dTbv/Mqjp+PJaoeoJuQWbh+5jzQD1XQXHqXeYlA8nK1 FWdt2KbuTQXazAezT6GY+ZT14x1BFjipTV08KEAFpadFvhXKm5Kzuzg5Lw3NYnW4Vk6d MHKZv3OdjwE5IikF2gZ4pJP4LXSo6hgi9NfvzQNhO7UvvrsMgI0diXsZIiLgY5N4ZuA1 RFNvaPWBmaN/0o8xlEigVVPDpOEXjZjewxCF5TFEFINx2GYa/XWrbbLzpd8ZTl1YpvyJ pmfb3ewBBW6kEXdcz3CIgLLJUmssBO46Zi9TOa46tixT88TIzgP4INHP/VKah1q7ur4f xbOg== X-Gm-Message-State: AOJu0Yw7nbAR/Cm/cDN9hbWPOPksMUbi5CqKJPbKU0lr1Iw9L8ZnJcvB ifTGXmByWTPQaQiTRYeHxAfEkcVBBFz4MTzd2s/ksgM4VE+ylEEoQVgZlW1VlD78dPhOLs1EB4G QNeX3zg== X-Received: by 2002:a05:6a21:4d8a:b0:1c3:cfc2:2b1f with SMTP id adf61e73a8af0-1c3fdd4d424mr6815533637.37.1721351237977; Thu, 18 Jul 2024 18:07:17 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Peter Maydell Subject: [PATCH v3 01/12] accel/tcg: Move {set, clear}_helper_retaddr to cpu_ldst.h Date: Fri, 19 Jul 2024 11:06:56 +1000 Message-ID: <20240719010707.1319675-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Use of these in helpers goes hand-in-hand with tlb_vaddr_to_host and other probing functions. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/user-retaddr.h | 28 ---------------------------- include/exec/cpu_ldst.h | 34 ++++++++++++++++++++++++++++++++++ accel/tcg/cpu-exec.c | 3 --- accel/tcg/user-exec.c | 1 - 4 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 accel/tcg/user-retaddr.h diff --git a/accel/tcg/user-retaddr.h b/accel/tcg/user-retaddr.h deleted file mode 100644 index e0f57e1994..0000000000 --- a/accel/tcg/user-retaddr.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef ACCEL_TCG_USER_RETADDR_H -#define ACCEL_TCG_USER_RETADDR_H - -#include "qemu/atomic.h" - -extern __thread uintptr_t helper_retaddr; - -static inline void set_helper_retaddr(uintptr_t ra) -{ - helper_retaddr = ra; - /* - * Ensure that this write is visible to the SIGSEGV handler that - * may be invoked due to a subsequent invalid memory operation. - */ - signal_barrier(); -} - -static inline void clear_helper_retaddr(void) -{ - /* - * Ensure that previous memory operations have succeeded before - * removing the data visible to the signal handler. - */ - signal_barrier(); - helper_retaddr = 0; -} - -#endif diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 71009f84f5..dac12bd8eb 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -379,4 +379,38 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, MMUAccessType access_type, int mmu_idx); #endif +/* + * For user-only, helpers that use guest to host address translation + * must protect the actual host memory access by recording 'retaddr' + * for the signal handler. This is required for a race condition in + * which another thread unmaps the page between a probe and the + * actual access. + */ +#ifdef CONFIG_USER_ONLY +extern __thread uintptr_t helper_retaddr; + +static inline void set_helper_retaddr(uintptr_t ra) +{ + helper_retaddr = ra; + /* + * Ensure that this write is visible to the SIGSEGV handler that + * may be invoked due to a subsequent invalid memory operation. + */ + signal_barrier(); +} + +static inline void clear_helper_retaddr(void) +{ + /* + * Ensure that previous memory operations have succeeded before + * removing the data visible to the signal handler. + */ + signal_barrier(); + helper_retaddr = 0; +} +#else +#define set_helper_retaddr(ra) do { } while (0) +#define clear_helper_retaddr() do { } while (0) +#endif + #endif /* CPU_LDST_H */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 9010dad073..8163295f34 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -41,9 +41,6 @@ #include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#if defined(CONFIG_USER_ONLY) -#include "user-retaddr.h" -#endif /* -icount align implementation. */ diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 80d24540ed..7ddc47b0ba 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -33,7 +33,6 @@ #include "tcg/tcg-ldst.h" #include "internal-common.h" #include "internal-target.h" -#include "user-retaddr.h" __thread uintptr_t helper_retaddr; From patchwork Fri Jul 19 01:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813366 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545088wro; Thu, 18 Jul 2024 18:09:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHfnmZ3iIyrPE34bMxxNJ7SDliwFubkEdE5CwAIpyL3GnZiPVI6+P/jWvYdDb3V9L1bTwsedU+Dh+pvIHaFusC X-Google-Smtp-Source: AGHT+IFiCu/7vksbeigFa64NSTKuCE3p4SD9gCT4b0zaYQ8RyLuyrBQH7tf3DwnYwOj92ykKN9fN X-Received: by 2002:a05:622a:13c7:b0:447:f43c:191a with SMTP id d75a77b69052e-44f969935d6mr31971001cf.21.1721351356891; Thu, 18 Jul 2024 18:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351356; cv=none; d=google.com; s=arc-20160816; b=UlFNY0skWXYk0oWz+qjAyAKwIGjSp0o3Eah9NHIhDS9kcVw7+/6KXHjfH6ApFOdU+O DBUgxOUV7Emb8KcBmcV61g1xXM/In+nQag1skMqu9AOYiWUXhR+Vnx2xaYrjRUOIBKty McEZ/L/zDBDl833WyB3Sr7+Zt5divU9CtTEAPZDSwAVIplHM8z8ET3Fm6UbHhUBzGZO9 JJW1SFbTtyPlU3BY4kuAgvQpEJ/74F0nP96X5fWUfqgH8nJHOGFAgiijng9FOxWcWJ7Q YXyK887l1wgHC6JoNL3BVxv0RsE5VfiB3peLaZNB6eEXzwOrHnFjA5kkSmHKiVSQXF7Z sDrQ== 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:dkim-signature; bh=lffTC77hfuBCBlcm53ysSfFxUjHJ9OXDuax++3VtjJ0=; fh=qjFy40K+ZQaomz0djLvfgk0/gq57yB0/W8d5nzdAVZA=; b=SM1qFtx5oSomPhI5MgjE8wm2faX8fQUowb1svqbJwFIu5v73fQYjS57uJJOS2/Va0F 5Tm5qi2ZxgS5PER7N4xsAxvA3wQGnKQ02HqW4cZTgpgK86qIV5Lo0EpPNaJE3SaHYnLF GnNwjnQra4/XIFevfWzuUgVtbXl7KkuPhELWz/tIQQDWp2H6NTcvpXJHojhDWhsERcU+ 9bR4XeIoazqGCNyBXxOuAhd4XOp5ZjKcFCHbbQ1inQlVElTUrXX4RIDnLgDlFYmRGBSS XAaNX+YVwNNVah7NdS/9qZd2Cd1gQMAYYpdy9TzyznTQ4K5/u85LrrdowcaUW620yshc zSLg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gftxvehN; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccfdd56si4598031cf.71.2024.07.18.18.09.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:16 -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=gftxvehN; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc68-0003bS-6r; Thu, 18 Jul 2024 21:07:48 -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 1sUc5m-0002u1-KC for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:29 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5j-0000jN-Sv for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:25 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fb3b7d0d56so9671665ad.1 for ; Thu, 18 Jul 2024 18:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351242; x=1721956042; 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=lffTC77hfuBCBlcm53ysSfFxUjHJ9OXDuax++3VtjJ0=; b=gftxvehNrfN5FV6jZov2DcfkBumsBw37zrftGYDBZ1J8NhUQDznwtS41HFALXN/gCQ dG4V4vw52P+NKd/Za7IR1HG49ZqOBxeWpr9qlAXg+n3WMZ3GsCZlb9P86FNASAlVkws9 zi+qUE9W4VIjV0qFao2npxR63DAFsS5TuMhYa/bTocAyAvIu/Dh+yTcLc1D8u/Wi3UGn buZXhtLWoDJeBR7ZfuLUSGFVrp2s7FTgtYjyQ6b5qvJ53WPB8G2cYuSKoUePB+4HW2lm NcBbnDLd8WisInBv5LpYXbuDFuv6MNFG+AKqTyikIusHhd2mgXT6EkT/yggj8O0CXWTj Znww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351242; x=1721956042; 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=lffTC77hfuBCBlcm53ysSfFxUjHJ9OXDuax++3VtjJ0=; b=d/GKL+4Q2DME17gt4kxAlGOADvEw2ixnLOtHHrdWvwob9wSkG8N2ghkRnBg799DLmT 2oGCQKtDCiM99ZNRmS4BHfcAjk8bGhvIBHawDt5GCM4DGQRnBzRnPxm0nmMCrM/1DwDU 7XV2l700o67IbQPNZMZ/XYeszq9eaACG5nd7tNaeHxS5l9V4JmZENTzzPXpltRNgawp5 lTywsKAb50g6zi/5Xbo9Fhngo52IFkaqNoCyor0/7TcvXeIpu8fs2MORL3Gn/WM6I8Nt eEW1h/b2mLBj87XqtPnn/FU7+i1QeD1+c2NRqz9N+2l2t65mbAOkPEE3eFF2rqnLVEfh x1qw== X-Gm-Message-State: AOJu0Yxl2+zE1m0cuu4UDKWajelydyhKd1SsIq7/jaa/ZfSrkype0Is0 ZybQ8HztFxrvYovHS6kbTifNv044in3jA9P8mqvcSrQQh4jqhgFPF0ERjJ26K0ekrDTHzSnWnvz v5Dc/TA== X-Received: by 2002:a17:902:d506:b0:1fc:327a:1f48 with SMTP id d9443c01a7336-1fc4e1077a8mr63280235ad.12.1721351241529; Thu, 18 Jul 2024 18:07:21 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Peter Maydell Subject: [PATCH v3 02/12] target/arm: Use set/clear_helper_retaddr in helper-a64.c Date: Fri, 19 Jul 2024 11:06:57 +1000 Message-ID: <20240719010707.1319675-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Use these in helper_dc_dva and the FEAT_MOPS routines to avoid a race condition with munmap in another thread. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/tcg/helper-a64.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 0ea8668ab4..c60d2a7ec9 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -928,6 +928,8 @@ uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) { + uintptr_t ra = GETPC(); + /* * Implement DC ZVA, which zeroes a fixed-length block of memory. * Note that we do not implement the (architecturally mandated) @@ -948,8 +950,6 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) #ifndef CONFIG_USER_ONLY if (unlikely(!mem)) { - uintptr_t ra = GETPC(); - /* * Trap if accessing an invalid page. DC_ZVA requires that we supply * the original pointer for an invalid page. But watchpoints require @@ -971,7 +971,9 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) } #endif + set_helper_retaddr(ra); memset(mem, 0, blocklen); + clear_helper_retaddr(); } void HELPER(unaligned_access)(CPUARMState *env, uint64_t addr, @@ -1120,7 +1122,9 @@ static uint64_t set_step(CPUARMState *env, uint64_t toaddr, } #endif /* Easy case: just memset the host memory */ + set_helper_retaddr(ra); memset(mem, data, setsize); + clear_helper_retaddr(); return setsize; } @@ -1163,7 +1167,9 @@ static uint64_t set_step_tags(CPUARMState *env, uint64_t toaddr, } #endif /* Easy case: just memset the host memory */ + set_helper_retaddr(ra); memset(mem, data, setsize); + clear_helper_retaddr(); mte_mops_set_tags(env, toaddr, setsize, *mtedesc); return setsize; } @@ -1497,7 +1503,9 @@ static uint64_t copy_step(CPUARMState *env, uint64_t toaddr, uint64_t fromaddr, } #endif /* Easy case: just memmove the host memory */ + set_helper_retaddr(ra); memmove(wmem, rmem, copysize); + clear_helper_retaddr(); return copysize; } @@ -1572,7 +1580,9 @@ static uint64_t copy_step_rev(CPUARMState *env, uint64_t toaddr, * Easy case: just memmove the host memory. Note that wmem and * rmem here point to the *last* byte to copy. */ + set_helper_retaddr(ra); memmove(wmem - (copysize - 1), rmem - (copysize - 1), copysize); + clear_helper_retaddr(); return copysize; } From patchwork Fri Jul 19 01:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813363 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp544948wro; Thu, 18 Jul 2024 18:08:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXVtVzPZib0U1SRA8eRipizQaTa9P2x5dw989rYNrgDGdv8WF7uCuSPO4yZhpN3mqi6go10alOYa9rus8QVQUBD X-Google-Smtp-Source: AGHT+IH0p0psak8+YGqE3hHfIccBC/mMb+3DSMcefDXFMGFo9/OUebDnjCwBiOu+kvLBjW4m2NJD X-Received: by 2002:a05:6214:2a81:b0:6b5:e58a:63a6 with SMTP id 6a1803df08f44-6b78ca82f33mr68249736d6.34.1721351322311; Thu, 18 Jul 2024 18:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351322; cv=none; d=google.com; s=arc-20160816; b=BVrytILbmlM4CeZvAPXAEyRCIxNv9UAO99MaN0dIDWiLj5JDsvQgpU3q0wYgBi8EQV PeRmVB39Vx2Z/nIjgmhApnx9+7nX/E2M2MCzfzWsLZjTTdjnjytAhO8SF0jnwDVpIi/a ugatYiNdjJpiqSmR3RmlEZkcGSAMcOFMcBTmmHiCwxYCUgZgKJXyBBs4v1+YigWGxGDI HgN4h2/W0gI9JWOEf8b/atYx6wYF5a5ETCuO6XKl9BahxUJVQBqOnAyLktYHZg2KMqyt C2wSJCR8XPjmHrMPyrfCKUkdfDuED3+HAc8Hgeehl3kKLVGLRLJgw3Mej0BhVwg8W96X XgVg== 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:dkim-signature; bh=jMsQ8jSa2C8xRls4TTp8Ou8tDoyMnkK5KK/Q8+Xs4/o=; fh=PMD1cJf9IbYeK/VmAJgusCYc7DxmYIcIgC7fGquy+wg=; b=PoEiVFGPr2NpDUvywIPgA1yF5fr1x58AJxsGYIPMNtxKr4wrKOWZVzwzS0Vrks2jmT X3MC5dN1MSsIgdYj71Q+3Lz9lrL5jgaaZbX7h5R/UuSywJGagqjElMMXJJyalRAQ+FCT RkXNzTTBeJgQew8wZia53NXNWDK8rPq//D/mSKWa20va5xDjTGePYL4qqg8dGUXRme8R DAxNibjPwUl00ByW3hXU//0YL7sLhO5tRiDbEj628dPp8gMSyvGcM8IuRbXWfcbelP4A Uzc6vWAahmIIFHbecdZhe3TrnkvwhzjXauC/1kjUHHLX31MmaWpBnOCcTrI219W3P/36 5JxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I0/VwhUz"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac9c3bf4si4218506d6.372.2024.07.18.18.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:08:42 -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="I0/VwhUz"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6d-0005B7-Vx; Thu, 18 Jul 2024 21:08:21 -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 1sUc5p-0002uW-3g for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:29 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5n-0000km-7e for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:28 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fb3b7d0d56so9671835ad.1 for ; Thu, 18 Jul 2024 18:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351245; x=1721956045; 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=jMsQ8jSa2C8xRls4TTp8Ou8tDoyMnkK5KK/Q8+Xs4/o=; b=I0/VwhUzsyxWIvd0RxFcBcFTCiHJs+Zhs7yG41Ti9MUJQI9DjNn1Arh9YmolF6Geyg QRutRHCsqF+8gqVwEJ8/a6u0BPtM4NGyYdGGmeQIE4IOw8oIDe3Yuw8JQSCKzA0Xnbc6 ywYkZD8wcVjx9Vpsr3UUztTWdg9AJnbdxFPCl8a4HtB3cTuTIWQI++gf2PkI/3xonm5Q 0yKHvobfctF+cI3LbQX+4a5ydblHdth0XhOJQabyvuiXtZucOsSfnMxjaGiFBrDEba1Z +OhoAGdCdPUO4e9Ut/BKm1ig9w7ogUCRLaKmUlXVoeCZh7TkfJC+zu5FjJCAcpioKMpT sXpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351245; x=1721956045; 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=jMsQ8jSa2C8xRls4TTp8Ou8tDoyMnkK5KK/Q8+Xs4/o=; b=H0j6VM6Kw07nQJsyEFds9Sjgu7JnsXNLtzHMsZ8n8HzxF0IbV3q5zjea/hNenL4Efn L6imhe/bdqSqTnM6iTrvgk5ahUTBZ/P0tTGYdlX/EXR0Yhb9jxDBo6gPSQcggz0KSHJi AnxBqpYeji9vJQoZGrKaRzy72KttlkOMdjEynEFOe0sy/M7s65wh5dXaxKoj6Rkd5WVO LJiNti412kmHdjPtIGl1EkdODNZNyf814f4ry179ak3l5jlRZu1zBcAj6xbCN0qgq/mB UkttlG59X2snnFb/wPJtCV3ZymA4oHyvrTAlY6XdgNvgqgp3mujujPGaCcaGlv1TMM1J R1Kw== X-Gm-Message-State: AOJu0YwoADaSQ+iIkVzkpqmVEMvicAf4pjgYnzaK20JEfPnTuQeYdN98 ssat/jXEbLkkLrEZ/lvhCOTW7OTGoPidFCFcHELyIicpDF3+mkvB7VZrPD60ovJ2DhTARDzAEsv jTbYNMw== X-Received: by 2002:a17:903:1c5:b0:1fb:7e12:ee3a with SMTP id d9443c01a7336-1fc4e1318bbmr55951805ad.24.1721351244933; Thu, 18 Jul 2024 18:07:24 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 03/12] target/arm: Use set/clear_helper_retaddr in SVE and SME helpers Date: Fri, 19 Jul 2024 11:06:58 +1000 Message-ID: <20240719010707.1319675-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Avoid a race condition with munmap in another thread. Use around blocks that exclusively use "host_fn". Keep the blocks as small as possible, but without setting and clearing for every operation on one page. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/tcg/sme_helper.c | 16 ++++++++++++++ target/arm/tcg/sve_helper.c | 42 +++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c index e2e0575039..ab40ced38f 100644 --- a/target/arm/tcg/sme_helper.c +++ b/target/arm/tcg/sme_helper.c @@ -517,6 +517,8 @@ void sme_ld1(CPUARMState *env, void *za, uint64_t *vg, clr_fn(za, 0, reg_off); } + set_helper_retaddr(ra); + while (reg_off <= reg_last) { uint64_t pg = vg[reg_off >> 6]; do { @@ -529,6 +531,8 @@ void sme_ld1(CPUARMState *env, void *za, uint64_t *vg, } while (reg_off <= reg_last && (reg_off & 63)); } + clear_helper_retaddr(); + /* * Use the slow path to manage the cross-page misalignment. * But we know this is RAM and cannot trap. @@ -543,6 +547,8 @@ void sme_ld1(CPUARMState *env, void *za, uint64_t *vg, reg_last = info.reg_off_last[1]; host = info.page[1].host; + set_helper_retaddr(ra); + do { uint64_t pg = vg[reg_off >> 6]; do { @@ -554,6 +560,8 @@ void sme_ld1(CPUARMState *env, void *za, uint64_t *vg, reg_off += esize; } while (reg_off & 63); } while (reg_off <= reg_last); + + clear_helper_retaddr(); } } @@ -701,6 +709,8 @@ void sme_st1(CPUARMState *env, void *za, uint64_t *vg, reg_last = info.reg_off_last[0]; host = info.page[0].host; + set_helper_retaddr(ra); + while (reg_off <= reg_last) { uint64_t pg = vg[reg_off >> 6]; do { @@ -711,6 +721,8 @@ void sme_st1(CPUARMState *env, void *za, uint64_t *vg, } while (reg_off <= reg_last && (reg_off & 63)); } + clear_helper_retaddr(); + /* * Use the slow path to manage the cross-page misalignment. * But we know this is RAM and cannot trap. @@ -725,6 +737,8 @@ void sme_st1(CPUARMState *env, void *za, uint64_t *vg, reg_last = info.reg_off_last[1]; host = info.page[1].host; + set_helper_retaddr(ra); + do { uint64_t pg = vg[reg_off >> 6]; do { @@ -734,6 +748,8 @@ void sme_st1(CPUARMState *env, void *za, uint64_t *vg, reg_off += 1 << esz; } while (reg_off & 63); } while (reg_off <= reg_last); + + clear_helper_retaddr(); } } diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c index dd49e67d7a..f1ee0e060f 100644 --- a/target/arm/tcg/sve_helper.c +++ b/target/arm/tcg/sve_helper.c @@ -5738,6 +5738,8 @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, reg_last = info.reg_off_last[0]; host = info.page[0].host; + set_helper_retaddr(retaddr); + while (reg_off <= reg_last) { uint64_t pg = vg[reg_off >> 6]; do { @@ -5752,6 +5754,8 @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, } while (reg_off <= reg_last && (reg_off & 63)); } + clear_helper_retaddr(); + /* * Use the slow path to manage the cross-page misalignment. * But we know this is RAM and cannot trap. @@ -5771,6 +5775,8 @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, reg_last = info.reg_off_last[1]; host = info.page[1].host; + set_helper_retaddr(retaddr); + do { uint64_t pg = vg[reg_off >> 6]; do { @@ -5784,6 +5790,8 @@ void sve_ldN_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, mem_off += N << msz; } while (reg_off & 63); } while (reg_off <= reg_last); + + clear_helper_retaddr(); } } @@ -5934,15 +5942,11 @@ DO_LDN_2(4, dd, MO_64) /* * Load contiguous data, first-fault and no-fault. * - * For user-only, one could argue that we should hold the mmap_lock during - * the operation so that there is no race between page_check_range and the - * load operation. However, unmapping pages out from under a running thread - * is extraordinarily unlikely. This theoretical race condition also affects - * linux-user/ in its get_user/put_user macros. - * - * TODO: Construct some helpers, written in assembly, that interact with - * host_signal_handler to produce memory ops which can properly report errors - * without racing. + * For user-only, we control the race between page_check_range and + * another thread's munmap by using set/clear_helper_retaddr. Any + * SEGV that occurs between those markers is assumed to be because + * the guest page vanished. Keep that block as small as possible + * so that unrelated QEMU bugs are not blamed on the guest. */ /* Fault on byte I. All bits in FFR from I are cleared. The vector @@ -6093,6 +6097,8 @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, reg_last = info.reg_off_last[0]; host = info.page[0].host; + set_helper_retaddr(retaddr); + do { uint64_t pg = *(uint64_t *)(vg + (reg_off >> 3)); do { @@ -6101,9 +6107,11 @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, (cpu_watchpoint_address_matches (env_cpu(env), addr + mem_off, 1 << msz) & BP_MEM_READ)) { + clear_helper_retaddr(); goto do_fault; } if (mtedesc && !mte_probe(env, mtedesc, addr + mem_off)) { + clear_helper_retaddr(); goto do_fault; } host_fn(vd, reg_off, host + mem_off); @@ -6113,6 +6121,8 @@ void sve_ldnfff1_r(CPUARMState *env, void *vg, const target_ulong addr, } while (reg_off <= reg_last && (reg_off & 63)); } while (reg_off <= reg_last); + clear_helper_retaddr(); + /* * MemSingleNF is allowed to fail for any reason. We have special * code above to handle the first element crossing a page boundary. @@ -6348,6 +6358,8 @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, reg_last = info.reg_off_last[0]; host = info.page[0].host; + set_helper_retaddr(retaddr); + while (reg_off <= reg_last) { uint64_t pg = vg[reg_off >> 6]; do { @@ -6362,6 +6374,8 @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, } while (reg_off <= reg_last && (reg_off & 63)); } + clear_helper_retaddr(); + /* * Use the slow path to manage the cross-page misalignment. * But we know this is RAM and cannot trap. @@ -6381,6 +6395,8 @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, reg_last = info.reg_off_last[1]; host = info.page[1].host; + set_helper_retaddr(retaddr); + do { uint64_t pg = vg[reg_off >> 6]; do { @@ -6394,6 +6410,8 @@ void sve_stN_r(CPUARMState *env, uint64_t *vg, target_ulong addr, mem_off += N << msz; } while (reg_off & 63); } while (reg_off <= reg_last); + + clear_helper_retaddr(); } } @@ -6560,7 +6578,9 @@ void sve_ld1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, if (unlikely(info.flags & TLB_MMIO)) { tlb_fn(env, &scratch, reg_off, addr, retaddr); } else { + set_helper_retaddr(retaddr); host_fn(&scratch, reg_off, info.host); + clear_helper_retaddr(); } } else { /* Element crosses the page boundary. */ @@ -6782,7 +6802,9 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, goto fault; } + set_helper_retaddr(retaddr); host_fn(vd, reg_off, info.host); + clear_helper_retaddr(); } reg_off += esize; } while (reg_off & 63); @@ -6986,7 +7008,9 @@ void sve_st1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, do { void *h = host[i]; if (likely(h != NULL)) { + set_helper_retaddr(retaddr); host_fn(vd, reg_off, h); + clear_helper_retaddr(); } else if ((vg[reg_off >> 6] >> (reg_off & 63)) & 1) { target_ulong addr = base + (off_fn(vm, reg_off) << scale); tlb_fn(env, vd, reg_off, addr, retaddr); From patchwork Fri Jul 19 01:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813371 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545195wro; Thu, 18 Jul 2024 18:09:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWyya5icIZ6wNGuOvSjKxwF6Ge6pAqnIDTKNe9xULqY0T0Q5YxYlkSnS046pzpoobe1haPVkOG/w1rL/JbAVr4Z X-Google-Smtp-Source: AGHT+IHnWV04P9nQdU1IoIughcL6/4ZzoXlfpmKKxUJkULKs9VSlUPfCzd0wH9oqXsSfww0QnVvB X-Received: by 2002:a05:622a:60d:b0:447:ef7c:edd3 with SMTP id d75a77b69052e-44f96a51752mr28779611cf.40.1721351378091; Thu, 18 Jul 2024 18:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351378; cv=none; d=google.com; s=arc-20160816; b=z0NKm2gPJ7ujVX3V/KPNPb95EpPc5Sie89tbswdAY+Vn7Sb8no+dzzTKtCktfTakZI xk2anSvJqWUR7zXSc0/is6huGlR33hJ4VgXRUdx6tNGzv9mex0lUr2rYEaSdGPH7Bu1w G7D3PGajYgPQns8dzUJCdGSHxU4o3uwW6/08hE5sUwE1wruVfw55/9ehVzZQ1Q8cLylq 9ng3oYAs0CUkEfRFmyXbQvowTQI8f9MroVji/OV22NdW4p68uBIRU5wpgptzYU8pr8aY xBAf8qIiVdsjxyk5+jeeg/PvNsUFkOo7r3sWi74ED9E8srNy03LoW8Y6fRciXFNZDnZa d36Q== 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:dkim-signature; bh=T/SUfCnTpRQkNLbtLFhLzUNUB0u06MHsZx7MB+lBLUc=; fh=yRLCku87Tm1ZVhWXmjCuh00faiCzdFZ7tm3MnwaPv5I=; b=pxIfqH/2wO5NJb2i/TTLPA603UZV16rTT1RoQevpvIb0kFzNARcwVE/zoSyFrP3zB5 eu/UMHHV/S8OYvnCpdqgvGnj84SljmJ1UBIeMi2Pe3uMKhU3Vez7WvGQ/yz0XZSKUd60 6gOfKpls6R5pNroepFOdtrf1onG5BMrR+bl1H2lKoFeIfOtPUDAH1GoX/2cf1BWdsfmX qazAZng/VVw0o49dniPBgRdWpJ4ICMXnJaIVMAoj5MQTrsD07RmTn/6KN5CjWY7Qcox1 MUwE+D4POg4f2QSSR6qdkPFGF/2FSam279PlGoeRSo6SQwXHgZR0cbm/M4qGU5Y4qZ1j lGeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YjsquKBm; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf0f8fdsi4473561cf.723.2024.07.18.18.09.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:38 -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=YjsquKBm; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6k-0005kV-2i; Thu, 18 Jul 2024 21:08:26 -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 1sUc5y-0003Hv-UV for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:41 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5u-0000mD-7N for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:36 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fc566ac769so11728665ad.1 for ; Thu, 18 Jul 2024 18:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351249; x=1721956049; 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=T/SUfCnTpRQkNLbtLFhLzUNUB0u06MHsZx7MB+lBLUc=; b=YjsquKBmU2OKdeWRj5y1IYkFT2Zoirmb0L1jzJ2KhT05hfp0dQxPUXj3ncMB+rttK3 tGRQNXKhXH99C0UfDurBpmCPPUXkqb3y5BVnABvrtcfG4DX+rHE2W475Rn2lt8xBKEYy /K4Vy1QQurMEkFF43HQpn147EnpJWfTlK5CR3DKfwBxsEi9EMTNLRjv3vsbRMfRQhrlW Fu6WU2IPCHwSMnADfCo+wN2y/fV1+SWiCmgvU0k0CRkcJOT1GRtlzf2wwXP01rO7Rzc4 e0i5090qUXSx3Cu/81TVh0upS0zVQLPAUvczuHwQotk1MEqoAUyOLrHHOtCFxkSKEOfF Fsyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351249; x=1721956049; 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=T/SUfCnTpRQkNLbtLFhLzUNUB0u06MHsZx7MB+lBLUc=; b=Il+mivfuIxzCr1upA12ojQrrSKnqFcp/10dGkIrPhXvZ9kHEJ8kKcBENpQjQRrqqzj XZB8eHr80x/xMA47jQMLmKQlN7V9+T3QyOBtqsODppDaXRvYKw0vwvj82MWVmxkKt9u4 GSdmir01cDiDs2RywNKjW9LsFti0XmLgCG6XsYtqAu1zo1ALoDrDN62SFofbLwbLNvdE 9mLdw/LEyKrAIOvKLu4P6cnqI+xZDoqqRDRGYe5LYRQYlmJCOxtiy/kP0APfMMZQ/iyg Wd3F93KYY7qHRRqTALD9X+5llilvwsEDtwWXIFsP6pi4V9fQ4ho5ksURRTd1pwoF0Sm8 fgLQ== X-Gm-Message-State: AOJu0YwMmrshZt9qw79HQHgiCGAc9GOpNPzd5DjLWC7GQ9ftOIv50m0E 0BjAox4dYrk0fFPp1Amu+1XNDH3SMf0cQOuDUWzR3ALQ7KNrWC+RTLb0rtk6B7IRiTk82d2bIyn kU+YYdQ== X-Received: by 2002:a17:902:db0d:b0:1fb:1b16:eb80 with SMTP id d9443c01a7336-1fc4e15c311mr52103855ad.26.1721351248839; Thu, 18 Jul 2024 18:07:28 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, BALATON Zoltan , Nicholas Piggin Subject: [PATCH v3 04/12] target/ppc/mem_helper.c: Remove a conditional from dcbz_common() Date: Fri, 19 Jul 2024 11:06:59 +1000 Message-ID: <20240719010707.1319675-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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: BALATON Zoltan Instead of passing a bool and select a value within dcbz_common() let the callers pass in the right value to avoid this conditional statement. On PPC dcbz is often used to zero memory and some code uses it a lot. This change improves the run time of a test case that copies memory with a dcbz call in every iteration from 6.23 to 5.83 seconds. Signed-off-by: BALATON Zoltan Message-Id: <20240622204833.5F7C74E6000@zero.eik.bme.hu> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Nicholas Piggin --- target/ppc/mem_helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index f88155ad45..361fd72226 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -271,12 +271,11 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, } static void dcbz_common(CPUPPCState *env, target_ulong addr, - uint32_t opcode, bool epid, uintptr_t retaddr) + uint32_t opcode, int mmu_idx, uintptr_t retaddr) { target_ulong mask, dcbz_size = env->dcache_line_size; uint32_t i; void *haddr; - int mmu_idx = epid ? PPC_TLB_EPID_STORE : ppc_env_mmu_index(env, false); #if defined(TARGET_PPC64) /* Check for dcbz vs dcbzl on 970 */ @@ -309,12 +308,12 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - dcbz_common(env, addr, opcode, false, GETPC()); + dcbz_common(env, addr, opcode, ppc_env_mmu_index(env, false), GETPC()); } void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - dcbz_common(env, addr, opcode, true, GETPC()); + dcbz_common(env, addr, opcode, PPC_TLB_EPID_STORE, GETPC()); } void helper_icbi(CPUPPCState *env, target_ulong addr) From patchwork Fri Jul 19 01:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813372 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545289wro; Thu, 18 Jul 2024 18:09:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwQxKvf8dE2KX+XDgh7xFVt9Qzi2ccv3+ykDA8yDSpn81DC4iLDmOF1Y91sRgug0fdcMH3nMwSE6NwcZwtwTsC X-Google-Smtp-Source: AGHT+IEN25Cov5KqnfXlhfI7LINEOa1RtiksrR7rXR1VBKdJjZI3egeU0qfm6vzJi/t7YDYIZLhY X-Received: by 2002:a05:6102:554c:b0:48f:e69d:5953 with SMTP id ada2fe7eead31-49159885c8cmr6962981137.19.1721351396084; Thu, 18 Jul 2024 18:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351396; cv=none; d=google.com; s=arc-20160816; b=uNxjTBk0gbqiZwvCviv5IM8A4jFK0cfCY+lT7y1CI0hR7VCOwm0rOt4kCNKMpqfDfM ICJME4HnsAb04WxebOoI/1lU5V8c5t+Pyfb+uIE0xa+k3Cx0qDAjT/zfI++HarrxxabV kVXP/oT2busrGo1DSsoAZjLHbj+WpcX7H8hFMFNAxwkaM+vobkmgZYOZfKUR8BquArbG kXdXvgji4G8DlHypmt7V08sCNvs6JsdJ/wqVBLv0SRIU6p0JZ+Rupx3q6Hg5ym32/2QB hW24goqyebM5QbteuVoMrNhNjc38fTc0yn1a3e5jzdcvb3dT3Z3U8mJlJRxlrNmjxtzY 3E7A== 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:dkim-signature; bh=qQ06f1POln3X8Sb8fDa8/CDLulrLL54olCBz3brWMPA=; fh=Rc2oOAtVcw1QgMi4H4R5cDBav9mgTQMB7BmgqsQhSJ8=; b=POgZEusf4q8j68aVCJIfZNOQB6Bw7BsXM5/zvPc3ONNbb9WMekwKXRtvptsMqz74Pu EJWps5Qk4ZId6UwmfYfv976IVTbhc4d7RHDf5NbzOb9Mg2gEp1SLflIMe2rT4XkvX8Yp FZEdiGmt5c5Kzc4bCrwnLo6pBeZ8YEf8Trpn3+JKDk5q7Zcz4WEKGegd4LjK6peTR1Vx VqzSmZrv3qjZW+EvJAoQY/Azk5UOlEpaMZ/XNXlznJVy1QwWhQj3hg0kyUVR+EhOQzcF +RbZRlsHlvnXPLJqMssVzAhsY/9JDjzw/CfSLzpz73WztH5LmVPag/oJn/Asjh2BPcJx 7Gbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HIgrXQvi; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccfdd56si4608471cf.71.2024.07.18.18.09.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:56 -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=HIgrXQvi; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6j-0005hV-Qg; Thu, 18 Jul 2024 21:08:25 -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 1sUc5y-0003Hx-Ui for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:41 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5u-0000ml-MG for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:37 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1fc4fcbb131so13396695ad.3 for ; Thu, 18 Jul 2024 18:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351253; x=1721956053; 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=qQ06f1POln3X8Sb8fDa8/CDLulrLL54olCBz3brWMPA=; b=HIgrXQvijkfwIOy0gZzA5J5UwBcIKZUzRC+Jyo3xzqNlBZG4WjXb3zP5Mb0Ews37sp 0iBkAH7iQ45kgAHY8gZbIHvCdAZghfZVxpP8I8wBtDhyqYuS9EttXICk4j1Vv2E9aaoe Waw8jD2rR3gFQIqI64edXjGldGJlrSyUsc9cOeRbRsvQ4dg8I4a/Kh8/4kNHDT3rUulJ F8LWIZmTizxMwc6odIaVZEy2Wnwau1haoVXONYkO2ZWErSgZRezY3aNERNszuUsaSRrY ab+neIXBox/Z0eqeKqKcynXOKjEU+5b4CWOhpKQ+9LZvTQhZZ8Rbvi7+dZMsygRSIV6R WDlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351253; x=1721956053; 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=qQ06f1POln3X8Sb8fDa8/CDLulrLL54olCBz3brWMPA=; b=bAWoLBqwJJ3e3os0n3obj0mmRY8kLHcyWKjYAGO1kZABKskVFwpPH9SnypB7nxwkyW DRJp8mSV7bmQ+bt7WAPFp/Ks1QupeKrMxbCz0J7ZelbYyn2J7w4yhysooajve39OM402 UmTaY1PatgnxS7sxHrtwnBPsuR2KPFPXDGzaaRNCsHfaSoEkxEmA9wSv2kG9KNirg2nd r9509fb1V7qdRzyXI95mzH0VmDh+A8dYdR1sONd81uFJqTi6MVh67REMId6HEj0tM3Qq p3uSstaYAKUdzHYXGAO6xLH/RMd9dgAIJvUH5VSMWeBTmff3pigTbuivk/U3ifmsg4/7 CSAg== X-Gm-Message-State: AOJu0Yz6t4Mx0pQHz0PbprGXmaLhlCd0CbWtsrGs752hPxtBxRa+GUls o2c7te0WWOiN/uWOqt5GWU5dQU7yKzP00XdJXEFSBxR6DgO9YKqD0PqhKk1eYJBykmCMBp58/aW xWCHzvQ== X-Received: by 2002:a17:903:41c7:b0:1fa:8f64:8b0d with SMTP id d9443c01a7336-1fc4e154b4fmr67172795ad.4.1721351252633; Thu, 18 Jul 2024 18:07:32 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Nicholas Piggin , BALATON Zoltan Subject: [PATCH v3 05/12] target/ppc: Hoist dcbz_size out of dcbz_common Date: Fri, 19 Jul 2024 11:07:00 +1000 Message-ID: <20240719010707.1319675-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 The 970 logic does not apply to dcbzep, which is an e500 insn. Reviewed-by: Nicholas Piggin Reviewed-by: BALATON Zoltan Signed-off-by: Richard Henderson --- target/ppc/mem_helper.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 361fd72226..5067919ff8 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -271,22 +271,12 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, } static void dcbz_common(CPUPPCState *env, target_ulong addr, - uint32_t opcode, int mmu_idx, uintptr_t retaddr) + int dcbz_size, int mmu_idx, uintptr_t retaddr) { - target_ulong mask, dcbz_size = env->dcache_line_size; - uint32_t i; + target_ulong mask = ~(target_ulong)(dcbz_size - 1); void *haddr; -#if defined(TARGET_PPC64) - /* Check for dcbz vs dcbzl on 970 */ - if (env->excp_model == POWERPC_EXCP_970 && - !(opcode & 0x00200000) && ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { - dcbz_size = 32; - } -#endif - /* Align address */ - mask = ~(dcbz_size - 1); addr &= mask; /* Check reservation */ @@ -300,7 +290,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, memset(haddr, 0, dcbz_size); } else { /* Slow path */ - for (i = 0; i < dcbz_size; i += 8) { + for (int i = 0; i < dcbz_size; i += 8) { cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr); } } @@ -308,12 +298,22 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - dcbz_common(env, addr, opcode, ppc_env_mmu_index(env, false), GETPC()); + int dcbz_size = env->dcache_line_size; + +#if defined(TARGET_PPC64) + /* Check for dcbz vs dcbzl on 970 */ + if (env->excp_model == POWERPC_EXCP_970 && + !(opcode & 0x00200000) && ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { + dcbz_size = 32; + } +#endif + + dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); } void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - dcbz_common(env, addr, opcode, PPC_TLB_EPID_STORE, GETPC()); + dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); } void helper_icbi(CPUPPCState *env, target_ulong addr) From patchwork Fri Jul 19 01:07:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813367 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545096wro; Thu, 18 Jul 2024 18:09:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWVCHQtwfjyGDpM3qz7nDsWfhlB25a/KUP9UawIGeGeMdeyREtIpanCTyv/prr9RUrJt40yCt4mOwdVvBYsKD+E X-Google-Smtp-Source: AGHT+IEo7GRmhSp1UowYoFZl985gtM5Jyas37g2UtOI6+kDoikqQabqy7b6uHn06y0qEBuTS0Va4 X-Received: by 2002:a05:6102:54a1:b0:48f:e9d9:3ad0 with SMTP id ada2fe7eead31-4915994b86cmr8036030137.27.1721351358198; Thu, 18 Jul 2024 18:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351358; cv=none; d=google.com; s=arc-20160816; b=tRLugLbMcVfUdvKamvKVnQK8TW03AknBzXVKZTHV2cp2af/GU4NfUD8jIjb+3vPRir IHNEHmFFd4nUnDxvnihAIKwV/CMq3aYyFRUSJTc5mwqqIHygL6+3sVFLfU4wXba9al7q ZOn2EJrBhHW2W8M1Ivy6iT3T0oV9r5395yTZqTzyKHgq9TlZ17upsRvr7QcsryYHPIts eo0OyM3lo7f6HFXwQ991MyPLhiVlTdHbNXTB+cs01RXdvzldfy3Lh6R8ksLz4+xPba9e KGjbLpnqxuoGjxug8oS/xQAe5yTI7yAEsPZ24sjMl5/htH8+CiqjHOzzIm2QSL/nHgXY 1hhg== 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:dkim-signature; bh=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; fh=Rc2oOAtVcw1QgMi4H4R5cDBav9mgTQMB7BmgqsQhSJ8=; b=X9SOku+0qs9KtJ+uSt+qDpKWrQvM2+9Y8lCITP0K7OW/sfokbwWOHyV4LI1XFFhY0g GGSfn4FozQ1MVJX+xYI8griS7w6xOMerksJl+6n64o3sjKlCSaiImWz984piTPMOmgBd pCcUHT/CbVIpMGDaEO8+62AIKDSmfldb8xGql7Xx3azwDL4JyvbQKqSikXdKds+m6gzh I4Cg9sCUfUQHGCVwBz5SHJC+6sEM7+FfMrRuh/aLMhbiXcbpT9E/U6OHDiIwKF/4UPM5 VmW6BiIOqcW8QIrwwNWIRcKjhVbU0Xwlgy3Xmkj5XHyyB/RGIUeXyTR3UlTPoGz1Mcrr AcGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uFWfHCsO; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cdd3dc8si4263881cf.470.2024.07.18.18.09.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:18 -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=uFWfHCsO; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6l-0005vs-JC; Thu, 18 Jul 2024 21:08:27 -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 1sUc62-0003Tp-PT for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:44 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc5y-0000oF-N7 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:41 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fc658b6b2eso9408185ad.0 for ; Thu, 18 Jul 2024 18:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351256; x=1721956056; 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=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; b=uFWfHCsOzEFDKVpv3bEq9FU9tl93BofivGm38wbi4M/bCQzU+nCQ1CqreYZzhZjcl8 2oq8oXy7KRtRW6ES1YYxn3EHzZoSQE9JFKtBzdsEnhmNQbvLewMUviDIEGccBzBlRwr5 TwIxOi0JaXb3/+A+kpclmwQclW7iTmwcuFqwYf6FLcWujWbMPotVDAc6voly6KrVReJ0 PcXj3zfYVD8UJ6zaEAUAOKaU5mTEd8rJB10fn/DNGuzjptBawxQHmpjQ5vQJZPbfGl5j aVa8ZGTsUF/iekekupPhtOcg2X5IAZCIV/v3QnEr0jRE4HqRKSMd6lN/mtK+Es1yMZ3B NPEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351256; x=1721956056; 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=vMEEORHFY/5AJeKs7AXO2kip576OxvLWKFUcuNYKW6c=; b=v3KrlxWzFVBYdtJQYLgJnbB2GzeJ6kXDG8ehxX0QvzoHeL6sdqBJFFpqhQnXJSpOOf Ozav9FM5UN6rMDRKy7e8X6JbZBTW6mgTjnQK8hJDe84/4y6MeFPsa4Jl/4PpBYVsGar2 XXOd8vC+djboJRzhwIRfBh8IiT/YYc0uKD45jlTBcczTMgCJQTlwkJaSCJbquFpv7K7v BlNZfxHk257XujB3fCp+YdpbByPuoyMgHvFAUBH85xqEzuPb/BECwlzSqruxM3Bu74IV 7mhrOcr7WDm25PDkjX4CfgLmnJ0Gxd1wj7Bp154BnnloxNcei+QEzXtrzejSg5W/4gnR Z6jA== X-Gm-Message-State: AOJu0Yx2zurFuJGpJNRSOwAgXZShN04HloqeUoba1f81uGDuJIISN7QX 1GWqKMJznW1bk/fba8hz8jzDWVCpJHaoZ6qcNbKJHb1dankCJdCbADvduMZpK+nb7byI7aRo+lK eUP84ZQ== X-Received: by 2002:a17:902:ec89:b0:1fb:8466:7df3 with SMTP id d9443c01a7336-1fc4e567292mr61058435ad.28.1721351256302; Thu, 18 Jul 2024 18:07:36 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Nicholas Piggin , BALATON Zoltan Subject: [PATCH v3 06/12] target/ppc: Split out helper_dbczl for 970 Date: Fri, 19 Jul 2024 11:07:01 +1000 Message-ID: <20240719010707.1319675-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 We can determine at translation time whether the insn is or is not dbczl. We must retain a runtime check against the HID5 register, but we can move that to a separate function that never affects other ppc models. Reviewed-by: Nicholas Piggin Reviewed-by: BALATON Zoltan Signed-off-by: Richard Henderson --- target/ppc/helper.h | 7 +++++-- target/ppc/mem_helper.c | 34 +++++++++++++++++++++------------- target/ppc/translate.c | 24 ++++++++++++++---------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 76b8f25c77..afc56855ff 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -46,8 +46,11 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) DEF_HELPER_4(lsw, void, env, tl, i32, i32) DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) -DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, i32) -DEF_HELPER_FLAGS_3(dcbzep, TCG_CALL_NO_WG, void, env, tl, i32) +DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) +#ifdef TARGET_PPC64 +DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) +#endif DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 5067919ff8..d4957efd6e 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -296,26 +296,34 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, } } -void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode) +void helper_dcbz(CPUPPCState *env, target_ulong addr) { - int dcbz_size = env->dcache_line_size; - -#if defined(TARGET_PPC64) - /* Check for dcbz vs dcbzl on 970 */ - if (env->excp_model == POWERPC_EXCP_970 && - !(opcode & 0x00200000) && ((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { - dcbz_size = 32; - } -#endif - - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); + dcbz_common(env, addr, env->dcache_line_size, + ppc_env_mmu_index(env, false), GETPC()); } -void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode) +void helper_dcbzep(CPUPPCState *env, target_ulong addr) { dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); } +#ifdef TARGET_PPC64 +void helper_dcbzl(CPUPPCState *env, target_ulong addr) +{ + int dcbz_size = env->dcache_line_size; + + /* + * The translator checked for POWERPC_EXCP_970. + * All that's left is to check HID5. + */ + if (((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { + dcbz_size = 32; + } + + dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); +} +#endif + void helper_icbi(CPUPPCState *env, target_ulong addr) { addr &= ~(env->dcache_line_size - 1); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0bc16d7251..9e472ab7ef 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -178,6 +178,7 @@ struct DisasContext { /* Translation flags */ MemOp default_tcg_memop_mask; #if defined(TARGET_PPC64) + powerpc_excp_t excp_model; bool sf_mode; bool has_cfar; bool has_bhrb; @@ -4445,27 +4446,29 @@ static void gen_dcblc(DisasContext *ctx) /* dcbz */ static void gen_dcbz(DisasContext *ctx) { - TCGv tcgv_addr; - TCGv_i32 tcgv_op; + TCGv tcgv_addr = tcg_temp_new(); gen_set_access_type(ctx, ACCESS_CACHE); - tcgv_addr = tcg_temp_new(); - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbz(tcg_env, tcgv_addr, tcgv_op); + +#ifdef TARGET_PPC64 + if (ctx->excp_model == POWERPC_EXCP_970 && !(ctx->opcode & 0x00200000)) { + gen_helper_dcbzl(tcg_env, tcgv_addr); + return; + } +#endif + + gen_helper_dcbz(tcg_env, tcgv_addr); } /* dcbzep */ static void gen_dcbzep(DisasContext *ctx) { - TCGv tcgv_addr; - TCGv_i32 tcgv_op; + TCGv tcgv_addr = tcg_temp_new(); gen_set_access_type(ctx, ACCESS_CACHE); - tcgv_addr = tcg_temp_new(); - tcgv_op = tcg_constant_i32(ctx->opcode & 0x03FF000); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbzep(tcg_env, tcgv_addr, tcgv_op); + gen_helper_dcbzep(tcg_env, tcgv_addr); } /* dst / dstt */ @@ -6486,6 +6489,7 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->default_tcg_memop_mask = ctx->le_mode ? MO_LE : MO_BE; ctx->flags = env->flags; #if defined(TARGET_PPC64) + ctx->excp_model = env->excp_model; ctx->sf_mode = (hflags >> HFLAGS_64) & 1; ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR); ctx->has_bhrb = !!(env->flags & POWERPC_FLAG_BHRB); From patchwork Fri Jul 19 01:07:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813368 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545118wro; Thu, 18 Jul 2024 18:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJQg++jpdvdJfckWF+CMmRFL1sEstk8B8r8ejvRA8gy9CliJF9iLm3P9xWHt6K/loH13NWabQFVg8PxpuduFCf X-Google-Smtp-Source: AGHT+IGnSqqrW0p0iDHxld/eG41X3pFGTpf0jjSFhVFB4ZR8CwfNrTY4AQQr0TYqWscLi07aqRRW X-Received: by 2002:a05:622a:c6:b0:43d:f946:faed with SMTP id d75a77b69052e-44f96a56a95mr34549541cf.26.1721351361241; Thu, 18 Jul 2024 18:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351361; cv=none; d=google.com; s=arc-20160816; b=c7p0xtxuvGXLtVrgC0nC3SLMj1ZcjUmtuvofu4Unv1eWsMI/j7xLC829AaSMJcaejd IA128J2qFScZcvhhOHy5IUGxgQXqzirSDYHA/xhLDp4/w9EcZYM6lzEKzNBl8hTCaj5e p0P+g7bOAiP2qXkTmcu/3x7jFYnWJ2TX0jM44FabMRLzMhnJeTJH9e8FM0aeF08kNtMw EwBBRNRAvTmKfwZ65YvT11YusUxs+UgYsfiza9Gh+jkEpKtWyLKOxRUr+xs28pd0aHN8 YCbQU9lSC/TmzvSWZ0ZkqA2MhCUCPHztgjWqw2SpxhEcV2uhteF9y1xc1O2FjMzh/BFC wmPg== 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:dkim-signature; bh=qvZQYGxfhFbqPHPcUgtNXtbdH2OSgyvIGjZjBPS5VAI=; fh=/Slz4xbUrbq3y08cw9sY58k/LHu7k+IMs9GTwVwwc7g=; b=n7m7McmXYf25DXd9LrGFFEO9paU1NLWDXMoiqcQdyJKoLGQUJJPHAZaZvd3Gkyii/M He5jt70puN4x0dYzEBZUI22XkfOyvvo6zlf1/E4YGUuhFUN/TEpygW5jVVxpEmpydBi8 pRT1dzMC+Mi0FPd8e+eC5WCVI+QoiWG5kWcC64/4YNXbWqHMYI7u/JqZ/jiO+eT5R4IQ 35+IcVy1viWYxEfrvFIv5PEpKEtc1sBx3revK/xShGBvJxzo2BXeC/5nNhlkOmhWlOzQ EBBx5QESHVDU8u0q8/YVhFGAQSPlglnKIgK3NHnfAac8R1QBYHIUTj3rjoZeMEydlz3n StcA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qp/x/VGL"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf05327si4245811cf.658.2024.07.18.18.09.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:21 -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="Qp/x/VGL"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6c-00053Q-GX; Thu, 18 Jul 2024 21:08:19 -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 1sUc69-0003iK-70 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:50 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc62-0000q6-HH for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:45 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fc49c1f3e5so13757575ad.1 for ; Thu, 18 Jul 2024 18:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351260; x=1721956060; 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=qvZQYGxfhFbqPHPcUgtNXtbdH2OSgyvIGjZjBPS5VAI=; b=Qp/x/VGLybP0vyIxTGb+r6mCd8Zl1fLG16iE0QcK4JmBKN5F24wtlZheYeBmIPTRjY v/IbZg2QjfsBMlGy0PYxigUJ6omZ7p6r63vu9fsvRNuCzkVBHHsRScu71i/pVn1OkNli yplbRVXDp7dogSEip9DRDUyyHsLB4MMZQnIUTngy4GT0Rj3OqoyOuegjrycyecIE6P52 4HKKUS7E74uTm+JdQgmGGUbvtcV8G99zjSGGXsCVaUcnsPWl8MSmDmVwBBeyos/aOvwK KIB2Y/tBFSixOxG1Qga/9xtck5ksgZUNkWPUPdhe216BZf7mKRS1pzdkjbBC+N7zcVUy PGsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351260; x=1721956060; 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=qvZQYGxfhFbqPHPcUgtNXtbdH2OSgyvIGjZjBPS5VAI=; b=fgl2bOEVJti3gRCY6A8BKMeymdMmOMhobLnPOrimCjabWhZHhWTSaEoTyb+mRuhduM +nUfhRyl3fPzPMzw33vsUblEk2MuzawYMoCptvOAGMIkjXG+4MyXk+cda3ZNATGanVCQ xP6nA3oLuSInvI1hHC+pjb6LsRaHkk1PuEihLDqd0LADusiB7OGuLP7Jy2CJ3Zqh//oU 4+GkT0/C9bb3Po4oEfDxqlbGrJ3hgBXW4BglB+GaQuy3Phxjysb0KWjigBe5gNCleQF2 nv8Nm9X5jXySvkOO41JSHsgVChBVhhT6Wn/RGnaMTck2/T+qHR/p8QL/EOavIiDEWAag +wMw== X-Gm-Message-State: AOJu0YxiwN8ETFSPKLUCKqmcigJ1Gv3Y0vTbzPBdtLtg/tkKyO4eI4MZ g92WeV4NIPDwp5Ona8jbclkz4hWEBoYU+zSa0uC0+gOuXzmfYAw26+OH5cGrTX/hoP9v3g2cAEs MiWUxpA== X-Received: by 2002:a17:903:2451:b0:1fb:57e7:5bab with SMTP id d9443c01a7336-1fc4e16191fmr52789145ad.36.1721351259904; Thu, 18 Jul 2024 18:07:39 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Nicholas Piggin Subject: [PATCH v3 07/12] target/ppc: Merge helper_{dcbz,dcbzep} Date: Fri, 19 Jul 2024 11:07:02 +1000 Message-ID: <20240719010707.1319675-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Merge the two and pass the mmu_idx directly from translation. Swap the argument order in dcbz_common to avoid extra swaps. Reviewed-by: Nicholas Piggin Signed-off-by: Richard Henderson --- target/ppc/helper.h | 3 +-- target/ppc/mem_helper.c | 14 ++++---------- target/ppc/translate.c | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index afc56855ff..4fa089cbf9 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -46,8 +46,7 @@ DEF_HELPER_FLAGS_3(stmw, TCG_CALL_NO_WG, void, env, tl, i32) DEF_HELPER_4(lsw, void, env, tl, i32, i32) DEF_HELPER_5(lswx, void, env, tl, i32, i32, i32) DEF_HELPER_FLAGS_4(stsw, TCG_CALL_NO_WG, void, env, tl, i32, i32) -DEF_HELPER_FLAGS_2(dcbz, TCG_CALL_NO_WG, void, env, tl) -DEF_HELPER_FLAGS_2(dcbzep, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_3(dcbz, TCG_CALL_NO_WG, void, env, tl, int) #ifdef TARGET_PPC64 DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl) #endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index d4957efd6e..24bae3b80c 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -271,7 +271,7 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, } static void dcbz_common(CPUPPCState *env, target_ulong addr, - int dcbz_size, int mmu_idx, uintptr_t retaddr) + int mmu_idx, int dcbz_size, uintptr_t retaddr) { target_ulong mask = ~(target_ulong)(dcbz_size - 1); void *haddr; @@ -296,15 +296,9 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, } } -void helper_dcbz(CPUPPCState *env, target_ulong addr) +void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx) { - dcbz_common(env, addr, env->dcache_line_size, - ppc_env_mmu_index(env, false), GETPC()); -} - -void helper_dcbzep(CPUPPCState *env, target_ulong addr) -{ - dcbz_common(env, addr, env->dcache_line_size, PPC_TLB_EPID_STORE, GETPC()); + dcbz_common(env, addr, mmu_idx, env->dcache_line_size, GETPC()); } #ifdef TARGET_PPC64 @@ -320,7 +314,7 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr) dcbz_size = 32; } - dcbz_common(env, addr, dcbz_size, ppc_env_mmu_index(env, false), GETPC()); + dcbz_common(env, addr, ppc_env_mmu_index(env, false), dcbz_size, GETPC()); } #endif diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 9e472ab7ef..cba943a49d 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -4458,7 +4458,7 @@ static void gen_dcbz(DisasContext *ctx) } #endif - gen_helper_dcbz(tcg_env, tcgv_addr); + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(ctx->mem_idx)); } /* dcbzep */ @@ -4468,7 +4468,7 @@ static void gen_dcbzep(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_CACHE); gen_addr_reg_index(ctx, tcgv_addr); - gen_helper_dcbzep(tcg_env, tcgv_addr); + gen_helper_dcbz(tcg_env, tcgv_addr, tcg_constant_i32(PPC_TLB_EPID_STORE)); } /* dst / dstt */ From patchwork Fri Jul 19 01:07:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813370 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545156wro; Thu, 18 Jul 2024 18:09:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXsKvh15VE0u6xyWy9O4A4FXp1xb0tRvj5qB1PXZkdZW6yAC4VhCmNeEVZMBpEwyOmyI+AlTReHmiU2Mo8BjETm X-Google-Smtp-Source: AGHT+IHgpcSX64rEa1d8NUjThS2Y6YGkew58QE4sKrMAcjM+aJPcAEqZQgnAd8S7UZktSg2AhHss X-Received: by 2002:a05:622a:1387:b0:447:f518:283c with SMTP id d75a77b69052e-44f96a8bbb5mr35847451cf.54.1721351367974; Thu, 18 Jul 2024 18:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351367; cv=none; d=google.com; s=arc-20160816; b=TqkoRovWwYOq7x6a6PyqqlZ+x5jJ1tz16Bk/HlYgcsy+4Ga//dXiJNjUP5SBCqYhPg bVCMgu7PQYgo8AQStriHJu1xBSCNWshE0AGKflAnO3xtQFkutY3zem30DUoIwx0lvBZJ Gq2HxD6QuodP6lC5ENP8fjlufSstaPhzdn51LLRwbvVaLqxZs4PehDW9JCZHhX2DB8Ig 0PkSD5iDRdGfN3Bmc0k8gyv//W44Qh40NeEN0nfUXSRsPahXAVGQDHiSMv8vXplIpnZy 802sYLyZK8FmhKsgHAyz5eB3ZcrM4kEkHdNWSK3Boz13GIZSIOc/ofj4kbfPF4tX3opo rEhw== 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:dkim-signature; bh=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; fh=PMD1cJf9IbYeK/VmAJgusCYc7DxmYIcIgC7fGquy+wg=; b=um4xCjixXbTQcZtQva3SpFSi2mCruuyQcEqbvj5QKtwERQH/wwGWzCW537xqYysm87 9B+DJG1d6aS6wZmqmqhV5h6B0Rv/z+8r7MKaIQYTFty6dC/UzCV1y7uWGWdRdcjfk6FM bVVEfDHwmxh4rkgsh1gSv35SOEXhtgLhKSU8S77WMrHBXQVMPduGHD8QP+Az7F8KoV+d xwcxjoLTXzb0T524nCwxMoIG8PMalSSJ3dum8mJezvRjLR0EaRYF91muhM5HDktuTrV9 jIzGo2vnOVazHNDjvN7/NeiqPKJ3llO06Z8zj8Fb8j+EcNpOjfei6HK4K7r36h3vyk2t ZP5w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eHfOuBfx; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf1b395si4473371cf.788.2024.07.18.18.09.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:27 -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=eHfOuBfx; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6j-0005fa-GM; Thu, 18 Jul 2024 21:08:25 -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 1sUc6D-0003xU-Pv for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:56 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc68-0000rX-W8 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:51 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2cb5e0b020eso697091a91.2 for ; Thu, 18 Jul 2024 18:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351263; x=1721956063; 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=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; b=eHfOuBfxlYFntoICqJAcXq1CW+YQXOKEnUwa+sy6LYJu+Ucy9vt/DVX6YtzJbciV78 y2gY/yZ7m5p3rBbPDFqM/ySoXiTu9NvwNtns3t9bbjQH6VFUr4HsQ9ZMrakchGaX7pQp aVLAo7g4f26YvrEt2wH6RFZuyJhKNZo7h0eOFx8gf48wFt+KGvZHHKVIa+1em8g+HZwT p73tF9JayhQP+CnZQFGBIONL3UaljJZ9DRaRUjrALkzZ02xBKbBpy1s0C6YLKTLSosHe /1CFllgV+7pUuWSrejhDJc6tNjOua0X3iFtmuOckiBhp9EwlbOKwVhQufnthzSej79I9 hJ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351263; x=1721956063; 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=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; b=PCmnzCzKg2t+H4c7I5MEcUUKrzIp+UZNFP/9owkK0JlhWSMklH6a2SVlHFoQDjo6st W097gn5kr+MkZCq9QpFbxD0elLMNzfGgfCM2LN9Nj6ZACNT6BEqU1HJcKWthld6wTDCe kz0TrtfbO2uRLYaUK1ENngFbQo+4Ku6yvCTn+tvlHueFj0hn2P1xd1ErjhsPav+0hRl5 MEgLCRhYfS+dtBVWf+teApcKqnV9X2zMQ4UVJnb8uiZJ9OjvsRXzjiWeWCNrQSWfZyI+ 946FkeFH0oLhQzqljymai7Tl+rYkzZD8+05cHDTRnkRa3PmvtZD3ogtpgIflLpBUli4C C6TA== X-Gm-Message-State: AOJu0Yz9cBvrAn6njDANdp6GUTgNoFhxHEEGfaNOk5WTtl0CT0mQu7hF Xwo8a+QHQYmNVg2WMnSGoHdK7xNa9E1oJYzCaKaG7yPh/BBP8TX3N7FuXxBPEpSmg/kKyMJKDEQ gkg7UWQ== X-Received: by 2002:a05:6a20:7f93:b0:1c0:f2ee:7dc0 with SMTP id adf61e73a8af0-1c3fdddca31mr7468239637.55.1721351263037; Thu, 18 Jul 2024 18:07:43 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 08/12] target/ppc: Improve helper_dcbz for user-only Date: Fri, 19 Jul 2024 11:07:03 +1000 Message-ID: <20240719010707.1319675-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Mark the reserve_addr check unlikely. Use tlb_vaddr_to_host instead of probe_write, relying on the memset itself to test for page writability. Use set/clear_helper_retaddr so that we can properly unwind on segfault. With this, a trivial loop around guest memset will spend nearly 50% of runtime within helper_dcbz and host memset. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/ppc/mem_helper.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 24bae3b80c..953dd08d5d 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -280,20 +280,27 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, addr &= mask; /* Check reservation */ - if ((env->reserve_addr & mask) == addr) { + if (unlikely((env->reserve_addr & mask) == addr)) { env->reserve_addr = (target_ulong)-1ULL; } /* Try fast path translate */ +#ifdef CONFIG_USER_ONLY + haddr = tlb_vaddr_to_host(env, addr, MMU_DATA_STORE, mmu_idx); +#else haddr = probe_write(env, addr, dcbz_size, mmu_idx, retaddr); - if (haddr) { - memset(haddr, 0, dcbz_size); - } else { + if (unlikely(!haddr)) { /* Slow path */ for (int i = 0; i < dcbz_size; i += 8) { cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr); } + return; } +#endif + + set_helper_retaddr(retaddr); + memset(haddr, 0, dcbz_size); + clear_helper_retaddr(); } void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx) From patchwork Fri Jul 19 01:07:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813369 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545120wro; Thu, 18 Jul 2024 18:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXCy0MX2gBoRpoywpBtOUPxN21Ct+hKHbFvSnIPA2X3hCN/UvQu5gx6o1Eib6FUxpuxMq2QlSGzuG8MiDtoemQ X-Google-Smtp-Source: AGHT+IGGyLntRVdEwKNLMsPlnbRazIBvEvd4J57x5m7wz2r4PxDc8I4nDS0NwAANNPnYcDca8hwZ X-Received: by 2002:a05:6214:481:b0:6b5:d7a1:ead7 with SMTP id 6a1803df08f44-6b78ca9cbdcmr75008416d6.14.1721351361449; Thu, 18 Jul 2024 18:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351361; cv=none; d=google.com; s=arc-20160816; b=ojs5eJVZTOfu7+EkgcpX4Hw6ULjicqo0YYklx8yuHTF4mztOfsNQnUp41Boxs04ILY 0E1lQHeWqp9Zwd6+GiAcIwUkZQoDZe+c52ZSbwLW0KMnU/91cL1qbFS/T3/PoF/R9Nt0 Quky9KCn1PNJHm10RRCJammsJyfUL1+mQ88yd/y8EnMZ0act1uA+hfGCS3qmIXLDiJRD J5CEz0QI07+QHoRpwbLpgPYYUdOrzMR+GiLKLWAFOlemC7TFur8Lj9wvIPABOYRVtbU7 ACrgBb2Fv6Z64AD3e+KJvEuk02DB6IhvrlqIyKFidyzBP5nGs5G5Y8QFd9wlyhvmKYDt A6rw== 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:dkim-signature; bh=0Aw83kLLuGjCQHx2MdR2LGZJ7cF9lloOkwjusYN+Kq0=; fh=qjFy40K+ZQaomz0djLvfgk0/gq57yB0/W8d5nzdAVZA=; b=FwNVm9ilAkKjS345sthwWv0RZDj2uKCDT6zBFGlFzZOukyN/EBtO+Sx7A/VrjK/dDQ xi366YTHQgn4fhqcY09tUviRUcv9GQ5DmOnGfLS3C9oO5w05mZT67lR/EuzsCySM0ebb IF48pC+2GmiwW8rc/e0RI7CY8+NnUBdzd+J+DGNYsyJQoStV3BS1gnxeJOcdBY+QvZWE bbQF/bLw3RrP28vyghtaXKRvg8AwfP0ctk5bTUugOmomzfBLbWTPlsiG/piEhR1VSI9S RdKm0BF9E3bEke16MzTgCx7tVWbFPpTbjVN7rNmQ07Ed4ckCxkLnnMA9VlaMny6R/6g1 lH5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xnq1hW9U; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac999987si4084746d6.220.2024.07.18.18.09.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:21 -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=Xnq1hW9U; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6n-0006D3-AD; Thu, 18 Jul 2024 21:08:29 -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 1sUc6D-0003xA-NM for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:53 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc6A-0000sO-5h for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:52 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-6e7e23b42c3so944884a12.1 for ; Thu, 18 Jul 2024 18:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351267; x=1721956067; 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=0Aw83kLLuGjCQHx2MdR2LGZJ7cF9lloOkwjusYN+Kq0=; b=Xnq1hW9U8AKohHX1kvqaD9LobrReHnOJ2YqtRWPqzKSs5wf8RcSywsG83TOfNa2YvO 7OY2p2Ma9au4xVzohyukefYYfrvm5suQ1aAET8T/ZB2bnXjaXWoeP1PxLxIt90whmXrG l11PjIZPsWsVK40JaMY8m0UxddI/RulehRKdokvQFFglprgiDP4HXSR+mbxgGcnikkGJ rf3L1hDd8cgM7d4c2b5yWCscCJdCfAzOTm9CisDT6KgqK0tc5at76y35efAHsqtR9lJq L1OJfxyujNh5rbTZFGLa2jYv2cIPqc7cDkGRwrhUq5hBxcxT9olSIPnfCxG/fkm0oPED UVZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351267; x=1721956067; 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=0Aw83kLLuGjCQHx2MdR2LGZJ7cF9lloOkwjusYN+Kq0=; b=sygcxegZnd6dhQt/QTGMX09YYUine9N1m30OCtbuzlj4Gr7F0Z44tri+bBV/HqKa7H MRNCv2tHPvgYsSOpgngBcFbG0+UCSXy6YotcuYWV+EQE4g4YfYVg3sYdmSZ3WZKcxTmH EwOWr4gjP859ly9amSq6FOzCvzJF8JZDWRo86PsyoXkP6CupqVTMKZLezyD1fF7OHDIz CGkcVhWXU5t4w3pZoVQtybOXN9mOsG7YV0mzW6Jrbfv+xGNlQoMpkma8ciK7Or3rH2BP +C4WG7cXk3dfQKkJgcqcAJdnAWeNchG1JI4laB3qS+QRALRjG3ZEW9JoEg9Y5kLMhNDB 1p6g== X-Gm-Message-State: AOJu0YzgoTjRI5ylVgugWIgb0Eeq0XwbxbfEyOClCruRs8hb+jiLXgsP GhjAxmYbVyBErn4uDRpoTnfthgYvlvcyMkP54fJ3Vkx9LD+4yqIOCUszSYRFvHeKUFkaKY3JpgI MlD+QNA== X-Received: by 2002:a05:6a21:99a0:b0:1c4:17e1:14df with SMTP id adf61e73a8af0-1c417e116f0mr1350522637.48.1721351266616; Thu, 18 Jul 2024 18:07:46 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Peter Maydell Subject: [PATCH v3 09/12] target/s390x: Use user_or_likely in do_access_memset Date: Fri, 19 Jul 2024 11:07:04 +1000 Message-ID: <20240719010707.1319675-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Eliminate the ifdef by using a predicate that is always true with CONFIG_USER_ONLY. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/s390x/tcg/mem_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 6cdbc34178..5311a15a09 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -225,10 +225,7 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, uint8_t byte, uint16_t size, int mmu_idx, uintptr_t ra) { -#ifdef CONFIG_USER_ONLY - memset(haddr, byte, size); -#else - if (likely(haddr)) { + if (user_or_likely(haddr)) { memset(haddr, byte, size); } else { MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); @@ -236,7 +233,6 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, cpu_stb_mmu(env, vaddr + i, byte, oi, ra); } } -#endif } static void access_memset(CPUS390XState *env, S390Access *desta, From patchwork Fri Jul 19 01:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813365 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545078wro; Thu, 18 Jul 2024 18:09:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcEQn3bfGh2CdBsdZnv7k99Xls5O4+4mANOhi7gZjqSPRougYV4eb7wptvcQXm1wGAXoCUtPLFQTyPMqWTNj9r X-Google-Smtp-Source: AGHT+IG0gP3AiwcOyedEB+FFfMENoJ6bu6AeAb50ykegHwSWvcwAdFBTcGqHJoDdXn+wXjcOueUv X-Received: by 2002:ad4:5764:0:b0:6b5:e006:11b0 with SMTP id 6a1803df08f44-6b79c56c64dmr57520196d6.20.1721351354271; Thu, 18 Jul 2024 18:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351354; cv=none; d=google.com; s=arc-20160816; b=H9sAPmmPohYRg3y2W8ygsPxoOAB6FC74qWC6JaCH/HeTCiFp29R8sTAiLeS13eh6xb HBnagKO+qER4qPBB/qzK1G7PrVR2P5HtSBu5ELiW7WUjwl/HGl8a15uCUtrgbFUP0y6B TVbKSWVFbFr6jYw19IrEZH5vyBxUalwILM6/QNf1N33L/4vMS4lr7WRLtWC+hX30+Zvt KucaOGgwAo0FaKX/iC0nHhEg+RwYWV6H4yDNtamCWlY4+7dgFwp7z3sHBPC7JV69fV29 AcRNzKZiQ4fucGQmuUzgo52b225DAUxGwWREEpYnMlAljjnuM4NLZB2F+ZTZ8rs7IXOO claQ== 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:dkim-signature; bh=xqmmPMBGBkj8EkL2sBghBJ5bQR2DDW9j3L8Pj6+n++Q=; fh=PMD1cJf9IbYeK/VmAJgusCYc7DxmYIcIgC7fGquy+wg=; b=J3LHyAC8LQOHtv0Rlku6UlI8bWsqWlTxKnip5evlTvejH3VAtFJ52LQb4NJcSM8Hi0 Iddw+YP7ZABWOZnKIZrgXMFdKTjCccLSfyBVxxKQuOH7amhLr0TVXas/XZ6iQk0B+lkx GOZMvZnhlTnfu4dEseoU0FSMqGfDXQ12SjxPXBOZEaDw/mBeVEeBe+c7uPK0x0UeBJfI IBx4HGP5iv6EPf8ONUEUkD0UcQWr7IMF4aOBK2RMK3Y+x6IOJ1nadb+TTUXKtjvsSzvj Ms+cXa2GID6VVtJgGUztwoNBUqcmW9jfOCyhooPAUSufHlsF+Kksf4g71hcO6TTI4haB fmrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUzvaTX5; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf19482si4253171cf.773.2024.07.18.18.09.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:14 -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=yUzvaTX5; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6k-0005nV-Gf; Thu, 18 Jul 2024 21:08:26 -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 1sUc6F-00047L-L8 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:08:04 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc6B-0000tr-Cd for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:54 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fc611a0f8cso9825165ad.2 for ; Thu, 18 Jul 2024 18:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351270; x=1721956070; 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=xqmmPMBGBkj8EkL2sBghBJ5bQR2DDW9j3L8Pj6+n++Q=; b=yUzvaTX5AVJHx5ho1YSJXenhVWf/8ZRR/bJgKGxfnvZMom07oXG+bu+TX3GrTkUsDO V+2TwwJx62tMXO9q4EtRzmfjxk0WMhie4YhN5NIKqk6nbjTxDg9GoYRBMAfAhutRinS1 ToKnceAsGpZ5Prnp1rUtTeS+uFP11QtpPjLrpeMPi8RSmGlLl2f8favFu6H2yz9S1SO8 Dyk10r1l7Q0zDRgagw0jUGyFfZlVEpabo04gb6BkPqRdBu8yP10847r1GJMaYEQJxnVk aDoxSCPlNYpOo4sfoyimekos0FD8zQFDKzMt+EdnOkbg+ANQ5ZprXKstuwwPZufETJX7 m37g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351270; x=1721956070; 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=xqmmPMBGBkj8EkL2sBghBJ5bQR2DDW9j3L8Pj6+n++Q=; b=W6BPBqxOz2oNxM2qzAF7v2+rQb8FFX1YRsDE6UN6k5Ed/1fE2mBdhkQrq8HsliCCt/ Xhc9mvBkU6P9F5W1+OPWmjnYm4zfnRnlaOoskmBVMqNcB4OkS8oa4f3zoiNvpIeymVQq /L1gIrtMcSoQYwHDrtOeFBN46vVUmp6svDE2rbTKPKWqJcwPstwBPZz3ANFHwDxoh3Ad ZhQTBl4ojEHn+3BqfqUN6V3F3sw/xKFPlND27+1Z2Lm6ss5iU6d5Gm6astB3eLXRw5X3 pfoidLGctEWY1RVkDD93Ji+4WVW84+7sS3cu3+Zy0Ge2YRWecQCzIB6oiHz1CsWghN5g Kl6A== X-Gm-Message-State: AOJu0YyAW12CZJTRs5uEuLLXow0Bzv8dA2UGpvSjkJSX14j3SwrYTNIF jphGAIW1aBw/2vd9KDk0WVmsB71m3B8VsH/ICb5sExJUTDrAtqoJhPXVrDpHNnG0N2T/9REOGfE zhvtvKg== X-Received: by 2002:a17:902:e751:b0:1fd:6677:69b4 with SMTP id d9443c01a7336-1fd66776de8mr1859415ad.49.1721351269676; Thu, 18 Jul 2024 18:07:49 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 10/12] target/s390x: Use user_or_likely in access_memmove Date: Fri, 19 Jul 2024 11:07:05 +1000 Message-ID: <20240719010707.1319675-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Invert the conditional, indent the block, and use the macro that expands to true for user-only. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/s390x/tcg/mem_helper.c | 54 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 5311a15a09..331a35b2e5 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -296,41 +296,39 @@ static void access_memmove(CPUS390XState *env, S390Access *desta, S390Access *srca, uintptr_t ra) { int len = desta->size1 + desta->size2; - int diff; assert(len == srca->size1 + srca->size2); /* Fallback to slow access in case we don't have access to all host pages */ - if (unlikely(!desta->haddr1 || (desta->size2 && !desta->haddr2) || - !srca->haddr1 || (srca->size2 && !srca->haddr2))) { - int i; + if (user_or_likely(desta->haddr1 && + srca->haddr1 && + (!desta->size2 || desta->haddr2) && + (!srca->size2 || srca->haddr2))) { + int diff = desta->size1 - srca->size1; - for (i = 0; i < len; i++) { - uint8_t byte = access_get_byte(env, srca, i, ra); - - access_set_byte(env, desta, i, byte, ra); - } - return; - } - - diff = desta->size1 - srca->size1; - if (likely(diff == 0)) { - memmove(desta->haddr1, srca->haddr1, srca->size1); - if (unlikely(srca->size2)) { - memmove(desta->haddr2, srca->haddr2, srca->size2); - } - } else if (diff > 0) { - memmove(desta->haddr1, srca->haddr1, srca->size1); - memmove(desta->haddr1 + srca->size1, srca->haddr2, diff); - if (likely(desta->size2)) { - memmove(desta->haddr2, srca->haddr2 + diff, desta->size2); + if (likely(diff == 0)) { + memmove(desta->haddr1, srca->haddr1, srca->size1); + if (unlikely(srca->size2)) { + memmove(desta->haddr2, srca->haddr2, srca->size2); + } + } else if (diff > 0) { + memmove(desta->haddr1, srca->haddr1, srca->size1); + memmove(desta->haddr1 + srca->size1, srca->haddr2, diff); + if (likely(desta->size2)) { + memmove(desta->haddr2, srca->haddr2 + diff, desta->size2); + } + } else { + diff = -diff; + memmove(desta->haddr1, srca->haddr1, desta->size1); + memmove(desta->haddr2, srca->haddr1 + desta->size1, diff); + if (likely(srca->size2)) { + memmove(desta->haddr2 + diff, srca->haddr2, srca->size2); + } } } else { - diff = -diff; - memmove(desta->haddr1, srca->haddr1, desta->size1); - memmove(desta->haddr2, srca->haddr1 + desta->size1, diff); - if (likely(srca->size2)) { - memmove(desta->haddr2 + diff, srca->haddr2, srca->size2); + for (int i = 0; i < len; i++) { + uint8_t byte = access_get_byte(env, srca, i, ra); + access_set_byte(env, desta, i, byte, ra); } } } From patchwork Fri Jul 19 01:07:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813373 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545332wro; Thu, 18 Jul 2024 18:10:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWTTnXRkLz8LOGDWTKegM6Z+yKLFTwTQHE4EVUtK92a5gcBHOapAa1qVFXBNVH5mA5yBNLZQtVkZePLyMFH/3iS X-Google-Smtp-Source: AGHT+IHR+2J8hhnYfxA9PpN6B2btz6qbbD7Mu8sp2b/BHGLB63TgErPKLILhHtozD3NvTbmvg/7M X-Received: by 2002:a05:620a:29d2:b0:7a1:456b:fd43 with SMTP id af79cd13be357-7a193923669mr336221785a.37.1721351403826; Thu, 18 Jul 2024 18:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351403; cv=none; d=google.com; s=arc-20160816; b=lzhQ2eX6kEEncdLTSBBAJkCqsx6AkqdIzSIryjfGlSdiHT8HlwtPhoNeJa3N9a/oLB KnyKwwuqk/ccq4UMZw5WlcEqyPHRIZcHlgBzcrj5qQJXU3+xbBsQjej3hhRtvK1y5GJz ujNMaJxFeJ26OsLa/lNf5PHlVtKVOhRd7scaYrO6+aNw9hCEsjWB+NKfV7Oj62X5Sc7P 8FbqjD3LqkOWMVGRWYfSCOztBFw8vypoTHMd4+L7AeY+k1WHQs+mD+T5nt/+TRHkdgZO aR58QtQXz0lOi8LkwWr2hz4DBkr3MeOj5Qiuko//T0TMwOEKYuOWaus7r+6wxVjAkvP0 rz1g== 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:dkim-signature; bh=we9LurCnVs1ZjMT75ahcYUh77trqQXlGLoe9LPxQn/4=; fh=PMD1cJf9IbYeK/VmAJgusCYc7DxmYIcIgC7fGquy+wg=; b=iZD3PzJXsGsuA9JXIUOgIlz45NPhGh7Sq4iC3YOsIH3T2BPQiP5eddrcK1ijMp5wNv sbpMeSJE1N2ElAV3kCSDiBau/XGf56IaVXr7fqOIfuQLT3e/I46hLZdE0vT8NiC0z8xH jO6I/oEZSPMZRHbxRKiL1tjz+UHZCNraqHK2Erl3QfO2xyMNEg1KaVT04Ome6hZ3TwyC +usBsYbWgMsj4S9fEFtEZf6dq5HCbXtGLpZ/PTwwuuhON8kMgRDSh84EfmdiE2toS4Gi CO2zHhvz+WRIArtdnU6gcPFUIU1D4OFXbEQ1YeU6w5SswKEx3sxvYWYRhx0Werp6uT8P hJZg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dLl5tQZR; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19906c7besi48896185a.473.2024.07.18.18.10.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:10:03 -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=dLl5tQZR; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6m-00062s-D6; Thu, 18 Jul 2024 21:08:28 -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 1sUc6J-0004F3-S1 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:08:05 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc6F-0000v9-Bp for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:57 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-793a3a79a83so1038382a12.3 for ; Thu, 18 Jul 2024 18:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351273; x=1721956073; 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=we9LurCnVs1ZjMT75ahcYUh77trqQXlGLoe9LPxQn/4=; b=dLl5tQZRDkqakOwlu3riUvpoq+XUuiGzcxqs4hNBKym2Ff7/saOuUXRWHEw2TkS/0k i2E5l1YTT/Ri8ylUbQSF9xwpy9uF5R+oeNWUpOmefvSGnOwGuRJIXWcbtN3w7iLKC5L8 Rog7n58S2M4eKyUJ/Dcu0Ky0rvm2cE4n4AlyQsuAAQirpwhcHk3Di10Kgv7jBE0GtOTP HF5DFK32wjx/pKvSd7xqc1hR9q4fMT8kJ+wRsWpMAqWKOAISqJ3AHbljpC5qt/KeD/0L sn2dVU/cQ7C+5SMeflymtTS5cMJtagy+sJikdnNb3ccXaZKEoGdkfwP6ccubyszcBJdB vBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351273; x=1721956073; 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=we9LurCnVs1ZjMT75ahcYUh77trqQXlGLoe9LPxQn/4=; b=GiYNzupRCyOk6mLwd+bKQYYz5q4uRltk/8aZy0B5cRig5Iqhx54LkWKfUONu3Q/M1c 82APD2aHCjhfWmgUNpd/TBzyc7HYhzn8WGij/DIJhqYwMpLTHoNCmja0sldK0dWwHsSy i/WiaMwszl+Bdh0UdMwGR+Irf5E6+2vAmtFE99FiPC8qiwSsjYBl0VFJkVRdfYyzwYGI JpF2xRAO9M2W1llBUdyTIlcFKttW5ILMWSnz2IBErXCFON3Hcr/xXxhYGn3pxd+PuF7l lZwvIBQ2aMQjXc/zOsTScGXd6ELILKkLbKsGG5PDbOXDmNZ+lCoeQjZ2nU3vTHH1V1yl mINg== X-Gm-Message-State: AOJu0YxdOgyA3VbiZpCNoaAQ8qx3pax7Up/WS6W76L50dmb3XCFqs7QC k6bxxwZcXsdoBMY8iy8O5Tyh4X/OFELmhW66oPLrUREcBsZK3b3j6Iq3LP8CdpwWWievDWbGb0w ZE6lkzg== X-Received: by 2002:a05:6a20:c797:b0:1c0:e728:a99e with SMTP id adf61e73a8af0-1c3fdcc6affmr7325553637.26.1721351273002; Thu, 18 Jul 2024 18:07:53 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 11/12] target/s390x: Use set/clear_helper_retaddr in mem_helper.c Date: Fri, 19 Jul 2024 11:07:06 +1000 Message-ID: <20240719010707.1319675-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 Avoid a race condition with munmap in another thread. For access_memset and access_memmove, manage the value within the helper. For uses of access_{get,set}_byte, manage the value across the for loops. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/s390x/tcg/mem_helper.c | 43 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 331a35b2e5..0e12dae2aa 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -238,14 +238,14 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, static void access_memset(CPUS390XState *env, S390Access *desta, uint8_t byte, uintptr_t ra) { - + set_helper_retaddr(ra); do_access_memset(env, desta->vaddr1, desta->haddr1, byte, desta->size1, desta->mmu_idx, ra); - if (likely(!desta->size2)) { - return; + if (unlikely(desta->size2)) { + do_access_memset(env, desta->vaddr2, desta->haddr2, byte, + desta->size2, desta->mmu_idx, ra); } - do_access_memset(env, desta->vaddr2, desta->haddr2, byte, desta->size2, - desta->mmu_idx, ra); + clear_helper_retaddr(); } static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, @@ -366,6 +366,8 @@ static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + set_helper_retaddr(ra); + for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca1, i, ra) & access_get_byte(env, &srca2, i, ra); @@ -373,6 +375,8 @@ static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, c |= x; access_set_byte(env, &desta, i, x, ra); } + + clear_helper_retaddr(); return c != 0; } @@ -407,6 +411,7 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest, return 0; } + set_helper_retaddr(ra); for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca1, i, ra) ^ access_get_byte(env, &srca2, i, ra); @@ -414,6 +419,7 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest, c |= x; access_set_byte(env, &desta, i, x, ra); } + clear_helper_retaddr(); return c != 0; } @@ -441,6 +447,8 @@ static uint32_t do_helper_oc(CPUS390XState *env, uint32_t l, uint64_t dest, access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + set_helper_retaddr(ra); + for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca1, i, ra) | access_get_byte(env, &srca2, i, ra); @@ -448,6 +456,8 @@ static uint32_t do_helper_oc(CPUS390XState *env, uint32_t l, uint64_t dest, c |= x; access_set_byte(env, &desta, i, x, ra); } + + clear_helper_retaddr(); return c != 0; } @@ -484,11 +494,13 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint32_t l, uint64_t dest, } else if (!is_destructive_overlap(env, dest, src, l)) { access_memmove(env, &desta, &srca, ra); } else { + set_helper_retaddr(ra); for (i = 0; i < l; i++) { uint8_t byte = access_get_byte(env, &srca, i, ra); access_set_byte(env, &desta, i, byte, ra); } + clear_helper_retaddr(); } return env->cc_op; @@ -514,10 +526,12 @@ void HELPER(mvcrl)(CPUS390XState *env, uint64_t l, uint64_t dest, uint64_t src) access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + set_helper_retaddr(ra); for (i = l - 1; i >= 0; i--) { uint8_t byte = access_get_byte(env, &srca, i, ra); access_set_byte(env, &desta, i, byte, ra); } + clear_helper_retaddr(); } /* move inverse */ @@ -534,11 +548,13 @@ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) src = wrap_address(env, src - l + 1); access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + + set_helper_retaddr(ra); for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca, l - i - 1, ra); - access_set_byte(env, &desta, i, x, ra); } + clear_helper_retaddr(); } /* move numerics */ @@ -555,12 +571,15 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + + set_helper_retaddr(ra); for (i = 0; i < l; i++) { const uint8_t x = (access_get_byte(env, &srca1, i, ra) & 0x0f) | (access_get_byte(env, &srca2, i, ra) & 0xf0); access_set_byte(env, &desta, i, x, ra); } + clear_helper_retaddr(); } /* move with offset */ @@ -580,6 +599,8 @@ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) /* Handle rightmost byte */ byte_dest = cpu_ldub_data_ra(env, dest + len_dest - 1, ra); + + set_helper_retaddr(ra); byte_src = access_get_byte(env, &srca, len_src - 1, ra); byte_dest = (byte_dest & 0x0f) | (byte_src << 4); access_set_byte(env, &desta, len_dest - 1, byte_dest, ra); @@ -595,6 +616,7 @@ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) byte_dest |= byte_src << 4; access_set_byte(env, &desta, i, byte_dest, ra); } + clear_helper_retaddr(); } /* move zones */ @@ -611,12 +633,15 @@ void HELPER(mvz)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + + set_helper_retaddr(ra); for (i = 0; i < l; i++) { const uint8_t x = (access_get_byte(env, &srca1, i, ra) & 0xf0) | (access_get_byte(env, &srca2, i, ra) & 0x0f); access_set_byte(env, &desta, i, x, ra); } + clear_helper_retaddr(); } /* compare unsigned byte arrays */ @@ -961,15 +986,19 @@ uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) */ access_prepare(&srca, env, s, len, MMU_DATA_LOAD, mmu_idx, ra); access_prepare(&desta, env, d, len, MMU_DATA_STORE, mmu_idx, ra); + + set_helper_retaddr(ra); for (i = 0; i < len; i++) { const uint8_t v = access_get_byte(env, &srca, i, ra); access_set_byte(env, &desta, i, v, ra); if (v == c) { + clear_helper_retaddr(); set_address_zero(env, r1, d + i); return 1; } } + clear_helper_retaddr(); set_address_zero(env, r1, d + len); set_address_zero(env, r2, s + len); return 3; @@ -1060,6 +1089,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, *dest = wrap_address(env, *dest + len); } else { access_prepare(&desta, env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); + set_helper_retaddr(ra); /* The remaining length selects the padding byte. */ for (i = 0; i < len; (*destlen)--, i++) { @@ -1069,6 +1099,7 @@ static inline uint32_t do_mvcl(CPUS390XState *env, access_set_byte(env, &desta, i, pad >> 8, ra); } } + clear_helper_retaddr(); *dest = wrap_address(env, *dest + len); } From patchwork Fri Jul 19 01:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813364 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp544976wro; Thu, 18 Jul 2024 18:08:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUB/3ANWAaYNQArICQFrEPIDOKDQCRYMJkDtCkve97fr5T001wM9xqUqmoY4S3rY6Ya2d/ELNbtLy9Z45CXktnb X-Google-Smtp-Source: AGHT+IHb7tBtiI6lFVpPzaMhcHfl1mbc+FgNgTR2tdzs1Cgi2l0CeSxtID8kvaesYihqpPVCixMP X-Received: by 2002:a05:620a:25cd:b0:79f:bcf:9e6b with SMTP id af79cd13be357-7a1938c4b9bmr305639285a.2.1721351328441; Thu, 18 Jul 2024 18:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351328; cv=none; d=google.com; s=arc-20160816; b=Y1cKRdeRTjSXNXBz6t4uO0ARlb+ZYN+v1PpC6v8M+5K1zlueBblRF/1rLTz+4GwYyz tyqpAcZzJYZj87x2I81Ju7bD34N99QfPpFts5CohvTLUJBDuLwSXD3Yp9m3YFYVgAr4N ECYhtg0qM5rF2zg4lCbMe3hzLLShk/mC6gjiVwo5u+WwNe8CUu/2FFFRyetmDD/DUZf4 sG30ldlHoQcxb3MkmZcJjl0S2jbqfUSTv98Szvn27zNVHtWKMlBXn1brCoc209CpMeyp i+Fymv28yc3kRnHYWtxGMSdn/4ev/DD113KSfSucRP1WY+JXmIw4ZYfLRYYbXpNEcbe2 1kiQ== 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:dkim-signature; bh=wN2PEtP+rz1MoCCGhce/mKwLbs1GmxS63nYc3i7jjaE=; fh=qN53BJayG90QoD48HyNZmoatqRxFsVfNeGAKRdp9QnQ=; b=UncciXtSBiGEjhp+GAod54ncit13cKxI6AAiu9/iXb6oODCWYAXjKsxCijNINsJLWJ gvqH23CwFULDsfX0gCYO+6L7kgtolppUfpwuo6d0bOyQbIdx4J8W2UclvgQr5fKhStci RTCH2MN8mmpDifCX+H2ZFYwaaINS3IA/l61wIGK+sKDxj8O/NHkYt7o2EonnJJF0Jzwq nR5XMxNC4H2TC3CK/CuV/uahe8UYr8NFKghSQKltuEBXnsZEG/GO+ZgLmkNt3pccghzk ZK3J4oyzuKxqHJUKr2CF3jM0wg8kGYZz84K/TpLDYjgzd/itqtobaJkg8NfxQMU94Sib 8Zag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GIS28H9g; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a198f98115si50295685a.87.2024.07.18.18.08.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:08:48 -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=GIS28H9g; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6r-0006jk-K1; Thu, 18 Jul 2024 21:08:33 -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 1sUc6M-0004FZ-Hx for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:08:05 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc6J-0000wG-KI for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:08:01 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-78512d44a13so847489a12.1 for ; Thu, 18 Jul 2024 18:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351277; x=1721956077; 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=wN2PEtP+rz1MoCCGhce/mKwLbs1GmxS63nYc3i7jjaE=; b=GIS28H9gxYaJWBJymaxkuh1fOecsIoYL7Dl83TWmR8h1ntX059QDEKjAv4R9euVO9L 6I0figjFdEWQrkOExWHM/qxVkhUBcTVkXaVkD0BKTA1oa08XqAy6mIzQiRJKUu1JLmq3 ry7nEs1DUwactNHxoT98P6Wvi3PSp0oF4E4mdtma1eb0yT84d2Zm1heG44Cs9P88PHap oreeVqHVSeFR+AS/UbFjpl7vodxP75hkfetUt9WSPdDdkGd6g2JaJoU8C3RQMHXMojLo Q0IeJ7T7HDDHnuzHD31Lr8A+UjNWHE+9ByrhYyn92IuwO3f1nsACi8MX3SmnG6kYHzNZ jDlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351277; x=1721956077; 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=wN2PEtP+rz1MoCCGhce/mKwLbs1GmxS63nYc3i7jjaE=; b=xONqIMvodZ59UtJ23l0QNj7otJ64tQEWriwdkY+YLPdFunD2AzJwGiUaIlZdHtO0FJ OcOlBgI10+OjvR5ULKi5XB6URSPSZfYQWhr5YjDH+Ae3Is7T8EYuQ5yRkywiUG5q3bKz 32hvDfvc9tG1MEjWPHQwK38CQIq8jOSWYzJ6HV2+Jh3Rwg6Tz/m5H9TVhEoqirbYhf35 wxabcLKv4zu5ZRpn6fSBnTzGRnt4fWzOBR1/cSto++KTPM5IYRo/6UBVL9McM16RDecL EHOIpT6lvWLG1S662w+nVvLnGPAmChZ8JtesSGE+t5bYHl5XhLVy4WcMRIfrNANgyZX7 ybyg== X-Gm-Message-State: AOJu0Ywhhu5Ug2XPFBpTzo5JAe/csdYF5pRngWP12JhgyqUIAhYS5DpM YzBOk96X2I/I5ixc2hfBBCjW6pyRIT4X7bMR7jj9lHCBY28XFYAIzR8s2AKIr7YHeohdCCEJXDX Ked5MfA== X-Received: by 2002:a05:6a21:6da3:b0:1c3:a760:9757 with SMTP id adf61e73a8af0-1c3fddf4e40mr9104790637.49.1721351276741; Thu, 18 Jul 2024 18:07:56 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v3 12/12] target/riscv: Simplify probing in vext_ldff Date: Fri, 19 Jul 2024 11:07:07 +1000 Message-ID: <20240719010707.1319675-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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 The current pairing of tlb_vaddr_to_host with extra is either inefficient (user-only, with page_check_range) or incorrect (system, with probe_pages). For proper non-fault behaviour, use probe_access_flags with its nonfault parameter set to true. Acked-by: Alistair Francis Signed-off-by: Richard Henderson Reviewed-by: Max Chou --- target/riscv/vector_helper.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 1b4d5a8e37..10a52ceb5b 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -474,7 +474,6 @@ vext_ldff(void *vd, void *v0, target_ulong base, vext_ldst_elem_fn *ldst_elem, uint32_t log2_esz, uintptr_t ra) { - void *host; uint32_t i, k, vl = 0; uint32_t nf = vext_nf(desc); uint32_t vm = vext_vm(desc); @@ -493,27 +492,31 @@ vext_ldff(void *vd, void *v0, target_ulong base, } addr = adjust_addr(env, base + i * (nf << log2_esz)); if (i == 0) { + /* Allow fault on first element. */ probe_pages(env, addr, nf << log2_esz, ra, MMU_DATA_LOAD); } else { - /* if it triggers an exception, no need to check watchpoint */ remain = nf << log2_esz; while (remain > 0) { + void *host; + int flags; + offset = -(addr | TARGET_PAGE_MASK); - host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, mmu_index); - if (host) { -#ifdef CONFIG_USER_ONLY - if (!page_check_range(addr, offset, PAGE_READ)) { - vl = i; - goto ProbeSuccess; - } -#else - probe_pages(env, addr, offset, ra, MMU_DATA_LOAD); -#endif - } else { + + /* Probe nonfault on subsequent elements. */ + flags = probe_access_flags(env, addr, offset, MMU_DATA_LOAD, + mmu_index, true, &host, 0); + + /* + * Stop if invalid (unmapped) or mmio (transaction may fail). + * Do not stop if watchpoint, as the spec says that + * first-fault should continue to access the same + * elements regardless of any watchpoint. + */ + if (flags & ~TLB_WATCHPOINT) { vl = i; goto ProbeSuccess; } - if (remain <= offset) { + if (remain <= offset) { break; } remain -= offset;