Remove the "got meltdown?" conditional from INTRENTRY by doing it
authorguenther <guenther@openbsd.org>
Sat, 21 Jul 2018 02:19:54 +0000 (02:19 +0000)
committerguenther <guenther@openbsd.org>
Sat, 21 Jul 2018 02:19:54 +0000 (02:19 +0000)
 unconditionally and codepatching it out on CPUs that don't need/do
 the mitigation.
Align the from-{kernel,userspace} targets in INTRENTRY with _ALIGN_TRAPS
Align x2apic_eoi using KUENTRY() instead of the artisinal
 segment+label+.globl bits it uses currently
s/testq/testb/ for SEL_RPL checks

ok kettenis@ mlarkin@

sys/arch/amd64/amd64/vector.S
sys/arch/amd64/include/frameasm.h

index e06547f..1f4be77 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vector.S,v 1.73 2018/07/12 14:24:54 guenther Exp $    */
+/*     $OpenBSD: vector.S,v 1.74 2018/07/21 02:19:54 guenther Exp $    */
 /*     $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $  */
 
 /*
@@ -472,9 +472,7 @@ KTEXT_PAGE_END
 /* XXX See comment in locore.s */
 #define        XINTR(name,num)         Xintr_##name##num
 
-       KUTEXT
-       .globl _C_LABEL(x2apic_eoi)
-_C_LABEL(x2apic_eoi):
+KUENTRY(x2apic_eoi)
        pushq   %rax
        pushq   %rcx
        pushq   %rdx
index 05a9ecb..33ab8b4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: frameasm.h,v 1.18 2018/07/10 08:57:44 guenther Exp $  */
+/*     $OpenBSD: frameasm.h,v 1.19 2018/07/21 02:19:54 guenther Exp $  */
 /*     $NetBSD: frameasm.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $        */
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 /* For real interrupt code paths, where we can come from userspace */
 #define INTRENTRY_LABEL(label) X##label##_untramp
 #define        INTRENTRY(label) \
-       testq   $SEL_RPL,24(%rsp)       ; \
+       testb   $SEL_RPL,24(%rsp)       ; \
        je      INTRENTRY_LABEL(label)  ; \
        swapgs                          ; \
        movq    %rax,CPUVAR(SCRATCH)    ; \
+       CODEPATCH_START                 ; \
        movq    CPUVAR(KERN_CR3),%rax   ; \
-       testq   %rax,%rax               ; \
-       jz      98f                     ; \
        movq    %rax,%cr3               ; \
+       CODEPATCH_END(CPTAG_MELTDOWN_NOP);\
        jmp     98f                     ; \
        .text                           ; \
+       _ALIGN_TRAPS                    ; \
        .global INTRENTRY_LABEL(label)  ; \
 INTRENTRY_LABEL(label):        /* from kernel */ \
        INTR_ENTRY_KERN                 ; \
        jmp     99f                     ; \
+       _ALIGN_TRAPS                    ; \
 98:    /* from userspace */              \
        INTR_ENTRY_USER                 ; \
 99:    INTR_SAVE_MOST_GPRS_NO_ADJ      ; \