From patchwork Wed Jan 4 11:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 13088510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43E92C4332F for ; Wed, 4 Jan 2023 11:53:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pD2Ix-0007UF-Hi; Wed, 04 Jan 2023 06:51:35 -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 1pD2Iw-0007S8-4X; Wed, 04 Jan 2023 06:51:34 -0500 Received: from gandalf.ozlabs.org ([150.107.74.76]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pD2Iu-0002PF-DV; Wed, 04 Jan 2023 06:51:33 -0500 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Nn7H32JpWz4y0Q; Wed, 4 Jan 2023 22:51:27 +1100 (AEDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Nn7Gy6Zy1z4y0B; Wed, 4 Jan 2023 22:51:22 +1100 (AEDT) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, Thomas Huth , Halil Pasic , Christian Borntraeger , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Eric Farman , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PATCH 1/5] confidential guest support: Introduce a 'check' class handler Date: Wed, 4 Jan 2023 12:51:07 +0100 Message-Id: <20230104115111.3240594-2-clg@kaod.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230104115111.3240594-1-clg@kaod.org> References: <20230104115111.3240594-1-clg@kaod.org> MIME-Version: 1.0 Received-SPF: pass client-ip=150.107.74.76; envelope-from=SRS0=6L6x=5B=kaod.org=clg@ozlabs.org; helo=gandalf.ozlabs.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater Some machines have specific requirements to activate confidential guest support. Add a class handler to the confidential guest support interface to let the arch implementation perform extra checks. Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: "Philippe Mathieu-Daudé" Cc: Yanan Wang Signed-off-by: Cédric Le Goater Reviewed-by: Thomas Huth --- include/exec/confidential-guest-support.h | 4 +++- hw/core/machine.c | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/exec/confidential-guest-support.h b/include/exec/confidential-guest-support.h index ba2dd4b5df..9e6d362b26 100644 --- a/include/exec/confidential-guest-support.h +++ b/include/exec/confidential-guest-support.h @@ -23,7 +23,8 @@ #include "qom/object.h" #define TYPE_CONFIDENTIAL_GUEST_SUPPORT "confidential-guest-support" -OBJECT_DECLARE_SIMPLE_TYPE(ConfidentialGuestSupport, CONFIDENTIAL_GUEST_SUPPORT) +OBJECT_DECLARE_TYPE(ConfidentialGuestSupport, ConfidentialGuestSupportClass, + CONFIDENTIAL_GUEST_SUPPORT) struct ConfidentialGuestSupport { Object parent; @@ -55,6 +56,7 @@ struct ConfidentialGuestSupport { typedef struct ConfidentialGuestSupportClass { ObjectClass parent; + bool (*check)(const Object *obj, Error **errp); } ConfidentialGuestSupportClass; #endif /* !CONFIG_USER_ONLY */ diff --git a/hw/core/machine.c b/hw/core/machine.c index f589b92909..bab43cd675 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -502,11 +502,12 @@ static void machine_check_confidential_guest_support(const Object *obj, Object *new_target, Error **errp) { - /* - * So far the only constraint is that the target has the - * TYPE_CONFIDENTIAL_GUEST_SUPPORT interface, and that's checked - * by the QOM core - */ + ConfidentialGuestSupportClass *cgsc = + CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(new_target); + + if (cgsc->check) { + cgsc->check(obj, errp); + } } static bool machine_get_nvdimm(Object *obj, Error **errp)