From patchwork Sat Jul 10 15:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 472333 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1362646jao; Sat, 10 Jul 2021 08:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAp/wPcpIFycvKM8SnAEtCLmwXD1HqKUyKpMPHP5ygscuJEgRy5w5C4wLWi9DZh0U2DrIZ X-Received: by 2002:ab0:906:: with SMTP id w6mr32500593uag.37.1625931235142; Sat, 10 Jul 2021 08:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625931235; cv=none; d=google.com; s=arc-20160816; b=Ix9jPoSFU3BUlosqdfd1guveCEY8Sk/pAOgRl2zEMklVLVxgoqSNB1XWGCxgzq0sua Cc7d9lr1FYua9XYto5U/0r7sm2HrBGCTcJk+Du+VDJVIOy3uC0DFpT3ZygBZ7O2HNM67 c51HonhbDQOHyiAOWgzsl0oDKKY6LaQMoShBCBwNARCvCxeiecanS/6cbKYedTv4QtLy jWy/3gaEM7bL6Sj5TyVkDzSln6689Kvps+ag/wGXHgZXBqaYm6fcqaW2PBzuAUSDPiSr k47KJr9Fn5Xb+gXXK0I3E4/QT9Rmh5H2ZXS+esS1+5Ow8XXSSjiZLQ8jQfHwQ8Adsa8i 2l0Q== 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=VN95zM/QiA1dKqmcNx9SH5nqAvJGbQXCoyX6bpKYZ80=; b=qwIIp8Fq9DpuqOt6rxgcK2KLm3T57PYJYEkjrsHLCReBZkXQUiGXRcWOzfgFMO3ZdS tEhggZawiQKWL/lPi0EU1OgqHWl7/6YY4qMTJzG1caeHja9jb088R/qWiHwLdHgD+kOD vNre03nrn5upfUJAIQYip6DKAn+1plw+xjooei3llJs4nT6537wAtpDNOM1xCluy8+3P 6OQzEZzCoktGGOOe2eOOSfie7WCEcpjJAx6NYYRW9zlpnG1smfEfBhzrqfOKEs/j+EP9 AHH2i7fTDwEsnejpu3QjL6yQtHyGz6smrVVABTF8c52OwQxm76OogBhb1rAoN+w9UcZ3 Jcvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xwApZ3sX; 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 z26si1620565uaq.67.2021.07.10.08.33.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jul 2021 08:33:55 -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=xwApZ3sX; 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]:45146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2EzK-0002dT-GV for patch@linaro.org; Sat, 10 Jul 2021 11:33:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2ExJ-0004wg-RA for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:31:49 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:45639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2ExI-0002CB-0v for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:31:49 -0400 Received: by mail-pg1-x52b.google.com with SMTP id y17so13140004pgf.12 for ; Sat, 10 Jul 2021 08:31:47 -0700 (PDT) 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=VN95zM/QiA1dKqmcNx9SH5nqAvJGbQXCoyX6bpKYZ80=; b=xwApZ3sXPHwhMQLPV31hIAce4ZF4vSuX2WMx0cgfJeditQZIT/JV8M1OibGCCek0Z+ X0LJ+AyM6q1TOM6Q080db4hcmtMgXOK7pUXr3v9fKUc/J5k0cdf8gRtkqR/6iPNQbJ2c ZS9RAznldlgrFTW6vumK9T4euxhpPX13gJfyOqy8zS/bEkKUt87VFLEYPSaCzwtqjVDz 1LNZ5CFm2aAQfhl2kJWuC36SdC6ll5PbwTN5zfpgrYGBT5ueApxqCOF/5DrZ+myMQ80S jN6sWITDEG/fau8VbwiIbsfwF67THHZudk4PW50/nMAxO0QX68iOV7AOxOw8Dud2ZWOB uDqg== 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=VN95zM/QiA1dKqmcNx9SH5nqAvJGbQXCoyX6bpKYZ80=; b=KDAzLAERM0sFQwD2+J+0IoT/5Q99JIKyk1ubxkJIkqIs//syNUte7lUcKXpXe16rI0 6jWcL2fybzyiUBbbpsUWzouWco/z7i4sLrFTu2ybL+pRSapJZ17Qn8IM0GJGV8RpMCGN Lq3UMRQp/IPZrIRqcxDQZJfgk77i6yA93PCq4lU28hvuCM8HfnPgfbA/vABELQEqhmdE gEWJcWCXUiMRL5FRyPqyD2dzWRls/v661/uoCUvdHeDRScrRpfjd3aFWq+4iy+VvWARt i9sxxp4wdGZKoWMxeXtjBkt1h9rgztK5RjCL7qMyP9NSaaMml7T7Q0hjsH2zmBv9AJzc gh2w== X-Gm-Message-State: AOAM531EBCh1HHKyUzwWPsS312wEcythqvVpqOO4UeUp46gMoPB0/E1t nXWiGDTVk9SozLFFiQ9N/cMtZziLn/ZXXw== X-Received: by 2002:a63:5946:: with SMTP id j6mr45108065pgm.0.1625931106894; Sat, 10 Jul 2021 08:31:46 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id u23sm11975374pgk.38.2021.07.10.08.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 08:31:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 03/41] accel/tcg: Hoist tcg_tb_insert() up above tb_link_page() Date: Sat, 10 Jul 2021 08:31:05 -0700 Message-Id: <20210710153143.1320521-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710153143.1320521-1-richard.henderson@linaro.org> References: <20210710153143.1320521-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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: Liren Wei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Liren Wei TranslationBlocks not inserted into the corresponding region tree shall be regarded as partially initialized objects, and needs to be finalized first before inserting into QHT. Signed-off-by: Liren Wei Message-Id: Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 7929a7e320..75e4d06557 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1657,6 +1657,13 @@ TranslationBlock *tb_gen_code(CPUState *cpu, return tb; } + /* + * Insert TB into the corresponding region tree before publishing it + * through QHT. Otherwise rewinding happened in the TB might fail to + * lookup itself using host PC. + */ + tcg_tb_insert(tb); + /* check next page if needed */ virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; @@ -1675,9 +1682,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, orig_aligned -= ROUND_UP(sizeof(*tb), qemu_icache_linesize); qatomic_set(&tcg_ctx->code_gen_ptr, (void *)orig_aligned); tb_destroy(tb); + tcg_tb_remove(tb); return existing_tb; } - tcg_tb_insert(tb); return tb; }