Skip to content

Commit f6f5204

Browse files
committed
Merge tag 'x86_urgent_for_v6.1_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Add new Intel CPU models - Enforce that TDX guests are successfully loaded only on TDX hardware where virtualization exception (#VE) delivery on kernel memory is disabled because handling those in all possible cases is "essentially impossible" - Add the proper include to the syscall wrappers so that BTF can see the real pt_regs definition and not only the forward declaration * tag 'x86_urgent_for_v6.1_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu: Add several Intel server CPU model numbers x86/tdx: Panic on bad configs that #VE on "private" memory access x86/tdx: Prepare for using "INFO" call for a second purpose x86/syscall: Include asm/ptrace.h in syscall_wrapper header
2 parents 35697d8 + 7beade0 commit f6f5204

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

arch/x86/coco/tdx/tdx.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define VE_GET_PORT_NUM(e) ((e) >> 16)
3535
#define VE_IS_IO_STRING(e) ((e) & BIT(4))
3636

37+
#define ATTR_SEPT_VE_DISABLE BIT(28)
38+
3739
/*
3840
* Wrapper for standard use of __tdx_hypercall with no output aside from
3941
* return code.
@@ -98,30 +100,39 @@ static inline void tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
98100
panic("TDCALL %lld failed (Buggy TDX module!)\n", fn);
99101
}
100102

101-
static u64 get_cc_mask(void)
103+
static void tdx_parse_tdinfo(u64 *cc_mask)
102104
{
103105
struct tdx_module_output out;
104106
unsigned int gpa_width;
107+
u64 td_attr;
105108

106109
/*
107110
* TDINFO TDX module call is used to get the TD execution environment
108111
* information like GPA width, number of available vcpus, debug mode
109112
* information, etc. More details about the ABI can be found in TDX
110113
* Guest-Host-Communication Interface (GHCI), section 2.4.2 TDCALL
111114
* [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.
112121
*
113122
* The GPA width that comes out of this call is critical. TDX guests
114123
* can not meaningfully run without it.
115124
*/
116-
tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out);
117-
118125
gpa_width = out.rcx & GENMASK(5, 0);
126+
*cc_mask = BIT_ULL(gpa_width - 1);
119127

120128
/*
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.
123132
*/
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");
125136
}
126137

127138
/*
@@ -758,7 +769,7 @@ void __init tdx_early_init(void)
758769
setup_force_cpu_cap(X86_FEATURE_TDX_GUEST);
759770

760771
cc_set_vendor(CC_VENDOR_INTEL);
761-
cc_mask = get_cc_mask();
772+
tdx_parse_tdinfo(&cc_mask);
762773
cc_set_mask(cc_mask);
763774

764775
/*

arch/x86/include/asm/intel-family.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107

108108
#define INTEL_FAM6_SAPPHIRERAPIDS_X 0x8F /* Golden Cove */
109109

110+
#define INTEL_FAM6_EMERALDRAPIDS_X 0xCF
111+
112+
#define INTEL_FAM6_GRANITERAPIDS_X 0xAD
113+
#define INTEL_FAM6_GRANITERAPIDS_D 0xAE
114+
110115
#define INTEL_FAM6_ALDERLAKE 0x97 /* Golden Cove / Gracemont */
111116
#define INTEL_FAM6_ALDERLAKE_L 0x9A /* Golden Cove / Gracemont */
112117
#define INTEL_FAM6_ALDERLAKE_N 0xBE
@@ -118,7 +123,7 @@
118123
#define INTEL_FAM6_METEORLAKE 0xAC
119124
#define INTEL_FAM6_METEORLAKE_L 0xAA
120125

121-
/* "Small Core" Processors (Atom) */
126+
/* "Small Core" Processors (Atom/E-Core) */
122127

123128
#define INTEL_FAM6_ATOM_BONNELL 0x1C /* Diamondville, Pineview */
124129
#define INTEL_FAM6_ATOM_BONNELL_MID 0x26 /* Silverthorne, Lincroft */
@@ -145,6 +150,10 @@
145150
#define INTEL_FAM6_ATOM_TREMONT 0x96 /* Elkhart Lake */
146151
#define INTEL_FAM6_ATOM_TREMONT_L 0x9C /* Jasper Lake */
147152

153+
#define INTEL_FAM6_SIERRAFOREST_X 0xAF
154+
155+
#define INTEL_FAM6_GRANDRIDGE 0xB6
156+
148157
/* Xeon Phi */
149158

150159
#define INTEL_FAM6_XEON_PHI_KNL 0x57 /* Knights Landing */

arch/x86/include/asm/syscall_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef _ASM_X86_SYSCALL_WRAPPER_H
77
#define _ASM_X86_SYSCALL_WRAPPER_H
88

9-
struct pt_regs;
9+
#include <asm/ptrace.h>
1010

1111
extern long __x64_sys_ni_syscall(const struct pt_regs *regs);
1212
extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);

0 commit comments

Comments
 (0)