x86/CET: Fix build following c/s 43b98e7190
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 30 May 2020 00:41:26 +0000 (01:41 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 30 May 2020 00:56:01 +0000 (01:56 +0100)
OSSTest reports:

  x86_64.S: Assembler messages:
  x86_64.S:57: Error: no such instruction: `setssbsy'
  /home/osstest/build.150510.build-amd64/xen/xen/Rules.mk:183: recipe for target 'head.o' failed
  make[4]: Leaving directory '/home/osstest/build.150510.build-amd64/xen/xen/arch/x86/boot'
  make[4]: *** [head.o] Error 1

All use of CET instructions, even those inside alternative blocks, needs to be
behind CONFIG_XEN_SHSTK, as it indicates suitable toolchain support.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/boot/x86_64.S
xen/arch/x86/setup.c
xen/arch/x86/x86_64/compat/entry.S
xen/arch/x86/x86_64/entry.S

index 551acd9e9447f56ceb0285c1a3ca7c354acf9de4..d61048c583b3326de11cf22dbb13449d1e2068e0 100644 (file)
@@ -31,7 +31,7 @@ ENTRY(__high_start)
         jz      .L_bsp
 
         /* APs.  Set up shadow stacks before entering C. */
-
+#ifdef CONFIG_XEN_SHSTK
         testl   $cpufeat_mask(X86_FEATURE_XEN_SHSTK), \
                 CPUINFO_FEATURE_OFFSET(X86_FEATURE_XEN_SHSTK) + boot_cpu_data(%rip)
         je      .L_ap_shstk_done
@@ -55,6 +55,7 @@ ENTRY(__high_start)
         mov     $XEN_MINIMAL_CR4 | X86_CR4_CET, %ecx
         mov     %rcx, %cr4
         setssbsy
+#endif
 
 .L_ap_shstk_done:
         call    start_secondary
index 665274674dc302da1bd39168f2d91bfdf8e8f4a8..2aa1cd50b8540d8528b343c6e5e1e5a159f4577a 100644 (file)
@@ -664,7 +664,7 @@ static void __init noreturn reinit_bsp_stack(void)
     stack_base[0] = stack;
     memguard_guard_stack(stack);
 
-    if ( cpu_has_xen_shstk )
+    if ( IS_ENABLED(CONFIG_XEN_SHSTK) && cpu_has_xen_shstk )
     {
         wrmsrl(MSR_PL0_SSP,
                (unsigned long)stack + (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8);
index 2ca81341a4d25bf530ace33884f73121b3873bf6..c3e62f87342794130520b391fb657f910b43bf58 100644 (file)
@@ -198,7 +198,9 @@ ENTRY(cr4_pv32_restore)
 
 /* See lstar_enter for entry register state. */
 ENTRY(cstar_enter)
+#ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
+#endif
         /* sti could live here when we don't switch page tables below. */
         CR4_PV32_RESTORE
         movq  8(%rsp),%rax /* Restore %rax. */
index 6470266d2fb7160ef404e33c3bd4d2d7d2ee1c71..8b57a0004096b1a8a767d10de005c4888c3638c8 100644 (file)
@@ -193,12 +193,14 @@ restore_all_guest:
         cmpl  $1,%ecx
         ja    .Lrestore_rcx_iret_exit_to_guest
 
+#ifdef CONFIG_XEN_SHSTK
         /* Clear the supervisor shadow stack token busy bit. */
 .macro rag_clrssbsy
         rdsspq %rcx
         clrssbsy (%rcx)
 .endm
         ALTERNATIVE "", rag_clrssbsy, X86_FEATURE_XEN_SHSTK
+#endif
 
         movq  8(%rsp), %rcx           # RIP
         cmpw  $FLAT_USER_CS32,16(%rsp)# CS
@@ -235,7 +237,9 @@ iret_exit_to_guest:
  * %ss must be saved into the space left by the trampoline.
  */
 ENTRY(lstar_enter)
+#ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
+#endif
         /* sti could live here when we don't switch page tables below. */
         movq  8(%rsp),%rax /* Restore %rax. */
         movq  $FLAT_KERNEL_SS,8(%rsp)
@@ -269,7 +273,9 @@ ENTRY(lstar_enter)
         jmp   test_all_events
 
 ENTRY(sysenter_entry)
+#ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
+#endif
         /* sti could live here when we don't switch page tables below. */
         pushq $FLAT_USER_SS
         pushq $0
@@ -889,6 +895,7 @@ handle_ist_exception:
         movq  %rdi,%rsp
         rep   movsq
 
+#ifdef CONFIG_XEN_SHSTK
         /* Switch Shadow Stacks */
 .macro ist_switch_shstk
         rdsspq %rdi
@@ -909,6 +916,7 @@ handle_ist_exception:
         setssbsy
 .endm
         ALTERNATIVE "", ist_switch_shstk, X86_FEATURE_XEN_SHSTK
+#endif
 1:
 #else
         ASSERT_CONTEXT_IS_XEN