From nobody Mon Sep 16 20:04:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1695053439; cv=none; d=zohomail.com; s=zohoarc; b=A1B36sZFbxu0ep0LC7bVoj4SWr/81isuU0e9ezbMGmezUgfJPvvDZYIc8LtXJDd0qsFRcfuz/mouHU510XDzAm3EDtF1Pz5yvLRnNvcdlsSu9diPQPwgH0vXqnbHgKgwfBLSHi+IOatcN5C2GlqIxeQ/0KW9mBu1E5yv7sEijsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695053439; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NjaIM1Qc6nHbnxZLIT5jjyB717NwyoCy1EteOD4KAlE=; b=B/8I4KcszcLoW6Hp9S8iEGnoDR8J8/2CfF6hxgo6KUNweYWTEoMdCGHzVzE2AB3yKkKbAMC15glKJ9zgYvN9NdDCbh5EYvJ6sDbNm2FJGLUxIISM38vNOdDtBUkbNVxxNTaru/iH4MVoc2QWQdC7aGQW6WQnPbYkzGJ0JVaVcCA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695053439199548.6325475589434; Mon, 18 Sep 2023 09:10:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiGji-0000Zg-Bn; Mon, 18 Sep 2023 12:04:34 -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 1qiGja-0008Bo-BD for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:04:26 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiGjU-0004Kj-87 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:04:26 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9a9f139cd94so635662166b.2 for ; Mon, 18 Sep 2023 09:04:19 -0700 (PDT) Received: from localhost.localdomain (static-212-193-78-212.thenetworkfactory.nl. [212.78.193.212]) by smtp.gmail.com with ESMTPSA id f13-20020a170906390d00b00982a92a849asm6628019eje.91.2023.09.18.09.04.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 09:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695053058; x=1695657858; 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=NjaIM1Qc6nHbnxZLIT5jjyB717NwyoCy1EteOD4KAlE=; b=t0llDNmNfv8UG/Uz7Bv6Oz3tQavpDDy9Ti61u5vtH5yvyk3IOrlWWqvH94ZYYlU7xF EkwwbHMyCBq2p6TZax4+x4M56FfeV9AQA8kz3B8ZLLMYHRL32xp8LPLQ6OcFIm7XPWZQ HqXImbNEWR0a1vbL9/WKqKcVZRkB+cF30o8q7POkfy9/6dYevY8FDc/Q7Q6OtPT92kPO yoT3qkklnYcu70Q6TmvYboUPHlQklwyhLESAnTMgeO6oChdZJJiY/+wuj3kMZAWRZL4u z+D5xF+F1Vb+hj38/xOL2NobShGA6ogToBuI6Ie5UFQMP1XhhiMo5UBpWG7KkFq+Tbde 8ftg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695053058; x=1695657858; 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=NjaIM1Qc6nHbnxZLIT5jjyB717NwyoCy1EteOD4KAlE=; b=hnTs8YFehGUdk9oFiaokdOB4RA54iJIlkX9eMCP5DIakJJzoNunATJ1F93K1sbcHyP /fPEVRPccOWWGyAXh2BoplEvChRjV6A2rJ1mKMsU3IxTx5Aa/TAG7qMMZIIAG6Pj2ZzH KzktYXgSL9CqO66OQO4UCF93UyCZdlaNEnF9IvD8DJsOFNLuno1Yh70tOblXP6C8/Fuq Kmg1hUCtyKaZNBZhZFuB9k1UsCtfcpfo5dTQLKaeUWBW9BhXo6ixeBUjnUJQoo5JQ4LX l4cRG/ce0JsBfLlTi1cCIhjdV3MrSqlSVo3lZ3mgQ1weH3Pz920zErDuQ0e6nBSRoXKs wUDg== X-Gm-Message-State: AOJu0Yzi8YCHq9L+B6a45cz8dEGYmuDl8I8gyg6XNgkh2Ozv5zpKFbki Q/yH3i1/yn/KFm2x4EQW9vaVLZSLFQTKWKcWg6/T6dbE X-Google-Smtp-Source: AGHT+IH1BGqTiq3uZIcjIgDgFSn4hEE/bGsbSKhsdURXDBkyUNQTShuSyFgzOD2PM8QK12Z2NIlVUQ== X-Received: by 2002:a17:907:75f1:b0:9a1:da9a:f1c2 with SMTP id jz17-20020a17090775f100b009a1da9af1c2mr7861010ejc.11.1695053058645; Mon, 18 Sep 2023 09:04:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Max Filippov , David Hildenbrand , Peter Xu , Anton Johansson , Peter Maydell , kvm@vger.kernel.org, Marek Vasut , David Gibson , Brian Cain , Yoshinori Sato , "Edgar E . Iglesias" , Claudio Fontana , Daniel Henrique Barboza , Artyom Tarasenko , Marcelo Tosatti , qemu-ppc@nongnu.org, Liu Zhiwei , Aurelien Jarno , Ilya Leoshkevich , Daniel Henrique Barboza , Bastian Koppelmann , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Alistair Francis , Alessandro Di Federico , Song Gao , Marcel Apfelbaum , Chris Wulff , "Michael S. Tsirkin" , Alistair Francis , Fabiano Rosas , qemu-s390x@nongnu.org, Yanan Wang , Luc Michel , Weiwei Li , Bin Meng , Stafford Horne , Xiaojuan Yang , "Daniel P . Berrange" , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Jiaxun Yang , Richard Henderson , Aleksandar Rikalo , Bernhard Beschow , Mark Cave-Ayland , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Nicholas Piggin , Greg Kurz , Michael Rolnik , Eduardo Habkost , Markus Armbruster , Palmer Dabbelt Subject: [PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features() Date: Mon, 18 Sep 2023 18:02:48 +0200 Message-ID: <20230918160257.30127-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918160257.30127-1-philmd@linaro.org> References: <20230918160257.30127-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1695053439706100001 Some CPUs need to check the requested features are compatible with the requested accelerator. This has to be done *before* the accelerator realizes a vCPU. Introduce the verify_accel_features() handler and call it just before accel_cpu_realizefn(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 4 ++++ cpu.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c90cf3a162..1e940f6bb5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -103,6 +103,9 @@ struct SysemuCPUOps; * @class_by_name: Callback to map -cpu command line model name to an * instantiatable CPU type. * @parse_features: Callback to parse command line arguments. + * @verify_accel_features: Callback to verify if all requested CPU are + * compatible with the requested accelerator. Called before the + * accelerator realize a vCPU. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. * @memory_rw_debug: Callback for GDB memory access. @@ -183,6 +186,7 @@ struct CPUClass { * class data that depends on the accelerator, see accel/accel-common.= c. */ void (*init_accel_cpu)(struct AccelCPUClass *accel_cpu, CPUClass *cc); + bool (*verify_accel_features)(CPUState *cs, Error **errp); =20 /* * Keep non-pointer data at the end to minimize holes. diff --git a/cpu.c b/cpu.c index 0769b0b153..84b03c09ac 100644 --- a/cpu.c +++ b/cpu.c @@ -136,6 +136,11 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) /* cache the cpu class for the hotpath */ cpu->cc =3D CPU_GET_CLASS(cpu); =20 + if (cpu->cc->verify_accel_features + && !cpu->cc->verify_accel_features(cpu, errp)) { + return false; + } + if (!accel_cpu_realizefn(cpu, errp)) { return; } --=20 2.41.0