xref: /openbmc/qemu/backends/confidential-guest-support.c (revision 596c330b19cf00384ec14d0bff25758ed204b49d)
1 /*
2  * QEMU Confidential Guest support
3  *
4  * Copyright Red Hat.
5  *
6  * Authors:
7  *  David Gibson <david@gibson.dropbear.id.au>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or
10  * later.  See the COPYING file in the top-level directory.
11  *
12  */
13 
14 #include "qemu/osdep.h"
15 
16 #include "system/confidential-guest-support.h"
17 #include "qapi/error.h"
18 
19 OBJECT_DEFINE_ABSTRACT_TYPE(ConfidentialGuestSupport,
20                             confidential_guest_support,
21                             CONFIDENTIAL_GUEST_SUPPORT,
22                             OBJECT)
23 
24 static bool check_support(ConfidentialGuestPlatformType platform,
25                          uint16_t platform_version, uint8_t highest_vtl,
26                          uint64_t shared_gpa_boundary)
27 {
28     /* Default: no support. */
29     return false;
30 }
31 
32 static int set_guest_state(hwaddr gpa, uint8_t *ptr, uint64_t len,
33                            ConfidentialGuestPageType memory_type,
34                            uint16_t cpu_index, Error **errp)
35 {
36     error_setg(errp,
37                "Setting confidential guest state is not supported for this platform");
38     return -1;
39 }
40 
41 static int get_mem_map_entry(int index, ConfidentialGuestMemoryMapEntry *entry,
42                              Error **errp)
43 {
44     error_setg(
45         errp,
46         "Obtaining the confidential guest memory map is not supported for this platform");
47     return -1;
48 }
49 
50 static void confidential_guest_support_class_init(ObjectClass *oc,
51                                                   const void *data)
52 {
53     ConfidentialGuestSupportClass *cgsc = CONFIDENTIAL_GUEST_SUPPORT_CLASS(oc);
54     cgsc->check_support = check_support;
55     cgsc->set_guest_state = set_guest_state;
56     cgsc->get_mem_map_entry = get_mem_map_entry;
57 }
58 
59 static void confidential_guest_support_init(Object *obj)
60 {
61 }
62 
63 static void confidential_guest_support_finalize(Object *obj)
64 {
65 }
66