From patchwork Wed Jul 26 20:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 706634 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp971156wrs; Wed, 26 Jul 2023 14:14:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGgfkkapa3AWX6h7BzX2I9LvFkOzIUrP7BHfpb8foM/h2kgHLk8ChGRwpK9nQO60PuuDSF1 X-Received: by 2002:a05:620a:370d:b0:765:9e6b:138c with SMTP id de13-20020a05620a370d00b007659e6b138cmr996607qkb.34.1690406093658; Wed, 26 Jul 2023 14:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690406093; cv=none; d=google.com; s=arc-20160816; b=aAY22TWQz1fEb4sqyWjksGrhGrYX+jL8Tpb5GqDkwM51KWMsGEVlNlzTrd0sLnuP9X oQzxRin6Xf7pmoRbABIc6X3h3T1As60sb0TSerV6jWZhHoum3uBF8JPB5TEvDI8SG3PW JZP3/c15kfTz9Uk4MKfHCp7VezojZZbbWbcmB0ngZ0DwZtbiFiNDoJoLn4TvyfhimGLQ JawaAmI3xA6AzCX0OmYO3MiugEYsXWDjO3yZ7Y3q2mIg/4aEhreSH67Z+N+1g4T6caUM 9zOT993no6PvMBGzV9jJ1E42Clx7wFoi7AKBUJwqd+oc4lZZBIBRk5iZ0Atnr9weURlu FoqQ== 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:message-id:date:subject:to:from:dkim-signature; bh=UO4NGNMOmfX4cDWpdhP1KDrgQG8uGQRDWa46RjUxab0=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=1Bm8gy3OkyUoaJeSqLuixwy+t7PEIviYjGnpbCdZiFk2z4bHeN2GAoVc0OL3PO8tc4 VlXJxg/jMAiC96bKR84qzVAMoYXuvRr7eNBUWfUOfWafSEJMrzmFTx2bOJ3GpPsqVUV5 6meJGyWEVPFP+xhkzkFcVNqgXiDoHMUAuGcNROYz0SK7vWyYqmXP12IEl2bBlsBsMfd2 hQKrC0uTIKe6BBvLhZszKNXNdK8LMPfxG/h4raF0S2OWKjpJuS2KGNjuTVvRB8i4qLvv dj79gYIGXlKarBOFVJtXe4N7tD0qDg59TjxHLAwNtFxR8+Y3NwixY8y0pmXo2rojldBR fcYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gNHfxS7t; 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 i13-20020a05620a248d00b00767e714ea83si8767975qkn.351.2023.07.26.14.14.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jul 2023 14:14:53 -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=gNHfxS7t; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOkt7-00037N-6N; Wed, 26 Jul 2023 16:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOkt5-00036z-O8 for qemu-devel@nongnu.org; Wed, 26 Jul 2023 16:13:35 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOkt4-00087v-9o for qemu-devel@nongnu.org; Wed, 26 Jul 2023 16:13:35 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bb775625e2so918035ad.1 for ; Wed, 26 Jul 2023 13:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690402412; x=1691007212; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=UO4NGNMOmfX4cDWpdhP1KDrgQG8uGQRDWa46RjUxab0=; b=gNHfxS7tDwh0K27WQx+5FSXIzqLVvwaxz+zQ9QPqxl7XxoHP1QehtkkWlVGC9nkK32 znan2SQ296PF5quTa5DuxsvfkAcBvJQSWdP6KSyu/1kk9tuoO8WsEReY4isnQUWM8UGK 5DfsDy21nLMlfEvpbui9gMh3hYgwItSi/5ydPSblbR51THMEY+7fmgz8sWIXwWt1AATG VD/ybjLgT9fu7nvJA//4bQKrKsS23O9NkP4KKVZv5ZlFEFYR6EMMHbkp6K2cTIbpNdBc jC/Q1e1VvJpzKM9wKiwOTBnfbkwS035n41GV8vnbmQoHmXkO0RpJayy98ZGXay2xyndm qTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690402412; x=1691007212; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UO4NGNMOmfX4cDWpdhP1KDrgQG8uGQRDWa46RjUxab0=; b=YJtMsSKLmaVPHyAM5iALC7U1pO8GiScHU8MMBQGUsE9dPVm8Xv+2+KV/blrAKrsCrD kJKoR5gTijhJyQ5U0+4eP6FR4lpkKa2fcl8wHIEbkwoboKNCFSvV8rklg4yV+l6Dqgq6 wxp2Qjoe4HVMwwPRjdC6NYPC9wTu1vNZqb4HRBSuLbHM+WFbuw7LkiH1k8kdKzhner1Q XLEBtWskH+MOXEWQ0CnZ98Hl2sW2bKw6ZmIzP2AH7ZeEyzRb2KDCQL0QGn6cLuU25bwd L9am/tkWR/XBIhcTCqHxExgG+q14MqsIZnKKLViYBTTye2I5GAkBIzdixFL1rdDAtMT1 +B5w== X-Gm-Message-State: ABy/qLb3ObWIZY8cBQOLaVrVl3lFKST2+xXpZTNfVSa/WXz9+owMk2ul pE0iJZD3H7eXnKIRwcvAqCp/idyaaKkuKSwRL3U= X-Received: by 2002:a17:903:41c7:b0:1b3:b84b:9008 with SMTP id u7-20020a17090341c700b001b3b84b9008mr615229ple.5.1690402412010; Wed, 26 Jul 2023 13:13:32 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:9456:37ab:20dc:17e1]) by smtp.gmail.com with ESMTPSA id ji17-20020a170903325100b001b246dcffb7sm13545894plb.300.2023.07.26.13.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 13:13:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.1] accel/tcg: Clear tcg_ctx->gen_tb on buffer overflow Date: Wed, 26 Jul 2023 13:13:30 -0700 Message-Id: <20230726201330.357175-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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-bounces+patch=linaro.org@nongnu.org On overflow of code_gen_buffer, we unlock the guest pages we had been translating, but failed to clear gen_tb. On restart, if we cannot allocate a TB, we exit to the main loop to perform the flush of all TBs as soon as possible. With garbage in gen_tb, we hit an assert: ../src/accel/tcg/tb-maint.c:348:page_unlock__debug: \ assertion failed: (page_is_locked(pd)) Fixes: deba78709ae8 ("accel/tcg: Always lock pages before translation") Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a1782db5dd..b2d4e22c17 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -374,6 +374,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, "Restarting code generation for " "code_gen_buffer overflow\n"); tb_unlock_pages(tb); + tcg_ctx->gen_tb = NULL; goto buffer_overflow; case -2: