From patchwork Mon Jul 24 08:53:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705737 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1664905wrt; Mon, 24 Jul 2023 01:54:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGK3JCbZ9dSBiBa2XZ/ARYbdn/zCaU5+c56XiITAd1rwQgIxQscL7ufmgkZ/LWaDTnz60V7 X-Received: by 2002:a0c:f593:0:b0:630:1732:7084 with SMTP id k19-20020a0cf593000000b0063017327084mr6426992qvm.61.1690188842747; Mon, 24 Jul 2023 01:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188842; cv=none; d=google.com; s=arc-20160816; b=cxoDMLTrC9sPM5j41uRNZfLbW6HMtXUyH7ZXhg9p7DbDlysy2BYxDfWHfR1LZRoxks KIrvOo6MSEryH3aGKJJk+vCN4ATRIYCJYX8ynNbCjjfpts5ss3NqBJGs+sofosAEgEWu V1BTVT5JlX3Vs50g9Q5pGBWWzu2JomKwH5f/LbXgN3aBDRahuok1h/Ci3gzKitJlGCFn EWnZi0ABsVDyOcxzB52N9/6aMZvt+NCRKva5EaNt0I6vUNvwAcHEmTWtUZOP6QWIOAmp KgAljDxZPcCEYg0OLMhGEBVc0vni4UvVhaNnJMRYHeG5PgpjcfN3vEPrWBPf/ackH2P8 iSww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=o3gKpL8DiepyBHxNbIedU4D/NFgh/WMqJ9tvA2IW734=; fh=R2DFDnjXVhhOWsqShXj56qpqBRa2r/KSSSQq8BCMjd0=; b=Vgdo1BMKUN+Z0Lib4JklarQiBZf4VPqjjStr0QeC/NTyxh2jkIlVtrjU2ev3C7msB8 iAu3KUJz84Yec/ghfvLfl94Clmx8En6Jws7AQb/ksrMVkuDJhpFYQXB59hzJ6o9dUR04 QRD3uu7m6XxHgVqMLnZ13dCVV1qwWf3I2IcprnmiDTcTW6d911J3/VTC8uqXtWTs8YAN 4W4vvzgCdKdsgs8MVT2N7I4dY9PDlvtpxqG9ujhRHIvWUY3+TdIn5LHxaKgXxJG9Qkr/ MZaLJcwfDIfeAm9Mo5NVw49JBWWwJ7Uc6ayJ0z6O2RB7S9nsbXS5iK/ieIKyza+T6u2o GNoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BIuusPkj; 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 h25-20020a0cb4d9000000b005eefc559ac9si1430954qvf.401.2023.07.24.01.54.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:54:02 -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=BIuusPkj; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 which) ptrdiff_t offset = tcg_tbrel_diff(s, (void *)ptr); tcg_out_mem_long(s, LD, LDX, TCG_REG_TB, TCG_REG_TB, offset); - /* 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); - /* When branch is out of range, fall through to indirect. */ tcg_out32(s, BCCTR | BO_ALWAYS); /* For the unlinked case, need to reset TCG_REG_TB. */ @@ -2528,10 +2527,12 @@ void tb_target_set_jmp_target(const TranslationBlock *tb, int n, intptr_t diff = addr - jmp_rx; tcg_insn_unit insn; + if (USE_REG_TB) { + return; + } + if (in_range_b(diff)) { insn = B | (diff & 0x3fffffc); - } else if (USE_REG_TB) { - insn = MTSPR | RS(TCG_REG_TB) | CTR; } else { insn = NOP; } From patchwork Mon Jul 24 08:53:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705738 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665159wrt; Mon, 24 Jul 2023 01:54:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6LHYTNWcY9++MZ3z5+fVPMG6w0tRwJOTnyQXL7BB2jR25CC7k7kBacZTzRsRhQtC7MSq+ X-Received: by 2002:ad4:5be2:0:b0:631:f9ad:1d46 with SMTP id k2-20020ad45be2000000b00631f9ad1d46mr9586715qvc.47.1690188875278; Mon, 24 Jul 2023 01:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188875; cv=none; d=google.com; s=arc-20160816; b=0QcZLtIxRQmLTVAiS5SRrFpyicFPzeiXzAFy24A9d6kdcd/XL0xQ8fs9ulMw/ntIo4 jG0Tn1Zags8jToLAQBT4Ep/v6Sualh1xhfeUgTWSjMXwvNJuAY0QD0lPzXcZRCw6TRT6 dFy7k7bw8qweIP3zCXE94p++nMDVDnfRw3h/RbLlEvAuluGXu4uZmRcW+fnq7XFYQJ+h yVZ9EBFZRSVFpJ5LaWrRoUJX7RLh1dZMSiCzasfhhCG9D17/UFFdugTjBZc/ykbk8Zdd Jxgw6rYhq/0j2M6hFq5eoYBXiz84VowZBB6jDiMILUBG4ELFW0kM/C53Qe66idekNyls RSRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=YIZ//uqvzyazKLUP5z3YoDBSBVlSC65GXHLWCWeqo2o=; fh=dar3VLbuhlF4sfQjYytRTFhcEwFCm4WmC7f2qzZT2aY=; b=tyNzokF1JrBh94N3i6qoJpJrVgyL7trZYz6F85va34TQZg9j7rdbff5/qYjUT1VAlb yoBKt4JXfPK3xvxBbQ9SaRsoEg6lHxjn7kXPbL5K/72+ArmFObGWOjQICWnAztxCKeHW H3XTsVzZ6iEWvDLl+P3Xe5zfVStnW0MfdLVfYF4MuYk3RLJ9Ev9M1AnwFXmB+g3TuC5u w2PYVKFTAgeV35N1NmFGH1F8ukp8pTyu6+J6cLj1l6Dz7ppUStS+q3+u9prm/uHymcVh Q6px/+5BI42rl98VnYH1gD6zf5yxFMOKj54JVXWoB+nR4ELgWO22bh73sXPYqbNaf9KK Jddg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y68Q6yBp; 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 a4-20020a0cca84000000b0063cf8568a9fsi1886851qvk.500.2023.07.24.01.54.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:54:35 -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=Y68Q6yBp; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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); +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))) \ + = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 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, target_ulong addr, #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} +#define WITH_MMAP_LOCK_GUARD() 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) void mmap_unlock(void) { + assert(mmap_lock_count > 0); if (--mmap_lock_count == 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) void mmap_unlock(void) { + assert(mmap_lock_count > 0); if (--mmap_lock_count == 0) { pthread_mutex_unlock(&mmap_mutex); } From patchwork Mon Jul 24 08:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705739 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665165wrt; Mon, 24 Jul 2023 01:54:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlENvCUN2vVUVSfH6kDZCdtjYxxtTiYOLgTxqgxY6RUM2okCqyVHADQxrLZZyQ6/21ByO5Xd X-Received: by 2002:a0c:e510:0:b0:63c:fa85:e291 with SMTP id l16-20020a0ce510000000b0063cfa85e291mr3385871qvm.42.1690188876192; Mon, 24 Jul 2023 01:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188876; cv=none; d=google.com; s=arc-20160816; b=GKplvx31opovRmca4Wh7FaxBIlT9xdCjzwzgoksiCrvbIuxSDVZEGUIg8PvZblcxGM 4uhulktKTssCFPCJEsL8/Q+5dBtZeZdOOT/TWyQkmxRy27BV4LGyVt7VYusfD0lH2dlW NFUpi3n3m3ktV042dH+4KL355vP3fH7Buc7Pxb6NgfCpDQvcrMqU9BNortdw7RMaMEE7 WkHT+ISAUM3uEDzjxKNLunbcNsGfmoXxvo+P6jskgzdGChkZrR8HMR9CLonmww+YjAab 2vZ13QwUSVS0j4E+qOIBG0unfNDJGZVDraKcPomf/3IWjP0JevAWu4aufNcck/OajUXZ 84NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=Kx8DX46zDkvv/0NYLawLSaPgKsBMt29LaRgzXxGcPGg=; fh=dar3VLbuhlF4sfQjYytRTFhcEwFCm4WmC7f2qzZT2aY=; b=WCppXMb2Gcj4WStlQR96NwndNBGh6nIwqoky2FCfwu35BjfuwJCfeCy3QunqnLLJ3r EAKGEGln46iDNJjEyIRIMKl/9UhEZ0NvtKjMpwWjo0GjIWpaL/Y50fzaIG2FDPwEFgkd 3RO4imIcLg6sz5B2nm/cuQzu8VTRF/4zD/aLBRK6AMe2CvLADIWBvYhiii59gSDsfDg2 COsG5I1+zv6n8nrVgVZ3FihJNdLtn+8zw3xwSA3qxZprXkFTGQtNhSWYKtjG9cUg5FTx Yxm7vPN979r/kQhW8gq3UuW+HHFxFH8rXVo//uCRiUZ6IAnLhP2TCT/AL6DRa85XYku+ tjsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJE8bUXX; 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 m7-20020a0562141bc700b006372b2854b9si5251533qvc.475.2023.07.24.01.54.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:54: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=VJE8bUXX; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = __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 From patchwork Mon Jul 24 08:53:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705744 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665770wrt; Mon, 24 Jul 2023 01:56:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpnxMi/xzr+9sm4GN20F4lm9bpbX5AiMKDoORealqdA3KvkMGcR0sxFX/i6oIMyuaKFP8n X-Received: by 2002:ac8:7f8d:0:b0:403:b41b:a6c6 with SMTP id z13-20020ac87f8d000000b00403b41ba6c6mr6219067qtj.38.1690188986216; Mon, 24 Jul 2023 01:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188986; cv=none; d=google.com; s=arc-20160816; b=E0mwCT9qq0Rmjxk4I0WcdTQhs/PUWltJAFsAjJDxDs9MXULbW/pcxLtPI4k6v0zj1q ggUsLaIunQnK/o7QQy+/SkT555Ani8//etQ0lA1jztVtJgYYuuA4CR7oEgcn4CQ3afUg u0bMjWUB7Rec5ifNJmJ251WQFlVzIeLI4dG1oi0DhL3zwEvAin3fKAlUqyZZ6f0Rk+Jm 20Ju/zbiDikkUqGg5cNHYPGviZk+Hq/2hKcCABNkhupy/04r/1P+LBXv5vgIajlRjxTj umbn9A1/LlK+UmZsLQhGt7p43zlW4Qpzv0EISm1C1+4Il06Z7eoKf9cqcdDZYH1tO9rr flAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=FtcjV7RLMVbCUSYkAiLh5IZllixWR3iJOTzr/2oXRS0=; fh=dar3VLbuhlF4sfQjYytRTFhcEwFCm4WmC7f2qzZT2aY=; b=eBf9JSQ4pYvehkAQlHTK1piMvs2Yi8JDwBYj8tVNGAsv+XfPd3g4h5/8SG0/aeK75p GBS4yk79siVZDjjUmBKRwaGLu12yQXYaK0qWD0LAOfWB1icC+m4065GRqBNceRc89cxI 1HCUexBHNIT5e8rco3fqmLGornb3GExCfjgW5OHQUATX1Yh79pwCYWAffCjHFX7Nvx1y qxSyYCULl7JbqKbinTF8ksGtWW4elLD+uDOYl2UlTPOfCu6rRFmc8NM0XIxaDThNNjhJ pgFG5RLUv4aE5dj6AjPZO4j9wKuVLVPPDAHzs7ht4CdhgtqdH/nvuLsn9nJcwlLGnD+q 7PDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cvcAyU+A; 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 p20-20020a05622a13d400b0040547442debsi4704026qtk.56.2023.07.24.01.56.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:56:26 -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=cvcAyU+A; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = __builtin_assume_aligned(pv, 8); - return *p; + WITH_MMAP_LOCK_GUARD() { + if (!page_check_range(h2g(pv), 8, PAGE_WRITE_ORG)) { + uint64_t *p = __builtin_assume_aligned(pv, 8); + return *p; + } } #endif @@ -186,25 +188,27 @@ static Int128 load_atomic16_or_exit(CPUArchState *env, uintptr_t ra, void *pv) return atomic16_read_ro(p); } -#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); + } } /* Ultimate fallback: re-execute in serial context. */ From patchwork Mon Jul 24 08:53:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705743 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665718wrt; Mon, 24 Jul 2023 01:56:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFEgxTe52YjyZV5ddXcqeaNDJ9NyWGIy6ConHbE6wdEgub9T4hfQcRUeg0ab0cpeqF4e2sM X-Received: by 2002:a05:620a:2495:b0:767:2e2b:b4ff with SMTP id i21-20020a05620a249500b007672e2bb4ffmr6262659qkn.52.1690188978306; Mon, 24 Jul 2023 01:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188978; cv=none; d=google.com; s=arc-20160816; b=daxsL9Imj9Pq9sez1481evzurwemh/CFcu1yiFKn3qIxkcW1D4xWcNr/4AWDTxGl6d vXG/dB+F+BC1Y5E0k+xWeGQ/Gzs7arkTlAZBfgVpfioua6giBfusKPRSIfbpArxvYNtl dvS+UaiYhb6C9S9m6Jy4mLhFPGg2e0uhMg9TOFvZv5SBF+9F1NUrEZT/N59zK18RolK1 D7n37zR3axuQPeRteQOuVrGUAC23Al+uG2PVOkfpTg2TvA5gNeXH06oHvtWiQIRn1Hrx mb+FWEisQbVGMNO9lfJ+ru8V8fu0xViYQBbOlzuM3Jni9kCO3sJ+YDhIBG5CEg8phgde cZ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=2zCvmEJYFTqfiAcu8CvxN/tos2dn//8Q84Fs7tMAmMg=; fh=1nyMqyj5TfbEVas17tu9g51suQyOzyRz6ARF0T2njjQ=; b=u2iFNUcMIksh9SrDSl8YtUo/jB41QSxdkUIzILBYOHvlfXUWD31kG2kjxrjpISKWSt kncvI2DefEOEOCHmEqddg1P0a6z5XIOYcAyYAcZwmpqW3Nyn11yFmFwqxvAeloxMV3wX Y1h5kp+O64IBsX+LZZdvVmF8NFbCbKhV+EOUULcz/4o6GM951MEIjo0RpuBbu0dCjfGC r+3A/Es8Wfbx2apofOK2xxzM0XQ8EpNQMshbDlTpQbwuugBKGAW3BoT3bpl0Sunil2+r 4w4zrjf5VN1bpUqQxdRfcZNhGJtSmNM/2muCe8frRDkIjCEzxyU1qQvvbG6ZGJxPe7E8 zT7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eT1Sq9I1; 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 g19-20020ae9e113000000b00765a7b69a74si4842215qkm.673.2023.07.24.01.56.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:56:18 -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=eT1Sq9I1; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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=none,0xffff 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 TCGMovExtend *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, I3), #define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I3, I4), +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1, I2, I3, I4), typedef enum { #include "tcg-target-con-set.h" @@ -668,6 +669,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode); #undef C_O2_I2 #undef C_O2_I3 #undef C_O2_I4 +#undef C_N1_O1_I4 /* Put all of the constraint sets into an array, indexed by the enum. */ @@ -687,6 +689,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode); #define C_O2_I2(O1, O2, I1, I2) { .args_ct_str = { #O1, #O2, #I1, #I2 } }, #define C_O2_I3(O1, O2, I1, I2, I3) { .args_ct_str = { #O1, #O2, #I1, #I2, #I3 } }, #define C_O2_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str = { #O1, #O2, #I1, #I2, #I3, #I4 } }, +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str = { "&" #O1, #O2, #I1, #I2, #I3, #I4 } }, static const TCGTargetOpDef constraint_sets[] = { #include "tcg-target-con-set.h" @@ -706,6 +709,7 @@ static const TCGTargetOpDef constraint_sets[] = { #undef C_O2_I2 #undef C_O2_I3 #undef C_O2_I4 +#undef C_N1_O1_I4 /* Expand the enumerator to be returned from tcg_target_op_def(). */ @@ -725,6 +729,7 @@ static const TCGTargetOpDef constraint_sets[] = { #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, I3) #define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I3, I4) +#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1, I2, I3, I4) #include "tcg-target.c.inc" @@ -4703,7 +4708,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *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 = true; } else if (ts->val_type == 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(TCGOpcode 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); 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(TCGOpcode op) 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); 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); case INDEX_op_st_vec: return C_O0_I2(v, r); From patchwork Mon Jul 24 08:53:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705740 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665169wrt; Mon, 24 Jul 2023 01:54:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmDK9UhZXFAzn6uT+gU/kUX/LEwjEenouuWv8I2J3hTbI3GsnGGeh0M1oOFsa4je2vxo8z X-Received: by 2002:a05:622a:1016:b0:400:aaa0:a4f9 with SMTP id d22-20020a05622a101600b00400aaa0a4f9mr9428568qte.17.1690188876964; Mon, 24 Jul 2023 01:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188876; cv=none; d=google.com; s=arc-20160816; b=b/cxZc+gRCzixdHiQnI5z1RNwi08P1J2DhFKvepi56lAtqKMJZqs0kHHR1kMbCPlRI eOMZoxR756AgfqyJaRtLU3sio5MaW+xnlh/4FDHsHNTnfDul3Xo6hsZNqXb9aWeW1E27 +WITO96VMaoqQCwpwtSc5V6WhFfCyRYXALL3rpNSjUCjA/bv6ZcHwkDP3UJfzaCQN3qh +dCYvCb0g+yBcpEMSvdoJd2fbDtbpCul4nLqfAQHXhTrMB/ExOttYHm63rvJTgxX1uix oiqK/rFfeUgV1mTrdXVeFvGHfeh8MSa4vnllURkbbVHFRNwY1uFchUTJSb25Epb3lJer EDCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=MwLIjhqnbiVZ/y9qr7U0+BJ2Kjk5/r2inTh7YJ6LvNY=; fh=AGfuRVwW69BvMljaNDG+1N3OIAsj3OPhBNKReXU7Ojo=; b=fOfTRn4B46Ljli7lSh+MwFHtDYIsGxAdXQdMN+d1b9KHgzWx3+yoKzOAdnQtmWVY5Z /aaUV7fMXglexUIV1ygiD6reN2ogviklmYnvbHCrkXCCFvU8wQAgMrH7jslough+M5m7 gIp210gqEN1UauIP1cpPHvuAL4gwhPBI1KYHfq9F9yTtenw9VEVUA0Xro/bRikNsAwld 2MgfztnptXEe65zJdbLdgA07OvyEGa6RMB69GGoZiCzsJtjp0Cx7wmMIPD59zqemd5fh 22vOcmNV2aKoGyr4POVfAuRO1nTtR+Lg08VaJQ5ESpIF/SW9zXjGXozdkj8BVU95QeQo StOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M3GpOBBs; 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 a22-20020ac85b96000000b003ff3046e43dsi5061756qta.767.2023.07.24.01.54.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:54: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=M3GpOBBs; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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, int midx, vaddr page) /* Check if we need to flush due to large pages. */ if ((page & lp_mask) == 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, assert_cpu_is_self(cpu); - 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); qemu_spin_lock(&env_tlb(env)->c.lock); for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { @@ -591,7 +591,7 @@ static void tlb_flush_page_by_mmuidx_async_2(CPUState *cpu, 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, idxmap); /* This should already be page aligned */ addr &= 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); /* This should already be page aligned */ addr &= 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); /* This should already be page aligned */ addr &= TARGET_PAGE_MASK; @@ -728,7 +728,7 @@ static void tlb_flush_range_locked(CPUArchState *env, int 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, int midx, */ if (((addr + len - 1) & d->large_page_mask) == 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, assert_cpu_is_self(cpu); - 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); 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 >= TARGET_PAGE_SIZE); - tlb_debug("vaddr=%" VADDR_PRIx " paddr=0x" HWADDR_FMT_plx + tlb_debug("vaddr=%016" VADDR_PRIx " paddr=0x" HWADDR_FMT_plx " prot=%x idx=%d\n", addr, full->phys_addr, prot, mmu_idx); From patchwork Mon Jul 24 08:53:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705742 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp1665180wrt; Mon, 24 Jul 2023 01:54:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRJ4BVl57kdtkTJuI8VnING0qrGv3Eh7ChLXwStXaSzZKd0MH+w+P7Y77+2z71M7ud4MDv X-Received: by 2002:ad4:4529:0:b0:625:aa49:ea0d with SMTP id l9-20020ad44529000000b00625aa49ea0dmr7538572qvu.32.1690188879214; Mon, 24 Jul 2023 01:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188879; cv=none; d=google.com; s=arc-20160816; b=tuQ/tbp9RzsyzAwrRSYW6PhC1coyDiXCCriJvCYzXBcSr30vtfq5XLWGL/qB00UrB9 gSt4AGY8ZAGTyu3WnpN66JLH8oVRBpJxxZrcQhatwVWNDXTvyxk7FShrThHeVHvCBOu1 fKTNifXeaG4Q74U+WU0s1EmF8DSLqRi1JOmVNJjIBr/WNgPNjAnUQLQXikfLZ6aLxwUF VtpGTCgB5To3L0Rw3kY5UXMFcX8tt98T1t48tmEsdfFa260XZWz54aPr2rkR6/QPgLPR f4T7RhkGWioNzTCv7EpLO6bV3Al0TUV2t3O+/hzd28y5gRec9QcJAMGsIB2tPmYQFybV K5qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=T1Y8T/xVALsYcshJKAiwyXKIcg4f5npWahbPLhzxr0I=; fh=wW9QqZrIwvXdufqLCSIM/cmhul7Gan52SjZSN+eK1NU=; b=aNsmxcebss+uvru2ChQCWeG7Xy4xyNhNtM64SOx5MLztm/5V8wlWMGQ6xkvw3t9uqR 01lKV2nAriaq2x0VQPmc8UatmGuGMwrWnc1fG1m3hhlUwxUJt8SFpXXCZ+a0gIYm4Uk9 gtfnwNjWADs99SnapaK4Wpntyv+K8v+hAed6ciJBoq2Fskb4SdN1b3A2sm5lzsZ3E3dB OAatgMJsnsMq56sqDu0ZDstGhz1PfRSzGLpGIQLLSAHVC3E/Dtm2Lrm/Au0PTYQvd3XD xP5suWPvmSxIWHSrLu8c4FT3KajnRZHtCO9+ZGfAjWDSlekbq+0YldrDMxWkrmAokZnO Y8pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LeSKyAQ1; 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 g27-20020a0caadb000000b0063cdb867b93si4216051qvb.67.2023.07.24.01.54.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2023 01:54: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=LeSKyAQ1; 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] 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 { static IntervalTreeRoot pageflags_root; -static PageFlagsNode *pageflags_find(target_ulong start, target_long last) +static PageFlagsNode *pageflags_find(target_ulong start, target_ulong last) { IntervalTreeNode *n; @@ -153,7 +153,7 @@ static PageFlagsNode *pageflags_find(target_ulong start, target_long last) } static PageFlagsNode *pageflags_next(PageFlagsNode *p, target_ulong start, - target_long last) + target_ulong last) { IntervalTreeNode *n;