From patchwork Sun Oct 13 22:12:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 835090 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1734903wrd; Sun, 13 Oct 2024 15:13:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcr1R2vzYN/zPgbYWDDig06Xq82v12CpHcYxVAoEB1vJkMkB+OgufjgkVIFLbeCUNlpbjvjw==@linaro.org X-Google-Smtp-Source: AGHT+IFvKgr9w7t8e7AineaFQa+dvX2jxRYPY++y1yqqfeTJtp72XVJq/6eMEPaqtd3vo+ep4DVo X-Received: by 2002:a05:620a:2989:b0:7b1:1947:ca99 with SMTP id af79cd13be357-7b120fba6b8mr1031008685a.22.1728857638646; Sun, 13 Oct 2024 15:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728857638; cv=none; d=google.com; s=arc-20240605; b=ZQHpyGXhblp+FPlOIXNgMN1OulyK3A+Htg/N+6mtKP7HXupoOrQXUWAUym3NBU6r1b 8T53qkk2JrPHUsNLhp/h9NLwCZS3p6epU+I4M0ItlXhDcfxvBATl2uld5jvWG+5J8vOO lXRK4C4Bue74Y3pniD69q1R581uSjRmkpXmlwr9RSbDswtzwgkjo9ECvFtrp+CQUiaWT kfhWxV4d3QmXATyZ75nbzCC0Fpsc8ZIVqUbNrhND/jJBMyq7gwX07V45fIa10mmCWOKy C+e55wffn/zT9Hyq85q8O3DQ2+e/nWTSlQdTQoOoWAY7SKQopV5tao3s9ZJx3lTtJTEw oJ6g== 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=H6LoCevcYPwKGPsieGU+G82S8Cv4YZiZPQ3U7O/YR2o=; fh=kwMy2JzrTyElblCFUsqlEElk7fGLKH7lxTyZL+lE/vY=; b=ZPBqViz8nZA98i6CQ0xedzlhj12KjzCKyfYnnoSY0mSshTBGWP57bEPz4KJ1bFwvdb xlJmxgl+4A/FCsz6ipLbK/bMo4TImrfGyMWGJ0ev2PzLE9Wm8FqE3de4b0xKd9+OJH1l Opt79HDOQg7EaVKRGG9skbwZKKe0NZ9Xxcu9v51xeilEzAdp/5MTEZHz7SEGaqc3Ct9n 3+1G9R4uL5IJzDLU2s07B2fVq8GSdZ/wkSnS4vAhe8Qv+KPusm0DsfR7GfLORQZT8LcZ bcnzx50WBrC1Il+wexh+siiUzt2CvfDp8R1Icw+RCqX+JASTl0YUsVeRCsBfLgm2NhP1 EPfQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TJDEQQDg; 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-7b1149331f9si885197085a.172.2024.10.13.15.13.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 Oct 2024 15:13:58 -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=TJDEQQDg; 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 1t06pg-0007Bk-Dx; Sun, 13 Oct 2024 18:13:01 -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 1t06pX-00079u-AO for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:52 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t06pU-0000v6-Rg for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:50 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2e30db524c2so1117338a91.1 for ; Sun, 13 Oct 2024 15:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728857567; x=1729462367; 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=H6LoCevcYPwKGPsieGU+G82S8Cv4YZiZPQ3U7O/YR2o=; b=TJDEQQDgYv6ZUfEW9vKlPf9Oa4h55QPu1NcZP/GuQBD9CaXVhrAxOa45F5zNJD2ISZ 9TsVCXEdD5Q7BNQVhPDkZfO4VQ4l2Usv1vycjZu4+44p7+XKCxodQeT7D9DiItZ0/3oT 53kI9o89KeB9DUnn6/JJMOgjJwtXSFPFTX+ZFmwqyDY7fLY9cznJPrw3+gYD1nmWrWxf bZ6Wf2QO2ZS51LvkDJ0bEEQ2TSIRW+5FGn6hzT/9Xp8uxVqsoQ3Tnz52jEkENWGMgKbD JU7X1cGDTR6CBJg9IEyl6QQP8+hu0Y91J87aeK6+DScvcRETsK7uuxN86N1/yPgl1qUQ uGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728857567; x=1729462367; 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=H6LoCevcYPwKGPsieGU+G82S8Cv4YZiZPQ3U7O/YR2o=; b=xHd0ze6OGZRPngftxGG5Kxb1vJkh0zQL8aDekEteTKxMR1Je+4K1U0i2xEEg4wale1 cB7E98uDLV+gXhXpFAMGNd9csHIkz88XO6jh2dnLJroatqVoy888HE2L8I2YBsKngSSA SXpR4Fj7PZ8Ncr1i5s4bXUVj1isxX/pkkkgIAwb347vtacOwz7Qt597a+dAN8bMfb6Ng /vgy3cfZy9qDkpEgu3HIOSGfQZymvmBLP7iIsfsim/Iwh+kWkQSofmCPGd7A3AWoPqrM 9cu7dSJqPDZeGOoW7qEBco45RMfMYaW2Dez1O9M+2MKH8NGMGPdXs7RZZRKrFgqSLAxa bpwg== X-Gm-Message-State: AOJu0YzGYoRZNluRxK64s9iwgZqyJe3sgKY51HPQaB1ON8bZz5Wk4+W/ OyqqlKdmRsj68GqIwRjCD0mTYQ4b3EfR+cCcsNVRuhw1L+s+tpMbZaSY6JsOetzetLfllLTuRiJ F X-Received: by 2002:a17:90a:bd8d:b0:2e2:ebab:792d with SMTP id 98e67ed59e1d1-2e31538f0dbmr7407496a91.41.1728857567462; Sun, 13 Oct 2024 15:12:47 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2d5df1eebsm7271958a91.17.2024.10.13.15.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 15:12:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 11/27] include/exec/memop: Introduce memop_atomicity_bits Date: Sun, 13 Oct 2024 15:12:19 -0700 Message-ID: <20241013221235.1585193-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241013221235.1585193-1-richard.henderson@linaro.org> References: <20241013221235.1585193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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 Split out of mmu_lookup. Reviewed-by: Helge Deller Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 a975fe5f89..35cda1e2b0 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1767,20 +1767,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); } }