From patchwork Tue Aug 16 20:33:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 597528 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp2713837maz; Tue, 16 Aug 2022 14:10:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR4RIDtEHiGF1ZCohqLzVH2YTOLVQ5jeAo1jFvN4oJ8DupKNOTdKYp/Q2Kcy5YtVondjXDeL X-Received: by 2002:ad4:5cc3:0:b0:474:8dda:dfb6 with SMTP id iu3-20020ad45cc3000000b004748ddadfb6mr19567441qvb.82.1660684242782; Tue, 16 Aug 2022 14:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660684242; cv=none; d=google.com; s=arc-20160816; b=nWSJckfCdjLo3FKMEsl4gPKhjVFMSUZYG5Dri6/IacWzSD9h2tWlpwrrQiGObHFSvQ TaU7khU8H83MeAK/i3BVsPOFAcTceyYxz/pwPB6LqzrJtRiSjX4wQVyaVTo8BjCU5QE+ hn7NM76S6dZiQHwi57G22FKVKQhVxMsg43kj/+xj/A/vOs48yZNamtAhpQBcVJ+2xiRc hk9nnXUBbqUgcUnSIKVl4AJW9I7QXqb+ZhBn9YXvHCo0w8aq7AnmOlvTW3NTSRpWs6qv bPxHq73SHku/sUiyT7jf/5CKhuFmuCbvsZypxKaVtMHO0uFuDHaDoUoHUWHiUlunNgPU AaQA== 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=nnTf8vYQrhFGbCh9F71+TS9pu/cqcKGq2pxwJ/zBizo=; b=iW+tTgmA305x8efN4KslaIDC6QlYu4Bk392Si1bThUjmyEEs/cIz4xiJT/bUU810ZU V4/11UwUdi2dOdmg5UJOsLtVqHP3mF0UFYuy3+1jySYH6UPgCvDL3A9g2E1PD8QQPzl9 uskxy2em4o+lOUitgTbLPGq6GJO/l3Y7xRXDwO+5pr7OcCHEuOOlPD3srzaz1DUp8bFU JihHBZpcNBcQJ/uMTy2CIqGMWAAsZA+duSAp/7K9UkA0u4vap795dduZuPoWajhsbkn0 X/14yWeEoe9/0179ibSdXHQVZtc+sshHt0qdy3s2vlafUzOE5V8lX0Bbukx5tPlP1YkQ gglQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQWys5LK; 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 kz10-20020a056214544a00b0047662b67b52si5438313qvb.566.2022.08.16.14.10.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Aug 2022 14:10:42 -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=kQWys5LK; 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]:60960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO3pi-000265-BE for patch@linaro.org; Tue, 16 Aug 2022 17:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO3H7-00057d-96 for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:58 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:44710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO3H1-0004bj-71 for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:57 -0400 Received: by mail-ot1-x332.google.com with SMTP id t11-20020a05683014cb00b0063734a2a786so8171229otq.11 for ; Tue, 16 Aug 2022 13:34:49 -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=nnTf8vYQrhFGbCh9F71+TS9pu/cqcKGq2pxwJ/zBizo=; b=kQWys5LKPME3++maxshyi9tj+cntKWUdfJhPQpwWnj1cYxmgIWhu4tBpmw3ONlN02s TGgdIUN20FNABTeNBe/G8tkDudR+wer6XfpyWETM/ZZ4F+w97+O64wsq2FH60CRyBU9t Y1cQ9W07hptdQuQkvNKn9JsbrvJ2qvKNHdkg3pxW4fwkrOIuhaCoTwwkjyfMQz9ef2GY Htgs16/gDFMDBThSorwJhsUf1X1MAgJmNhQZtWCP9DE2xeDLSWkZSFpvTBb/nLP7NY1y LcVDkI00LpRyKMicl2MFcDYewKNNLeK/RvzlDdmSahYCv+3QReVnIHng3ALaCqHe4296 9k2g== 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=nnTf8vYQrhFGbCh9F71+TS9pu/cqcKGq2pxwJ/zBizo=; b=ngnEHnRQHAt6nY7XCzDuGiMPGNZ4oWyNZa8Ya0fSD9WF6k1eLF0UK8EojizCEN3jKk 0tykpNRbrjc2Ao7Bbir/K/H9MMfKJeNaLx38Ahnh+jDBU2xCjAIa5KjEVEs8zIYQMnmk /FD6asUOlDpYDFFUT9De6W6kNFnK8Oa3DH98wyqOpc0tnGe0sBndAheXAUaJzJsRLEyU EXTzSJXp1t9+yyONYvsEP3z61mStLoDUVkwYo8y5oW3jbCr4ITxlG4jvEsIvkG5Xdhf5 wKPd0yHDSTpfp0Bn5FBomt3BQ6bnO10S93ZQGgetfG+744Uom6rE784jz0DRU1h0LIrA fvQw== X-Gm-Message-State: ACgBeo0Sipx9Gy1jF81swKXYMl1stMKenFAw8fyFgyuiL2FoCLF7doze +pOGEDEbwhwWteInKbw/oUBRo7rKJbXx2A== X-Received: by 2002:a9d:7a55:0:b0:637:1874:a2cb with SMTP id z21-20020a9d7a55000000b006371874a2cbmr8269625otm.318.1660682089295; Tue, 16 Aug 2022 13:34:49 -0700 (PDT) Received: from stoup.. ([2605:ef80:80f6:61fa:9bc2:5095:d612:5e22]) by smtp.gmail.com with ESMTPSA id y23-20020a056870b01700b0010ef8ccde67sm2285220oae.13.2022.08.16.13.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 13:34:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, alex.bennee@linaro.org, iii@linux.ibm.com Subject: [PATCH v2 20/33] accel/tcg: Do not align tb->page_addr[0] Date: Tue, 16 Aug 2022 15:33:47 -0500 Message-Id: <20220816203400.161187-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816203400.161187-1-richard.henderson@linaro.org> References: <20220816203400.161187-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-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" Let tb->page_addr[0] contain the offset within the page of the start of the translation block. We need to recover this value anyway at various points, and it is easier to discard the page offset when it's not needed, which happens naturally via the existing find_page shift. Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 16 ++++++++-------- accel/tcg/cputlb.c | 3 ++- accel/tcg/translate-all.c | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7b8977a0a4..b1fd962718 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -174,7 +174,7 @@ struct tb_desc { target_ulong pc; target_ulong cs_base; CPUArchState *env; - tb_page_addr_t phys_page1; + tb_page_addr_t page_addr0; uint32_t flags; uint32_t cflags; uint32_t trace_vcpu_dstate; @@ -186,7 +186,7 @@ static bool tb_lookup_cmp(const void *p, const void *d) const struct tb_desc *desc = d; if (tb->pc == desc->pc && - tb->page_addr[0] == desc->phys_page1 && + tb->page_addr[0] == desc->page_addr0 && tb->cs_base == desc->cs_base && tb->flags == desc->flags && tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && @@ -195,12 +195,12 @@ static bool tb_lookup_cmp(const void *p, const void *d) if (tb->page_addr[1] == -1) { return true; } else { - tb_page_addr_t phys_page2; - target_ulong virt_page2; + tb_page_addr_t phys_page1; + target_ulong virt_page1; - virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; - phys_page2 = get_page_addr_code(desc->env, virt_page2); - if (tb->page_addr[1] == phys_page2) { + virt_page1 = TARGET_PAGE_ALIGN(desc->pc); + phys_page1 = get_page_addr_code(desc->env, virt_page1); + if (tb->page_addr[1] == phys_page1) { return true; } } @@ -226,7 +226,7 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, if (phys_pc == -1) { return NULL; } - desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; + desc.page_addr0 = phys_pc; h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); } diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index ae7b40dd51..8b81b07b79 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -951,7 +951,8 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, can be detected */ void tlb_protect_code(ram_addr_t ram_addr) { - cpu_physical_memory_test_and_clear_dirty(ram_addr, TARGET_PAGE_SIZE, + cpu_physical_memory_test_and_clear_dirty(ram_addr & TARGET_PAGE_MASK, + TARGET_PAGE_SIZE, DIRTY_MEMORY_CODE); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a8f1c34c4e..20f00f4335 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1167,7 +1167,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) qemu_spin_unlock(&tb->jmp_lock); /* remove the TB from the hash list */ - phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); + phys_pc = tb->page_addr[0]; h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags, tb->trace_vcpu_dstate); if (!qht_remove(&tb_ctx.htable, tb, h)) { @@ -1291,7 +1291,7 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, * we can only insert TBs that are fully initialized. */ page_lock_pair(&p, phys_pc, &p2, phys_page2, true); - tb_page_add(p, tb, 0, phys_pc & TARGET_PAGE_MASK); + tb_page_add(p, tb, 0, phys_pc); if (p2) { tb_page_add(p2, tb, 1, phys_page2); } else { @@ -1644,11 +1644,12 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, if (n == 0) { /* NOTE: tb_end may be after the end of the page, but it is not a problem */ - tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); + tb_start = tb->page_addr[0]; tb_end = tb_start + tb->size; } else { tb_start = tb->page_addr[1]; - tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK); + tb_end = tb_start + ((tb->page_addr[0] + tb->size) + & ~TARGET_PAGE_MASK); } if (!(tb_end <= start || tb_start >= end)) { #ifdef TARGET_HAS_PRECISE_SMC