From patchwork Thu Feb 18 09:47:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 384373 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3534738jao; Thu, 18 Feb 2021 01:58:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUo2nWQbGxx9TM+KQEQ3Jkpl0NKDmnCfpIklrpO61tI4rGL9g21V6+KJhNFtJ65mQRJv7B X-Received: by 2002:a25:830e:: with SMTP id s14mr5914526ybk.42.1613642283508; Thu, 18 Feb 2021 01:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613642283; cv=none; d=google.com; s=arc-20160816; b=KIaEwUBBx/a2ADluQcBMvGuCWXZ82ckYCZuT2TFn/6DmqMlkJsiAViEue6lna6U9Jj YpfOOLC1deZV2gcI+HhZq8gyk93twLkncn2SwcNWkP8IEeveM+hXMG535ycENzCXPgiy Y5J9Ybnhw3CDHLHi50kAItQfjYDHVh47kRKGNB7dzKdGxgTsEWv33TpWsLzQVPueUPhx 7yGtCOHZRINEZgg+1YY94+2BViPsugpmnAyscf4lzTyOYmhLkSsMUHTJwuoNBF7oEHZx b+4ZEjEzUiD2PaTT3/DjFnWBsWIGINdTg9TnTZEbdD/7akfVHqxQghInNd6Ja39IOAJF mlyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=cfDw5C6zvUmFdQECRjitQbGFP3IAXxbCAzqXHPWLjR0=; b=GErxInopF5EyTDKb4aZB+lTzlS/Ft7cIOe++kWziljXWZrtBDgQoMVUrW6QLTnNRNz zMmfmwkqHT1z/K57S98drykUZJErJSxivtbx8mkRLlffmWWz0VM4zhep7u5pEY2xnv9d vK2dxU1W4bL6qIAdty2mCN8yAvu176TPPAd0TbPy81g5IfepFcqkhBdJYaR6gXzzrqcN S4R4QLunueHyNdySWE3rsLj6+3PGgOhLYmgobmJpFaXisNfl2DDAggazw4WiZ3g7HQYj REEiIfjeRRWdS0GOm0ZDKonK40+zonZkTbww/Zd06qEdMk0vgflpSHC99N7CBxCph2um 7Xtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tJNa3xcp; 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=fail (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 j124si4886438ybj.127.2021.02.18.01.58.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Feb 2021 01:58:03 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=tJNa3xcp; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCg4Q-0001ue-Uo for patch@linaro.org; Thu, 18 Feb 2021 04:58:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCfuK-00075e-F1 for qemu-devel@nongnu.org; Thu, 18 Feb 2021 04:47:36 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:33789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCfuF-0007If-Ko for qemu-devel@nongnu.org; Thu, 18 Feb 2021 04:47:36 -0500 Received: by mail-wr1-x42b.google.com with SMTP id 7so2223434wrz.0 for ; Thu, 18 Feb 2021 01:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cfDw5C6zvUmFdQECRjitQbGFP3IAXxbCAzqXHPWLjR0=; b=tJNa3xcpbF/wfS3dZoq1UjDb4tqq4g5CYyFftQJNjLwOSEtKgtp7mDzJAiETHHEdTa WMX/WrK4W+lYikTxtgQzrwsG2Kir9Of3oI2/jW96F8enXr7y2TduwoTE0pmCZJwbpXnr NyMEClPinG+Argfwxtaqxo1rtbY+ce8VZOeTvcQw44796OekiA4XwwXa83SUanDp6J/B C1cqQzMRhhfoO1xxYzKH2mULd2vj+ETmkDIxIrxo3Fd64HgaP3zeQskODgtOfpRBHcAt Kn5pXcN8mfO3pS2JITlasA4fPqehIJZC+zxV+uLsfEjQxXlDBXCAFub4PA0ViH7gtzP4 uB1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cfDw5C6zvUmFdQECRjitQbGFP3IAXxbCAzqXHPWLjR0=; b=OtpOdsHijf5SpJn4XCde3RmbTqCXQFuohICHW1MQXCt4nkPAJ5tiTgFxBl5D4otjgT pgESiY3w30bhtjv8J5vn92T58NzDRiL4Qu5gGONiw8Mc0XtLf6JcELTkS9K37A+zDIgY qtPlghv7P1tU3ctKL89pwtBCf8GlqT/OAVVnhM7cEqLwejsiLYjh8rjvArsTW34ju2Kv AsAoK3vICagHB2k2ITRciODHLP2ChfNk5paaUdDh6P+tUDJfoW1rdJ62qDSK+O9sL5Tg MTcKB3MFklNGiC7jpNe+tajy1MdSUMnptfCiyVFF/L5m2nBOQvzutNEaI83jaQnFTLCB MCpQ== X-Gm-Message-State: AOAM532imSDD0YTKsgO1Rmro0BwF+BBeV50qzmbh48fKB01sKfWJ7HEq m6Y/E9PZjjLRUstMkvmhg656MA== X-Received: by 2002:a05:6000:1788:: with SMTP id e8mr3471481wrg.171.1613641650314; Thu, 18 Feb 2021 01:47:30 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m11sm6690599wmi.25.2021.02.18.01.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 01:47:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A9CB41FFA6; Thu, 18 Feb 2021 09:47:08 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 18/23] accel/tcg: re-factor non-RAM execution code Date: Thu, 18 Feb 2021 09:47:01 +0000 Message-Id: <20210218094706.23038-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210218094706.23038-1-alex.bennee@linaro.org> References: <20210218094706.23038-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no real need to use CF_NOCACHE here. As long as the TB isn't linked to other TBs or included in the QHT or jump cache then it will only get executed once. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20210213130325.14781-19-alex.bennee@linaro.org> -- 2.20.1 Signed-off-by: Alex Bennée diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index c0b98e76b9..72b3c663c5 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1779,7 +1779,8 @@ static inline void tb_page_add(PageDesc *p, TranslationBlock *tb, #endif } -/* add a new TB and link it to the physical page tables. phys_page2 is +/* + * Add a new TB and link it to the physical page tables. phys_page2 is * (-1) to indicate that only one page contains the TB. * * Called with mmap_lock held for user-mode emulation. @@ -1798,17 +1799,6 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, assert_memory_lock(); - if (phys_pc == -1) { - /* - * If the TB is not associated with a physical RAM page then - * it must be a temporary one-insn TB, and we have nothing to do - * except fill in the page_addr[] fields. - */ - assert(tb->cflags & CF_NOCACHE); - tb->page_addr[0] = tb->page_addr[1] = -1; - return tb; - } - /* * Add the TB to the page list, acquiring first the pages's locks. * We keep the locks held until after inserting the TB in the hash table, @@ -1881,9 +1871,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, phys_pc = get_page_addr_code(env, pc); if (phys_pc == -1) { - /* Generate a temporary TB with 1 insn in it */ - cflags &= ~CF_COUNT_MASK; - cflags |= CF_NOCACHE | 1; + /* Generate a one-shot TB with 1 insn in it */ + cflags = (cflags & ~CF_COUNT_MASK) | 1; } cflags &= ~CF_CLUSTER_MASK; @@ -2097,6 +2086,17 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb_reset_jump(tb, 1); } + /* + * If the TB is not associated with a physical RAM page then + * it must be a temporary one-insn TB, and we have nothing to do + * except fill in the page_addr[] fields. Return early before + * attempting to link to other TBs or add to the lookup table. + */ + if (phys_pc == -1) { + tb->page_addr[0] = tb->page_addr[1] = -1; + return tb; + } + /* check next page if needed */ virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1;