From patchwork Sat Oct 5 15:25:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 832976 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp1256162wra; Sat, 5 Oct 2024 08:28:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfqvsYxJoI4lIYBO04h+wKLAeVTe4miPr7TGfQzNlqyAxk0xCwEg35KttHCb/IkrSPngT/nQ==@linaro.org X-Google-Smtp-Source: AGHT+IEb2BBBPMDo4CjMWO1tA+g8aDMkI9FblgLP8ruwzWP4xCsXH7eJBT23fzvAI3LBgJV93Kfy X-Received: by 2002:a05:620a:29d2:b0:7a9:c2d5:a9f0 with SMTP id af79cd13be357-7ae6f42dfadmr912352685a.6.1728142119955; Sat, 05 Oct 2024 08:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728142119; cv=none; d=google.com; s=arc-20240605; b=FgCkRacJuwb71ZpBHRc6KeQeXx/mL4gpPrOOVapmHjDqnVXAM2zUG9rwCA4OVvtzA+ UUsnQ3/0Gj0FGP4KC6zBQoJbCuh2X35OJ5wSSBK4JxHEbO+zBI+HnHWbUc6YnpSFOa5Q z6yJrCsSLokA/DUwYodvOnK4xKL3HP6qwX8t2OJ6DawCEsGPS2M1rb1JQZiYEKeu8GVD J0XUZBSpryJi7/cl+Pspg8UFFMybaJT+K47vTwoyJEDuIGcOIeML7xt3Qr/n3/mBt/hB W2ULSryUkuZse3h/c0c9zk87/98pAnRkyxpMerCnOOrcxVZ+OwyLGrYAFKrnVeMR7UHK UWRQ== 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=FWoHeYfgV2GpAPrn/G2BuFpPK1PhIFnIHcTBQOX+g4L6cUyWNbqSo/w4Zak6mlrai2 oUxUN/9V4s54Tt9VedRsFwuLqqvjDX1ksTLVVgRvJvGNk/NomhYIhfhm85C6FVKwdT3Z xA0IU2nU+Yfb+dinGAQJUuFfRJnpsyzCR3M9U9W87G2K+DXKqbYDskhuVAiAR0bXRc5b besnumz5M4eh3EZS1340/Sz7WvJGDipxSPClFiM0NXN1Fuawf3BF4U4ca3cWFBOY5m4x YE9FmdHdbsxNyEfkDZQydLGT0LJhp5RsPjLlpYv8NGWzT/du4vkIco8MXM/6mrryHaiQ +U0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LL9FfGzl; 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-7ae757797ecsi208375785a.749.2024.10.05.08.28.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2024 08:28:39 -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=LL9FfGzl; 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 1sx6fT-00021Q-LS; Sat, 05 Oct 2024 11:26:03 -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 1sx6fQ-0001yw-Dl for qemu-devel@nongnu.org; Sat, 05 Oct 2024 11:26:00 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sx6fO-0002Lh-Ux for qemu-devel@nongnu.org; Sat, 05 Oct 2024 11:26:00 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20b7a4336easo22654155ad.3 for ; Sat, 05 Oct 2024 08:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728141957; x=1728746757; 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=LL9FfGzlAJTA4MPYk9UKoMqE1mSDqEY9PsTFfA1nY07kgq15e4KJ/NswBtEztVDMEP 7y5kUv2wNHH5UcC0C/F+kSHZzZZHkec3zGwC54y3PN2Yzp2s2LY+vvqlAqzpHK/1vc6Q oh/qtdE7VHV2pLAkpJoVBxqtQMpk+tfv9Y6QODtvPA0R/EubhGgh7TQmPhGYjXO8740G 4p5s6XrnlXujaLMvdl+tju4RYNVJ1zCATkAOrV2IC9vlvieN0U8izUebCTTWCRCL+Z67 FrFtNVr6cE3qpJZClhh4Ydbb0/8zni54IZC2LRMLei4gplWnPRNHJxVEq79zQMqKYx6i 9iiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728141957; x=1728746757; 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=nyLj+dUqodUaGX5RRJU9GskkkTE/MEteUhkVNq+McUyz+pD3vEaS+MtYGp1VTsTfTc rxRIGvllC2WOuhtENAI1kY/jay0EF94yStgGw92uJWaAPxyAssq7dS+pfu5wIJiN9j7c GrtXv4um8rnSbMVWOg0qAmpvp5Vp5ASVggiBRWXDsxMazaldgMjWZxKAFN4bjTaak4xf DO5e0OzhXOMVY0BErzCY/PAcn1zvLEsBdj+P7u6oFpYXtpyHSoRY8irAbkEdpQFY3eF7 quNU+kwKuqKITwp4lMXhUCKZCUWbisjoDJAJxztXyw0raMTuW9eQdrGS9Yee5T0g53vK yJgQ== X-Gm-Message-State: AOJu0Yx5ONKdF+I2ODrzH7hXFFMZHXWPHHJukPjIQDp8PFSy5z/286Ul w3xW8hOQRJiioy2rro541V7Sb0JgxEbjH2NZk/aA7mji7AyxcbkpwkIG0r/hj/Z7RHPxqTh3m3d k X-Received: by 2002:a17:902:ec81:b0:20b:90ab:67de with SMTP id d9443c01a7336-20bfde594f1mr78046015ad.8.1728141957612; Sat, 05 Oct 2024 08:25:57 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1396948dsm14351765ad.225.2024.10.05.08.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 08:25:57 -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 05/20] include/exec/memop: Introduce memop_atomicity_bits Date: Sat, 5 Oct 2024 08:25:36 -0700 Message-ID: <20241005152551.307923-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241005152551.307923-1-richard.henderson@linaro.org> References: <20241005152551.307923-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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. 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 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); } }