From patchwork Thu Jul 11 13:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 812067 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp219177wrs; Thu, 11 Jul 2024 06:21:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUocreZoJF7phDk3W0peSR27bgULp1i8uIsjxUhXyLZQUpQ/zSx8P0nM5ALKzFVerXJvhZeNz3RVffDXDBqyODz X-Google-Smtp-Source: AGHT+IGap2sm4LdtDrmsObbM/KdithoKUlxJdbda0wJkvObnOa1ph4dEsjU1cC8tNJzhEA2ElnYW X-Received: by 2002:a05:600c:6dca:b0:426:5269:983a with SMTP id 5b1f17b1804b1-426707cc00dmr64923455e9.8.1720704085865; Thu, 11 Jul 2024 06:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720704085; cv=none; d=google.com; s=arc-20160816; b=RUe1AZJuMuw5zrv2VvIhu9DFayxt2qb6m0wM0cixQXnt4yw0MjtIlZbLlGKISJM807 qzABKyCsG3vH9KHEIpwsgOHI/fH9Eg/fUJuYSqj4+IHQdprsz1JGJyaUmeqbHxkgSLZj gWYBFoAEZGGpOpxuH87f/1jCgFLx9WoA+r8znTax5mugyOCRDpZnT3fAn1L4QGj3bQFz 8mU9pQ8T/1ZtHxRugGi4uvBi++P4Y+mHYyTz1fZS0cwLcjEuvD6+EE8FrzDEgndLtIxT UMTTVBy/q/crlqe88WAtig/sLPFAtuE6KyJdwGqhzybsyDUdIEQ/1q/MFzapqzJlREAr +8fw== 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:to:from :dkim-signature; bh=vyZll+1B9ZVexjTDYnpEmOSbqEikHHbpXaR8VQUCSuc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Iyllhfz6dZNzg8bBRwx2yJ23MF5h1U/M1IGZDQwvKFxxC0ez+gm9ggp49KuEZgh4wV oEEQfhZc3OByU9QZA+4isDU2ao6shOufW1V+4Y0ZsEJt73q3e9zNM8lxhhFVgaWcOrrk Qkk5GIYM5Kyg/C/LkxydnOUzgxgcGbyxAuHCQZcQKDFOZUrxDdjOghQlLMymAFf9Cddy dIsqk41YfhTYJxlhgtCmyWOxYF4f3+bCwgmPgmOQMz+bwzG9R4BVEZDNbpoVIoO74P83 VrJm8EyAx3SKKS4zH6R3RdhnaY0TkWj2kuNprMhZ2DzCuAFfp5vj+fNfWovx8vxgGL/i JIVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Axun5N3l; 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 ffacd0b85a97d-367de896c4csi3035004f8f.188.2024.07.11.06.21.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jul 2024 06:21:25 -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=Axun5N3l; 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 1sRthQ-0002G3-1c; Thu, 11 Jul 2024 09:19:04 -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 1sRthD-0001YH-RB for qemu-devel@nongnu.org; Thu, 11 Jul 2024 09:18:51 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRth7-00063u-B7 for qemu-devel@nongnu.org; Thu, 11 Jul 2024 09:18:50 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42795086628so5716065e9.3 for ; Thu, 11 Jul 2024 06:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720703912; x=1721308712; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vyZll+1B9ZVexjTDYnpEmOSbqEikHHbpXaR8VQUCSuc=; b=Axun5N3lsVTSBvNjJdw4ZscloJod/qmZj8XSd4Hnoz4jsCOfMOotZhvylSPjqnhhaL NEf2fBQj37LgSyn8SoEcWlrW4XZlg02BLNGrtU3r2A8Da6hEQeA4Le9XK8Fwt0ncZOQP 6s2ctIaVstZjdfN7uJH1DQr6syO0DFGw+j3LZmodbMwT675cOPaQQ+7WBORh1EgvsGym LQ6Bk4G6Zb7hoOtIAQtCdXiO9psmUY/HfWWGSGhOKIrIvGOUebzUsBm+31txIXIAtzts 2Dm+3kX42jDiruhAqJGw082Jd838ZSxaNbg6oAaRmjQkHAnODOHP7VRtaTyA705zb76n DSHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720703912; x=1721308712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vyZll+1B9ZVexjTDYnpEmOSbqEikHHbpXaR8VQUCSuc=; b=RC+KpzY9SvbWL0kzsmWMpaCzSjLl8D7r/ARJLT1cetB2HneNtaLebZ87KO+cQPxXxC USdInO6prD/mnKhPrAY7EI3jq7UBdEZ/ZSMLQvf488y/UXd3n1b7l2Zn5B/rfVkqQMcv 3pMRtxFBUI2oy+5UgNgbxEHB31tCVoOSlR2HRcLzHo36X9Vktlyi0xdbEg8EgzdSFGBT Bm+nsKTki70ubMR3e5Qgqc8a7pTOk2gxaBx4kMuHIVmPiRBq3xM64a9RzQTGb8VVoCiY hLWBWjSraRvOa+lr+wrskjQ6RleXhM9Og2Cj2Cwf01Xl2YfA6fY5skAC+GCfJUBUkIDA 5Gnw== X-Gm-Message-State: AOJu0YxRWlpKM8uq2NYgtNABWYAzA8ms9PCSyR8r8iYoa5j/KFHE9ysq b/1tfvYhynCCyTGDv0VB/FlAf1TW8hkL+PFzBBb687GbpqLpA6dzD+HJSVP+1CQjuGQTImPSr2O B81I= X-Received: by 2002:a05:600c:5345:b0:426:602d:a243 with SMTP id 5b1f17b1804b1-426707d8a90mr60422765e9.16.1720703912231; Thu, 11 Jul 2024 06:18:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f736939sm119412025e9.37.2024.07.11.06.18.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 06:18:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/24] accel/tcg: Make TCGCPUOps::cpu_exec_halt mandatory Date: Thu, 11 Jul 2024 14:18:13 +0100 Message-Id: <20240711131822.3909903-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711131822.3909903-1-peter.maydell@linaro.org> References: <20240711131822.3909903-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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-bounces+patch=linaro.org@nongnu.org Now that all targets set TCGCPUOps::cpu_exec_halt, we can make it mandatory and remove the fallback handling that calls cpu_has_work. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- include/hw/core/tcg-cpu-ops.h | 9 ++++++--- accel/tcg/cpu-exec.c | 11 +++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 099de3375e3..34318cf0e60 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -122,10 +122,13 @@ struct TCGCPUOps { * to do when the CPU is in the halted state. * * Return true to indicate that the CPU should now leave halt, false - * if it should remain in the halted state. + * if it should remain in the halted state. (This should generally + * be the same value that cpu_has_work() would return.) * - * If this method is not provided, the default is to do nothing, and - * to leave halt if cpu_has_work() returns true. + * This method must be provided. If the target does not need to + * do anything special for halt, the same function used for its + * CPUClass::has_work method can be used here, as they have the + * same function signature. */ bool (*cpu_exec_halt)(CPUState *cpu); /** diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6711b58e0b2..245fd6327da 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -682,13 +682,8 @@ static inline bool cpu_handle_halt(CPUState *cpu) #ifndef CONFIG_USER_ONLY if (cpu->halted) { const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; - bool leave_halt; + bool leave_halt = tcg_ops->cpu_exec_halt(cpu); - if (tcg_ops->cpu_exec_halt) { - leave_halt = tcg_ops->cpu_exec_halt(cpu); - } else { - leave_halt = cpu_has_work(cpu); - } if (!leave_halt) { return true; } @@ -1082,6 +1077,10 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp) static bool tcg_target_initialized; if (!tcg_target_initialized) { + /* Check mandatory TCGCPUOps handlers */ +#ifndef CONFIG_USER_ONLY + assert(cpu->cc->tcg_ops->cpu_exec_halt); +#endif /* !CONFIG_USER_ONLY */ cpu->cc->tcg_ops->initialize(); tcg_target_initialized = true; }