From nobody Tue Nov 26 08:35:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1709186585; cv=none; d=zohomail.com; s=zohoarc; b=bVBS6+M2M2BtXKIiPTBZgZ0au/ButhjMeedLS452Nm/N1qU2RD40B0GUn8hjL4vtNIvQzyUTEPrH7reA7j3shnXHVoOvlw2X6Z4J7lefzEwuwCPJp0+Rfm6OUr1gwrATMNLhNC/hv7w4SlWM/RC3CgjQ9EwpY+9JLu3kAvz+PJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709186585; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sDD7N4+Q+mngOZCGTWW/PR0ZHW36G2whEJfkk0OsJzs=; b=b/dJVYJ5ho2zo3n3olJrlMQMRUZ5GdM1hp+Y8i/sGVB3PDZCbkqzbz4Lv9xF6JTfWxlK32oyKKQ0FvwdIaGfuhY47pK3PL+RdRRk/3XQ9HnpqW6sNfQUX/xYqbID/Zalbk3EsUHfFEfxVZilC0/RQoMqDO6zPplEGks9DcUVQr4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1709186585466531.0023613912007; Wed, 28 Feb 2024 22:03:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfZTd-0000Tr-Ol; Thu, 29 Feb 2024 01:01:07 -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 1rfZTW-0000SK-2M; Thu, 29 Feb 2024 01:01:01 -0500 Received: from mgamail.intel.com ([192.198.163.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfZTU-0001Lg-1Q; Thu, 29 Feb 2024 01:00:57 -0500 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 22:00:51 -0800 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by orviesa008.jf.intel.com with ESMTP; 28 Feb 2024 22:00:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709186456; x=1740722456; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A9e+ujl7YTIuPGXbZJj3fMaZkvIQhsHO8qbu//JANj4=; b=a+Dw8k7fd40djz5PFqpTdKMQvHUJ1FA25dicFFhFpXW1GTlL0lljrFlI L1ydU/KIkbtfH3CzrpICr8xyCD6/Gaa4Rqd9scmt8jL3ZeMw01dbFPBc3 tRYXhPBIKv3QqD66weJPyzARGxwwi76ZaF4OsSDX67ReAfjUr/Sv1w1bO vH+36OUqL4Y+4VDlocZTEOVI36RKUr+awTp+IEWvSyADWgCGMmbTyL2c0 kGa9PGP4NwygOEVLPj3cafHbTJWIcqhhRH5P1KqzKynjPqJPRs1EMdV82 q0jhMZcLTQ3FuPD2caJLnXXI/elZzP9suPO6vcNGvabB0jFzySWlGjYAj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14274153" X-IronPort-AV: E=Sophos;i="6.06,192,1705392000"; d="scan'208";a="14274153" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,192,1705392000"; d="scan'208";a="8266084" From: Xiaoyao Li To: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Harsh Prateek Bora , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Paolo Bonzini , Marcelo Tosatti Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 1/4] confidential guest support: Add kvm_init() and kvm_reset() in class Date: Thu, 29 Feb 2024 01:00:35 -0500 Message-Id: <20240229060038.606591-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229060038.606591-1-xiaoyao.li@intel.com> References: <20240229060038.606591-1-xiaoyao.li@intel.com> MIME-Version: 1.0 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=192.198.163.11; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.102, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.596, HK_RANDOM_FROM=0.999, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1709186586678100003 Content-Type: text/plain; charset="utf-8" Different confidential VMs in different architectures all have the same needs to do their specific initialization (and maybe resetting) stuffs with KVM. Currently each of them exposes individual *_kvm_init() functions and let machine code or kvm code to call it. To make it more object oriented, add two virtual functions, kvm_init() and kvm_reset() in ConfidentialGuestSupportClass, and expose two helpers functions for invodking them. Signed-off-by: Xiaoyao Li --- Changes since rfc v1: - Drop the NULL check and rely the check from the caller; --- include/exec/confidential-guest-support.h | 34 ++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/include/exec/confidential-guest-support.h b/include/exec/confi= dential-guest-support.h index ba2dd4b5dfc4..e5b188cffbfd 100644 --- a/include/exec/confidential-guest-support.h +++ b/include/exec/confidential-guest-support.h @@ -23,7 +23,10 @@ #include "qom/object.h" =20 #define TYPE_CONFIDENTIAL_GUEST_SUPPORT "confidential-guest-support" -OBJECT_DECLARE_SIMPLE_TYPE(ConfidentialGuestSupport, CONFIDENTIAL_GUEST_SU= PPORT) +OBJECT_DECLARE_TYPE(ConfidentialGuestSupport, + ConfidentialGuestSupportClass, + CONFIDENTIAL_GUEST_SUPPORT) + =20 struct ConfidentialGuestSupport { Object parent; @@ -55,8 +58,37 @@ struct ConfidentialGuestSupport { =20 typedef struct ConfidentialGuestSupportClass { ObjectClass parent; + + int (*kvm_init)(ConfidentialGuestSupport *cgs, Error **errp); + int (*kvm_reset)(ConfidentialGuestSupport *cgs, Error **errp); } ConfidentialGuestSupportClass; =20 +static inline int confidential_guest_kvm_init(ConfidentialGuestSupport *cg= s, + Error **errp) +{ + ConfidentialGuestSupportClass *klass; + + klass =3D CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs); + if (klass->kvm_init) { + return klass->kvm_init(cgs, errp); + } + + return 0; +} + +static inline int confidential_guest_kvm_reset(ConfidentialGuestSupport *c= gs, + Error **errp) +{ + ConfidentialGuestSupportClass *klass; + + klass =3D CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs); + if (klass->kvm_reset) { + return klass->kvm_reset(cgs, errp); + } + + return 0; +} + #endif /* !CONFIG_USER_ONLY */ =20 #endif /* QEMU_CONFIDENTIAL_GUEST_SUPPORT_H */ --=20 2.34.1