From nobody Tue Nov 26 16:46:18 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=1707208258; cv=none; d=zohomail.com; s=zohoarc; b=auwcVT6MqDZ9KsHOIvrOZOaE3pRGqSgvPYVKBlAEbCEoEhBLnxujXZbCZR64brz58tcdFDYO5LJhnAFM1ez8lAs9LKtkDdp3qbsZrSH4MfWtH/FjR5AueNSkfec+sWCRh7efh9aakHzUsSs6SYNhRc/Cu6dAFwGAyFI3dlaM61k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707208258; 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=YYHiwk0crg8O1noRoe2aNvudL34mpOGpG0rm/nsPMaY=; b=ax01NksgGJcjHrN5q/LGU3dbDqIvD6177WXUwty4Dauh3ATCF+0PF304/GKcl8glELEaUZgnCrcmThVJ7PUvG/Ke1HbuROeWNZK+FgKOZVY2MlvFFSgaZ+5QZC3QB5sA9DWIhI/Nc5tfvFYfMGG2Sok78wHAGrQhWsgOE5Ux1uE= 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 1707208258260915.5792816303532; Tue, 6 Feb 2024 00:30:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXGpM-00052E-0k; Tue, 06 Feb 2024 03:29:12 -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 1rXGpI-00051a-Qj; Tue, 06 Feb 2024 03:29:08 -0500 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXGpH-00023T-8c; Tue, 06 Feb 2024 03:29:08 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 00:29:05 -0800 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by orsmga001.jf.intel.com with ESMTP; 06 Feb 2024 00:28:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707208148; x=1738744148; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ORLsYIrX434K64t7KoSOv6XzRl/gB3m2JYbyMfbauuQ=; b=XgO2wO3+TW6Qm7DOm7+QX8y8rIWRBVxugQi64XzmbrruiKXOT+t9Wa5X 9UyXVy4OBaJS1L/JZnvxe3Z1d3D95Kx2BN8Miwb+nhTdiTcyG4S7yL+Og 1WIi66PCD/qjZmsx6/9mMy2stCcZ6/k5JBlwjzov7s9ysVSGDCPRrOK/v xZncQANFY1PFzngnfm1W4BiCXutJCIGUWZfurtSR4sHNWh7itP7/+Su5t nN4KhIPY3ZR4ba8mY7OHv5YjKq9Z8rxXMQQyPUejOOfSd8eWZ8WRyMRgZ UcuAk/UxI44fVZibjk0QnJkN6U6fOP9dbA8Oo7sSGv/P9FZsl1xcu+zwS w==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="4578234" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="4578234" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="824112662" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="824112662" 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: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH 1/4] confidential guest support: Add kvm_init() and kvm_reset() in class Date: Tue, 6 Feb 2024 03:28:49 -0500 Message-Id: <20240206082852.3333299-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206082852.3333299-1-xiaoyao.li@intel.com> References: <20240206082852.3333299-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=198.175.65.15; envelope-from=xiaoyao.li@intel.com; helo=mgamail.intel.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.285, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.999, 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: 1707208260469100003 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 --- include/exec/confidential-guest-support.h | 42 ++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/include/exec/confidential-guest-support.h b/include/exec/confi= dential-guest-support.h index ba2dd4b5dfc4..ff0bfb26ad7a 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,45 @@ 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; + + if (!cgs) { + return 0; + } + + 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; + + if (!cgs) { + return 0; + } + + 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