From patchwork Sat Jul 22 11:35:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 705246 Delivered-To: patch@linaro.org Received: by 2002:a5d:60ca:0:b0:317:2194:b2bc with SMTP id x10csp886961wrt; Sat, 22 Jul 2023 04:35:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFA5bTfKD1UBiXTAPve73uIvJ2cZbeDZJrE36r/PBtlC0MCSyKsjzQjEQJffSSTD89gEWBm X-Received: by 2002:a0c:e283:0:b0:637:a75:2473 with SMTP id r3-20020a0ce283000000b006370a752473mr1994897qvl.7.1690025753470; Sat, 22 Jul 2023 04:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690025753; cv=none; d=google.com; s=arc-20160816; b=EP9rCdrQsqh3TDigFGw2Wmet11pNeR6IpRj6yYk9pOaxkZBM4gwalTEu0wgVr5MdPr wcGCRVwCbRlpxGEBllqqDJrSMHVxMoOvw/CSwrFIEx1OJoUdZ+YxySokvDUfJGH+gTt7 Ew3anBG3JbSLfYVwSoykTlg0hdoW7FPKsTNC6Fm6F3qGMXhFW9cH8/LW9409pmHGT0fg Kphtnic28QlR/IDkDcCrURGMEcsoViUxhbqsdnXgXiLIaaIn0dxSVJ1+uZ14ug8Cj5NM xdLkgWDabi3b2GzQAPMflZm7++3W1P68cuFX/nStUEhPAT1zlbNYyPyJax510emnPUTi B6FQ== 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=56N41Jk8Te2RCjYHiOR0ZCSY9ldifZTYSDR9kOo+b2U=; fh=dar3VLbuhlF4sfQjYytRTFhcEwFCm4WmC7f2qzZT2aY=; b=IlxZJBI3mCpv7ptYSbg0WbP3gWOXEXUCB3P54wlKJxsa8FLF1GQyyD3KzLMIHVhPkW o6f8hXl5HVzY7ytoe1uIp1VHTIfZ6uqVgnYe7tUAkwPPovl/WTtkvJyycx1Luu4Gda6u i6m2fBJM3g8inT/VPohoeKyBbUH06Pp0liNhN9hepH1Fv3N4TWE/JulyHDZp2Em+t0jK Sas/WLZ+yYDOfMRSMejL4sRi1/VD3kBmHZ5gfxY/0YwBZRPHx2a2If+d0gzEztA8lXHj EBmcD5zlSIkOr3XhQb6YOhKW27PsSk9tiCCVCe3WCLMcPt6WNSrQmrCUcbDlFLI55LbK AXQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TDvjO372; 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 o11-20020a0c8c4b000000b00623a0060cd5si2659189qvb.458.2023.07.22.04.35.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jul 2023 04:35:53 -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=TDvjO372; 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 1qNAtP-00062j-FJ; Sat, 22 Jul 2023 07:35:23 -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 1qNAtL-00061r-7e for qemu-devel@nongnu.org; Sat, 22 Jul 2023 07:35:19 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNAtG-0000hx-S0 for qemu-devel@nongnu.org; Sat, 22 Jul 2023 07:35:18 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3110ab7110aso2393260f8f.3 for ; Sat, 22 Jul 2023 04:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690025710; x=1690630510; 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=56N41Jk8Te2RCjYHiOR0ZCSY9ldifZTYSDR9kOo+b2U=; b=TDvjO372y0/2S/Tg67GpOM/VdYPdh942AdISz8v93jQqFloG1bc7fmKQhVTYVlfgP9 LinF3hs0tJwTgc4WMeSKzuQZvDu+ymol9B+GjjFjf8x6JzYPed7GSMNlj89hf9eBvgLc teInbui6kOCvvEfXssoiHaM4jPwuWtAJwbE+K7AWOC3OGzUdSLTTDI9xNPVa4yZa0IqE kVKtP88cuzwLa0EJ+0/oLb8goi3V37ZF3ZD9WGCTdOr1hpxehGAMf7uHd7OYP1agDJ8d 16sU62JXykq+Q673ojomUO/svoCqbxb7XLABLY9hbvE2JlhXiLfPQCSsJIy+ClTDowgS VAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690025710; x=1690630510; 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=56N41Jk8Te2RCjYHiOR0ZCSY9ldifZTYSDR9kOo+b2U=; b=dh79XgMTUHfYmq2XL6hug/KQKcI2Mf6pvZaCb36QA8mmEiICtREWw6xrAyr3vxfSJz BQamiZ3ZvnGvpG5zD9DBCvKJnSIyrVIhtc7AuBq5o9ISf/KHrLg42Uv/ZIt3bsfCFVrq QRHuYCQUBf6oFIg4nfGGLLNYhq9QKaywMqJ3YDitGEh7zGkOjBtzuke7ljJhWQfMyjfA M7Dv/dttdNXEyPL/s/jVaq9WBTP74b6J2O4EcnjobVwKqefZo3OuDWlVOdGG3T8lc5zS J7WfGO0P6f7KrP1Q9IAhBZNZUVnRCH6mLPU+8UvvD0TpOo94mdncCrG/a/dkaS6nxtM/ 7Raw== X-Gm-Message-State: ABy/qLYzvuDRq+hkYzN3CHWA/td3nbkLzw9mZOrLokeGWcwgM2Z0NN+K oeUA1I9uny7lSsq0SM/m3hr9T//1nj9/cPjflmFCTQ== X-Received: by 2002:adf:fcc2:0:b0:314:3503:15ac with SMTP id f2-20020adffcc2000000b00314350315acmr3900272wrs.10.1690025710117; Sat, 22 Jul 2023 04:35:10 -0700 (PDT) Received: from stoup.acentic.lan (179.181-106-213.static.virginmediabusiness.co.uk. [213.106.181.179]) by smtp.gmail.com with ESMTPSA id y15-20020a7bcd8f000000b003fbdd5d0758sm5130938wmj.22.2023.07.22.04.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 04:35:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH v2 2/3] accel/tcg: Fix sense of read-only probes in ldst_atomicity Date: Sat, 22 Jul 2023 12:35:06 +0100 Message-Id: <20230722113507.78332-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230722113507.78332-1-richard.henderson@linaro.org> References: <20230722113507.78332-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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). Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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