From patchwork Fri Sep 30 21:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 610971 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1759215pvb; Fri, 30 Sep 2022 14:49:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM75AvTT1wFln0sg1q2g7RtT4Hp/p1TQThAjdVWVOi7gWsJ0ih72lHGgVj8IJ+CYXR1rgzV9 X-Received: by 2002:a05:620a:134d:b0:6cb:c03d:dbd3 with SMTP id c13-20020a05620a134d00b006cbc03ddbd3mr7406580qkl.447.1664574563034; Fri, 30 Sep 2022 14:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664574563; cv=none; d=google.com; s=arc-20160816; b=UpSqVEhLPnkZrwviVAbUcwhBubGQat8+wnOu4wPc/F/NiBCCAbonjBJ36SHrLc3lQm 2c8zt5a+yntzhQ3sfFVoDif4XIWBrfeoqdqyJEXOOd1r8cg+KcgVD4BexB5GW20c/FEy tUf6EUO83SrYT6ezpEyDvZI3QF6z/6HvyCdm47JzpttoF/LDDugr2zeqrKVQ9a2eDtPq f2qUYOrQ8RRTn/jTVdpiFgA3/aDykBreq+OW4uhUkUeLSodXECSpOstZGXDCG8ckJHNF qnMkb/nYekpxn4UkmHMAdrjKPD/SNYVjOYRpluIbDuanca2WASYwrt7y20rzlQAen2JI kh9A== 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=N5kqswpGeydfw7dvf5MO+UlFHzfp0nRUBM8Fh5E48cY=; b=DdNW8E9Hn8nq9tao4cj4oHwYEGe39rjbEU+e3x2aD5sje5EUZDMfusRsHd7dld8isy jldmu7sLWqQTeCPz6WLWbvMVGiwKAVBmB9K0M+GIaIcImnLuehGnsNOLA9bYhUtTJz9K yYASwhDShQQAgjj6onNzW0AvGOm/bPAoBoI6RW/tqq4bP7HV0P/a2b9nq3FUNLE7vHJC gBAOA18uaejHwiJt6E2eH51fCp8IzFzKavMs1XbobCOQCyBonScChL7tBMJGavOn/ZDy 1V/OWFP+ogY0kLtTFxEdYs9W0cwFq2TqjsaMyX29sPXsxlxkVPrIt+6bXAat9trGbr3j MnKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUUY5LuG; 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 j6-20020ac85c46000000b0035bb6035086si2041789qtj.71.2022.09.30.14.49.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Sep 2022 14:49:23 -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=kUUY5LuG; 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]:56866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeNso-0001Nk-K5 for patch@linaro.org; Fri, 30 Sep 2022 17:49:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeNX9-00076P-Gb for qemu-devel@nongnu.org; Fri, 30 Sep 2022 17:26:59 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:42940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeNX7-0005Rz-UW for qemu-devel@nongnu.org; Fri, 30 Sep 2022 17:26:59 -0400 Received: by mail-qk1-x72a.google.com with SMTP id d15so3609192qka.9 for ; Fri, 30 Sep 2022 14:26:57 -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=N5kqswpGeydfw7dvf5MO+UlFHzfp0nRUBM8Fh5E48cY=; b=kUUY5LuG62oTMUJWtVOk0p5BQRD4sZhamyDzxUIOJNAoc7soFvryWhijc4OuQ1ca6y tldoeFhXYb1Dx+R3Tsfl8Du0EYAPOnMVHBA0RWG6Ra4x64Cqs1EdzGazOOOEKqCCy0/P EAE62V833szwAptfEWD4X5g67YozNwJNpD0FhF1fqYh9USNpjmVRkhZKyJyaM/3JwxOK MEaM1l8+5cLYr0KflyomyO7UuKCmGfwvJefv9JvB6VKK0HLUdm9jmD+XHSFoID+IkDJu A7hS18119KLCcV9eP95hSjVeSdQVvCIUG3Wyw/cDpgELTfCoJVC32Ww/IQaA0feCVqJ7 zi/A== 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=N5kqswpGeydfw7dvf5MO+UlFHzfp0nRUBM8Fh5E48cY=; b=cDDOUAvk9sjUNjH7NHcLrbtfqj5MhconMOeXyjX9j5GuFWBdZE4X2Ej90ByTwurtzV Di3ZWQwtPWwufd/JTPBc2GIZquH4n94CsEmlF9JIwY7E/nICTpgv6EWknlix35UnydLU CXv92u8eJAWSIymoho4OU1YtBamlPrJ+Z0OBmUxgXEh4nOy+28xR85hOIG1S62Xc8PWq kILUzf/tdN66NFWUN6iwCYZVuq4I+sZaGbOhp1g6YZEPqgKMVHa1642YQxPmKQSn1/p3 rVFmOcgzymNhvrKjR2Cj/isFaJvyiFbEFoaSEw5ZTNmEO7YY2gKDvUi02esY5pUa8L2O tvQQ== X-Gm-Message-State: ACrzQf1eoFC/I2cXDoBmTRVlCQwZhL1W5lPab/dGIaWfhV909YdNEjWB kSmiW3/NYs3qaP6arwzW0fb5cfCj1acD+Q== X-Received: by 2002:a05:620a:31aa:b0:6ce:b6f8:e235 with SMTP id bi42-20020a05620a31aa00b006ceb6f8e235mr7673640qkb.733.1664573216811; Fri, 30 Sep 2022 14:26:56 -0700 (PDT) Received: from stoup.. ([2605:ef80:80a1:5a60:d0d7:468b:5667:114b]) by smtp.gmail.com with ESMTPSA id l18-20020a05620a28d200b006ce813bb306sm3696370qkp.125.2022.09.30.14.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 14:26:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linux.org, alex.bennee@linux.org Subject: [PATCH v6 14/18] accel/tcg: Inline tb_flush_jmp_cache Date: Fri, 30 Sep 2022 14:26:18 -0700 Message-Id: <20220930212622.108363-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220930212622.108363-1-richard.henderson@linaro.org> References: <20220930212622.108363-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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 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" This function has two users, who use it incompatibly. In tlb_flush_page_by_mmuidx_async_0, when flushing a single page, we need to flush exactly two pages. In tlb_flush_range_by_mmuidx_async_0, when flushing a range of pages, we need to flush N+1 pages. This avoids double-flushing of jmp cache pages in a range. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- accel/tcg/cputlb.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a0db2d32a8..c7909fb619 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -107,14 +107,6 @@ static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr) } } -static void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr) -{ - /* Discard jump cache entries for any tb which might potentially - overlap the flushed page. */ - tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); - tb_jmp_cache_clear_page(cpu, addr); -} - /** * tlb_mmu_resize_locked() - perform TLB resize bookkeeping; resize if necessary * @desc: The CPUTLBDesc portion of the TLB @@ -541,7 +533,12 @@ static void tlb_flush_page_by_mmuidx_async_0(CPUState *cpu, } qemu_spin_unlock(&env_tlb(env)->c.lock); - tb_flush_jmp_cache(cpu, addr); + /* + * Discard jump cache entries for any tb which might potentially + * overlap the flushed page, which includes the previous. + */ + tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); + tb_jmp_cache_clear_page(cpu, addr); } /** @@ -792,8 +789,14 @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, return; } - for (target_ulong i = 0; i < d.len; i += TARGET_PAGE_SIZE) { - tb_flush_jmp_cache(cpu, d.addr + i); + /* + * Discard jump cache entries for any tb which might potentially + * overlap the flushed pages, which includes the previous. + */ + d.addr -= TARGET_PAGE_SIZE; + for (target_ulong i = 0, n = d.len / TARGET_PAGE_SIZE + 1; i < n; i++) { + tb_jmp_cache_clear_page(cpu, d.addr); + d.addr += TARGET_PAGE_SIZE; } }