From patchwork Tue Aug 23 22:05:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599489 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2740182mae; Tue, 23 Aug 2022 15:13:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6sPCkAvTHurkvOzgCv2AQWhfG6VXJNOLvfqiomHYyQeCareOpIe/4e3Xt3TRd7IyBjD9xa X-Received: by 2002:ad4:5f09:0:b0:496:51d4:5e8a with SMTP id fo9-20020ad45f09000000b0049651d45e8amr21957793qvb.11.1661292823397; Tue, 23 Aug 2022 15:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661292823; cv=none; d=google.com; s=arc-20160816; b=ZZtnD1vhBF6QCh3Bkb3MRFO0ArZ8bNrG94W3NOkpdt8mefXlwL3k0HYJsBqMQM2rkL mjg0vQxwPYXEWWSB/jpf6hqEpuB7lfwVIjD/Ih5C8LJZY+l/UNaiXmTAVWnTUUTDQ0WX xt7hE5HhDlaGnG0I3K9QNYHrV8ZKMyL/SckYiXNowrKz0Im+3rO+9jH/hAajiETpzth7 Q0mdWTvQcY1l/+eC2A0Pn4VkhxiKP0UkqQJO06ydfE5T7AvtVUVYw795/BTK74m3WO0w qCclZxcQhM6wG2veWX+FL5sY9GhtA6MvAQAIQDIkaZeeUmDSHpg4EIcf8/T+mikZd7oO w/yQ== 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=x4zWBtw9jvwUVwVAd9mRUcqQWThPixmn/z1menAiivA=; b=s6cwkxNWXhT3c9agAd9vTzUmLnLV55C99zrSzfzYAF0qabq1C3YZzphL1ABJ9KXxoY gmVoKD0JZtV4q+QtJwbUUdF8erYlMjyxMJP/9DrF6ebWVaePYCTytYCXzrtbt/fsPMFx g9gLcZLMVECk9bhzUiMdqbHA8Y47kMh/LiLz6hsFWDr+IOinWmu8YOAjrfiOl4vZ5s8r INWmnyrPBdUdqxMHog3mIae+RU1ptqHO7OjSq9XxfVi0/9Bb2VsjqWAtanWH7VEq06TF 2Hs6BTL3zypmJ+Zrqjd5yILPl0aHVi8Js5gJEPeVNwDWGWXOA/L/kgIw4XFmuHJxyVy9 mBDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cswY3eoR; 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 y8-20020a05620a25c800b006b8baa517c6si7717153qko.260.2022.08.23.15.13.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Aug 2022 15:13:43 -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=cswY3eoR; 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]:35756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQc9W-0004gs-Uv for patch@linaro.org; Tue, 23 Aug 2022 18:13:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQc27-0000Ce-Fn for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:06:03 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:37612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQc25-0001PW-S4 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:06:03 -0400 Received: by mail-pl1-x633.google.com with SMTP id m2so14038964pls.4 for ; Tue, 23 Aug 2022 15:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=x4zWBtw9jvwUVwVAd9mRUcqQWThPixmn/z1menAiivA=; b=cswY3eoR7PQAzVE0RptNqm7H79rXehegzgfY6qFMg4aww3V1+JN5/scSkn1XHAY5k/ v1jfoTbvcPX56hqBT7NgmhySELbQSH41yXfyeLvo0NyASO7VpdkJIv38zfUZKhZ/l5nL Fbso4amudkY0/UTAKNcxl6X3dpHSxKugXGfSmcW3WVlmP9pyAViOvEox4gpngqGFjMwb QolEYnE+0FN5fdWYR4HlOUApKcFASD4z+FoK3DKzaLOig7fUaB8B4Ve1LvDm0milCQYK 1G4k1+sG6s4NotCTHUH4hEfeFlaFL3N+b5mK3DFmOl+JbX6J8+go6s4o4QI4JTZ7Ffxj nqGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=x4zWBtw9jvwUVwVAd9mRUcqQWThPixmn/z1menAiivA=; b=jXEA0ws5NnynMyUvmVDFhubOCc/NsFbngoVKeCjEhNA6Yd1g4mFB15fQM9HWA3XdMV 9Ulk2mt4br45miysWqeloM5FQtydS4yubtZzUplKD+YlVZWuA4SpwhKA+rDQMzsVSbgF HnaKEG0JkjB2MfsmwpO1Pn05MTG0Ie+DrfOr/8AsHqYI2XR6DHKVYo8CZxMC6m2NSOHy wzb49Y+CddPtld0K/lPYuZgFVzbaf4S0JFBTSuDQJ/2AuYwRlLxRjvL/qqZa3F3r6Pk0 /IH/WBbu6t8+XBNf92QQXWujh4VbB1laz//VKX+54ALJqjOvvzowJUcf2xSxWZsOVNP6 IYEw== X-Gm-Message-State: ACgBeo3vZ0OqjcDB+8QVAQ0VdDB95BJEqjqpZPyL1CyjEzw8YPcMsZEO Ixt1qQi3yKwU4UwgHqT+JHy17VhFvsIjtA== X-Received: by 2002:a17:902:c949:b0:172:e3c3:bdeb with SMTP id i9-20020a170902c94900b00172e3c3bdebmr12461478pla.80.1661292360122; Tue, 23 Aug 2022 15:06:00 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:46f9:77b4:ec0a:c2d9]) by smtp.gmail.com with ESMTPSA id n12-20020a170902f60c00b0017292073839sm11020974plg.178.2022.08.23.15.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 15:05:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, laurent@vivier.eu, alex.bennee@linaro.org Subject: [PATCH v7 13/20] accel/tcg: Document the faulting lookup in tb_lookup_cmp Date: Tue, 23 Aug 2022 15:05:35 -0700 Message-Id: <20220823220542.1993395-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220823220542.1993395-1-richard.henderson@linaro.org> References: <20220823220542.1993395-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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" It was non-obvious to me why we can raise an exception in the middle of a comparison function, but it works. While nearby, use TARGET_PAGE_ALIGN instead of open-coding. Signed-off-by: Richard Henderson Acked-by: Ilya Leoshkevich --- accel/tcg/cpu-exec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7887af6f45..5f43b9769a 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -198,7 +198,16 @@ static bool tb_lookup_cmp(const void *p, const void *d) tb_page_addr_t phys_page2; target_ulong virt_page2; - virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + /* + * We know that the first page matched, and an otherwise valid TB + * encountered an incomplete instruction at the end of that page, + * therefore we know that generating a new TB from the current PC + * must also require reading from the next page -- even if the + * second pages do not match, and therefore the resulting insn + * is different for the new TB. Therefore any exception raised + * here by the faulting lookup is not premature. + */ + virt_page2 = TARGET_PAGE_ALIGN(desc->pc); phys_page2 = get_page_addr_code(desc->env, virt_page2); if (tb->page_addr[1] == phys_page2) { return true;