From patchwork Thu Sep 1 06:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 601806 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp264353mae; Thu, 1 Sep 2022 00:29:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZWmLpG3N9+E/dATUCi/loGe6BnKobSpT9YLN6GnjykeE2rra4loj7pFTfJ9zpoRDVqZAX X-Received: by 2002:a05:620a:4154:b0:6bb:822c:ccd3 with SMTP id k20-20020a05620a415400b006bb822cccd3mr18307685qko.1.1662017365909; Thu, 01 Sep 2022 00:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662017365; cv=none; d=google.com; s=arc-20160816; b=RgrfPoTbVv3UXoY2j5zhPG1uuO498q0CXaJYOI0uCwspkJxtkYaFg51AoZG9UFn/1f ccupJFXhuvdOHt1REJhRmGUdFIuWOLFYfQPW7yWRGAb0ApogWprOweUan8xIKtgOeTo9 7R8iYqe2sQvqDT8W26uuH1F6mWDajVmSWAnWAucVtB23NoC9EUt2ESKyGVeh4vR2+FiG Lfivk5JEPDyGDwaZZbfjVKX7GvZoXlFWA1zGK9449rnC7GN3xHxIjQWVeL5bv25vKLd5 FZw70HCHt07fdvTdy/qs5Q6w0cmZgNu2Re5v2pxWNtbozFsNAbg+w1dQO9PmNIJNzMM3 sYSQ== 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=ujccLVKCijRdDPQ/HnHwXlYB6uGsYnyTUieJgReaMHB5ONsrJsLiGwfJ64NdAbHkcy qAMn1KROvzUb86WWjsoxdfZRrzG1ETwY7CH9RZkW9NzyzC5DfmN8zMIlHKvOkIrem3fq jqFD0QZ7P5WhaRwi2fobbjdLn8OsuZ5Htlapxrmh/gBnjIcXedfwos6Rzjol33Xc1l2T 30ro/gIYLWcM5PnN+XUCpDnyaqBQEdxJb2jP5WA9sNCt2ABmzU5jJ+be3ae9CLlv9txG rkfI14T5aStlnWDoLtpGh4bo1lgAW8GgEHavouUrWeMRFtZrj89Ek40Ua4jliIpwB/lX bfmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IE51DO+n; 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 y14-20020ac8708e000000b0033cc061d03dsi8259629qto.370.2022.09.01.00.29.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Sep 2022 00:29:25 -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=IE51DO+n; 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]:48986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTedh-0004rZ-GT for patch@linaro.org; Thu, 01 Sep 2022 03:29:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe4b-00069m-14 for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:09 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:52124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe4Z-0003P1-89 for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:08 -0400 Received: by mail-wm1-x334.google.com with SMTP id ay12so8477586wmb.1 for ; Wed, 31 Aug 2022 23:53:06 -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=w1ES14kbaqz1aOCbKXN9PfcL6E/pNAFDrn35F0KK2iE=; b=IE51DO+n1JT5HFRxYYsDddn8SpP7goxnuo4Bi/L0WeQfap45zQDipNVYZyELxi0xFY D7yvdDIBka3a81rdKwjTcMp5OCCgJO7cGFE0Fw0fP33mLmjS4S3NeuxkB553KtNKCAIs qTOGKVG4f0uCRM549P+KC7T3NzYOLbdUQ6stqyzdSNNftJ/vrwSuqyCR3+Sg7SX+gw3C 8HH6wv3068+d6PGhQs3YRNGP9fnd63mYobyjiR+vE+JmsSGKxhrXL+HU+t+9ZAAKsy2r aFq2bXPyqWmtBAA0r0z/xqyjaANdXiThKKDF+GuwNUon/+/74VzD68THMw+CiaSigzhR 2tDg== 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=w1ES14kbaqz1aOCbKXN9PfcL6E/pNAFDrn35F0KK2iE=; b=KOlZztuQr6r507QnjNzwHZCjBdenP1p7vTJTeppZo3jW/fWC9sPEepKrrgzOurPQw9 TI26iAbOypdpsad1A79JivOcU2ICr8fcyHOn8oVlWiabQ1l+X6/SeII1scFPd7yw4dSO fpjhbrqpzzmnTcYsTPh2pmLCHePf7LwuonXn8IfXJAYQGqnhO/pMh0+uQUdtXVxmG22x Zb5hpu1A6wkw6jtiykqYYR7/MK1eqvhGMUG9vRW+nzgfydGlkn9dMZ7gOdBKivrAOeSe ZzcJB53Ow1p8gjy/JPIHtO4b7G7Q1dgM6Msj1ma+ugo6XFAH8ldrXuFBglK7Tsm7RTWa ugCA== X-Gm-Message-State: ACgBeo0IzKfOXFVdF6xnoyAdN+lu/4i7cTnmVI9n9Fs0Ox0beoUJSRWw UjvHtsOT/HyodNYjidrBmrGrplHthRU272WF X-Received: by 2002:a05:600c:3508:b0:3a6:10a9:8115 with SMTP id h8-20020a05600c350800b003a610a98115mr4248393wmq.164.1662015184649; Wed, 31 Aug 2022 23:53:04 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:53:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 13/20] accel/tcg: Document the faulting lookup in tb_lookup_cmp Date: Thu, 1 Sep 2022 07:52:03 +0100 Message-Id: <20220901065210.117081-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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;