Patch "x86/paravirt: add extra clobbers with ZERO_CALL_USED_REGS enabled" has been added to the 6.0-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    x86/paravirt: add extra clobbers with ZERO_CALL_USED_REGS enabled

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-paravirt-add-extra-clobbers-with-zero_call_used_.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fd0fc221ded82c1b2b8cc32bd577d681e01c5fec
Author: Bill Wendling <morbo@xxxxxxxxxx>
Date:   Fri Sep 2 21:37:50 2022 +0000

    x86/paravirt: add extra clobbers with ZERO_CALL_USED_REGS enabled
    
    [ Upstream commit 8c86f29bfb18465d15b05cfd26a6454ec787b793 ]
    
    The ZERO_CALL_USED_REGS feature may zero out caller-saved registers
    before returning.
    
    In spurious_kernel_fault(), the "pte_offset_kernel()" call results in
    this assembly code:
    
    .Ltmp151:
            #APP
            # ALT: oldnstr
    .Ltmp152:
    .Ltmp153:
    .Ltmp154:
            .section        .discard.retpoline_safe,"",@progbits
            .quad   .Ltmp154
            .text
    
            callq   *pv_ops+536(%rip)
    
    .Ltmp155:
            .section        .parainstructions,"a",@progbits
            .p2align        3, 0x0
            .quad   .Ltmp153
            .byte   67
            .byte   .Ltmp155-.Ltmp153
            .short  1
            .text
    .Ltmp156:
            # ALT: padding
            .zero   (-(((.Ltmp157-.Ltmp158)-(.Ltmp156-.Ltmp152))>0))*((.Ltmp157-.Ltmp158)-(.Ltmp156-.Ltmp152)),144
    .Ltmp159:
            .section        .altinstructions,"a",@progbits
    .Ltmp160:
            .long   .Ltmp152-.Ltmp160
    .Ltmp161:
            .long   .Ltmp158-.Ltmp161
            .short  33040
            .byte   .Ltmp159-.Ltmp152
            .byte   .Ltmp157-.Ltmp158
            .text
    
            .section        .altinstr_replacement,"ax",@progbits
            # ALT: replacement 1
    .Ltmp158:
            movq    %rdi, %rax
    .Ltmp157:
            .text
            #NO_APP
    .Ltmp162:
            testb   $-128, %dil
    
    The "testb" here is using %dil, but the %rdi register was cleared before
    returning from "callq *pv_ops+536(%rip)". Adding the proper constraints
    results in the use of a different register:
    
            movq    %r11, %rdi
    
            # Similar to above.
    
            testb   $-128, %r11b
    
    Link: https://github.com/KSPP/linux/issues/192
    Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
    Reported-and-tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Fixes: 035f7f87b729 ("randstruct: Enable Clang support")
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
    Link: https://lore.kernel.org/lkml/fa6df43b-8a1a-8ad1-0236-94d2a0b588fa@xxxxxxxx/
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220902213750.1124421-3-morbo@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 89df6c6617f5..bc2e1b67319d 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -414,8 +414,17 @@ int paravirt_disable_iospace(void);
 				"=c" (__ecx)
 #define PVOP_CALL_CLOBBERS	PVOP_VCALL_CLOBBERS, "=a" (__eax)
 
-/* void functions are still allowed [re]ax for scratch */
+/*
+ * void functions are still allowed [re]ax for scratch.
+ *
+ * The ZERO_CALL_USED REGS feature may end up zeroing out callee-saved
+ * registers. Make sure we model this with the appropriate clobbers.
+ */
+#ifdef CONFIG_ZERO_CALL_USED_REGS
+#define PVOP_VCALLEE_CLOBBERS	"=a" (__eax), PVOP_VCALL_CLOBBERS
+#else
 #define PVOP_VCALLEE_CLOBBERS	"=a" (__eax)
+#endif
 #define PVOP_CALLEE_CLOBBERS	PVOP_VCALLEE_CLOBBERS
 
 #define EXTRA_CLOBBERS	 , "r8", "r9", "r10", "r11"



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux