A few manual ret-cleans. Seeing as these pertain to interrupt servicing,
authorderaadt <deraadt@openbsd.org>
Sun, 21 Jul 2024 16:19:25 +0000 (16:19 +0000)
committerderaadt <deraadt@openbsd.org>
Sun, 21 Jul 2024 16:19:25 +0000 (16:19 +0000)
the stack utilization ends up near the the deep end of the stack where,
retcleans are useful. tested for a while in snaps
ok bluhm

sys/arch/amd64/amd64/vector.S

index de24a29..c51f872 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vector.S,v 1.95 2024/02/12 01:18:17 guenther Exp $    */
+/*     $OpenBSD: vector.S,v 1.96 2024/07/21 16:19:25 deraadt Exp $     */
 /*     $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $  */
 
 /*
@@ -145,6 +145,7 @@ INTRENTRY_LABEL(calltrap_specstk):
        SMAP_CLAC
        movq    %rsp,%rdi
        call    kerntrap
+       movq    $0,-8(%rsp)
        movl    $MSR_GSBASE,%ecx        # restore GS.base
        movq    %r12,%rax
        movq    %r13,%rdx
@@ -157,6 +158,7 @@ INTRENTRY_LABEL(calltrap_specstk):
        wrmsr
        CODEPATCH_END(CPTAG_IBPB_NOP)
        call    pku_xonly
+       movq    $0,-8(%rsp)
        popq    %rdi
        popq    %rsi
        popq    %rdx
@@ -199,6 +201,7 @@ INTRENTRY_LABEL(trap03):
        leaq    dt_prov_kprobe, %rdi
        movq    %rsp, %rsi
        call    dt_prov_kprobe_hook
+       movq    $0,-8(%rsp)
        cmpl    $0, %eax
        je     .Lreal_kern_trap
 
@@ -451,6 +454,7 @@ GENTRY(alltraps)
 recall_trap:
        movq    %rsp, %rdi
        call    usertrap
+       movq    $0,-8(%rsp)
        cli
        jmp     intr_user_exit
 END(alltraps)
@@ -476,6 +480,7 @@ GENTRY(alltraps_kern_meltdown)
 #endif /* DIAGNOSTIC */
        movq    %rsp, %rdi
        call    kerntrap
+       movq    $0,-8(%rsp)
 2:     cli
 #ifndef DIAGNOSTIC
        INTRFASTEXIT
@@ -489,6 +494,7 @@ GENTRY(alltraps_kern_meltdown)
        movl    %ebx,%edx
        xorq    %rax,%rax
        call    printf
+       movq    $0,-8(%rsp)
 #ifdef DDB
        int     $3
 #endif /* DDB */
@@ -567,6 +573,7 @@ KIDTVEC_FALLTHROUGH(resume_lapic_ipi)
        SMAP_CLAC
        movq    %rbx,IF_PPL(%rsp)
        call    x86_ipi_handler
+       movq    $0,-8(%rsp)
        jmp     Xdoreti
 2:
        movq    $(1 << LIR_IPI),%rax
@@ -775,6 +782,7 @@ KIDTVEC_FALLTHROUGH(resume_lapic_ltimer)
        movq    %rbx,IF_PPL(%rsp)
        xorq    %rdi,%rdi
        call    lapic_clockintr
+       movq    $0,-8(%rsp)
        jmp     Xdoreti
 2:
        movq    $(1 << LIR_TIMER),%rax
@@ -794,6 +802,7 @@ END(Xrecurse_xen_upcall)
 IDTVEC(intr_xen_upcall)
        INTRENTRY(intr_xen_upcall)
        call    xen_intr_ack
+       movq    $0,-8(%rsp)
        movl    CPUVAR(ILEVEL),%ebx
        cmpl    $IPL_NET,%ebx
        jae     2f
@@ -808,6 +817,7 @@ KIDTVEC_FALLTHROUGH(resume_xen_upcall)
        SMAP_CLAC
        movq    %rbx,IF_PPL(%rsp)
        call    xen_intr
+       movq    $0,-8(%rsp)
        jmp     Xdoreti
 2:
        movq    $(1 << LIR_XEN),%rax
@@ -841,6 +851,7 @@ KIDTVEC_FALLTHROUGH(resume_hyperv_upcall)
        SMAP_CLAC
        movq    %rbx,IF_PPL(%rsp)
        call    hv_intr
+       movq    $0,-8(%rsp)
        jmp     Xdoreti
 2:
        movq    $(1 << LIR_HYPERV),%rax
@@ -898,6 +909,7 @@ IDTVEC(intr_##name##num)                                            ;\
        movq    %rbx, %rsi                                              ;\
        movq    %rsp, %rdi                                              ;\
        call    intr_handler            /* call it */                   ;\
+       movq    $0,-8(%rsp)                                             ;\
        orl     %eax,%eax               /* should it be counted? */     ;\
        jz      4f                      /* no, skip it */               ;\
        incq    IH_COUNT(%rbx)          /* count the intrs */           ;\
@@ -1288,6 +1300,7 @@ KIDTVEC(softtty)
        incl    CPUVAR(IDEPTH)
        movl    $X86_SOFTINTR_SOFTTTY,%edi
        call    softintr_dispatch
+       movq    $0,-8(%rsp)
        decl    CPUVAR(IDEPTH)
        CODEPATCH_START
        jmp     retpoline_r13
@@ -1301,6 +1314,7 @@ KIDTVEC(softnet)
        incl    CPUVAR(IDEPTH)
        movl    $X86_SOFTINTR_SOFTNET,%edi
        call    softintr_dispatch
+       movq    $0,-8(%rsp)
        decl    CPUVAR(IDEPTH)
        CODEPATCH_START
        jmp     retpoline_r13
@@ -1314,6 +1328,7 @@ KIDTVEC(softclock)
        incl    CPUVAR(IDEPTH)
        movl    $X86_SOFTINTR_SOFTCLOCK,%edi
        call    softintr_dispatch
+       movq    $0,-8(%rsp)
        decl    CPUVAR(IDEPTH)
        CODEPATCH_START
        jmp     retpoline_r13