From patchwork Mon Jan 6 20:02:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 855282 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp9620686wrq; Mon, 6 Jan 2025 12:04:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWqUdqzfrBx9glCgbw/8Ej6szEYhC9RHiaPwl7Ij1ee28VYcYx3ABbhpQeohfgE5QZvB58UvA==@linaro.org X-Google-Smtp-Source: AGHT+IE186eq5REBzu4P8DGv165JOECK+1hZdsf0D6QUxFpVtfzYX9x+pVv/uBAjoO5ZdT13xI/C X-Received: by 2002:a05:6214:d0d:b0:6d8:9124:878d with SMTP id 6a1803df08f44-6dd2330c4dcmr1004531106d6.2.1736193851926; Mon, 06 Jan 2025 12:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736193851; cv=none; d=google.com; s=arc-20240605; b=HY+40lxfq2BZ3WpCwZtTOpFFo0vfu1ULlqJ5eFV4RF4CTP72Rdk07dKfIeiuSjb0aU VNbmE5q2N1c88671+b0kL/MrJhmfNxC63xvyEm5fAnn/aj7Y2tIq7BOfHg339TW38pI9 fT1Ah7moxDgSnVXrZnvzojiuMTMzXtI+iwIzNOdOX8hekOJsEgTf06Y86CV9REtSLhBz +QsWpzQFDjklFOfbu+CbmvHKMSZOMwbxhtVgN6s19bBW0YG2vmp188/RBp9+1JhkRzpV RURH0JOQZU/+OQN+AQqUawB66xp4SOoxGQYh/r6kvkOEffWANVmbHYvIPs1UzBBWsVYr WPfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature; bh=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; fh=YIGq2OjjvJJvfOLa9lPT9cLAg4GPwPsWWWag+t9HO1Y=; b=b1VKtRMBTe2izWBpN/YFEbv+hKJ31IsPwwzf/fW0nlZ0GR/yFy6U9EiqV6XfscyAxA /SIknNy/u8L3rJQAqP4CipsKjXVnGfevFzWN1eLCnkkQB49ivbIeesaV/3NHqGWFZE1j cqXLxBncz3NKBuwq4OeEGy252ndP8BPUoKQycyyfRLHOH72/SajVk9hyMcXjIjuSfETG tRJsU/FlHrr6odyADy0yznUVLtL3f8jV8DsHQZLPeAhwhhmGGworVnvSovijywOXweXh nc2+AcZAtF5eCKrcIORFAENll+UMZrxc4XeljgxxZ/4Ulsl2C0Hgr0hmwI7hOIaEOECe 0Kpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hzfaOnrn; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18253448si482385596d6.344.2025.01.06.12.04.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jan 2025 12:04:11 -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=pass header.i=@linaro.org header.s=google header.b=hzfaOnrn; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtJx-0002ci-GT; Mon, 06 Jan 2025 15:03:29 -0500 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 1tUtJv-0002bY-60 for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:27 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtJs-0003Bi-Hj for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:26 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4362bae4d7dso106049105e9.1 for ; Mon, 06 Jan 2025 12:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193803; x=1736798603; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; b=hzfaOnrnEYyw/2oiK8Y6o3uzZVjK/UGRAGLtu//IDwuBZ2YPrF8wqZGZPnQg0Xqrc7 1mSLEVB1FUHymds5xfAVeZdw5RaRTXJJYFdBcKGXAaNo1sjJ+KGYNe76hLTVUmIuZ3Gx F5FV42/SOoKhJ2mH0qDNfwvb609WL9u9CU9/tNCVW+5rW8TL68BzrL1WB0V0Rf3qZ32t G3VtjpVnepmHoNB6Tf7+iI6Yk4/r8553/nZ0H9P/Ijp+wv1Fm2EnbPq+/e6m5DvNKgWq Nhy90QfE0GPsUhtCjliXIkYbFC9/GBHuY4tiyvxxX974SPDj/8jOzISxnRjv2Np0hwn1 rF0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193803; x=1736798603; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FEstRp4e2Qb00qEl2/J4TP29Zm1C+ONgiSLe4ofc5Fw=; b=Y/hsfW0M8+7BtbqHcjdCQyXtJYKlwDvJr66pyI4QTVZfVnKtjfTp2KDy0UNEWahNiN jyeU2icSSWoMdEEqnrs6i6H7bOKLupGv9SZxYZJPvzKaaL2J7swL+z3luaD3J8bejpms hymbmbEM9Lfb19bKEQ+ARLpE0jyyb7+JRn50RT7eHDPJYpGjjJ3ZQ5Fp7W0vRJR+GJUB 8ZpF3S6ogbtxPCG4qYBbDMWDDgKurfiLIx5wh/4kRLriKmrHmdZdF0SFGxUCXytON3PA 3hq56nrrIznEJ34PWPUmZ/OnwwXGplyNQGoFhVBBtIViAHKbkXbDY8Ul1Hk1V8BfXvsm CLjg== X-Gm-Message-State: AOJu0YySV2ILOOiZ8WbZ/rvrtGHPQOFk+bKvC2Tu6z884gtJWMz5Cjug mOFw5pGSdVExnSsot8+x5QzGZpD1orqRpJvPXQEqONvUAnlFZFizLlI/fALk8nG0eIfW6XeWOTx BEQ8= X-Gm-Gg: ASbGncuxq/yvsu46jpIA5UevwBY4SA9kd7Jk4xbTCl7ckD9tzYWL5G30T1g/iP+ZLYj 3uvE1noGI4Cv6Aqc836kzruGDUlHAQ7KV1BiSEk9R1mTnqp7NONLtI4yJEoLOvbUZZ2MJQAwWU2 IJVJtLCk855CCJpuI9ySvQwzTCaLjs9fE6Jt7qrn7FNmdkGWR6d9qnUi4j7vZBXqJGsGrB1XQfG mEuJ+sXfcRIibijKyFl3IHKrqoYPryAdMVH9ZTwwMs4w805LmOke1pQ2fbqYsL8asdXjoLecYmM m9cEOsrLZj0+1sF98ZKvZbDk9JQWHTg= X-Received: by 2002:a05:600c:4f84:b0:434:fec5:4ef5 with SMTP id 5b1f17b1804b1-43668643743mr497181795e9.14.1736193801273; Mon, 06 Jan 2025 12:03:21 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4365c08afcbsm586765365e9.21.2025.01.06.12.03.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:20 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?utf-8?b?RnLDqWQ=?= =?utf-8?b?w6lyaWMgQmFycmF0?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 3/7] accel/tcg: Implement tcg_get_cpus_queue() Date: Mon, 6 Jan 2025 21:02:54 +0100 Message-ID: <20250106200258.37008-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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=unavailable 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 Use a specific vCPUs queue for our unique software accelerator. Register the AccelOpsClass::get_cpus_queue() handler. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops.h | 10 ++++++++++ accel/tcg/tcg-accel-ops.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h index 6feeb3f3e9b..7b1d6288742 100644 --- a/accel/tcg/tcg-accel-ops.h +++ b/accel/tcg/tcg-accel-ops.h @@ -13,10 +13,20 @@ #define TCG_ACCEL_OPS_H #include "system/cpus.h" +#include "hw/core/cpu.h" void tcg_cpu_destroy(CPUState *cpu); int tcg_cpu_exec(CPUState *cpu); void tcg_handle_interrupt(CPUState *cpu, int mask); void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); +#ifdef CONFIG_USER_ONLY +#define tcg_cpus_queue cpus_queue +#else +/* Guard with qemu_cpu_list_lock */ +extern CPUTailQ tcg_cpus_queue; +#endif + +#define CPU_FOREACH_TCG(cpu) QTAILQ_FOREACH_RCU(cpu, &tcg_cpus_queue, node) + #endif /* TCG_ACCEL_OPS_H */ diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 6e3f1fa92b2..1fb077f7b38 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -47,6 +47,13 @@ /* common functionality among all TCG variants */ +CPUTailQ tcg_cpus_queue = QTAILQ_HEAD_INITIALIZER(tcg_cpus_queue); + +static CPUTailQ *tcg_get_cpus_queue(void) +{ + return &tcg_cpus_queue; +} + void tcg_cpu_init_cflags(CPUState *cpu, bool parallel) { uint32_t cflags; @@ -199,6 +206,7 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu) static void tcg_accel_ops_init(AccelOpsClass *ops) { + ops->get_cpus_queue = tcg_get_cpus_queue; if (qemu_tcg_mttcg_enabled()) { ops->create_vcpu_thread = mttcg_start_vcpu_thread; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; From patchwork Mon Jan 6 20:02:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 855283 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp9620825wrq; Mon, 6 Jan 2025 12:04:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXy1iFIlSBkqfUXyIQ8z44jPd7NI4MZuFOiJGQM+oQlVHM3Yl9O0GbEZ60JcYO4PHMxJlO2xw==@linaro.org X-Google-Smtp-Source: AGHT+IHfW+pOF3LLKbIWLVCSAe4f4Xk6duYKFFKf1dksDjcSd7nSn9i7MG2MK2BrM+Hk5o+Xgkd3 X-Received: by 2002:a05:6102:d8a:b0:4af:c5c8:bb4c with SMTP id ada2fe7eead31-4b2cc3873f0mr47254153137.16.1736193868188; Mon, 06 Jan 2025 12:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736193868; cv=none; d=google.com; s=arc-20240605; b=liBg8RnOG31STUt0q0KSnpFDuOLGe19FVoc+f9ZE0utxFBW2s2g23KwtTaq/Qx9w8R lsq2ZCIN91w6JswON7GUuT9jslZ4pX5iE7pHL8tAVEH+/XLAtCqrU+N4PeD1eguOYBP0 k2Ck0eVlutqe0vd3HfhgRrIhUqeWJDVzv9pRSbwS0kaFEQdOqqYTNztYNPuQVpaXJBQK t6IsMViIMB9aef8GsqLvMttIu4MY4eVRn1QcwY81VzM3Er00PNfZvLBkcnenXF+kMZLY qwmwAdYRC9THqxNY28JYBAAWC06fb08oUNOi1B9EmQwxhOdxOlTBY8oqXKSXH2WYwy/v NDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature; bh=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; fh=YIGq2OjjvJJvfOLa9lPT9cLAg4GPwPsWWWag+t9HO1Y=; b=QR8Na7NVIMlXE98LWw4pBgWc4kv89hiJ326G0kzynssKH4h01tziov7JVBwrqNK1hw rF0uVk6Yu2DFCu5yk1yj6Qbp70EEt31xn6abiVfhLnGnTeI7mTtczBsxM7Y2xdA0xf7E h7yxJbRo2PyC1s9ebxBhZ3NDXnpVn007UT6rM7T8CHeEEk8ZKcr9cUCgFEvkIGwv3wKO K9+pz0R8mcyZHGdq6c5qi16sVOe2ug8TIQYL+N1p8tqRSRTUI/keTbtQ6hEtCOX5Wcsl tfZGk1f2qWU6NWhdP4oDT+LZ3GivTTJjDmnTOg78JL3N+VPuoshX+zh2p9JflL+DC0U0 W0VQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fi+mmOV6; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-861d0da6e9dsi2638102241.72.2025.01.06.12.04.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jan 2025 12:04:28 -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=pass header.i=@linaro.org header.s=google header.b=fi+mmOV6; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtK9-0002ld-1r; Mon, 06 Jan 2025 15:03:41 -0500 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 1tUtK7-0002ja-2f for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:39 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtK3-0003FX-6M for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:38 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-385dece873cso5490594f8f.0 for ; Mon, 06 Jan 2025 12:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193813; x=1736798613; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; b=fi+mmOV6FpCWixDy/UGX6sSvUe51RRCle/PhRukH6wdUPnDYzo5O6GqGbFqrXsUgT4 ErIw1js0sFnfGpRJeY3CrpxElC0EG2i5NJPPN7Bw0KRTspIh8jQlk1cuzP+up25QF/Ou gpLWTpU/zTqDWmRnZSms5h+/81azirWJOt0sbfUUK1hjqxhsqrIPCY+XrvBXUltN3wWd mrwwOG2bk4GvHz9MOAbkAz8plix/jy7x6u67/96EtALeJeOEj0HYP5E2M5+6CcUa87a7 wCTRK/k4Zd6N2zA751tGOAq6WelbDkzSkmZE7Hlv1suwR9gEJbS+vKfQQ0P0IYPPHCkA tS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193813; x=1736798613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zxJ3+xb03FIgQb6HyhO+0vTNSYN1GRLEa0EnbI36swA=; b=gHICRBblk2pnF6BL6l/qw8tzAmkloZLZWQgM6YkwuQ1i7qqhS9H99r7YffVezh6T8M gOEZAb6uOGAU0dkVyqzxTLOlUgQvkkFnRgQSnWLel2fwRpqdIYg0xkbjqIxbUFhbA+sX dAz1ruEmrgzKTkYWWRg4KUllGqwv1Aw/F2c1l5a+JMY1eBPsttvgv9IPggVeR9p7A9x5 jVrd1WHy7epMjialxyGJkXk0FJ3m+zATzeud+HGIMcU1oBJLZAY1uqz02JjR5o0uwl/M vpMZm7ygR9G14h8/in6udMWuS4yS0TTnGloobQ5QQgFlgEnDAzp/iUpgaNZE+DBIS3pu 5OqA== X-Gm-Message-State: AOJu0YzpWaayFW2nSnbUiuO44gMYHU5+6gTWoK5+e1UvLa+qrxUBCGfe gYa59Ya09HNtJQySxHA0Zi7fpo9j+uTTs+NvVlLq8wCECw4ZCf4sfPNbGgXvTmkQnYRMDPzYF80 wpaM= X-Gm-Gg: ASbGncsx5R5jKP8laHfykcMZrLfVnGJfy/NhAea1DWa15jXNFdBrCzEcJyWXWjJ9ymb aj+pBxsCo6TI8xHZeYD7Rm4Cv+tP4n3Jco1LMzDbymYk6w57dJFcZHD5om8cKvg6rSKoKEV40nj 9G5WBAPTQxnErkt119tAH0OREu6xgBa795oUdxzmGqM9bQWgfSYtv7QuWUMYdFyS7iTlTLiEp9I qOiPvVzyixh8aPzHKJsalX1RHHx8hYXDmzLNXk5W5mQbq+y+7pm2Mm5SSXmHjOYHaDNRdg3e3W6 nqTDo6wIaOAQEjSfhstyIY61gEOgplw= X-Received: by 2002:adf:a3d9:0:b0:38a:39ad:3e31 with SMTP id ffacd0b85a97d-38a39ad4128mr24752061f8f.57.1736193813254; Mon, 06 Jan 2025 12:03:33 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6d02sm618987535e9.1.2025.01.06.12.03.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?utf-8?b?RnLDqWQ=?= =?utf-8?b?w6lyaWMgQmFycmF0?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 5/7] accel/hw: Implement hw_accel_get_cpus_queue() Date: Mon, 6 Jan 2025 21:02:56 +0100 Message-ID: <20250106200258.37008-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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=unavailable 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 We can only run a single hardware accelerator at a time, so add a generic hw_accel_get_cpus_queue() helper in accel-system.c, a file common to all HW accelerators. Register AccelOpsClass::get_cpus_queue() for each HW accelerator. Add a generic CPU_FOREACH_HWACCEL() macro. Signed-off-by: Philippe Mathieu-Daudé --- include/system/hw_accel.h | 9 +++++++++ accel/accel-system.c | 8 ++++++++ accel/kvm/kvm-accel-ops.c | 1 + accel/xen/xen-all.c | 1 + target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 6 files changed, 21 insertions(+) diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h index 380e9e640b6..12664cac6f9 100644 --- a/include/system/hw_accel.h +++ b/include/system/hw_accel.h @@ -2,6 +2,7 @@ * QEMU Hardware accelerators support * * Copyright 2016 Google, Inc. + * Copyright 2025 Linaro Ltd. * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -17,6 +18,14 @@ #include "system/whpx.h" #include "system/nvmm.h" +/* Guard with qemu_cpu_list_lock */ +extern CPUTailQ hw_accel_cpus_queue; + +#define CPU_FOREACH_HWACCEL(cpu) \ + QTAILQ_FOREACH_RCU(cpu, &hw_accel_cpus_queue, node) + +CPUTailQ *hw_accel_get_cpus_queue(void); + void cpu_synchronize_state(CPUState *cpu); void cpu_synchronize_post_reset(CPUState *cpu); void cpu_synchronize_post_init(CPUState *cpu); diff --git a/accel/accel-system.c b/accel/accel-system.c index a7596aef59d..60877ea7a28 100644 --- a/accel/accel-system.c +++ b/accel/accel-system.c @@ -27,9 +27,17 @@ #include "qemu/accel.h" #include "hw/boards.h" #include "system/cpus.h" +#include "system/hw_accel.h" #include "qemu/error-report.h" #include "accel-system.h" +CPUTailQ hw_accel_cpus_queue = QTAILQ_HEAD_INITIALIZER(hw_accel_cpus_queue); + +CPUTailQ *hw_accel_get_cpus_queue(void) +{ + return &hw_accel_cpus_queue; +} + int accel_init_machine(AccelState *accel, MachineState *ms) { AccelClass *acc = ACCEL_GET_CLASS(accel); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index a81e8f3b03b..5f4001860d5 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -93,6 +93,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); + ops->get_cpus_queue = hw_accel_get_cpus_queue; ops->create_vcpu_thread = kvm_start_vcpu_thread; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 852e9fbe5fe..ac5ed2dfb80 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -150,6 +150,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); + ops->get_cpus_queue = hw_accel_get_cpus_queue; ops->create_vcpu_thread = dummy_start_vcpu_thread; } diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index e7b56662fee..bb407c68e14 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -84,6 +84,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); + ops->get_cpus_queue = hw_accel_get_cpus_queue; ops->create_vcpu_thread = nvmm_start_vcpu_thread; ops->kick_vcpu_thread = nvmm_kick_vcpu_thread; diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index ab2e014c9ea..191214ca81d 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -86,6 +86,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); + ops->get_cpus_queue = hw_accel_get_cpus_queue; ops->create_vcpu_thread = whpx_start_vcpu_thread; ops->kick_vcpu_thread = whpx_kick_vcpu_thread; ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle; From patchwork Mon Jan 6 20:02:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 855284 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp9621282wrq; Mon, 6 Jan 2025 12:05:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXI78hhzi8wYrHskCbNAu0rm3BvuCGgddIjoaOGYntu0osqriWol12xsuluw02+UFVlX6dPTQ==@linaro.org X-Google-Smtp-Source: AGHT+IG5uL4DioSl2UFr71hdGFNyH08sPHdnhq/vlTQ8OZTNoljNhnEEUMp3mkcZtKJJ3orYWDiS X-Received: by 2002:a05:6102:1629:b0:4b2:5d16:f75 with SMTP id ada2fe7eead31-4b2cc31c5e0mr40881438137.4.1736193928875; Mon, 06 Jan 2025 12:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736193928; cv=none; d=google.com; s=arc-20240605; b=A+9AIZERKS/lAB8Oc5fEMPiKfqldqb4SsF01h2qmwESMeIXO/hHPcbMxm6ewug5ILf Gafgrh2NtFriS0m3lvarljPPyfNraTptKwRRW9POo8xD4cKSMLbVD6vd04huj2oK5YTy aBg/Md3YhaBvHz8jG2g0xuj3NM0XAJ4oZTCdM+IgOHih7dFAigbkkW0orkljfUqn532M BB2RE3Tg4jipz4YEkoywPikT9tx05mnx7R2MJ8hRnLOZ+ApJPdz13hNmiaIqhvXSB1wJ XMMYxjQW6uW3ZqGVPVXj843madHn4ZYC9crXAZtucaigmKhD/nVcL9qUEqch8NwuGj6h TXsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature; bh=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; fh=YIGq2OjjvJJvfOLa9lPT9cLAg4GPwPsWWWag+t9HO1Y=; b=GOOIGy8Dpr69xwdnQjj9qsbqlxkQaSFQ9tt6Ojm8A0bxZ+if1/s6bBCCS70w9G1kX5 lbP9uNJlwU0nC8qkWBhxRW+AU65wDEpn2oRj6fYARkNmEBaEIwERIPKtiKs+L7/KJCzE RdGa4UGA2658IhG6W7NgmFK2smlhpowci5bO4RY5ecB68XOMkliK8qAKPeJgeOPVGu7F 2yj3XSOtMCeVOat+6pe8IYwMfwBs4BDoKlgph/WToboZ0i1w1wE8u01SalV10RGMBQJq aUnoPajrQWkMcsji7fLSg90bi5aBLxJE160IOZU8QrbRhh9kelvDiAXRYJ0n/uktcMyT nJ5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LBR/DXZR"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4b2bf98d2c0si9256798137.17.2025.01.06.12.05.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jan 2025 12:05:28 -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=pass header.i=@linaro.org header.s=google header.b="LBR/DXZR"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtKN-0002sP-78; Mon, 06 Jan 2025 15:03:55 -0500 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 1tUtKK-0002qF-PC for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:52 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtKH-0003cP-BD for qemu-devel@nongnu.org; Mon, 06 Jan 2025 15:03:52 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso14193128f8f.2 for ; Mon, 06 Jan 2025 12:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736193828; x=1736798628; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; b=LBR/DXZRmSrzf6cNzKaXGzcg5zmJ7W8SRehar81uDGTmoZKgNXjqnmSMUvumBQrO/R sVm4d7K+uRJjwivKq2IARdDmn+wrFhIjdwM8eX+M7eS7FVh90eudcFo+XWw5sLQ4khZW l6uv2wKASPzPy8Y3GDGJWO7s+AMhfhJoMNBfBvjIZIzfQIeUa2lk/ELfjUUugXE4MvBv 3I7akvh9HzQTjLA5UXgX1O1MJUioU0NdS8924IenP/Icii1RQqDOGKBEvlX1KXI/sPZi ySEmN++NXtqf69DxjGpM382IhL8wTQ7CXTAAQ+j3RoQdKltV5Y8HaG4w77Rj9rpilhsG Gubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736193828; x=1736798628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iQTkKmwN0la/zq4/AmggU7ruV8aWhlAE2m8oe1Or7Yc=; b=cepJNaGUr6jx/FWifNIkbWGKbX0iVrHIQR+5CK5PyRHqxg+Y8c4037gZrngcVFNBpD +oUcbHyvtLz3SOqnnE2k+xyvKc0TEobPwut7Zt30pxZCbL4iH4AViK+rAXN5BYpw2otT 7CAsavC6PXIWpwx0O9GXA7TF5VYX6l5slGBgya4nobsN7tdQQiI56twwe7JGdXO0lWFm L3BmontxAQD+spaKJ8QGjYTkE0+hKKq7rq3MVX6rmEZ2wV85g4buNC5jSXk+qIhCw7Uw on9uYoQ9PpFnVzb5smud8DyWfWgXddsHGoCgRI6XfWgAKRtFbEhQ4u4jI6PWjsCs8hyf kGrw== X-Gm-Message-State: AOJu0Yxf9p+4Hyl/FxB6Q5u87IhjDD2XdPR7X61503LgMvssSw0ZnMqx YdNNstYR7n3zDlQoO1/pHnpZDKPXtxRbngdWnJFD3RXTPmvfUim0nrAwUrInHiLKMZvQzbqd9FJ oyfo= X-Gm-Gg: ASbGncszjujSgWa67lJgRVVe/jxZ/TL3ZNIQtNDbjkZNmubaDjfxirJbg7MTitLSyvM S0kiEu2NO73gcwDqxMimYIde8J3LoSxrmT7hkt5Pa5lhgQRG9H/8Zoyvb7BB6HROg+W0rUbIMpm TVFr0AzjttOZokyy3TChidq6A6n6RgST18APY4W8UASm+wHo7369zE71DvIwyYb3QHSb/goeMQt AOBGOqmKHIALkBqNVy9nnC4ba6sywc1WSRA031pLxcs4JkROJYhPmXJbRM++Y3PTnwRYyffoiIr 0fugErAFYzOQ3HbHlC17oD1uqdpzoZY= X-Received: by 2002:a5d:6c64:0:b0:385:f6f4:f8e with SMTP id ffacd0b85a97d-38a223ff1cemr40988273f8f.50.1736193825978; Mon, 06 Jan 2025 12:03:45 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436723cb159sm525092965e9.16.2025.01.06.12.03.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 Jan 2025 12:03:44 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , =?utf-8?b?RnLDqWQ=?= =?utf-8?b?w6lyaWMgQmFycmF0?= , Stefano Stabellini , Ilya Leoshkevich , Cameron Esfahani , Paolo Bonzini , kvm@vger.kernel.org, Alexander Graf , Paul Durrant , David Hildenbrand , Halil Pasic , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Yanan Wang , Reinoud Zandijk , Peter Maydell , qemu-s390x@nongnu.org, Riku Voipio , Anthony PERARD , Alistair Francis , Sunil Muthuswamy , Christian Borntraeger , Nicholas Piggin , Richard Henderson , Marcelo Tosatti , Thomas Huth , Roman Bolshakov , "Edgar E . Iglesias" , Zhao Liu , Phil Dennis-Jordan , David Woodhouse , Harsh Prateek Bora , Nina Schoetterl-Glausch , "Edgar E. Iglesias" , Eduardo Habkost , qemu-ppc@nongnu.org, Daniel Henrique Barboza , "Michael S. Tsirkin" , Anton Johansson Subject: [RFC PATCH 7/7] accel/kvm: Use CPU_FOREACH_KVM() Date: Mon, 6 Jan 2025 21:02:58 +0100 Message-ID: <20250106200258.37008-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106200258.37008-1-philmd@linaro.org> References: <20250106200258.37008-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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=unavailable 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 Only iterate over KVM vCPUs when running KVM specific code. Signed-off-by: Philippe Mathieu-Daudé --- include/system/kvm_int.h | 3 +++ accel/kvm/kvm-all.c | 14 +++++++------- hw/i386/kvm/clock.c | 3 ++- hw/intc/spapr_xive_kvm.c | 5 +++-- hw/intc/xics_kvm.c | 5 +++-- target/i386/kvm/kvm.c | 4 ++-- target/i386/kvm/xen-emu.c | 2 +- target/s390x/kvm/kvm.c | 2 +- target/s390x/kvm/stsi-topology.c | 3 ++- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/system/kvm_int.h b/include/system/kvm_int.h index 4de6106869b..0ef4c336b18 100644 --- a/include/system/kvm_int.h +++ b/include/system/kvm_int.h @@ -13,6 +13,7 @@ #include "qapi/qapi-types-common.h" #include "qemu/accel.h" #include "qemu/queue.h" +#include "system/hw_accel.h" #include "system/kvm.h" #include "hw/boards.h" #include "hw/i386/topology.h" @@ -168,6 +169,8 @@ struct KVMState char *device; }; +#define CPU_FOREACH_KVM(cpu) CPU_FOREACH_HWACCEL(cpu) + void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id, const char *name); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c65b790433c..9b26b286865 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -872,7 +872,7 @@ static uint64_t kvm_dirty_ring_reap_locked(KVMState *s, CPUState* cpu) if (cpu) { total = kvm_dirty_ring_reap_one(s, cpu); } else { - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { total += kvm_dirty_ring_reap_one(s, cpu); } } @@ -935,7 +935,7 @@ static void kvm_cpu_synchronize_kick_all(void) { CPUState *cpu; - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvm_cpu_synchronize_kick, RUN_ON_CPU_NULL); } } @@ -3535,7 +3535,7 @@ int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len) } } - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { err = kvm_update_guest_debug(cpu, 0); if (err) { return err; @@ -3574,7 +3574,7 @@ int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len) } } - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { err = kvm_update_guest_debug(cpu, 0); if (err) { return err; @@ -3592,7 +3592,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { if (kvm_arch_remove_sw_breakpoint(cpu, bp) != 0) { /* Try harder to find a CPU that currently sees the breakpoint. */ - CPU_FOREACH(tmpcpu) { + CPU_FOREACH_KVM(tmpcpu) { if (kvm_arch_remove_sw_breakpoint(tmpcpu, bp) == 0) { break; } @@ -3603,7 +3603,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) } kvm_arch_remove_all_hw_breakpoints(); - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { kvm_update_guest_debug(cpu, 0); } } @@ -4384,7 +4384,7 @@ static void query_stats_cb(StatsResultList **result, StatsTarget target, stats_args.result.stats = result; stats_args.names = names; stats_args.errp = errp; - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { if (!apply_str_list_filter(cpu->parent_obj.canonical_path, targets)) { continue; } diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 63be5088420..f2638cf2c22 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -17,6 +17,7 @@ #include "qemu/host-utils.h" #include "qemu/module.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "system/runstate.h" #include "system/hw_accel.h" #include "kvm/kvm_i386.h" @@ -196,7 +197,7 @@ static void kvmclock_vm_state_change(void *opaque, bool running, if (!cap_clock_ctrl) { return; } - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvmclock_ctrl, RUN_ON_CPU_NULL); } } else { diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 26d30b41c15..08354f08512 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -14,6 +14,7 @@ #include "target/ppc/cpu.h" #include "system/cpus.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "system/runstate.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" @@ -678,7 +679,7 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_id) * 'post_load' handler of XiveTCTX because the machine is not * necessarily connected to the KVM device at that time. */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); ret = kvmppc_xive_cpu_set_state(spapr_cpu_state(cpu)->tctx, &local_err); @@ -795,7 +796,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers, kvmppc_xive_change_state_handler, xive); /* Connect the presenters to the initial VCPUs of the machine */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); ret = kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp); diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index ee72969f5f1..aed2ad44363 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -29,6 +29,7 @@ #include "qapi/error.h" #include "trace.h" #include "system/kvm.h" +#include "system/kvm_int.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" #include "hw/ppc/xics.h" @@ -418,7 +419,7 @@ int xics_kvm_connect(SpaprInterruptController *intc, uint32_t nr_servers, kvm_gsi_direct_mapping = true; /* Create the presenters */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); icp_kvm_realize(DEVICE(spapr_cpu_state(cpu)->icp), &local_err); @@ -434,7 +435,7 @@ int xics_kvm_connect(SpaprInterruptController *intc, uint32_t nr_servers, } /* Connect the presenters to the initial VCPUs of the machine */ - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); icp_set_kvm_state(spapr_cpu_state(cpu)->icp, &local_err); if (local_err) { diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2f66e63b880..437911d6c6a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -329,7 +329,7 @@ void kvm_synchronize_all_tsc(void) CPUState *cpu; if (kvm_enabled()) { - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { run_on_cpu(cpu, do_kvm_synchronize_tsc, RUN_ON_CPU_NULL); } } @@ -2847,7 +2847,7 @@ static void *kvm_msr_energy_thread(void *data) * Identify the vcpu threads * Calculate the number of vcpu per package */ - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { for (int i = 0; i < num_threads; i++) { if (cpu->thread_id == thd_stat[i].thread_id) { thd_stat[i].is_vcpu = true; diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index e81a2458812..36ae9c11252 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -1422,7 +1422,7 @@ int kvm_xen_soft_reset(void) return err; } - CPU_FOREACH(cpu) { + CPU_FOREACH_KVM(cpu) { async_run_on_cpu(cpu, do_vcpu_soft_reset, RUN_ON_CPU_NULL); } diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index db645a48133..a02e78ce807 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1559,7 +1559,7 @@ static void handle_diag_318(S390CPU *cpu, struct kvm_run *run) return; } - CPU_FOREACH(t) { + CPU_FOREACH_KVM(t) { run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(diag318_info)); } diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topology.c index c8d6389cd87..cf1a9b5d218 100644 --- a/target/s390x/kvm/stsi-topology.c +++ b/target/s390x/kvm/stsi-topology.c @@ -10,6 +10,7 @@ #include "cpu.h" #include "hw/s390x/sclp.h" #include "hw/s390x/cpu-topology.h" +#include "system/kvm_int.h" QEMU_BUILD_BUG_ON(S390_CPU_ENTITLEMENT_LOW != 1); QEMU_BUILD_BUG_ON(S390_CPU_ENTITLEMENT_MEDIUM != 2); @@ -256,7 +257,7 @@ static void s390_topology_fill_list_sorted(S390TopologyList *topology_list) QTAILQ_INSERT_HEAD(topology_list, &sentinel, next); - CPU_FOREACH(cs) { + CPU_FOREACH_KVM(cs) { S390TopologyId id = s390_topology_from_cpu(S390_CPU(cs)); S390TopologyEntry *entry = NULL, *tmp;