|
34 | 34 | #define VE_GET_PORT_NUM(e) ((e) >> 16)
|
35 | 35 | #define VE_IS_IO_STRING(e) ((e) & BIT(4))
|
36 | 36 |
|
| 37 | +#define ATTR_SEPT_VE_DISABLE BIT(28) |
| 38 | + |
37 | 39 | /*
|
38 | 40 | * Wrapper for standard use of __tdx_hypercall with no output aside from
|
39 | 41 | * return code.
|
@@ -102,26 +104,35 @@ static void tdx_parse_tdinfo(u64 *cc_mask)
|
102 | 104 | {
|
103 | 105 | struct tdx_module_output out;
|
104 | 106 | unsigned int gpa_width;
|
| 107 | + u64 td_attr; |
105 | 108 |
|
106 | 109 | /*
|
107 | 110 | * TDINFO TDX module call is used to get the TD execution environment
|
108 | 111 | * information like GPA width, number of available vcpus, debug mode
|
109 | 112 | * information, etc. More details about the ABI can be found in TDX
|
110 | 113 | * Guest-Host-Communication Interface (GHCI), section 2.4.2 TDCALL
|
111 | 114 | * [TDG.VP.INFO].
|
112 |
| - * |
113 |
| - * The GPA width that comes out of this call is critical. TDX guests |
114 |
| - * can not meaningfully run without it. |
115 | 115 | */
|
116 | 116 | tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out);
|
117 | 117 |
|
118 |
| - gpa_width = out.rcx & GENMASK(5, 0); |
119 |
| - |
120 | 118 | /*
|
121 | 119 | * The highest bit of a guest physical address is the "sharing" bit.
|
122 | 120 | * Set it for shared pages and clear it for private pages.
|
| 121 | + * |
| 122 | + * The GPA width that comes out of this call is critical. TDX guests |
| 123 | + * can not meaningfully run without it. |
123 | 124 | */
|
| 125 | + gpa_width = out.rcx & GENMASK(5, 0); |
124 | 126 | *cc_mask = BIT_ULL(gpa_width - 1);
|
| 127 | + |
| 128 | + /* |
| 129 | + * The kernel can not handle #VE's when accessing normal kernel |
| 130 | + * memory. Ensure that no #VE will be delivered for accesses to |
| 131 | + * TD-private memory. Only VMM-shared memory (MMIO) will #VE. |
| 132 | + */ |
| 133 | + td_attr = out.rdx; |
| 134 | + if (!(td_attr & ATTR_SEPT_VE_DISABLE)) |
| 135 | + panic("TD misconfiguration: SEPT_VE_DISABLE attibute must be set.\n"); |
125 | 136 | }
|
126 | 137 |
|
127 | 138 | /*
|
|
0 commit comments