From patchwork Mon Jul 26 21:47:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 485865 Delivered-To: patch@linaro.org Received: by 2002:a17:907:d92:0:0:0:0 with SMTP id go18csp4015462ejc; Mon, 26 Jul 2021 14:48:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZbCxkspWgsx6MIChKCqABjnOQ+PJ6FQ48TuCKcs/r51eKbueEIdfidQfV0n3hzxBbIFId X-Received: by 2002:a05:6214:501d:: with SMTP id jo29mr2101025qvb.43.1627336092931; Mon, 26 Jul 2021 14:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627336092; cv=none; d=google.com; s=arc-20160816; b=EB9grTco0KAJpfto/X47qdxzFi5XKeIds2n7hnL7v0TwLy5cvG7xjhdNvi4LxC4Ju6 o924tKSoSTvnfvPsP4KmLH/3TE+2YWMrAm4e9lQ3IkjLdZdyt+Aq+Apt/oSVWV1xdpTo gZFUH7Rkkxae5F5UJDK+zoyf98t3UARu4fPGW5yZFFFeP+M9Ds/VCGot2JIgIx3aG7vZ 1I6j4zM+J7DujfHqz5dkYk1Y/wzxtvN/JAebCLmrrxDKQ34U6Fi0T38vy5vtAT8Aziym vJVrIr5hDRg1ox9404MIoP/H86IsLHHG2hwLDaE0f3BSCYckg00vvN2+j6hKu0GJHMGL Lnhw== 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=seot653Ng9+5CYOwzmZozwtUeX2yMDtfyc+Kr3qYmEI=; b=Wn4jP/vZfa1olVe/LUIdmgXZJAfa0hgnhG6zSoMPjHmVitCcOTbnvubCEJXdmXEcBD pViWFidyXj2cRqdEtJpRy8+TK0VSPuufYKOMj+df8ERCfr+Vl4ib/JnMPadwd+bxdvwJ vQ4CqKz9HGwP5KLyhcuGIxl1cYFqoW1a+iAZBbwo6g1On9k1OpFCwkFtdGy25wdQT7hf +v4YLsCwDM4vQYz+HoUVYoXR86Zpnj8Gn7032iXK80vaZsEmjqg86oAyZPzCI8XxOPFc biWeJNiZCOBTCNp3ZvUu8P18S59+4zOnSXXjwZbboQlnXNr8/zHWNntEhHXWSIqr079P ujJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jEL055Hz; 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 r10si557612qtn.316.2021.07.26.14.48.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jul 2021 14:48:12 -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=jEL055Hz; 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]:42938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m88SK-0002PO-9z for patch@linaro.org; Mon, 26 Jul 2021 17:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m88Rl-0002Lx-Kg for qemu-devel@nongnu.org; Mon, 26 Jul 2021 17:47:37 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:36632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m88Rj-000655-Cw for qemu-devel@nongnu.org; Mon, 26 Jul 2021 17:47:37 -0400 Received: by mail-pj1-x1035.google.com with SMTP id ds11-20020a17090b08cbb0290172f971883bso1016578pjb.1 for ; Mon, 26 Jul 2021 14:47:35 -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=seot653Ng9+5CYOwzmZozwtUeX2yMDtfyc+Kr3qYmEI=; b=jEL055HzoTzc+JltEs90SVn6YBKfLkYZBMD6i7iwy1v9gCWtUcYjRh94mBdHySaHlf M37o8I7RqFSzrMgaKtgF6u+e8MSBxzRgfhcNFl4OwuSXupM87RBnEcPscRZobIQIEf+P AL5DzQOgDPqTZYZBwJPYeiuJcRBnHBky5rBf2tK5xzQxf/7nUwz0raP9RdDbnoTm1GZO o5ajOfG1hT/6N8zPtRA+LtHBDbJHioace64buNpr0nNt8AZUrF8JX6Iv4VfEQw9K9Y7h AedQK/pTbR7SSO6mtpoJRxVYKG3Pd0QIOeqQPXBS1ZZTCTwGI71emBUkuAB2PS+4r8ml OWjg== 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=seot653Ng9+5CYOwzmZozwtUeX2yMDtfyc+Kr3qYmEI=; b=TgK9/m/QPd2mQHL25CJw4J9BbQ5WrVTtCzuxF4LjgJ6QmqXi3wnDVJuIK30zps1tiG O+K733tOnegCHZS3fBvtJkVPf0wP+K+ztevk7w3S9TGI0s4aRjVDE8tpH8TLaLYtBu6W gjolwTpzuG5Jq6xTeT/y1C3rAhjabedjV161LqaEKos92wx3lIDIDUcF8T9gProG1zBV LlB5hHg/TUg4D/6DVCk3KmgtHCkHbX9YbwUvZBdTWofxqapxtbV6sFLYfs7uNnTFd6Ii Dk8yzp3i3Y8YGErJFbmIYPUVnCn9aci/j+zv5Q0HRq2GINp/+XdMkGUucyHpc7JyJOsV howw== X-Gm-Message-State: AOAM531oW7Y9V7MW4Oi0oOOrrYWytmzR+0I0DpuwTEy5aHXMyBccAcSg 8YS+8blMDa6XQWB1bGa1B4+KhEHKqHyOiA== X-Received: by 2002:a17:90b:3905:: with SMTP id ob5mr4901734pjb.211.1627336054108; Mon, 26 Jul 2021 14:47:34 -0700 (PDT) Received: from cloudburst.home (2603-800c-3202-ffa7-497b-6ae4-953c-7ad1.res6.spectrum.com. [2603:800c:3202:ffa7:497b:6ae4:953c:7ad1]) by smtp.gmail.com with ESMTPSA id e8sm997679pfm.218.2021.07.26.14.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 14:47:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-6.1 01/12] accel/tcg: Don't use CF_COUNT_MASK as the max value of icount_decr.u16.low Date: Mon, 26 Jul 2021 11:47:18 -1000 Message-Id: <20210726214729.2062862-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726214729.2062862-1-richard.henderson@linaro.org> References: <20210726214729.2062862-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In cpu_loop_exec_tb() we were bounding the number of insns we might try to execute in a TB using CF_COUNT_MASK. This is incorrect, because we can validly put up to 0xffff into icount_decr.u16.low. In particular, since commit 78ff82bb1b67c0d7 reduced CF_COUNT_MASK to 511 this meant that we would incorrectly only try to execute 511 instructions in a 512-instruction TB, which could result in QEMU hanging when in icount mode. Use the actual maximum value, which is 0xffff. (This brings this code in to line with the similar logic in icount_prepare_for_run() in tcg-accel-ops-icount.c.) Fixes: 78ff82bb1b67c0d7 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Resolves: https://gitlab.com/qemu-project/qemu/-/issues/499 Message-Id: <20210725174405.24568-2-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index fc895cf51e..6e8dc29119 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -834,7 +834,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, /* Ensure global icount has gone forward */ icount_update(cpu); /* Refill decrementer and continue execution. */ - insns_left = MIN(CF_COUNT_MASK, cpu->icount_budget); + insns_left = MIN(0xffff, cpu->icount_budget); cpu_neg(cpu)->icount_decr.u16.low = insns_left; cpu->icount_extra = cpu->icount_budget - insns_left;