So clang 13 miscompiles dev/usb/umass_scsi.c with the combination if -Oz
authorkettenis <kettenis@openbsd.org>
Sun, 9 Apr 2023 19:48:37 +0000 (19:48 +0000)
committerkettenis <kettenis@openbsd.org>
Sun, 9 Apr 2023 19:48:37 +0000 (19:48 +0000)
and -mbranch-protection=bti.  So turn off the BTI protection in ramdisk
kernels for now.

ok deraadt@, miod@, phessler@

sys/arch/arm64/arm64/pmap.c
sys/arch/arm64/conf/Makefile.arm64

index edda6e8..beb0bd7 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.93 2023/03/27 19:02:47 kettenis Exp $ */
+/* $OpenBSD: pmap.c,v 1.94 2023/04/09 19:48:37 kettenis Exp $ */
 /*
  * Copyright (c) 2008-2009,2014-2016 Dale Rahn <drahn@dalerahn.com>
  *
@@ -1688,8 +1688,10 @@ pmap_pte_update(struct pte_desc *pted, uint64_t *pl3)
        else
                access_bits = ap_bits_user[pted->pted_pte & PROT_MASK];
 
+#ifndef SMALL_KERNEL
        if (pm == pmap_kernel())
                access_bits |= ATTR_GP;
+#endif
 
        pte = (pted->pted_pte & PTE_RPGN) | attr | access_bits | L3_P;
        *pl3 = access_bits ? pte : 0;
index 6bd73a6..1719e3d 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile.arm64,v 1.45 2023/03/27 19:02:47 kettenis Exp $
+#      $OpenBSD: Makefile.arm64,v 1.46 2023/04/09 19:48:37 kettenis Exp $
 
 # For instructions on building kernels consult the config(8) and options(4)
 # manual pages.
@@ -61,7 +61,7 @@ CWARNFLAGS+=  -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 
 CMACHFLAGS=    -march=armv8-a+nofp+nosimd \
                -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
-               -ffixed-x18 -mbranch-protection=bti
+               -ffixed-x18
 CMACHFLAGS+=   -ffreestanding ${NOPIE_FLAGS}
 SORTR=         sort -R
 .if ${IDENT:M-DNO_PROPOLICE}
@@ -70,6 +70,9 @@ CMACHFLAGS+=  -fno-stack-protector
 .if ${IDENT:M-DSMALL_KERNEL}
 SORTR=         cat
 COPTIMIZE?=    -Oz
+CMACHFLAGS+=   -mbranch-protection=none
+.else
+CMACHFLAGS+=   -mbranch-protection=bti
 .endif
 
 DEBUG?=                -g