hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/arch/x86/include/asm/segment.h
....@@ -31,6 +31,18 @@
3131 */
3232 #define SEGMENT_RPL_MASK 0x3
3333
34
+/*
35
+ * When running on Xen PV, the actual privilege level of the kernel is 1,
36
+ * not 0. Testing the Requested Privilege Level in a segment selector to
37
+ * determine whether the context is user mode or kernel mode with
38
+ * SEGMENT_RPL_MASK is wrong because the PV kernel's privilege level
39
+ * matches the 0x3 mask.
40
+ *
41
+ * Testing with USER_SEGMENT_RPL_MASK is valid for both native and Xen PV
42
+ * kernels because privilege level 2 is never used.
43
+ */
44
+#define USER_SEGMENT_RPL_MASK 0x2
45
+
3446 /* User mode is privilege level 3: */
3547 #define USER_RPL 0x3
3648
....@@ -210,15 +222,11 @@
210222
211223 #endif
212224
213
-#ifndef CONFIG_PARAVIRT
214
-# define get_kernel_rpl() 0
215
-#endif
216
-
217225 #define IDT_ENTRIES 256
218226 #define NUM_EXCEPTION_VECTORS 32
219227
220228 /* Bitmask of exception vectors which push an error code on the stack: */
221
-#define EXCEPTION_ERRCODE_MASK 0x00027d00
229
+#define EXCEPTION_ERRCODE_MASK 0x20027d00
222230
223231 #define GDT_SIZE (GDT_ENTRIES*8)
224232 #define GDT_ENTRY_TLS_ENTRIES 3
....@@ -289,7 +297,7 @@
289297 extern const char early_idt_handler_array[NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE];
290298 extern void early_ignore_irq(void);
291299
292
-#if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
300
+#ifdef CONFIG_XEN_PV
293301 extern const char xen_early_idt_handler_array[NUM_EXCEPTION_VECTORS][XEN_EARLY_IDT_HANDLER_SIZE];
294302 #endif
295303