From nobody Tue Feb 10 20:48:39 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711131133; cv=none; d=zohomail.com; s=zohoarc; b=eEgmo0CZ1bMNoyjv8P8vU3WiJUhAB2lV419BXZ/L3Q9ENJYoadSn5tmswtGU2eJlXLkF1AGKPs8gkF2UU3Nj4CMxRztfuWYRRp15ysHsHaz2mBsTeW6Wxy76XkywPoq+WeEElkTd57DMaxWJNdU4eNyp8K0f9kF6qFWbD6Ye25Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711131133; h=Content-Type: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=qEJ0yKlHrmKhZxiI7OJ9cPT/90ybcJyHoiSWV5zSPBM=; b=Ai3SA09oTdlGXMWH4fdLYhGnKKmfakIlhawMN+Bh79Xp8aLYn/K9KIYs2p4wnk1xiTlDlthp1mlDia1NhibcNJNdZ4yb+B+nzgthhf292D66Eu0J9MsqtQsLb8Izif4pWJVi1mloaPyrnwAKAAQCsUy+VVH6xo0nGmymQ2MRloM= 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 1711131133077853.8178814396292; Fri, 22 Mar 2024 11:12:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnjMm-0006Fo-MV; Fri, 22 Mar 2024 14:11:44 -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 1rnjMi-0006FI-Pz for qemu-devel@nongnu.org; Fri, 22 Mar 2024 14:11:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnjMd-0006wg-Hd for qemu-devel@nongnu.org; Fri, 22 Mar 2024 14:11:40 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-a9XBVqV6N-u7deljmJBvaA-1; Fri, 22 Mar 2024 14:11:33 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a4698fc37dfso153813866b.2 for ; Fri, 22 Mar 2024 11:11:33 -0700 (PDT) Received: from [192.168.10.118] ([151.95.49.219]) by smtp.gmail.com with ESMTPSA id k18-20020a1709065fd200b00a46cf8aea7bsm78399ejv.30.2024.03.22.11.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 11:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711131094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qEJ0yKlHrmKhZxiI7OJ9cPT/90ybcJyHoiSWV5zSPBM=; b=ShxpxK1ijMJX4QX8Yi30HHt1fUi4YalhneocT4epiHgCUX3wZj3fUguBw23jMqytkTfFy/ mBiwPeIVRYMzhosYDyh8E3ywsXXg+RpEqmNpPRGXdxtIe9nan90Xl+e8zI6lD24gwzBCW9 kFmCOEYom+dQrZvYVyz5tEoG+zpO7Hc= X-MC-Unique: a9XBVqV6N-u7deljmJBvaA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711131090; x=1711735890; 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=qEJ0yKlHrmKhZxiI7OJ9cPT/90ybcJyHoiSWV5zSPBM=; b=feReehN3+la4BMekfeeMMlKftnvomB3pdu7iL4CZupA4uvqZqnY34/cZz4EPY4gWVS qwDtTGH5USbV9jyeJONNJl1hWBhYRszcPwinfnizRpwp5utAJH3SGr+RtZzaEgJv4Uht mf7r3g0ldjX1ZVu1rAwVdVN9a4RnxEtM8NPw5dUTosmZ6FhwYgLsP5iry2fyx542TQtT PCdgSDeTv/0GpiONK+439MWOenkaSUxPSa/wddOielFp1xWjQxPw7UIHYED5lkwzkALE 8uakVvy2SX2xWQX3+xINADJrvI0UVLwSvPNdlOp18Z91oq/L57IiCgANC3iLMygAvpwK CxFA== X-Gm-Message-State: AOJu0Yyrr2diD6n0XjWIY2nhsbpSyW97a/F9upButS3Nzb4AtE7DPQic 3bz7GIifZrvu/VcBHux9llgUkdOiVKFqugRPIfm2QEOGvFefD48LSBjaJf+EuG6omrslmUpa+f6 +zEK/A4gMuI5unjLSUabSik0da+D5AB8Jyn368YRQFHOb+HItuxUVMz4Eydb0D+H2csLzPt0fDM Bo0x5nw07TFbOjbI2Xu/pWjpM13OOPRlzKe4Eh X-Received: by 2002:a17:906:70cb:b0:a46:74fe:904f with SMTP id g11-20020a17090670cb00b00a4674fe904fmr317489ejk.26.1711131090464; Fri, 22 Mar 2024 11:11:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYx4z0ulwvcCfL3z2eLajGwC0mrdXPAQ0RZtcJfdHMS7piBuQSjxKVjN1AdQV2hlqxeRqB4Q== X-Received: by 2002:a17:906:70cb:b0:a46:74fe:904f with SMTP id g11-20020a17090670cb00b00a4674fe904fmr317466ejk.26.1711131090017; Fri, 22 Mar 2024 11:11:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: xiaoyao.li@intel.com, michael.roth@amd.com, david@redhat.com Subject: [PATCH 03/26] confidential guest support: Add kvm_init() and kvm_reset() in class Date: Fri, 22 Mar 2024 19:10:53 +0100 Message-ID: <20240322181116.1228416-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240322181116.1228416-1-pbonzini@redhat.com> References: <20240322181116.1228416-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.222, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham 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 @redhat.com) X-ZM-MESSAGEID: 1711131135222100005 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li 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 facilitate the introduction of confidential guest technology from different x86 vendors, add two virtual functions, kvm_init() and kvm_reset() in ConfidentialGuestSupportClass, and expose two helpers functions for invodking them. Signed-off-by: Xiaoyao Li Message-Id: <20240229060038.606591-1-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini --- 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 ba2dd4b5dfc..e5b188cffbf 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.44.0