1 /*
2  * x86-specific confidential guest methods.
3  *
4  * Copyright (c) 2024 Red Hat Inc.
5  *
6  * Authors:
7  *  Paolo Bonzini <pbonzini@redhat.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10  * See the COPYING file in the top-level directory.
11  */
12 #ifndef TARGET_I386_CG_H
13 #define TARGET_I386_CG_H
14 
15 #include "qom/object.h"
16 
17 #include "exec/confidential-guest-support.h"
18 
19 #define TYPE_X86_CONFIDENTIAL_GUEST "x86-confidential-guest"
20 
21 OBJECT_DECLARE_TYPE(X86ConfidentialGuest,
22                     X86ConfidentialGuestClass,
23                     X86_CONFIDENTIAL_GUEST)
24 
25 struct X86ConfidentialGuest {
26     /* <private> */
27     ConfidentialGuestSupport parent_obj;
28 };
29 
30 /**
31  * X86ConfidentialGuestClass:
32  *
33  * Class to be implemented by confidential-guest-support concrete objects
34  * for the x86 target.
35  */
36 struct X86ConfidentialGuestClass {
37     /* <private> */
38     ConfidentialGuestSupportClass parent;
39 
40     /* <public> */
41     int (*kvm_type)(X86ConfidentialGuest *cg);
42 };
43 
44 /**
45  * x86_confidential_guest_kvm_type:
46  *
47  * Calls #X86ConfidentialGuestClass.unplug callback of @plug_handler.
48  */
49 static inline int x86_confidential_guest_kvm_type(X86ConfidentialGuest *cg)
50 {
51     X86ConfidentialGuestClass *klass = X86_CONFIDENTIAL_GUEST_GET_CLASS(cg);
52 
53     if (klass->kvm_type) {
54         return klass->kvm_type(cg);
55     } else {
56         return 0;
57     }
58 }
59 #endif
60