|
5 | 5 |
|
6 | 6 | #include <linux/init.h> |
7 | 7 | #include <linux/bits.h> |
| 8 | +#include <linux/mmzone.h> |
8 | 9 |
|
9 | 10 | #include <asm/errno.h> |
10 | 11 | #include <asm/ptrace.h> |
|
33 | 34 | #ifndef __ASSEMBLY__ |
34 | 35 |
|
35 | 36 | #include <uapi/asm/mce.h> |
| 37 | +#include <asm/tdx_global_metadata.h> |
| 38 | +#include <linux/pgtable.h> |
36 | 39 |
|
37 | 40 | /* |
38 | 41 | * Used by the #VE exception handler to gather the #VE exception |
@@ -119,11 +122,68 @@ static inline u64 sc_retry(sc_func_t func, u64 fn, |
119 | 122 | int tdx_cpu_enable(void); |
120 | 123 | int tdx_enable(void); |
121 | 124 | const char *tdx_dump_mce_info(struct mce *m); |
| 125 | +const struct tdx_sys_info *tdx_get_sysinfo(void); |
| 126 | + |
| 127 | +int tdx_guest_keyid_alloc(void); |
| 128 | +u32 tdx_get_nr_guest_keyids(void); |
| 129 | +void tdx_guest_keyid_free(unsigned int keyid); |
| 130 | + |
| 131 | +struct tdx_td { |
| 132 | + /* TD root structure: */ |
| 133 | + struct page *tdr_page; |
| 134 | + |
| 135 | + int tdcs_nr_pages; |
| 136 | + /* TD control structure: */ |
| 137 | + struct page **tdcs_pages; |
| 138 | + |
| 139 | + /* Size of `tdcx_pages` in struct tdx_vp */ |
| 140 | + int tdcx_nr_pages; |
| 141 | +}; |
| 142 | + |
| 143 | +struct tdx_vp { |
| 144 | + /* TDVP root page */ |
| 145 | + struct page *tdvpr_page; |
| 146 | + |
| 147 | + /* TD vCPU control structure: */ |
| 148 | + struct page **tdcx_pages; |
| 149 | +}; |
| 150 | + |
| 151 | + |
| 152 | +static inline u64 mk_keyed_paddr(u16 hkid, struct page *page) |
| 153 | +{ |
| 154 | + u64 ret; |
| 155 | + |
| 156 | + ret = page_to_phys(page); |
| 157 | + /* KeyID bits are just above the physical address bits: */ |
| 158 | + ret |= (u64)hkid << boot_cpu_data.x86_phys_bits; |
| 159 | + |
| 160 | + return ret; |
| 161 | + |
| 162 | +} |
| 163 | + |
| 164 | +u64 tdh_mng_addcx(struct tdx_td *td, struct page *tdcs_page); |
| 165 | +u64 tdh_vp_addcx(struct tdx_vp *vp, struct page *tdcx_page); |
| 166 | +u64 tdh_mng_key_config(struct tdx_td *td); |
| 167 | +u64 tdh_mng_create(struct tdx_td *td, u16 hkid); |
| 168 | +u64 tdh_vp_create(struct tdx_td *td, struct tdx_vp *vp); |
| 169 | +u64 tdh_mng_rd(struct tdx_td *td, u64 field, u64 *data); |
| 170 | +u64 tdh_vp_flush(struct tdx_vp *vp); |
| 171 | +u64 tdh_mng_vpflushdone(struct tdx_td *td); |
| 172 | +u64 tdh_mng_key_freeid(struct tdx_td *td); |
| 173 | +u64 tdh_mng_init(struct tdx_td *td, u64 td_params, u64 *extended_err); |
| 174 | +u64 tdh_vp_init(struct tdx_vp *vp, u64 initial_rcx, u32 x2apicid); |
| 175 | +u64 tdh_vp_rd(struct tdx_vp *vp, u64 field, u64 *data); |
| 176 | +u64 tdh_vp_wr(struct tdx_vp *vp, u64 field, u64 data, u64 mask); |
| 177 | +u64 tdh_phymem_page_reclaim(struct page *page, u64 *tdx_pt, u64 *tdx_owner, u64 *tdx_size); |
| 178 | +u64 tdh_phymem_cache_wb(bool resume); |
| 179 | +u64 tdh_phymem_page_wbinvd_tdr(struct tdx_td *td); |
122 | 180 | #else |
123 | 181 | static inline void tdx_init(void) { } |
124 | 182 | static inline int tdx_cpu_enable(void) { return -ENODEV; } |
125 | 183 | static inline int tdx_enable(void) { return -ENODEV; } |
| 184 | +static inline u32 tdx_get_nr_guest_keyids(void) { return 0; } |
126 | 185 | static inline const char *tdx_dump_mce_info(struct mce *m) { return NULL; } |
| 186 | +static inline const struct tdx_sys_info *tdx_get_sysinfo(void) { return NULL; } |
127 | 187 | #endif /* CONFIG_INTEL_TDX_HOST */ |
128 | 188 |
|
129 | 189 | #endif /* !__ASSEMBLY__ */ |
|
0 commit comments