From patchwork Sat Oct 5 20:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 832994 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1338642wra; Sat, 5 Oct 2024 13:07:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHH3FdvfYfPuweD2i112AQUdS9hqBQ6pJdLWJedUVtW7k+R+YEOYbLNPuGCyHQKJy6oXj/Jw==@linaro.org X-Google-Smtp-Source: AGHT+IGEfQIJsexAcj4zANnr5HVBtG8EdLmRqKc6Euw5li5xIE25VDnbcRHTk9+qXSBXEe0StQ09 X-Received: by 2002:a05:622a:2606:b0:45d:84a4:cecb with SMTP id d75a77b69052e-45d9ba81526mr117400871cf.35.1728158867478; Sat, 05 Oct 2024 13:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728158867; cv=none; d=google.com; s=arc-20240605; b=EUiTrpQr3p3DACShVNTtKRjcn6fplJ4l1ma0BEmRbilZy6QwUID3GTMiUlCZXwRE9O MQ9OuNr8UEN+/G43vNEVqD27INHbpSBlvAjQYh/xUdVqsIeFelDN+UnfUuFqfFy6z/Mg fqVIC5YnvOdVP3dQWKZSE3DZJoclO69+XzqH6Sf4ER8n0hag2oLmFfjHyrjGvEDvG3ed cJjuITbYu9A5tN8DErRaPZeHn866ZKwIr+KoAOKox5DiTUArdHv1cGOjJnt2dq2Ixof/ l8oIpBxxSEw9D4EAttTccki2hFUsaqwVU4Fe2XaQK7JoVlDgabBIvvcfd04QRfUTXbcV ESmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=rMIQXnxelIQ86qxYbOA8sg/WFq9fqYpMUetqZ1DDKfA=; fh=rQg8EQ8KH04w/0VkDYF6/ktgEyHJ2dqn1eatHCfBaLw=; b=Qd1B8LVtOVCrUoBCp6kvVXr1C6Y4Y3rCgzLguaU4+/e4PQswce4Qi7E6Junf9dhVNu vMU5kwA+uM3RMHHEtQ1UCYv4QNyun5e5bfK3va15WnEqfSaF1EslqcbFQU03C40yv7sU YGam98eqsPk+7SNiU5l1y2CL5rI3N3ZPO/xcWKHdE4L7bVNlHAZm2gW0d4t+gPQmlLmI DcGW3/96xO3H03b72DjFVNRwPkzBbEPpEVI2TeuSV8EH099BHyKaOet+WXd2TR7JbSmY njXphfhHwYQbcjslb7BbSkBZ85MZSkRkhj2teLKWVS+brJKgrbAh4rM5r42fyOsQwHBU U5/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PGghxLTt; 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-7ae75779eb1si257651385a.731.2024.10.05.13.07.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 13:07:47 -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=PGghxLTt; 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 1sxB2Z-0006Ib-Ek; Sat, 05 Oct 2024 16:06:11 -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 1sxB2Y-0006HZ-1V for qemu-devel@nongnu.org; Sat, 05 Oct 2024 16:06:10 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxB2W-0001j2-HI for qemu-devel@nongnu.org; Sat, 05 Oct 2024 16:06:09 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20bcae5e482so28618625ad.0 for ; Sat, 05 Oct 2024 13:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728158766; x=1728763566; 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=rMIQXnxelIQ86qxYbOA8sg/WFq9fqYpMUetqZ1DDKfA=; b=PGghxLTt2ynfVDocQ4D+KSHzuhMQ0qVlz0psDELCA8gLqiC+FCLCUzlLQu44sPtQht ytLS/5S4bu3wlr3cF093Kjh7LiNYP8dgjzPtsu9JkNVvi7Im+DhRZkEhitGusUMqSQIR AkRprgZaiHHZXLcrs4Bq7UYp2Uev7H0n1LRQh9XUmiKj5+2cWKDZy1+S5bonyzXyN6Jg /blAXFcVcE48xmUmXCJorOooh+pYnscnAeTPwgy2v8PHsQP4hrEQ4eYTvLPWIDS2vnQH +W1aTMlxxxrI2ITsS2KQNAN9sTbQIc9dA5RPE82DPagKoDe4LrQJyYsrMQZrUWDd1+YR JpBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728158766; x=1728763566; 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=rMIQXnxelIQ86qxYbOA8sg/WFq9fqYpMUetqZ1DDKfA=; b=waRF1jZs+A8u53rMlMiYVGze4Bm7zGIhLRgkV3ekI1O7/xdeydwxl97OB54bq081Kx ou3EjSjqmmvM6xXjwgxSJM4VaDfJmV98rgeBgWcNs9bxye2avb9dUaClTWlpokBo02h9 W0IZIhNQexVsj2TwbI2jF24hYQ1HIQgc796vfPVpi6iGKkzd0Rhq8PYEGE1kyWLailGj ciTfDY6VKLBHAiCoidAG5817NsxTLVPj6rP5VxlLRQX5t1rBxUxZqYSGazhd3QDvUDx8 ToPwY9CIieJYatO+rM5vjJY0T4i12pA/L7tIkPHQwpoUdavFZTMIu/rLvFQSDvwzv6NZ lEGw== X-Gm-Message-State: AOJu0YxO9f80Ko+k5F+1aLYfPdk4kk3rKAJvnVFUDhKF7bxA5TPkjXRr GMdCeKTi5kP4DCbsNfga4nI6PRr3t6lC8MDCZ0xDeSc+rm9zuGgpXkBm/xHVOqrbHi8601WpneK U X-Received: by 2002:a17:902:f545:b0:20b:a576:1896 with SMTP id d9443c01a7336-20bff190668mr89400615ad.43.1728158766201; Sat, 05 Oct 2024 13:06:06 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c13931055sm16493405ad.139.2024.10.05.13.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 13:06:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@kernel.org, peter.maydell@linaro.org, alex.bennee@linaro.org, linux-parisc@vger.kernel.org, qemu-arm@nongnu.org Subject: [PATCH v2 05/21] include/exec/memop: Introduce memop_atomicity_bits Date: Sat, 5 Oct 2024 13:05:44 -0700 Message-ID: <20241005200600.493604-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005200600.493604-1-richard.henderson@linaro.org> References: <20241005200600.493604-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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=unavailable 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 Split out of mmu_lookup. Signed-off-by: Richard Henderson Reviewed-by: Helge Deller Reviewed-by: Peter Maydell --- include/exec/memop.h | 24 ++++++++++++++++++++++++ accel/tcg/cputlb.c | 16 ++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/exec/memop.h b/include/exec/memop.h index f53bf618c6..b699bf7688 100644 --- a/include/exec/memop.h +++ b/include/exec/memop.h @@ -193,4 +193,28 @@ static inline unsigned memop_alignment_bits(MemOp memop) return a; } +/* + * memop_atomicity_bits: + * @memop: MemOp value + * + * Extract the atomicity size from the memop. + */ +static inline unsigned memop_atomicity_bits(MemOp memop) +{ + unsigned size = memop & MO_SIZE; + + switch (memop & MO_ATOM_MASK) { + case MO_ATOM_NONE: + size = MO_8; + break; + case MO_ATOM_IFALIGN_PAIR: + case MO_ATOM_WITHIN16_PAIR: + size = size ? size - 1 : 0; + break; + default: + break; + } + return size; +} + #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b5bff220a3..f5fca5a118 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1751,20 +1751,8 @@ static bool mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi, * Device memory type require alignment. */ if (unlikely(flags & TLB_CHECK_ALIGNED)) { - MemOp size = l->memop & MO_SIZE; - - switch (l->memop & MO_ATOM_MASK) { - case MO_ATOM_NONE: - size = MO_8; - break; - case MO_ATOM_IFALIGN_PAIR: - case MO_ATOM_WITHIN16_PAIR: - size = size ? size - 1 : 0; - break; - default: - break; - } - if (addr & ((1 << size) - 1)) { + a_bits = memop_atomicity_bits(l->memop); + if (addr & ((1 << a_bits) - 1)) { cpu_unaligned_access(cpu, addr, type, l->mmu_idx, ra); } }