[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/CET: Fix build following c/s 43b98e7190



commit b586a81b7a90d424b54275c79e759b0294aa2fb6
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Sat May 30 01:41:26 2020 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Sat May 30 01:56:01 2020 +0100

    x86/CET: Fix build following c/s 43b98e7190
    
    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@xxxxxxxxxx>
---
 xen/arch/x86/boot/x86_64.S         | 3 ++-
 xen/arch/x86/setup.c               | 2 +-
 xen/arch/x86/x86_64/compat/entry.S | 2 ++
 xen/arch/x86/x86_64/entry.S        | 8 ++++++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index 551acd9e94..d61048c583 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -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
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 665274674d..2aa1cd50b8 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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);
diff --git a/xen/arch/x86/x86_64/compat/entry.S 
b/xen/arch/x86/x86_64/compat/entry.S
index 2ca81341a4..c3e62f8734 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -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. */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 6470266d2f..8b57a00040 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -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
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.