From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188843; cv=none; d=zohomail.com; s=zohoarc; b=FuIV7QNF/w26xontROEygv5669P+4glMGaUCBp+qVpRCtIg2lNtkxTIsTbS41IO5e9KN/WJG0+TV07wk0zT/iHoDHTXROqFBOchSNMo57C5gbfIZ8kaaD3WL253zY0Fm3dpCuoq4N7KQp3dT4mYDKDMwbKyvWfzS0E02h9wPZOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188843; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o3gKpL8DiepyBHxNbIedU4D/NFgh/WMqJ9tvA2IW734=; b=CKg9Rwb1AkIA7aZBc3qZ7Xs7Mb2WMyG3vizjWSI5tfik+Pjg+wfC/eciHpyy4/LeIZwB0H3fxv04oFbPshVFMVfBI0a3zYAeSNySUd+xkHboznBc0uQD9hBfkp3PMffmuvPFjLWmPIrY0z9P/wCqq10WNFHTnHmUu1NX8rQFDbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188843055570.4742190787888; Mon, 24 Jul 2023 01:54:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrJv-000207-Tf; Mon, 24 Jul 2023 04:53:35 -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 1qNrJt-0001zY-Ub for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:33 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJs-0000dc-3f for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:33 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so30298835e9.1 for ; Mon, 24 Jul 2023 01:53:31 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188811; x=1690793611; 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=o3gKpL8DiepyBHxNbIedU4D/NFgh/WMqJ9tvA2IW734=; b=BIuusPkjdmdnR2lEx1QWO7sDaPIqJwwq9K8J7ymCrF5gQfE8MXaA+qTlhv75lOHcbH R5IrPmUacKR0HJdba32KsTaYQVbe4b5rTj1d/RGPQM6P2NQychtAUVJNZhgk0mvvPPtG pPuhjtm0jwXrlevE/J0EFdpZ7zdF5Gn4ggzXjSqPk/MiG64G+PD9KawMQ/05W8T4Zlh0 mFYZdAotDRVGiAj19quUYeeakoJj+5Z1KQ25FfcgYJDDqBzFWZetiv8wwT1dv3jtFIPa UP2Vc775TxUiZzHCWedWAO9EmY/kuE1HbZhuWHUOPfOkt+3LKMaXQw2ey0W20hSAUnj3 ggCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188811; x=1690793611; 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=o3gKpL8DiepyBHxNbIedU4D/NFgh/WMqJ9tvA2IW734=; b=hVkpsRE/Xsh3YcUHW5p+IXoSyOeTNfdmP2o9Lzk/a205reLl4tXzDjIBgRd0uWbFwv pKKFgg8dmKDlhxR4JuTzrD0gIx1mdNwMPGkWIdWhhJmX/0f74V4HpR+S99AexWVffwOO 254TVodb4bZ/lOPtIXyHy2Tt1nDBHsfVrbLDY9HLOsKBfcMp/wi03oLUPJlSg9/lu1xP Hf2/ERdJdNxSA0enZkWYA4Q5Y0A04BoTX/5w8nMOz6ADQKTGUhSIlNgAnnnYQ0OKSzo2 +kFRxOHwCljOK/GK1hnPXsAKLO5g9P4KmhxywwysMhtykHqaIYeMMcM/Xo3GzOJN1xZk Pc0Q== X-Gm-Message-State: ABy/qLbUQIQ/9CuppICMPbmxlXGJqgdaOqWHUGXufyiGn0yig1mILxag bSdOAowtqipLPL5RnHpwMDFbG32iZMK0L1MtriMseQ== X-Google-Smtp-Source: APBJJlFe77uR9VLoKfYNHu7vnvfFBXI3wEdMoC5nagrzTpoKLE5OhATUI5PiPYS68Prf51kn/jMvCg== X-Received: by 2002:a05:600c:2909:b0:3fc:85c:5ed2 with SMTP id i9-20020a05600c290900b003fc085c5ed2mr5823043wmd.11.1690188810698; Mon, 24 Jul 2023 01:53:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Jordan Niethe , Anushree Mathur , Michael Tokarev , Benjamin Gray Subject: [PULL 1/7] tcg/ppc: Fix race in goto_tb implementation Date: Mon, 24 Jul 2023 09:53:22 +0100 Message-Id: <20230724085328.4936-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188843793100001 Content-Type: text/plain; charset="utf-8" From: Jordan Niethe Commit 20b6643324 ("tcg/ppc: Reorg goto_tb implementation") modified goto_tb to ensure only a single instruction was patched to prevent incorrect behavior if a thread was in the middle of multiple instructions when they were replaced. However this introduced a race between loading the jmp target into TCG_REG_TB and patching and executing the direct branch. The relevant part of the goto_tb implementation: ld TCG_REG_TB, TARGET_ADDR_LOCATION(TCG_REG_TB) patch_location: mtctr TCG_REG_TB bctr tb_target_set_jmp_target() will replace 'patch_location' with a direct branch if the target is in range. The direct branch now relies on TCG_REG_TB being set up correctly by the ld. Prior to this commit multiple instructions were patched in for the direct branch case; these instructions would initialize TCG_REG_TB to the same value as the branch target. Imagine the following sequence: 1) Thread A is executing the goto_tb sequence and loads the jmp target into TCG_REG_TB. 2) Thread B updates the jmp target address and calls tb_target_set_jmp_target(). This patches a new direct branch into the goto_tb sequence. 3) Thread A executes the newly patched direct branch. The value in TCG_REG_TB still contains the old jmp target. TCG_REG_TB MUST contain the translation block's tc.ptr. Execution will eventually crash after performing memory accesses generated from a faulty value in TCG_REG_TB. This presents as segfaults or illegal instruction exceptions. Do not revert commit 20b6643324 as it did fix a different race condition. Instead remove the direct branch optimization and always use indirect branches. The direct branch optimization can be re-added later with a race free sequence. Fixes: 20b6643324 ("tcg/ppc: Reorg goto_tb implementation") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1726 Reported-by: Anushree Mathur Tested-by: Anushree Mathur Tested-by: Michael Tokarev Reviewed-by: Richard Henderson Co-developed-by: Benjamin Gray Signed-off-by: Jordan Niethe Signed-off-by: Benjamin Gray Message-Id: <20230717093001.13167-1-jniethe5@gmail.com> --- tcg/ppc/tcg-target.c.inc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index c866f2c997..511e14b180 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2496,11 +2496,10 @@ static void tcg_out_goto_tb(TCGContext *s, int whic= h) ptrdiff_t offset =3D tcg_tbrel_diff(s, (void *)ptr); tcg_out_mem_long(s, LD, LDX, TCG_REG_TB, TCG_REG_TB, offset); =20 - /* Direct branch will be patched by tb_target_set_jmp_target. */ + /* TODO: Use direct branches when possible. */ set_jmp_insn_offset(s, which); tcg_out32(s, MTSPR | RS(TCG_REG_TB) | CTR); =20 - /* When branch is out of range, fall through to indirect. */ tcg_out32(s, BCCTR | BO_ALWAYS); =20 /* For the unlinked case, need to reset TCG_REG_TB. */ @@ -2528,10 +2527,12 @@ void tb_target_set_jmp_target(const TranslationBloc= k *tb, int n, intptr_t diff =3D addr - jmp_rx; tcg_insn_unit insn; =20 + if (USE_REG_TB) { + return; + } + if (in_range_b(diff)) { insn =3D B | (diff & 0x3fffffc); - } else if (USE_REG_TB) { - insn =3D MTSPR | RS(TCG_REG_TB) | CTR; } else { insn =3D NOP; } --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188875; cv=none; d=zohomail.com; s=zohoarc; b=R1I9GJtWVgDKKp/uU2rZxdTG/F30PlMXXcBdUYSNzmEBksXrRZVgquNe5eXz1/4/4W/W01ROqnYZpZ2EvGvsDhDMu6cVEfbNKR2LTxUrCF3LVrr3k8K2lFTNRbcL1+RbJIsq3ETFUFmvFVR8gyf4q5gRy8SlFD3SIueOQMgwQrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188875; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YIZ//uqvzyazKLUP5z3YoDBSBVlSC65GXHLWCWeqo2o=; b=Yi/Tf5koDifT3O3LpcwbyVhgePPyHEacDNnj9sQaIZtkCFnRLBkwDQeFJS4MAOc7Hhc5kSyU7ShQh2cz1s+7VcehKKc8Xo+iQHzdaLRDpCmraXorpIzEHcaFT3ZNJiUuff+H4r2FYoId0HSXo8LprdC39MNuRMGpTGK2tp2roag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188875672810.3889236986194; Mon, 24 Jul 2023 01:54:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrJy-000240-OR; Mon, 24 Jul 2023 04:53:38 -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 1qNrJv-0001zz-DB for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:35 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJs-0000do-Od for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:35 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so30298925e9.1 for ; Mon, 24 Jul 2023 01:53:32 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188811; x=1690793611; 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=YIZ//uqvzyazKLUP5z3YoDBSBVlSC65GXHLWCWeqo2o=; b=Y68Q6yBpRe7nFafF/rtozIHScPn/vHIJoAv9oJAINzNRRnrlunbJ3TYW4iKlrcBrEN lDPR6Xlj5iGHc13D2/5Kh0RGkk30QV3ZmcL9cQzEZrZTd7gnn5pj7aAIyfb6bwR902qM zYIsYRUAbgnbD1kFU4PVIKYRlJWZx6J4+edK3UcBbbjj7FmxBVvQcY1Ifu7w4kKOwTdf ApHq8eIVvxBOc+7FaUNTGHUXdNMb/qbWJ6xYDmHjIzSIA2MX2iKNH/JRThi0jXKfhadt 8tQs9V2lgGW+v8NqM/vAIqcBZLrvJnj3PiNiXL8yE7p/pqGQ1TRc2WUZMvw4EN7X2nys In8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188811; x=1690793611; 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=YIZ//uqvzyazKLUP5z3YoDBSBVlSC65GXHLWCWeqo2o=; b=f8v/4myeCXetE7njcIg4w62ZwGHL3Bhqe7ReNaC2zU8rePSgLXVrathVJNjE5pToKU WqNP+gZ8xz6CapIZD1zrbFzt4hKrgtTkhgZEO+aJyXAxQ7QDrrWMJFmH8B8TC56YEdHE YBAE27HHKVTkI2ixWUKqJ4/LnSMD06kSIlCgrqlKn/Rckxi+a5JyV7Nds8V0Bz+ZCY55 PcLmgfIJT1q4Ri2nrK0VctHwCKetf69zNXu0W469aZFTeufqYQRTCZ2vOp9i1cg6c/73 L+BxVO5rgICiKipxB9Wb/PxVDvjSZHjkBoIV76+/zNgtZYaI544r+MRI1zjtdvZKId0D xZfQ== X-Gm-Message-State: ABy/qLZwVhF2YQMOw8aLtYMln+PgDUhHrOwMC1ZCTCfx8j3wQxSStq5I CATmJ8UvKXzmXGOvPHADf1CFaLCeXxGoyR+HjykJ4A== X-Google-Smtp-Source: APBJJlFzkj57ozsaWpw2OqH6P5YqWg4RORHorfs8z15HE97//O+twRHiO3++lxyfRoBBSJJZ2FZQlQ== X-Received: by 2002:a7b:ce0e:0:b0:3fa:934c:8360 with SMTP id m14-20020a7bce0e000000b003fa934c8360mr5658885wmc.8.1690188811407; Mon, 24 Jul 2023 01:53:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 2/7] include/exec: Add WITH_MMAP_LOCK_GUARD Date: Mon, 24 Jul 2023 09:53:23 +0100 Message-Id: <20230724085328.4936-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188877945100005 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 10 ++++++++++ bsd-user/mmap.c | 1 + linux-user/mmap.c | 1 + 3 files changed, 12 insertions(+) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 5fa0687cd2..d02517e95f 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -629,6 +629,15 @@ void TSA_NO_TSA mmap_lock(void); void TSA_NO_TSA mmap_unlock(void); bool have_mmap_lock(void); =20 +static inline void mmap_unlock_guard(void *unused) +{ + mmap_unlock(); +} + +#define WITH_MMAP_LOCK_GUARD() \ + for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \ + =3D (mmap_lock(), 0); _mmap_lock_iter =3D=3D 0; _mmap_lock_iter = =3D 1) + /** * adjust_signal_pc: * @pc: raw pc from the host signal ucontext_t. @@ -683,6 +692,7 @@ G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, tar= get_ulong addr, #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} +#define WITH_MMAP_LOCK_GUARD() =20 void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, vaddr addr); diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index aca8764356..74ed00b9fe 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -32,6 +32,7 @@ void mmap_lock(void) =20 void mmap_unlock(void) { + assert(mmap_lock_count > 0); if (--mmap_lock_count =3D=3D 0) { pthread_mutex_unlock(&mmap_mutex); } diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 44b53bd446..a5dfb56545 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -36,6 +36,7 @@ void mmap_lock(void) =20 void mmap_unlock(void) { + assert(mmap_lock_count > 0); if (--mmap_lock_count =3D=3D 0) { pthread_mutex_unlock(&mmap_mutex); } --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188876; cv=none; d=zohomail.com; s=zohoarc; b=USIyyYLzpB1Svb5HRblJPiLGblXu6cz6r8DzTDIRIEqJjQ7o+ybQxGU8jJvGP5Rswf6YuKcjHb3OIMKM/Vp9TXqglAFk2RUiLjCmRPIC7JnVjR7hYRmHYk2Iauq8mUvNtIebIf8XvAsU4NSCzy0YAjB3AmmGSNbntleUwugTlWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188876; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kx8DX46zDkvv/0NYLawLSaPgKsBMt29LaRgzXxGcPGg=; b=fvYDgN0Ateo2i3EISsShracXL79j1YtOsN65aiMvNTft0xw+9MgGQYG76//hcRw/UhD5drkLvAsaOxOual0oTWYZIw141QRt7mlx9OhWAlEgF2S5uhHlI/M4ZGOJUvjL7lYE5qNhmPLv8YNAcwY5eRSOHokgdBlLqzJ0XopP18w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188876525915.4102465799817; Mon, 24 Jul 2023 01:54:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrK2-00027k-6P; Mon, 24 Jul 2023 04:53:42 -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 1qNrJz-00026S-UB for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:39 -0400 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJu-0000eK-I1 for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:39 -0400 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4fb761efa7aso6133422e87.0 for ; Mon, 24 Jul 2023 01:53:34 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188812; x=1690793612; 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=Kx8DX46zDkvv/0NYLawLSaPgKsBMt29LaRgzXxGcPGg=; b=VJE8bUXXzaJDG06QLiLpqzguQc5+8z6r4khREXBoArNTUdmRHD+xDmV7oqNk00TCjx +N1GvQ17YNblLhwLjNaESgbaqqbxhrppHZq62Mbgr8a5gxVBEiMUvzwmgiypNjA/FHCd aUdIRdXiP3cykzp9wyt3sI0nD0HsX4cc1GhtatJqNWn6W3JKdVRjK0opmg0MGXWlPmHE Z9z2e+p5KmkotbQ2EaJ0FloyrjuhLRDkh9SlyA96VDgMVPcMpn6cL/cFjNy/OdJQ4HXk DinHe7b6gekVO5LbYommCNtWHvsuAgs9DD265Yyvs4p7nacYbiqpQ4YE25TMb0LyAcWG npEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188812; x=1690793612; 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=Kx8DX46zDkvv/0NYLawLSaPgKsBMt29LaRgzXxGcPGg=; b=H/1ycwMZpCvnzErkdi10KMhqEIdThFtiagtjRKD8Uka3ZvxIjd5szji+mdCrG/qhy8 28JUHrFQQguYkCJumyZcuPZtyMyG02IcOfOWEP/DSUjLkSo2Ijf4iLqY5wFPtk14glmb xCGWEHuyqW1xs7FBVK3WTkJu0n0F0FW4iH/llU4hN0Taa+rxxCgeIq86Ms3QMBqhP/kg 9m8LbUVKF0pEMd7NSc9uqJAFdXAmlDFNwg6aN+mRypZnGXYdUJzwOFG7rO25+n5eyARq S2enuLKTF3ZJNZ3D2imCC3ycXP9GzAbfIrJ9EvanmI/5E8+zdVgU9tKVVZRVlcDF0u/W w3KA== X-Gm-Message-State: ABy/qLYyezK8vYEVgCNR/zcXID26555+vUBF3SJqtBOT8Cr1Umh/waIp oK15rOPnkbVtYTlrdtvYIdKnMRtlywX5XmiZcmbwXQ== X-Google-Smtp-Source: APBJJlFTKy1KD/f8cL9zmgFIvGcWSep6qfNT14+MSzntnb/uy4trmHQrWjdIphsMYbSTmQ1AnybZjw== X-Received: by 2002:a05:6512:e8c:b0:4fd:fabf:b923 with SMTP id bi12-20020a0565120e8c00b004fdfabfb923mr578471lfb.14.1690188812140; Mon, 24 Jul 2023 01:53:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 3/7] accel/tcg: Fix sense of read-only probes in ldst_atomicity Date: Mon, 24 Jul 2023 09:53:24 +0100 Message-Id: <20230724085328.4936-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=richard.henderson@linaro.org; helo=mail-lf1-x135.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188877902100003 Content-Type: text/plain; charset="utf-8" In the initial commit, cdfac37be0d, the sense of the test is incorrect, as the -1/0 return was confusing. In bef6f008b981, we mechanically invert all callers while changing to false/true return, preserving the incorrectness of the test. Now that the return sense is sane, it's easy to see that if !write, then the page is not modifiable (i.e. most likely read-only, with PROT_NONE handled via SIGSEGV). Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/ldst_atomicity.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/ldst_atomicity.c.inc b/accel/tcg/ldst_atomicity.c.inc index 4de0a80492..de70531a7a 100644 --- a/accel/tcg/ldst_atomicity.c.inc +++ b/accel/tcg/ldst_atomicity.c.inc @@ -159,7 +159,7 @@ static uint64_t load_atomic8_or_exit(CPUArchState *env,= uintptr_t ra, void *pv) * another process, because the fallback start_exclusive solution * provides no protection across processes. */ - if (page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { + if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { uint64_t *p =3D __builtin_assume_aligned(pv, 8); return *p; } @@ -194,7 +194,7 @@ static Int128 load_atomic16_or_exit(CPUArchState *env, = uintptr_t ra, void *pv) * another process, because the fallback start_exclusive solution * provides no protection across processes. */ - if (page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { + if (!page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { return *p; } #endif --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188985; cv=none; d=zohomail.com; s=zohoarc; b=cm0cvtd06mywrFJxKsF/OD10KbvYwV/gUV6B1DcrYD41mQznuTpQ8U49kuF+OCSJTFH5x5uaVvSgLgbLRu0/q+RPSW7VkWpjjBjvv+sJAYsRTwySZG7ACcB7/YdRYG5LLTsU59Ub2R5+ygo6tY1vPzQkrM7IkEoaX56jzsclKYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188985; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FtcjV7RLMVbCUSYkAiLh5IZllixWR3iJOTzr/2oXRS0=; b=m9QchBX8vg0HCUPz+8aZDTrSX4WHi7+3MO7i0lBVdSOPZGEXgJSaJz46fiontOdkIA2Gr9/6qWUjlMVvr0ywAwbWcw5b4DuLBhs8uroqqfbwuYRqZA5BJjJQOmWfbOm1EWO120591+KH51Q0h+5TyMGOvtmYQzQNlXDQhXH6gRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188985882487.72601449990646; Mon, 24 Jul 2023 01:56:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrJx-00021g-L0; Mon, 24 Jul 2023 04:53:37 -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 1qNrJw-00020E-1D for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:36 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJu-0000eP-By for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:35 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fd190065a8so39351265e9.3 for ; Mon, 24 Jul 2023 01:53:33 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188813; x=1690793613; 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=FtcjV7RLMVbCUSYkAiLh5IZllixWR3iJOTzr/2oXRS0=; b=cvcAyU+AZgDpWf1Io/RLMTmwARxeWpyv0NX/Qw1BzUK/nboWFkW75BgBrvS6gfvL68 eZiPikHTEVYRF2/hSKo6pF9/nyWYc4SSf87FUH0PRnvedIv7xjGJGvGHUF+peQ8hKR8l D/NIUenF5dbkHS0Ck5nyi5DSGanLfaA38FPsqhBNFtdgouBlVDgzpS3+mdFYbMYHV4bi J3yfJkKLSWlZUX6o90n5uRf73Igk9i4Anqy0vo7sIHQJOZLqUFuys4r2RpRAfdKo+/Mm koWuZs08OODB73FfjKc0v5wrHWLfm9TwBYjtIoqxPgwxU9LrSfVGuQ5H6ZmbrHIKQFiM 2llQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188813; x=1690793613; 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=FtcjV7RLMVbCUSYkAiLh5IZllixWR3iJOTzr/2oXRS0=; b=G20qr+lFaDf98JRGtTXLtype2CfsXiYOLfFMXiIaobDrRhfV35UrPw16kTLMu9b5sz KUpR92gnng5+/dVjUC+eAbxQ+w9kMJIJCzTeUujM2Ia68TDZbyHEQg2X2blagfR0yf5V Mm9QvDfYuXbO4ajvXAafUd7eGAK4yC/2nGfZWm2w2wXAHwPhkvAdJjl8q9u4eZLr/j2b V+HJCq2THs6sfFewlyGfv9eF8rhS34qxDCDK8Y9wKyEGS1LITcfnMzoAohGHWRI+/jaG zoMYc4Avqh6SlAiEMB3h6Ycbtg8Ijkxzswy+sBM6Q1M7tAfw8reIiSyTfZSK+K0zDNn5 QNKw== X-Gm-Message-State: ABy/qLY2l7ufELbGztY5wSzpfbqTncRObIEhE3Th0YAkR0j+Fo8L/jw5 ZXknYE9ZfJczO4qXnQ4dcIhak9FsIyYnGGs/OGh5kg== X-Google-Smtp-Source: APBJJlEGSBOaLZEEzU68QdP5bgZ4Y3aU+n7ai8CGHWjia+YFD3eQB44EwwtEkY4ggIIvaUuW76BZBg== X-Received: by 2002:a05:600c:219a:b0:3fb:415f:a85b with SMTP id e26-20020a05600c219a00b003fb415fa85bmr7569973wme.3.1690188812917; Mon, 24 Jul 2023 01:53:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 4/7] accel/tcg: Take mmap_lock in load_atomic*_or_exit Date: Mon, 24 Jul 2023 09:53:25 +0100 Message-Id: <20230724085328.4936-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188986488100001 Content-Type: text/plain; charset="utf-8" For user-only, the probe for page writability may race with another thread's mprotect. Take the mmap_lock around the operation. This is still faster than the start/end_exclusive fallback. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/ldst_atomicity.c.inc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/accel/tcg/ldst_atomicity.c.inc b/accel/tcg/ldst_atomicity.c.inc index de70531a7a..e5c590a499 100644 --- a/accel/tcg/ldst_atomicity.c.inc +++ b/accel/tcg/ldst_atomicity.c.inc @@ -159,9 +159,11 @@ static uint64_t load_atomic8_or_exit(CPUArchState *env= , uintptr_t ra, void *pv) * another process, because the fallback start_exclusive solution * provides no protection across processes. */ - if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { - uint64_t *p =3D __builtin_assume_aligned(pv, 8); - return *p; + WITH_MMAP_LOCK_GUARD() { + if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { + uint64_t *p =3D __builtin_assume_aligned(pv, 8); + return *p; + } } #endif =20 @@ -186,25 +188,27 @@ static Int128 load_atomic16_or_exit(CPUArchState *env= , uintptr_t ra, void *pv) return atomic16_read_ro(p); } =20 -#ifdef CONFIG_USER_ONLY /* * We can only use cmpxchg to emulate a load if the page is writable. * If the page is not writable, then assume the value is immutable * and requires no locking. This ignores the case of MAP_SHARED with * another process, because the fallback start_exclusive solution * provides no protection across processes. + * + * In system mode all guest pages are writable. For user mode, + * we must take mmap_lock so that the query remains valid until + * the write is complete -- tests/tcg/multiarch/munmap-pthread.c + * is an example that can race. */ - if (!page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { - return *p; - } + WITH_MMAP_LOCK_GUARD() { +#ifdef CONFIG_USER_ONLY + if (!page_check_range(h2g(p), 16, PAGE_WRITE_ORG)) { + return *p; + } #endif - - /* - * In system mode all guest pages are writable, and for user-only - * we have just checked writability. Try cmpxchg. - */ - if (HAVE_ATOMIC128_RW) { - return atomic16_read_rw(p); + if (HAVE_ATOMIC128_RW) { + return atomic16_read_rw(p); + } } =20 /* Ultimate fallback: re-execute in serial context. */ --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188973; cv=none; d=zohomail.com; s=zohoarc; b=OwAdokv0Y5eEprraIdwjWyrvS9ecHqjD9uZd58jMVXoRBq2PamwuI/ImRxD8CACGvkRbDHxrbVZaN4+RE+WmdI2lC/5f7ozd2rnoAaT3t8GDnWgnSb5TCEd5GUvfN08keH4qfsxLBM1xBZgzEDDMYpZcttAzRKMn/ygtfu++DGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188973; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2zCvmEJYFTqfiAcu8CvxN/tos2dn//8Q84Fs7tMAmMg=; b=HnThE6kHe1LUZeCj12j2KUoLJQXyI/oyC+Tk9S7WHh4vysBJLfIdo5QwzfjWToQEyosICQQUqe/T9QQCDBxzDOrDBhtCE2M71eY2wn28kKlNhjm5pvwhJxazI9wXs7+VfESOu3a3K96S8TJuFelhMtoNIA+RLNVMlWBA4/5ZqI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188973521994.9803870958106; Mon, 24 Jul 2023 01:56:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrK1-00026l-5R; Mon, 24 Jul 2023 04:53:41 -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 1qNrJy-00023K-7q for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:38 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJv-0000er-9Q for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:37 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso39516165e9.1 for ; Mon, 24 Jul 2023 01:53:34 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188814; x=1690793614; 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=2zCvmEJYFTqfiAcu8CvxN/tos2dn//8Q84Fs7tMAmMg=; b=eT1Sq9I1U+ds2I5KVwn/NwqB0XzltNohvUhzxG19l7HtIdnSmW+HdONq09+CisDR86 TOBIUJC88BGjWolDqVYCyVQ5+9NiYRUd3d505OX+i2+5JNPQSA1gytLM6aH7Q6uHoMei Z923hLPKj3zl9oO1p/ZljeO9lSnNpOntMFPBhnv/tuV9cGbSbwRZeG+8JcKEeSF15q5V dbD507D9NMgX9yWt6MJG7798hpPU2u1btQr8pPSn4ijtIajXnEQNxyKISBSesevSTzpA 1Vzo7XiheUmNYsF39UNteTRk+J5MMBFqiSN3seSf9swGnYrBUsv1DIFqolHVRo5oaS5f obPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188814; x=1690793614; 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=2zCvmEJYFTqfiAcu8CvxN/tos2dn//8Q84Fs7tMAmMg=; b=eb8fmleKkyU/r50OZfN8gn4hLT3qJ8RsmTIWPyHBmk5N+TQVdc4QltNSbp3cSfy+ep 5TvHlHUdCm4B7poxhb852Kh2PWJWB6WzTFqewpq86iWOpu0nb2TC6St/or7FGrQ+/MYr MOkxHc+7IutQkjiuzviLqPseaWxrhBX4kULCUPJLQcbjaxUi5y6TrlptUjziGeNXdAqb qIia8rlPxZFKRSkbsafsY0L/vC+NBD+HTjItwBU2WhkFZ0MtOB32L7oUUwOGSHlnod7T 2DdffloBOt2FSAx081qiYsvs9ADiFq8ojtwN4/0og3EhLLbQUonQCuRVsJbx5M9On1ZW Vtsg== X-Gm-Message-State: ABy/qLZVzg6SXsowJqKai9HirDOPR6rMnTHJ1d0K3zjDdBh1ve13enDM gNm+xrX3HyBnQ443q/2qOOkxAKicW899dC6Zd58LDg== X-Google-Smtp-Source: APBJJlEcGyC7tpTcYe5pyyOqIYHhPbheQpcbI2ETvZPinCHYZujUNmXw8xztyMysX2F90DDESoespA== X-Received: by 2002:a7b:c315:0:b0:3fc:80a:cf63 with SMTP id k21-20020a7bc315000000b003fc080acf63mr8085728wmj.38.1690188813866; Mon, 24 Jul 2023 01:53:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich , qemu-stable@nongnu.org Subject: [PULL 5/7] tcg/{i386, s390x}: Add earlyclobber to the op_add2's first output Date: Mon, 24 Jul 2023 09:53:26 +0100 Message-Id: <20230724085328.4936-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188974420100003 Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich i386 and s390x implementations of op_add2 require an earlyclobber, which is currently missing. This breaks VCKSM in s390x guests. E.g., on x86_64 the following op: add2_i32 tmp2,tmp3,tmp2,tmp3,tmp3,tmp2 dead: 0 2 3 4 5 pref=3Dnone,0= xffff is translated to: addl %ebx, %r12d adcl %r12d, %ebx Introduce a new C_N1_O1_I4 constraint, and make sure that earlyclobber of aliased outputs is honored. Cc: qemu-stable@nongnu.org Fixes: 82790a870992 ("tcg: Add markup for output requires new register") Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20230719221310.1968845-7-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tcg/i386/tcg-target-con-set.h | 5 ++++- tcg/s390x/tcg-target-con-set.h | 8 +++++--- tcg/tcg.c | 8 +++++++- tcg/i386/tcg-target.c.inc | 2 +- tcg/s390x/tcg-target.c.inc | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target-con-set.h b/tcg/i386/tcg-target-con-set.h index 91ceb0e1da..5ea3a292f0 100644 --- a/tcg/i386/tcg-target-con-set.h +++ b/tcg/i386/tcg-target-con-set.h @@ -11,6 +11,9 @@ * * C_N1_Im(...) defines a constraint set with 1 output and inputs, * except that the output must use a new register. + * + * C_Nn_Om_Ik(...) defines a constraint set with outputs and + * inputs, except that the first outputs must use new registers. */ C_O0_I1(r) C_O0_I2(L, L) @@ -53,4 +56,4 @@ C_O2_I1(r, r, L) C_O2_I2(a, d, a, r) C_O2_I2(r, r, L, L) C_O2_I3(a, d, 0, 1, r) -C_O2_I4(r, r, 0, 1, re, re) +C_N1_O1_I4(r, r, 0, 1, re, re) diff --git a/tcg/s390x/tcg-target-con-set.h b/tcg/s390x/tcg-target-con-set.h index cbad91b2b5..9a42037499 100644 --- a/tcg/s390x/tcg-target-con-set.h +++ b/tcg/s390x/tcg-target-con-set.h @@ -8,6 +8,9 @@ * C_On_Im(...) defines a constraint set with outputs and inputs. * Each operand should be a sequence of constraint letters as defined by * tcg-target-con-str.h; the constraint combination is inclusive or. + * + * C_Nn_Om_Ik(...) defines a constraint set with outputs and + * inputs, except that the first outputs must use new registers. */ C_O0_I1(r) C_O0_I2(r, r) @@ -41,6 +44,5 @@ C_O2_I1(o, m, r) C_O2_I2(o, m, 0, r) C_O2_I2(o, m, r, r) C_O2_I3(o, m, 0, 1, r) -C_O2_I4(r, r, 0, 1, rA, r) -C_O2_I4(r, r, 0, 1, ri, r) -C_O2_I4(r, r, 0, 1, r, r) +C_N1_O1_I4(r, r, 0, 1, ri, r) +C_N1_O1_I4(r, r, 0, 1, rA, r) diff --git a/tcg/tcg.c b/tcg/tcg.c index 652e8ea6b9..ddfe9a96cb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -648,6 +648,7 @@ static void tcg_out_movext3(TCGContext *s, const TCGMov= Extend *i1, #define C_O2_I2(O1, O2, I1, I2) C_PFX4(c_o2_i2_, O1, O2, I1, I2), #define C_O2_I3(O1, O2, I1, I2, I3) C_PFX5(c_o2_i3_, O1, O2, I1, I2, I= 3), #define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I= 3, I4), +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1,= I2, I3, I4), =20 typedef enum { #include "tcg-target-con-set.h" @@ -668,6 +669,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcod= e); #undef C_O2_I2 #undef C_O2_I3 #undef C_O2_I4 +#undef C_N1_O1_I4 =20 /* Put all of the constraint sets into an array, indexed by the enum. */ =20 @@ -687,6 +689,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcod= e); #define C_O2_I2(O1, O2, I1, I2) { .args_ct_str =3D { #O1, #O2, #I1= , #I2 } }, #define C_O2_I3(O1, O2, I1, I2, I3) { .args_ct_str =3D { #O1, #O2, #I1= , #I2, #I3 } }, #define C_O2_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str =3D { #O1, #O2, #I1= , #I2, #I3, #I4 } }, +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str =3D { "&" #O1, #= O2, #I1, #I2, #I3, #I4 } }, =20 static const TCGTargetOpDef constraint_sets[] =3D { #include "tcg-target-con-set.h" @@ -706,6 +709,7 @@ static const TCGTargetOpDef constraint_sets[] =3D { #undef C_O2_I2 #undef C_O2_I3 #undef C_O2_I4 +#undef C_N1_O1_I4 =20 /* Expand the enumerator to be returned from tcg_target_op_def(). */ =20 @@ -725,6 +729,7 @@ static const TCGTargetOpDef constraint_sets[] =3D { #define C_O2_I2(O1, O2, I1, I2) C_PFX4(c_o2_i2_, O1, O2, I1, I2) #define C_O2_I3(O1, O2, I1, I2, I3) C_PFX5(c_o2_i3_, O1, O2, I1, I2, I= 3) #define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I= 3, I4) +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1,= I2, I3, I4) =20 #include "tcg-target.c.inc" =20 @@ -4703,7 +4708,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) * dead after the instruction, we must allocate a new * register and move it. */ - if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { + if (temp_readonly(ts) || !IS_DEAD_ARG(i) + || def->args_ct[arg_ct->alias_index].newreg) { allocate_new_reg =3D true; } else if (ts->val_type =3D=3D TEMP_VAL_REG) { /* diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index ab997b5fb3..77482da070 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3335,7 +3335,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_add2_i64: case INDEX_op_sub2_i32: case INDEX_op_sub2_i64: - return C_O2_I4(r, r, 0, 1, re, re); + return C_N1_O1_I4(r, r, 0, 1, re, re); =20 case INDEX_op_ctz_i32: case INDEX_op_ctz_i64: diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index a878acd8ca..a94f7908d6 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -3229,11 +3229,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) =20 case INDEX_op_add2_i32: case INDEX_op_sub2_i32: - return C_O2_I4(r, r, 0, 1, ri, r); + return C_N1_O1_I4(r, r, 0, 1, ri, r); =20 case INDEX_op_add2_i64: case INDEX_op_sub2_i64: - return C_O2_I4(r, r, 0, 1, rA, r); + return C_N1_O1_I4(r, r, 0, 1, rA, r); =20 case INDEX_op_st_vec: return C_O0_I2(v, r); --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188877; cv=none; d=zohomail.com; s=zohoarc; b=REKLXEPqGN1ROMAD8bZK8kQ9Noo+B5gmUIkFNzxSiPLQ5IftEjlhrcZXBf7/iOJk3FrKDMG3NiBVfgRaOmYXPLEDpPDkpJazD1Gclit0b42f6KStQlqpQ7Iq0mUAEnDj1R6ZmGTisCka7P9p8yDp13JOAgGBpb2at3uYDLVb6QY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188877; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MwLIjhqnbiVZ/y9qr7U0+BJ2Kjk5/r2inTh7YJ6LvNY=; b=SMeKQqQOdnys/s57qQ4XVaYxB+T+g/y74BHiTmUEfuaZk+xuAuzliRo/uBbNggPjtzKY6c1qyAJHt+/ShqLBK/c9DtNQZCsYUCEWSWhTyoIKy31Qs/QCeIIR6ttCI+NIhP/RypasEQwUlzwct6vTBIzRUuJYIC7jc7SLhVfVcgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169018887728336.47963919167751; Mon, 24 Jul 2023 01:54:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrK3-00028N-QT; Mon, 24 Jul 2023 04:53:43 -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 1qNrK1-00027C-H0 for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:41 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJw-0000f7-0T for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:41 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so38915625e9.1 for ; Mon, 24 Jul 2023 01:53:35 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188814; x=1690793614; 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=MwLIjhqnbiVZ/y9qr7U0+BJ2Kjk5/r2inTh7YJ6LvNY=; b=M3GpOBBs+/ZuFc8vFlyz30at+l1qOFV/I8aDEgi9jyJM7T7XGyMAWfLJ2TF+EAvqql aOPlGE9twb+SwYO3q2Ev+bCzj/LdtOcfdJMpEiQPwbGdAi7ornpgyHGAx7mE9qz8T6zb dAHfz5D6QuIegRovguNtz8v6RgDlIkC5nt8Ktkqt6OkYYCFXxy29lOMsbh0980s/kvWG 5dkZQYQwPQD1uwqRKUtegrw8a5Ym1tOgy8T7a3Nbm8ykiB+Q4FQxXpAqb4nUCKy34HRA Ti9SXs/lvkPrAqGWqCs0AOS1pfPPKMQuvz4j7JFzyaXiAH8g4uUIJFZFrHMgKYkjwJy6 umhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188814; x=1690793614; 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=MwLIjhqnbiVZ/y9qr7U0+BJ2Kjk5/r2inTh7YJ6LvNY=; b=jcYGrgrA0PXluNNiaKmpjNSTp4V3xwS7HzLQ8GT1ewlO4BahTvj3PJ8Rzxr6QImWOL mgD4zmlkmWJlbYArpSRKjyxjgOf9V+J5jUDRPlw8HfZNBNUF+S9BgEZOajdOOoZxL5W0 YrSEDucXvTnt5re2bhSBY2sHPbD10kcMC2wakHsjK39m50hBPHACH+rNsXw7Qnmw4Zq4 NLHzCTych5/J7Gad/byEOgP01K2FnhfJaWG73dxD36qS3ufaMkHmD5N1tlWu851qSV0J chhdhmNdarcUoSZlGDpzLbNXSqW1L1yD2kh27AwEj/jhkLK3wv1toM/sy48TzLNfeD8d 7iTw== X-Gm-Message-State: ABy/qLbefCvLZOpKNnhAXpUqIVEnDUVocNMvbkJ++EZ9ibaPVqKm/Syj dOFMC65xB5m2ImVr+LhrzHTsU22gLvA9noPfkmygew== X-Google-Smtp-Source: APBJJlFbSzyI/K4AVQb1ODAZXOvY+NuGWDpAmUVwmwfGy0eS12K6xvlsLueevYT9YakKgWosL57LCQ== X-Received: by 2002:a05:600c:259:b0:3fd:30f7:2be1 with SMTP id 25-20020a05600c025900b003fd30f72be1mr3774360wmj.39.1690188814654; Mon, 24 Jul 2023 01:53:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Anton Johansson Subject: [PULL 6/7] accel/tcg: Zero-pad vaddr in tlb_debug output Date: Mon, 24 Jul 2023 09:53:27 +0100 Message-Id: <20230724085328.4936-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188877945100006 Content-Type: text/plain; charset="utf-8" From: Anton Johansson In replacing target_ulong with vaddr and TARGET_FMT_lx with VADDR_PRIx, the zero-padding of TARGET_FMT_lx got lost. Readd 16-wide zero-padding for logging consistency. Suggested-by: Peter Maydell Signed-off-by: Anton Johansson Message-Id: <20230713120746.26897-1-anjo@rev.ng> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e0079c9a9d..ba44501a7c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -497,8 +497,8 @@ static void tlb_flush_page_locked(CPUArchState *env, in= t midx, vaddr page) =20 /* Check if we need to flush due to large pages. */ if ((page & lp_mask) =3D=3D lp_addr) { - tlb_debug("forcing full flush midx %d (%" - VADDR_PRIx "/%" VADDR_PRIx ")\n", + tlb_debug("forcing full flush midx %d (%016" + VADDR_PRIx "/%016" VADDR_PRIx ")\n", midx, lp_addr, lp_mask); tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); } else { @@ -527,7 +527,7 @@ static void tlb_flush_page_by_mmuidx_async_0(CPUState *= cpu, =20 assert_cpu_is_self(cpu); =20 - tlb_debug("page addr: %" VADDR_PRIx " mmu_map:0x%x\n", addr, idxmap); + tlb_debug("page addr: %016" VADDR_PRIx " mmu_map:0x%x\n", addr, idxmap= ); =20 qemu_spin_lock(&env_tlb(env)->c.lock); for (mmu_idx =3D 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { @@ -591,7 +591,7 @@ static void tlb_flush_page_by_mmuidx_async_2(CPUState *= cpu, =20 void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, uint16_t idxmap) { - tlb_debug("addr: %" VADDR_PRIx " mmu_idx:%" PRIx16 "\n", addr, idxmap); + tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%" PRIx16 "\n", addr, idxm= ap); =20 /* This should already be page aligned */ addr &=3D TARGET_PAGE_MASK; @@ -625,7 +625,7 @@ void tlb_flush_page(CPUState *cpu, vaddr addr) void tlb_flush_page_by_mmuidx_all_cpus(CPUState *src_cpu, vaddr addr, uint16_t idxmap) { - tlb_debug("addr: %" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap); + tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap= ); =20 /* This should already be page aligned */ addr &=3D TARGET_PAGE_MASK; @@ -666,7 +666,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState = *src_cpu, vaddr addr, uint16_t idxmap) { - tlb_debug("addr: %" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap); + tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap= ); =20 /* This should already be page aligned */ addr &=3D TARGET_PAGE_MASK; @@ -728,7 +728,7 @@ static void tlb_flush_range_locked(CPUArchState *env, i= nt midx, */ if (mask < f->mask || len > f->mask) { tlb_debug("forcing full flush midx %d (" - "%" VADDR_PRIx "/%" VADDR_PRIx "+%" VADDR_PRIx ")\n", + "%016" VADDR_PRIx "/%016" VADDR_PRIx "+%016" VADDR_PRIx = ")\n", midx, addr, mask, len); tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); return; @@ -741,7 +741,7 @@ static void tlb_flush_range_locked(CPUArchState *env, i= nt midx, */ if (((addr + len - 1) & d->large_page_mask) =3D=3D d->large_page_addr)= { tlb_debug("forcing full flush midx %d (" - "%" VADDR_PRIx "/%" VADDR_PRIx ")\n", + "%016" VADDR_PRIx "/%016" VADDR_PRIx ")\n", midx, d->large_page_addr, d->large_page_mask); tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); return; @@ -773,7 +773,7 @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState = *cpu, =20 assert_cpu_is_self(cpu); =20 - tlb_debug("range: %" VADDR_PRIx "/%u+%" VADDR_PRIx " mmu_map:0x%x\n", + tlb_debug("range: %016" VADDR_PRIx "/%u+%016" VADDR_PRIx " mmu_map:0x%= x\n", d.addr, d.bits, d.len, d.idxmap); =20 qemu_spin_lock(&env_tlb(env)->c.lock); @@ -1165,7 +1165,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, &xlat, &sz, full->attrs, &= prot); assert(sz >=3D TARGET_PAGE_SIZE); =20 - tlb_debug("vaddr=3D%" VADDR_PRIx " paddr=3D0x" HWADDR_FMT_plx + tlb_debug("vaddr=3D%016" VADDR_PRIx " paddr=3D0x" HWADDR_FMT_plx " prot=3D%x idx=3D%d\n", addr, full->phys_addr, prot, mmu_idx); =20 --=20 2.34.1 From nobody Fri May 17 03:12:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690188879; cv=none; d=zohomail.com; s=zohoarc; b=JPSgngXgD/PT1qMX0SWLkNsB7CqCMYTvOJNcFEvqEyxSSAB0yQ6UMUTciKmWm6qmbnC6bI2/uudL8r/kMdKz6cJMJrGBVbvIjY1kVT5QDwIXX0OdhAlYPfntBKE0Hi76PlbkNh/wN9en0IYU5hs1msBORzF1xQzAtzv0PTWD070= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690188879; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T1Y8T/xVALsYcshJKAiwyXKIcg4f5npWahbPLhzxr0I=; b=SdLYyOJx2bIymv71IVy8P/edIHJi8YIuulFyZtXOKamPih5QxkMlWrjVSKleNsOh3yV+Ohyxf87xCJ/ls1TJI0btmk+DKIdcI8gTFFA+2CCZYRjp9nrMISqciawG5Et+CXW9vmEJpXE5r5uIZvABmPZP3OFagwah/c0QrGVHsjI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690188879672299.1951133967124; Mon, 24 Jul 2023 01:54:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNrK0-00026e-Ic; Mon, 24 Jul 2023 04:53:40 -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 1qNrJz-00024g-3n for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:39 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNrJx-0000fh-J9 for qemu-devel@nongnu.org; Mon, 24 Jul 2023 04:53:38 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fb761efa7aso6133489e87.0 for ; Mon, 24 Jul 2023 01:53:37 -0700 (PDT) Received: from stoup.. ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id t8-20020a1c7708000000b003fa74bff02asm9570994wmi.26.2023.07.24.01.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 01:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690188816; x=1690793616; 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=T1Y8T/xVALsYcshJKAiwyXKIcg4f5npWahbPLhzxr0I=; b=LeSKyAQ1cY7wirUMvIv4NpuHYWyZ6wZ7HC6HZ6ZQAGyBwC/GqN0Iedp8sB74P/z8d7 nPe12tORKncsgJ/xlByaKUIOERzUD0ALCcHSNDsw6qEg5EkuBw1/KnpU9R6fsmyidg5m vK78FnqyEKtF8M94ipXYaP8EVg4fBqr/mZh9W5aTLz9U/enADkaUtgTIP7CrRKSRZSgM +6hUuS31pEJ63Hr8yYJFbHQWUhLYUWar2Rgn1u3n0FTQPqfNcH2hn6xq0tHaZeh0xtNZ ENmhDZhvgaWP18E3k/oHaLgQGZwmb4Of/ZOokMvRF25+Gw5zQd5nVaPyfGKYYgPvHO8v ywxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690188816; x=1690793616; 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=T1Y8T/xVALsYcshJKAiwyXKIcg4f5npWahbPLhzxr0I=; b=QDbe/RCwwZt8lI8OU7R+gv8UGeXuB3Dp3Q5e6yMtIA85xgOBeyODlZr5cP1ntDl5bZ RNP5mk1X/T17b5pAl7YXKfhhQz6z1mt2N8RofRIbBopO9PuEsAo+/UqnJleGqV5egAdk LyeAMihIc+axtHbxVOaCAoj0nC3sKptHoZ9hzJZ61vsBB45+s3zGPlTYI3IxOMlZyn1m EV1f09UXsfQU366awfGeLK80+3brrKTs8DlAu6XA70AOZepMJ49TRsUngX9J1U9ir5Kf WPntIkfSmfYJ25+Fmt/mPympYruWhkvUMuIlyKeQVkbWHosj0dW5Y6QYG8uJxQoJyBnJ 7Gww== X-Gm-Message-State: ABy/qLZDw0OJS7IvKPgsuvidYo9krVYBgbep4GIfOcZBP7CW8cyKChpk TzgbJqYm88fR09rwlQ4eqYaNH8Ktyl3TNU3PveaY3w== X-Google-Smtp-Source: APBJJlHLNIV/aNYs0N/0vz1Fm0H1dk4BlfuHuyww41rifiV5EevbsSg+ehaXtGWSedw+cmLRi3VNEg== X-Received: by 2002:ac2:58e4:0:b0:4f8:7503:2041 with SMTP id v4-20020ac258e4000000b004f875032041mr4207696lfo.37.1690188815869; Mon, 24 Jul 2023 01:53:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Luca Bonissi Subject: [PULL 7/7] accel/tcg: Fix type of 'last' for pageflags_{find,next} Date: Mon, 24 Jul 2023 09:53:28 +0100 Message-Id: <20230724085328.4936-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085328.4936-1-richard.henderson@linaro.org> References: <20230724085328.4936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=richard.henderson@linaro.org; helo=mail-lf1-x12a.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690188880107100017 Content-Type: text/plain; charset="utf-8" From: Luca Bonissi These should match 'start' as target_ulong, not target_long. On 32bit targets, the parameter was sign-extended to uint64_t, so only the first mmap within the upper 2GB memory can succeed. Signed-off-by: Luca Bonissi Message-Id: <327460e2-0ebd-9edb-426b-1df80d16c32a@bonslack.org> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index ac38c2bf96..ab48cb41e4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -144,7 +144,7 @@ typedef struct PageFlagsNode { =20 static IntervalTreeRoot pageflags_root; =20 -static PageFlagsNode *pageflags_find(target_ulong start, target_long last) +static PageFlagsNode *pageflags_find(target_ulong start, target_ulong last) { IntervalTreeNode *n; =20 @@ -153,7 +153,7 @@ static PageFlagsNode *pageflags_find(target_ulong start= , target_long last) } =20 static PageFlagsNode *pageflags_next(PageFlagsNode *p, target_ulong start, - target_long last) + target_ulong last) { IntervalTreeNode *n; =20 --=20 2.34.1