From patchwork Tue Jul 23 03:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813934 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2141536wro; Mon, 22 Jul 2024 20:36:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMsxRETB9yOMK2HCh6PTs8+gSY97WGWqN1CmJOCJFG/qJW7/lm4VEkk/yT96oWqq95T8nUzF1gvUjuJG1Q6KDj X-Google-Smtp-Source: AGHT+IFMGnpnH1Ij/xxBxZXMKr6BcUhSCWCwFJzfXK1Pr7lqq4Jn4kqGDbh2LnS225xqf1i7UKBY X-Received: by 2002:a81:fe0d:0:b0:65f:cd49:48e0 with SMTP id 00721157ae682-66a6a511b02mr106409577b3.31.1721705803819; Mon, 22 Jul 2024 20:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721705803; cv=none; d=google.com; s=arc-20160816; b=d5HceKxAgBPao5s1zvKx0G3UOFdN+2xXPAs+hyCcVfKcw0sWnpQD3H8J0f6B+n7NKc 2kCeACmY7lCoUObnuEpXLDiK8QMPU96zTISlFOTpQkDjX8RKhS0/pquQSHfri+0jbN/T UTXCtHjrmhpmjOExVvVNbHoFbnpoyesCKfi+4rOT1Lwg5mtIwOGid0E5zV9bUnIlHk9i E2bgrmR9WWXZud/taafgcoOou7PZ/mK5PbKjelT/ZVMiDQjTUuNzY7OrLyTYcJ971/y5 b8/0JyD6NdWvvIDz4z6AqLSSnaHQKU+z0j0qVoyqq4YbkxfTgA9swWw0doIVbgd3f5Mf Of9w== 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=uh4gAqAS6TTZXCMO8wLgp4N1p8byuXj34zq25Ai1zrU=; fh=tOREyZHlK9Diwyw/7bj5IUyLT4I5EVkj5DE8XDtMiTs=; b=Dsl9LLfWntcX4WMgPuOMsA7f9W3hnpCguppOr18GnlLfZ5B6n4WAeCK7RfUKTqRogd 6HLm0M86kzCPeDjindtDHdOQ1SWUPFSdmZLQeGUl9FTI3e/s6nHdcJyVbWLYWksSg9qc XwJPMamw+LU+Z6QwHBNtBy95pHcnUqb16VXr29JrIIWI2qUwAeFxLjCOt7PMTsTfHuES VUqNT36l2ZiQg9nro4Lt/LR20NPNkLKQx1s2yvw7CoS87Sn/1I8qd3E2AuI6rJKTAzap EPcSH7xJ6ubnYKz7WJg1IbmauSVOEQ1edGOUqOJf8zQK4N3i14rnBtFIvM32qr0IvkWn ibDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p52uYPIW; 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-6b7ac9e87d5si94229866d6.388.2024.07.22.20.36.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 20:36:43 -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=p52uYPIW; 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 1sW6J8-0002oN-Di; Mon, 22 Jul 2024 23:35:22 -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 1sW6J7-0002jr-Ai for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:21 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sW6J5-0001yh-Gh for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:21 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3daf0e73a5bso1294812b6e.0 for ; Mon, 22 Jul 2024 20:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721705718; x=1722310518; 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=uh4gAqAS6TTZXCMO8wLgp4N1p8byuXj34zq25Ai1zrU=; b=p52uYPIWwO8lYKuwnYun/0BYYakmQHATaLXmUawm5weeT8PmF9PTPPNRrec8jt1PNO NwWtWxmDWAFbgaYTLXOv8h8ylS1u95gNzRD6vLNgRT/t6Y7nbsqY9YAZDQ7Yu18zYLvr lARkZ2hIMD/iwPsQUY/FtxDmKZgrlJOq5WWuIpIFIfPVhGVZ5+w1rWgdDja7eztMI7NB AdqC2kbD4RubhadRWgJpBpu6sDT/OTamlGUM5vuiepnSHWwPz8nzEBexZ38VmwImnw5K oJfaydXdG9HZwRIGI3M04NRSI7WDFmPLWT1BEJ/le0lVukiAUdeFj1/2ZXOPyWJJDEKY krQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721705718; x=1722310518; 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=uh4gAqAS6TTZXCMO8wLgp4N1p8byuXj34zq25Ai1zrU=; b=Wu91vOMgr4YJkFgNGe2PMCaEE9ThYC5f/C/7rlj+a9DF/c/gUd29/4WcEkTvpM/f9O SvBKMICJkfXfa3Qs3Lp/4ROwE4Y3rb44SkddIGm7ofidzT5CL+Lbtafi2X75bODwDbFM eG5T518GIzu1vURsi48r6+gmO+W5ZlLp9lBvpQ6NpJ7wsBFoAEIu5bbDblDWAgyGJ45O xoGIr7mU6IxQQohttfXGLZHxEMljuFobQMpO+shh0pZbp+zkXHkFPmq6MtQQA3yuOehB uJwMV59tkKg3dKNLHHIlC0jAEqKtGBkaHpf3ENx8GNDMYSoELUwNBoo7qtu5kyxK4dm4 VvJw== X-Gm-Message-State: AOJu0YyyUQy6RK0TuEKC436EPJQ+YKxBsC0TI2aycZX9o1aiDHlfZp0g xvYUAKoUEWQkb1FM4rMnV9K+S+F7KSaONtmb8x+gq5c1G3aL57aRGAiMod4e+76Vx1qdzlZNSVL W/UYfnA== X-Received: by 2002:a05:6808:1514:b0:3da:a0a5:a249 with SMTP id 5614622812f47-3dae5fb0fbdmr11785351b6e.23.1721705718052; Mon, 22 Jul 2024 20:35:18 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70d2b96bfcasm2171380b3a.87.2024.07.22.20.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 20:35:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PATCH 08/12] target/ppc: Improve helper_dcbz for user-only Date: Tue, 23 Jul 2024 13:34:47 +1000 Message-ID: <20240723033451.546151-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723033451.546151-1-richard.henderson@linaro.org> References: <20240723033451.546151-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 no longer spend nearly 25% of runtime within page_get_flags. Reviewed-by: Peter Maydell 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_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)