From patchwork Wed Aug 18 19:18:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 498933 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp972089jab; Wed, 18 Aug 2021 12:32:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLVWmG6g5urHmYhT6vp8yRZefwrywA5dqwRgbSYkPQ1RcTBcYETXhVEBPQBsBStFIbMhQR X-Received: by 2002:ab0:49a4:: with SMTP id e33mr8203184uad.12.1629315156631; Wed, 18 Aug 2021 12:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629315156; cv=none; d=google.com; s=arc-20160816; b=ocRU3G8a+GSexZ3Qc7jYr1jbDzQfqpYeaWbsh/zNW07Sf6CThwZFZH3BE0hfexI6LZ DL2L5Y1kaniODxZ7rjGwZV7RJ7P111uo3ni5d1YZbaguIYviG7uUgWDZwE2sLqCjQPfJ /5B5b2RakXBxuq4OSdPY5WNhLybYA0cmoWUz6tqzbMc1eEBJNpkZAZ1x9igzKFgM/rkM bVOuE2VA/kDNnYD1snk7BDCGhIB670pr7C8Uw6QhVqaJaeaOIjxUew5oYeudRYmPPJlJ o0bXxCBig4rDHJYS305v+1kPOqgYVRHpZVXzAvtiWPTv3QzNTT58jneyR/seobViMolF YYjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=DmIhPz5TPVXbbigs7Q5NjzG9ob6whdFwbwdubQ9UQp4=; b=0edPO8Au9lg46pU2ne94eq1+jnEnrWCo+FdaSSUAUvmc/St/WxbbGAjaNbg+CjalCW ukwHSduxDlE0wv8AoiPdlKxHszTQiOIRjIyS/WnYybwb3o6Pc5cSn8/Ev2tx/uWEywO8 NZ/gHATmgpt9DK9kyap/jAxDSAI/LLLl1m9mv42OXmi+3Eml/NCpFctlsr705vSyxowz T1cX0eh2/NURGlaSN/tG/xC/754xcm4Uc4rHAjjyY+S7fItrTjJS6ErRJyd0Lvk+kyCD QE4NOZjYSo4yaYTKwYJKdiVnc+FM6fv/ov9iOMusiW0SLLhhjllNwZXe9mbmaPQIwAm2 DGBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KddNVoRF; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x21si343615vsf.280.2021.08.18.12.32.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Aug 2021 12:32:36 -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=KddNVoRF; 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 Received: from localhost ([::1]:44108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGRIi-0008WG-0N for patch@linaro.org; Wed, 18 Aug 2021 15:32:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGR6O-0000lX-I4 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:19:54 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:33609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGR6L-0000AU-Sp for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:19:52 -0400 Received: by mail-pf1-x42e.google.com with SMTP id w68so3174755pfd.0 for ; Wed, 18 Aug 2021 12:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DmIhPz5TPVXbbigs7Q5NjzG9ob6whdFwbwdubQ9UQp4=; b=KddNVoRFqaDeWHyIAmVh3l02GjqkkZOMo/y/sWd7VQ8uENUWCWoSgG6HxZjpZYWK6f mEiGblCDzMPlnS09gih/ELKhlC1xRMJIUDbcO/DWytPBnKru887GzAfgDmm813xaAtkX HjOfJqowshhqRch2+5RTaQQW3C1AxcrBgiJHlFFa9P/4K66L1wL9wKkxGv2NBasCha92 g3UV7qYLg+MTAFRmPLPSO8Rhih4phZvj2zrTZiK6sD2qwAlbbUI+R+UnFbVCptDvtPay zTlzHu+ZbclRZNMMp86WnlyF/qHFrPvQsdPzn4NKr8a68N+ff8+Z0yc1k01TP+lC7Wjp j0Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DmIhPz5TPVXbbigs7Q5NjzG9ob6whdFwbwdubQ9UQp4=; b=IWgQZ9LXUz3meKS+k3+8Tzvtnv19PaRj3CKChedT8xFl5GWFSJ8O55pkhzgWPk5+QH boTIWVNaiO20V22CEGnfONhKYhLSkdfwx/AvlrbvSusMAW95tnGBi/7ARc/sf+g/FKrm ktayRn0thgoB4Hd9MX+B1H3qONQEK779ubgRC/HEqDDDdFgHPwD9tL6QacfCs/OYa+kK oYYWlXOIqVTKvs36gKoap9iDwtSigFtqdmGQTzEF54tKFDyWa+b52u4v0GVgwfOKdc2A a0NQI5MFZ/j6x32nsLBb7bkSCLJ4eiugmhyUk7vjg6eqFv9/XpOxYyQ0xOGrnj/4Tsf6 FnhA== X-Gm-Message-State: AOAM531XrBQtxaZWC2t5QRAxRhplkMz5oPfGQgwPJUS2rmvOgay1ukT9 4jU/h92FW5iB5k88JvYaaWmFcfRlQyFYJA== X-Received: by 2002:a62:e308:0:b0:3e1:4077:4fbd with SMTP id g8-20020a62e308000000b003e140774fbdmr10969820pfh.51.1629314388646; Wed, 18 Aug 2021 12:19:48 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id a6sm524108pjs.40.2021.08.18.12.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:19:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/66] accel/tcg: Report unaligned atomics for user-only Date: Wed, 18 Aug 2021 09:18:35 -1000 Message-Id: <20210818191920.390759-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818191920.390759-1-richard.henderson@linaro.org> References: <20210818191920.390759-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the newly exposed cpu_unaligned_access for atomic_mmu_lookup, which has access to complete alignment info from the TCGMemOpIdx arg. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 90d1a2d327..5ad808a25a 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -28,6 +28,7 @@ #include "qemu/atomic128.h" #include "trace/trace-root.h" #include "trace/mem.h" +#include "internal.h" #undef EAX #undef ECX @@ -1230,11 +1231,22 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, int size, int prot, uintptr_t retaddr) { + MemOp mop = get_memop(oi); + int a_bits = get_alignment_bits(mop); + void *ret; + + /* Enforce guest required alignment. */ + if (unlikely(addr & ((1 << a_bits) - 1))) { + MMUAccessType t = prot == PAGE_READ ? MMU_DATA_LOAD : MMU_DATA_STORE; + cpu_unaligned_access(env_cpu(env), addr, t, get_mmuidx(oi), retaddr); + } + /* Enforce qemu required alignment. */ if (unlikely(addr & (size - 1))) { cpu_loop_exit_atomic(env_cpu(env), retaddr); } - void *ret = g2h(env_cpu(env), addr); + + ret = g2h(env_cpu(env), addr); set_helper_retaddr(retaddr); return ret; }