From nobody Thu Sep 19 00:17:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721351368; cv=none; d=zohomail.com; s=zohoarc; b=Ja0WANdXIQcsfGlcKqmFATPF3qPoOM9OPbmiXC9frG4fuGCZSVSb42eDoDwiznTJQTOdmcs2qQ1ZII+j9Y5CCh28jBtQbBlRn5BAjNurZ7i6DV8QYWfd/1r645oKt7MdJ2zhRpiOrGmQ2ezUsic0OsDDA74vlAS6KTKDjeeXYME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721351368; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; b=RvvDKuskWfPcJjSX7q4cuKKiKRK/o8kRAWc8xtJ5wShZ0NtmOkAVRqXoQnFG4I6NZQSXsfCBK+uvDLlXNqF6io/VT+EcV+/UjAWrDpKHSfeTUruuaJN5uBO5iAhXLAUfKnb2jhPadPx1ShjCdh4w6tHWgwKsijn3YvU7bvpQQtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721351368300183.13675251591405; Thu, 18 Jul 2024 18:09:28 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFwEW7dHs6y/yT3OG0IpseYV04+Gr0brN7p14g8wJ2VC2Ff2PwOEO9SC/Rva4EMrV4ScI4RFw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721351369957116300 Content-Type: text/plain; charset="utf-8" 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 --- 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_ulon= g addr, addr &=3D mask; =20 /* Check reservation */ - if ((env->reserve_addr & mask) =3D=3D addr) { + if (unlikely((env->reserve_addr & mask) =3D=3D addr)) { env->reserve_addr =3D (target_ulong)-1ULL; } =20 /* Try fast path translate */ +#ifdef CONFIG_USER_ONLY + haddr =3D tlb_vaddr_to_host(env, addr, MMU_DATA_STORE, mmu_idx); +#else haddr =3D 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 =3D 0; i < dcbz_size; i +=3D 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(); } =20 void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx) --=20 2.43.0