From patchwork Tue Sep 6 08:38:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 602960 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp4339119mae; Tue, 6 Sep 2022 01:58:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tBuEsS9uWd1P8qlemMPqwAcUg9wRkUoTApQUvSNYPW+S1TP8qNnPfbGXBorXkHj1ieu1T X-Received: by 2002:ad4:5fc8:0:b0:49d:24d4:dc48 with SMTP id jq8-20020ad45fc8000000b0049d24d4dc48mr11554795qvb.111.1662454684157; Tue, 06 Sep 2022 01:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662454684; cv=none; d=google.com; s=arc-20160816; b=yN0COC3PuasCY29O2aYZZutHoyrRx3jwfzyuD1RHhCw+7swSGbda3TxKpQcH3TxeHr Ox0bQNjRju0E9CM7TZnJUWi5qQV6GvAgcYV4sW0aWVahOMX0BmK2YSZt4be96TrBVLeO uY4Z/L15OFbNgZTqGVnIMtB7saSG/PE0ztTvjVY/hB4q9BBjz+X0vgL7ssAjGQQbUDmQ 8nnrnkKJ3G+Z61+4z8zZw8g+JldjVF9FjhW9VyJy3J9F5F4+a8SAbyjGWu08O8YnhAPJ M6btSQRWSSlXwdRG+Cy8n1C+96DLZ/H2kIerrI3AYGPpun+fIZADLjOl9QpJPN1Mp/1N kyOg== 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=w1ES14kbaqz1aOCbKXN9PfcL6E/pNAFDrn35F0KK2iE=; b=04SjE05HWOnjFiiYPV6tJ4kKW4FZm3Kb6gFey7Ezvdtzu2ayEDBOeetuSQNH1vEmOL 9KQQIb2pm3MIW2iJCrC7iwJvFt2/iL3Ucxl1fCJ0uVaShjvaSfflTigAomajZuqkPCje P4FJCDGy9x+068U/XluUAx2NEzHMamSOB8f3Uu0U+K5JJv4ynTSDVwCcrsucKQM3xC4O lSRc/koyGuYzBcrKdkq33qsnxPaZlRsz/X9zr5VzQvPR5kItfGxKUoPkB3znj0yEvByK pF5zfuGumrh19U/4azYEBu0xX0gCWWw7mPxEKljzGFZg7SLvFuIx20MP2WTl+0K83l70 G7zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N5sQY1pW; 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 bk29-20020a05620a1a1d00b006b94066d884si7848359qkb.88.2022.09.06.01.58.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Sep 2022 01:58:04 -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=N5sQY1pW; 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]:53588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVUPD-0003iV-NF for patch@linaro.org; Tue, 06 Sep 2022 04:58:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVU6P-0002lU-Ii for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:37 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:42750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVU6M-0005YU-Oo for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:36 -0400 Received: by mail-wm1-x332.google.com with SMTP id d12-20020a05600c34cc00b003a83d20812fso7001876wmq.1 for ; Tue, 06 Sep 2022 01:38:34 -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:subject:date; bh=w1ES14kbaqz1aOCbKXN9PfcL6E/pNAFDrn35F0KK2iE=; b=N5sQY1pWRY8owwFdPYBrC/62I2osS14erujcW1Qo6jfvz8mwMF6AOekVliHsr8Ula+ ZqDuKlGQnO2zLznj35NU+3s3XT203hARb+8fWdnWDmzPgRnzcP3XSD/ayKdWeBu0iVun nwhsphe5IDkmKkImXm+EwyNU9DYlma3NM1MpPmWhAOai9Zm/7cp0Gu2mbOfgi3f3j+Oh rdkUiicheZW0wl44TP8iCJvTjukZNsLQPa7H3zK3RDWgv+l24YuLBc05PQr/t9klN9xC O2a3zzZy3OrsVRVV6ZmPteJgAYLVUpqOtE0JxjHh5JkUeOPL8JDIrJp6qFMhaSBgQR02 m57g== 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 :subject:date; bh=w1ES14kbaqz1aOCbKXN9PfcL6E/pNAFDrn35F0KK2iE=; b=XXi8amKFGZOjrNNY2DSswxWuTYgILR/8T3a+IMgB+IiIFh4vlieC4Uy7N30bj0THII 4cAMO1IAAv5SySwrvRKeYOUF5FHyBeqixBOMm2oy3RFMbSTSKDEztSIfUPAC6m2qksRm GGtZh5KTXHv/0IhvfLiWDMa0qwyD7KFTkRm3D+ckc3rRMHItUy2Ir3ag524xQznYftVG MbkcVIyvbsWTZKpmbYew3KWC7pWOgewnGrNBQ+UZpnYBJy7tzMNMBctSJWaAkNZOFHk9 it2LLZNOUoNEJsfAJUBMnaoLiaPmXzdbimdrp1sTGRXh3bXT0iNYlLaBlyVbwwm+wOW7 JcOw== X-Gm-Message-State: ACgBeo2AiH6/WUh+N3LMQWVfY7mGDC6fnx24zWZtdDwFZBkdOUATGyCo UmBVE624uOF4LSu86W2m7l0de3+CUhOBbJTF X-Received: by 2002:a05:600c:1d14:b0:3a5:e8ba:f394 with SMTP id l20-20020a05600c1d1400b003a5e8baf394mr12966136wms.137.1662453512931; Tue, 06 Sep 2022 01:38:32 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:a5c0:5a80:ba98:3a71:8524:e0b1]) by smtp.gmail.com with ESMTPSA id g26-20020a7bc4da000000b003a54f49c1c8sm13421859wmk.12.2022.09.06.01.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 01:38:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Ilya Leoshkevich Subject: [PULL v3 13/20] accel/tcg: Document the faulting lookup in tb_lookup_cmp Date: Tue, 6 Sep 2022 09:38:08 +0100 Message-Id: <20220906083815.252478-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906083815.252478-1-richard.henderson@linaro.org> References: <20220906083815.252478-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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. Acked-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- 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;