From 38863611753ab7fd8d696f9c5baf253ebd0014c2 Mon Sep 17 00:00:00 2001 From: guenther Date: Sat, 21 Jul 2018 02:19:54 +0000 Subject: [PATCH] Remove the "got meltdown?" conditional from INTRENTRY by doing it 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 | 6 ++---- sys/arch/amd64/include/frameasm.h | 10 ++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index e06547f9b92..1f4be77736c 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -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 diff --git a/sys/arch/amd64/include/frameasm.h b/sys/arch/amd64/include/frameasm.h index 05a9ecb8b2a..33ab8b4b347 100644 --- a/sys/arch/amd64/include/frameasm.h +++ b/sys/arch/amd64/include/frameasm.h @@ -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 @@ -60,20 +60,22 @@ /* 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 ; \ -- 2.20.1