|
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.
|
@@ -98,30 +100,39 @@ static inline void tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
|
98 | 100 | panic("TDCALL %lld failed (Buggy TDX module!)\n", fn);
|
99 | 101 | }
|
100 | 102 |
|
101 |
| -static u64 get_cc_mask(void) |
| 103 | +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].
|
| 115 | + */ |
| 116 | + tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out); |
| 117 | + |
| 118 | + /* |
| 119 | + * The highest bit of a guest physical address is the "sharing" bit. |
| 120 | + * Set it for shared pages and clear it for private pages. |
112 | 121 | *
|
113 | 122 | * The GPA width that comes out of this call is critical. TDX guests
|
114 | 123 | * can not meaningfully run without it.
|
115 | 124 | */
|
116 |
| - tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out); |
117 |
| - |
118 | 125 | gpa_width = out.rcx & GENMASK(5, 0);
|
| 126 | + *cc_mask = BIT_ULL(gpa_width - 1); |
119 | 127 |
|
120 | 128 | /*
|
121 |
| - * The highest bit of a guest physical address is the "sharing" bit. |
122 |
| - * Set it for shared pages and clear it for private pages. |
| 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. |
123 | 132 | */
|
124 |
| - return BIT_ULL(gpa_width - 1); |
| 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 | /*
|
@@ -758,7 +769,7 @@ void __init tdx_early_init(void)
|
758 | 769 | setup_force_cpu_cap(X86_FEATURE_TDX_GUEST);
|
759 | 770 |
|
760 | 771 | cc_set_vendor(CC_VENDOR_INTEL);
|
761 |
| - cc_mask = get_cc_mask(); |
| 772 | + tdx_parse_tdinfo(&cc_mask); |
762 | 773 | cc_set_mask(cc_mask);
|
763 | 774 |
|
764 | 775 | /*
|
|
0 commit comments