CVS: cvs.openbsd.org: src

2024-07-01 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/07/01 23:50:02

Modified files:
sys/dev/hid: hidkbd.c 

Log message:
Support numpad on newer macppc Apple PowerBooks

This is for newer PowerBooks with ukbd(4), and doesn't affect older
models with akbd(4).  The Fn key now makes a numpad,

7  8  9  0  -  7  8  9  /  =
U  I  O  P  => 4  5  6  *
J  K  L  ; 1  2  3  -
M  .  /0  .  +

Also, Fn+F6 is Num Lock.  This acts like Num Lock on other USB
keyboards, and unlike Num Lock on akbd(4).

>From jon (at) elytron (dot) openbsd (dot) amsterdam



CVS: cvs.openbsd.org: src

2024-04-03 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/04/03 13:30:59

Modified files:
sys/arch/powerpc/include: mplock.h 
sys/arch/powerpc/powerpc: lock_machdep.c pmap.c 
sys/arch/powerpc64/powerpc64: pmap.c 

Log message:
Initialize earlier macppc's and powerpc64's pmap_hash_lock

At boot, the powerpc64 kernel was calling
pmap_bootstrap -> pmap_kenter_pa -> mtx_enter(_hash_lock)
before it did
pmap_init -> mtx_init(_hash_lock, IPL_HIGH)

Change from mtx_init to MUTEX_INITIALIZER.  This allows an option
WITNESS kernel to boot without warning of an uninitialized mutex.

Also change macppc's pmap_hash_lock from __ppc_lock_init to
PPC_LOCK_INITIALIZER, though WITNESS doesn't see this lock.

ok mpi@



CVS: cvs.openbsd.org: src

2024-04-03 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/04/03 12:32:47

Modified files:
sys/dev: ipmi.c 

Log message:
Change ipmi(4)'s taskq from IPL_NONE to IPL_MPFLOOR

The IPL_NONE mutex didn't block interrupts that can cause a powerpc64
kernel with option WITNESS to "panic: acquiring blockable sleep lock
with spinlock or critical section held (kernel_lock) _lock".

ok mpi@



CVS: cvs.openbsd.org: src

2024-03-02 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/03/02 20:09:39

Modified files:
gnu/llvm/llvm/lib/Target/PowerPC: PPCFrameLowering.cpp 

Log message:
For macppc, add missing CFI for cr2, cr3, cr4

clang -S was missing a line like ".cfi_offset cr2, -16" in functions
that spill cr2 (or cr3, cr4) to the stack.  This was breaking a few
C++ exceptions.  This fix adds the missing CFI.

This will fix the C++ exception that was crashing egdb from
ports/devel/gdb when you did "q to quit" in the pager.

ok kettenis@ tobhe@



CVS: cvs.openbsd.org: src

2024-03-02 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/03/02 19:40:10

Modified files:
sys/arch/macppc/dev: awacs.c 

Log message:
Fix awacs(4) audio on some iMac G3 models

This code affects iMac G3s with a slot-loading CD drive (from late
1999 to 2001, after the older tray-loading iMac G3s, and before the
iMac G4s).  Detect such iMacs by their model string (PowerMac2,1 or
PowerMac2,2 or PowerMac4,1), and configure their headphones and
internal speakers in a different way.  These iMacs have 3 places to
connect headphones (2 on front, 1 on right side).  They also have no
audio connection to the CD drive, so turn off the noisy CD input.

>From evan (dot) jss (at) protonmail (dot) ch; I edited the code to get
the model string.



CVS: cvs.openbsd.org: src

2024-02-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2024/02/10 20:57:10

Modified files:
usr.bin/pkg-config/OpenBSD: PkgConfig.pm 

Log message:
In pkg-config, accept both "CFlags:" and "Cflags:"

matthieu@ noticed that "pkg-config libpkgconf --cflags" failed because
libpkgconf.pc has "CFlags:" with upper-case 'F', but we accepted only
"Cflags:" with lower-case 'f'.  freedesktop.org's pkg-config accepts
both "C[Ff]lags", but is otherwise sensitive to case.

Accept "CFlags" by mapping it to "Cflags" when reading the file.  Fail
if the file has more than one "C[Ff]lags".

ok millert@ matthieu@



CVS: cvs.openbsd.org: src

2023-11-18 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/11/18 18:14:07

Modified files:
gnu/llvm/llvm/lib/Target/PowerPC: PPCISelDAGToDAG.cpp 

Log message:
Fix cc -ftrapping-math on macppc

Handle CALL_RM like CALL for 32-bit ELF.  If a function call has the
strictfp attribute, its opcode changes from CALL to CALL_RM.  If a
call uses the secure PLT, then it must getGlobalBaseReg() to set r30.

After I rebuilt xenocara/lib/pixman with this change, Xorg stopped
crashing on my macppc.  pixman uses cc -ftrapping-math which puts
strictfp on each function call.

https://github.com/llvm/llvm-project/pull/72758

ok jca@ tobhe@ deraadt@



CVS: cvs.openbsd.org: src

2023-11-14 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/11/14 14:31:01

Modified files:
etc/etc.powerpc64: login.conf 

Log message:
Bump powerpc64 default datasize to 1536M

This is for llvm 16; powerpc64 (like some other platforms) needs a
higher datasize limit to build base-clang 16.

ok jca@



CVS: cvs.openbsd.org: src

2023-11-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/11/10 19:52:55

Modified files:
regress/usr.bin/gzip: Makefile 
usr.bin/compress: main.c 

Log message:
Ignore -N in "gzip -dN 

CVS: cvs.openbsd.org: src

2023-08-18 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/08/18 18:47:51

Modified files:
sys/arch/powerpc64/powerpc64: cpu.c 

Log message:
Check for powerpc64 cores that fail to start

If the core failed to start (because opal_start_cpu didn't return
OPAL_SUCCESS), or failed to identify, then don't use the core.

Eduardo Pires told ppc@ in April 2023 about a machine that froze at
boot; cpu1 had failed to start with error -14 OPAL_WRONG_STATE.  See
https://marc.info/?l=openbsd-ppc=168106893329069=2

ok miod@



CVS: cvs.openbsd.org: src

2023-02-20 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/02/20 21:49:43

Modified files:
sys/arch/powerpc/powerpc: pmap.c 

Log message:
Set the current pmap in macppc's pmap_activate

This fixes a possible freeze in execve(2).  It sometimes froze when a
dual-cpu macppc started daemons during boot.  There is a chance that
uvm_map.c uvmspace_exec sees ovm->vm_refcnt != 1 and switches curproc
to a new pmap.  If this happened, then execve froze by trying to
copyout to the wrong pmap; curpcb->pcb_pm was old.  Fix by setting
pointers when uvmspace_exec calls pmap_activate.

ok miod@



CVS: cvs.openbsd.org: src

2023-02-05 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/02/05 23:41:38

Modified files:
sys/arch/powerpc/powerpc: pmap.c 

Log message:
Add missing check for pg != NULL

The code was reading pg->pg_flags, so clang assumed pg != NULL, then
optimized a later "if (pg != NULL)" to "if (1)", and allowed a call to
pmap_enter_pv(pted, NULL).  Such a call can freeze bsd.mp by trying to
lock NULL's ((struct mutex *)0x3c).  I froze bsd.mp this way by
starting Xorg on a macppc with nv(4) or r128(4) video, as it tried to
mmap the xf86(4) aperture.

ok miod@



CVS: cvs.openbsd.org: src

2023-02-01 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/02/01 12:02:50

Modified files:
lib/libcrypto/sha/asm: sha512-ppc.pl 

Log message:
For xonly, move sha512-ppc.pl's table from text to rodata

OpenBSD/macppc will enforce xonly on PowerPC G5, then libcrypto's
sha256 would crash by SIGSEGV, because it can't read text.

Use ELF relocations "@ha" and "@l" to find the table in rodata.  This
might break the PowerPC asm on a not-ELF platform (like AIX or Mac OS)
if someone would try it there.

ok kettenis@ deraadt@



CVS: cvs.openbsd.org: src

2023-01-30 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/01/30 18:27:58

Modified files:
sys/arch/powerpc/include: pmap.h pte.h 
sys/arch/powerpc/powerpc: pmap.c trap.c 

Log message:
Execute-only for macppc G5

The G5 PowerPC 970 has a Data Address Compare mechanism that can trap
loads and stores to pages with PTE_AC_64, while allowing instruction
fetches.  Use this for execute-only mappings, like we do on powerpc64.

Add a check to pte_spill_v for execute-only mappings.  Without this,
we would forever retry reading an execute-only page.

In altivec_assist, copyin would fail to read the instruction from an
execute-only page.  Add copyinsn to bypass x-only, like sparc64.

with help from abieber@ deraadt@ kettenis@
ok deraadt@



CVS: cvs.openbsd.org: src

2023-01-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2023/01/10 14:27:12

Modified files:
sys/arch/powerpc/powerpc: pmap.c 

Log message:
Use atomic ops on the set of used segment registers

Each pmap sets a bit in usedsr to claim 16 unique VSIDs for its
segment registers. Use atomic_cas_uint to set this bit (checking that
the other cpu didn't steal it) and atomic_clearbits_int to clear it.
Stop using splvm.

ok miod@



CVS: cvs.openbsd.org: src

2022-12-30 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/12/30 22:06:18

Modified files:
sys/arch/macppc/pci: vgafb.c 

Log message:
Look for the first 2 mem regions, ignore the rest

Some macppc nvidia graphics cards have a 3rd mem region, but nv(4)
wants to mmap the 1st and 2nd regions.

ok miod@



CVS: cvs.openbsd.org: src

2022-10-22 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/22 21:43:04

Modified files:
sys/arch/macppc/dev: adb.c apm.c 

Log message:
Connect macppc's power button and lid to the SUSPEND stubs

A kernel with option SUSPEND now calls gosleep() if I run zzz(8),
press the power button (when machdep.pwraction=2), or close the lid
(when machdep.lidaction=1).  Because gosleep() is an empty stub, the
macppc does not really suspend; it only suspends some devices and
immediately resumes.

The interrupt from the power button or the lid needs some thread
(other than systq) to call sleep_state().  Use taskq_create(9) to
create another thread.

Add a call to device_register_wakeup().  Without this call,
sleep_state() does nothing.

ok kettenis@ deraadt@



CVS: cvs.openbsd.org: src

2022-10-22 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/22 11:50:29

Modified files:
regress/sys: Makefile 
Added files:
regress/sys/altivec_ast: Makefile vecast.c 

Log message:
Add regress for powerpc* AltiVec with subnormal floats

Older CPUs do an AltiVec assist trap, EXC_VECAST_G4 or EXC_VECAST_G5
in /sys/arch/powerpc/powerpc/trap.c; newer CPUs (like POWER9) don't
trap.  The trap's emulation of subnormal floats should give almost the
same results as the POWER9.

This test is only for powerpc or powerpc64 with AltiVec.  anton@
explained how to skip the test if we're on the wrong arch or don't
have AltiVec.

ok anton@



CVS: cvs.openbsd.org: src

2022-10-22 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/22 11:20:18

src/regress/sys/altivec_ast

Update of /cvs/src/regress/sys/altivec_ast
In directory cvs.openbsd.org:/tmp/cvs-serv64353/altivec_ast

Log Message:
Directory /cvs/src/regress/sys/altivec_ast added to the repository



CVS: cvs.openbsd.org: src

2022-10-21 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/21 18:58:56

Modified files:
sys/arch/powerpc/conf: files.powerpc 
sys/arch/powerpc/include: trap.h 
sys/arch/powerpc/powerpc: trap.c 
Added files:
sys/arch/powerpc/powerpc: vecast.S 

Log message:
AltiVec assist for subnormal floats in vectors

The old CPU in a macppc traps AltiVec instructions when they encounter
denormal or subnormal floats.  Emulate most of them.  They operate on
vectors of 4 single-precision floats.  The emulations either use
scalar operations (so vmaddfp becomes 4 of fmadds) or a formula (like
vrsqrtefp's 1 / sqrt(b) = 1 / sqrt(b * 2**126) * 2**63).

I am forgetting to emulate some instructions (at least vrfin, vrfiz,
vrfip, vrfim).  If I don't emulate it, it will still cause SIGFPE.

Mac OS never emulated these instructions, but set AltiVec's "non-Java"
NJ bit (which changes all subnormal floats to zero).  FreeBSD also
sets NJ; NetBSD does SIGFPE; Linux emulates them.  The POWER9 running
OpenBSD/powerpc64 does them in hardware (without trapping).

ok kettenis@ miod@



CVS: cvs.openbsd.org: src

2022-10-21 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/21 16:42:36

Modified files:
sys/arch/macppc/dev: adb.c pm_direct.c pm_direct.h 
sys/arch/macppc/include: cpu.h 
sys/arch/macppc/macppc: machdep.c 
sys/dev/adb: adb.h akbd.c 

Log message:
hw.power, machdep.lidaction, machdep.pwraction for macppc

I can now use the power button to power off my macppcs running
OpenBSD.  The new sysctls machdep.lidaction and machdep.pwraction act
like acpibtn(4), but we are missing code to suspend or hibernate a
macppc.  Small kernels (bsd.rd) continue to ignore the power button.

adb(4) sends an environment interrupt when I unplug my PowerBook's AC
or close its lid.  Rename PMU_INT_WAKEUP to PMU_INT_ENVIRONMENT like
other BSDs and Linux.  Handle PMU_ENV_LID_CLOSED as a lid sensor and
PMU_ENV_AC_POWER by setting sysctl hw.power.  Power buttons can either
use PMU_ENV_POWER_BUTTON or go through akbd(4); handle both kinds of
power buttons in the same way.  Other models of macppc, with different
power buttons or lids, might not work yet.  The lid sensor looks like,

$ sysctl hw.sensors
hw.sensors.adb0.indicator0=On (lid open)

kettenis@ warned against calling prsignal() from interrupt context,
and pointed me to task_add(9).



CVS: cvs.openbsd.org: src

2022-10-21 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/10/21 15:26:49

Modified files:
sys/arch/macppc/macppc: machdep.c 
sys/arch/macppc/stand: Locore.c cache.c libsa.h 
sys/arch/powerpc/include: cpu.h 
sys/arch/powerpc64/powerpc64: syncicache.c 

Log message:
Change len in syncicache(_, len) from int to size_t

The powerpc64 part is under #if 0, so this change affects only macppc.
Simplify powerpc64's __syncicache (which had size_t len) and copy it
to macppc's syncicache (which had int len).

macppc was looping while ((l -= CACHELINESIZE) > 0).  The loop would
be infinite if l became an unsigned type like size_t.  It is simpler
to set size_t i = 0, do i += by, and loop while (i < len).  It helps
that dcbst and icbi can add 2 registers, from + i.



CVS: cvs.openbsd.org: src

2022-09-18 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/09/18 15:36:41

Modified files:
sys/arch/macppc/dev: pm_direct.c pm_direct.h 

Log message:
Define PMU_ADB_CMD and PMU_INT_ACK

Taking these definitions from NetBSD's pm_direct.h; most PMU_*
commands have the same names in the BSDs and Linux.

ok miod@ kettenis@



CVS: cvs.openbsd.org: src

2022-09-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/09/10 22:38:28

Modified files:
distrib/macppc/ramdisk: install.md 
distrib/powerpc64/ramdisk: install.md 

Log message:
Use installboot -p in install.md for macppc, powerpc64

ok kn@



CVS: cvs.openbsd.org: src

2022-09-05 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/09/05 15:52:53

Modified files:
distrib/sets/lists/comp: md.macppc 

Log message:
sync



CVS: cvs.openbsd.org: src

2022-06-17 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/06/17 21:23:19

Modified files:
usr.bin/compress: gzopen.c 

Log message:
Fix gzip byte counts with 32-bit integers

If zlib is without our local change in lib/libz/zlib.h r1.7, then
s->z_stream.total_in and s->z_stream.total_out might overflow on
architectures where uLong has 32 bits.  After overflow, the total
would be 4G below the correct total.

Calculate our own 64-bit totals.  When decompressing, take
(uLong)s->z_stream.total_in as a total modulo ULONG_MAX + 1.

ok tb@



CVS: cvs.openbsd.org: src

2022-05-12 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/05/12 09:51:23

Modified files:
gnu/usr.bin/clang: Makefile.inc 

Log message:
Drop old powerpc flags from the build of clang

Drop NOPIE_FLAGS = -fPIE and change CFLAGS on powerpc to be the same
as on other arches.

ok deraadt@ kettenis@



CVS: cvs.openbsd.org: src

2022-02-09 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/02/09 22:48:02

Modified files:
sys/arch/macppc/dev: apm.c 
sys/arch/powerpc/include: cpu.h 

Log message:
Add stubs for macppc suspend

These stubs don't work; they only pretend to suspend the machine.
SUSPEND + MULTIPROCESSOR doesn't build.  zzz(8) stops giving an error
message, even in no-SUSPEND kernels.

Add intr_enable in , adapted from powerpc64, because
subr_suspend.c calls intr_enable().



CVS: cvs.openbsd.org: src

2022-02-07 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/02/07 16:20:10

Modified files:
sys/arch/powerpc/powerpc: pmap.c 

Log message:
Allow writes to rw pages in pte_spill_v

In the powerpc pmap, hash collisions can spill page table entries.
Page faults can use pte_spill_v to reinsert a spilled pte.  If the
fault is a write (DSISR_STORE), then pte_spill_v tries to check for a
read-only page.  The existing check (pte_lo & PTE_RO_64) also matched
rw pages, because PTE_RO_64 is 3 and PTE_RW_64 is 2.  This caused
pte_spill_v to deny writes to rw pages.  Then uvm_fault might allow
the write; but uvm_fault can't handle some pages in the kernel.  Such
faults caused, "panic: uvm_fault: fault on non-pageable map", or
"panic: trap type 300".

Change it to ((pte_lo & PTE_PP_64) == PTE_RO_64).  This seems to fix
one reason why bsd.mp on a macppc dual G5 might panic.

ok kettenis@ miod@



CVS: cvs.openbsd.org: src

2022-02-07 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/02/07 15:28:15

Modified files:
sys/arch/powerpc/ddb: db_trace.c 

Log message:
Allow "ddb{1}> trace" through interrupt on macppc

If cpu0 sends PPC_IPI_DDB to cpu1, then cpu1 stops on its interrupt
stack.  Teach ININTSTK to allow traces through all interrupt stacks,
not only cpu0's.

ININTSTK now works by looping for all cpus.  It doesn't remember which
cpu owns the stack.  A macppc has at most 4 cpus.

ok kettenis@ miod@



CVS: cvs.openbsd.org: src

2022-02-05 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/02/05 10:11:56

Modified files:
lib/libm/src   : s_logb.c 

Log message:
Provide logbl(3) when long double is double

bcallah@ had same diff
ok guenther@



CVS: cvs.openbsd.org: src

2022-01-28 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2022/01/28 11:37:40

Modified files:
sys/arch/powerpc/ddb: db_interface.c db_trace.c 
sys/arch/powerpc/include: db_machdep.h 
sys/arch/powerpc64/powerpc64: db_trace.c 

Log message:
Give ddb more access to registers on macppc, powerpc64

Edit db_regs[] in db_trace.c on both powerpc and powerpc64, so ddb can
access $r14, $r15, $r16, $dar, $dsisr.

Only for powerpc: change db_trap_glue to copy all registers to and
from ddb_regs (it was skipping some); change db_set_single_step and
db_clear_single_step to flip the correct bit of srr1; delete
FIXUP_PC_AFTER_BREAK, which was off by 1 instruction.

"ddb{1}> s" on my PowerMac7,3 (dual G5 at 2700 MHz) began to panic
like, "*cpu0: mutex 0xa7d0a0 not held in tc_update_timekeep".  Add an
arbitrary delay(100) after sending PPC_IPI_DDB; I want cpu0 to get the
ipi before it can see db_active == 1 and skip acquiring a mutex.

ok kettenis@



CVS: cvs.openbsd.org: xenocara

2021-09-20 Thread George Koehler
CVSROOT:/cvs
Module name:xenocara
Changes by: gkoeh...@cvs.openbsd.org2021/09/20 16:48:08

Modified files:
app/xenodm/xenodm: auth.c 

Log message:
Allow login when ~/.Xauthority does not exist

If you had no .Xauthority, you needed to log in twice, because xenodm
created .Xauthority after your 1st session failed.

problem found by solene@
ok matthieu@ deraadt@



CVS: cvs.openbsd.org: src

2021-08-20 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2021/08/20 21:00:02

Modified files:
gnu/usr.bin/clang: Makefile.inc 
share/mk   : bsd.own.mk 

Log message:
Switch macppc to ld.lld

Add powerpc to LLD_ARCH.  Remove -Wl,-relax flag; ld.bfd needed it,
but ld.lld can't take this flag.

To avoid linker errors on macppc, you need a snapshot where
/usr/bin/ld is LLD.

ok kettenis@ deraadt@



CVS: cvs.openbsd.org: src

2021-05-20 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2021/05/20 18:39:35

Modified files:
sys/arch/powerpc/include: mplock.h 
sys/arch/powerpc/powerpc: lock_machdep.c 

Log message:
Fix __ppc_lock for page faults that recursively grab the lock.

The macppc kernel, when running on G5, may get page faults while
executing itself.  Because we reorder our kernels, these faults happen
in different places in each kernel.  I got unlucky with a bsd.mp where
the function __ppc_lock() crossed a page boundary.  The fault handler
recursively called __ppc_lock() and caused my G5 to freeze or hang
very early during boot, while trying to map the framebuffer.

Change the lock to spin while (mpl->mpl_cpu != NULL).  Acquire the
lock with a single atomic write, by setting mpl_cpu and leaving
mpl_count at 0.  Page faults that recursively call __ppc_lock() and
__ppc_unlock() should now not corrupt the lock.

In case we hold the lock but get a page fault before membar_enter() or
after membar_exit(), the recursive calls now have memory barriers.

Delete some unused functions.  In the past, __ppc_lock was __mp_lock,
but today, the only __ppc_lock is PMAP_HASH_LOCK.

ok kettenis@



CVS: cvs.openbsd.org: src

2021-05-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2021/05/10 11:29:41

Modified files:
sys/arch/macppc/conf: Makefile.macppc ld.script 
sys/arch/macppc/stand/ofwboot: Makefile 
Added files:
sys/arch/macppc/stand/ofwboot: ld.script 

Log message:
Add ld.script for macppc kernel, ofwboot

These are copies of powerpc64/conf/ld.script with some changes for
macppc.  They work with both ld.bfd and ld.lld.

The ld.script fixes ld.lld.  Without ld.script, lld would set the
symbol "etext" to a wrong value like 0x1034, then ofwboot would
freeze and fail to boot the kernel.  With ld.script, we PROVIDE a
correct etext.

ok kettenis@



CVS: cvs.openbsd.org: src

2021-04-20 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2021/04/20 18:22:16

Modified files:
gnu/llvm/llvm/lib/Target/PowerPC: PPCInstrInfo.td 

Log message:
Fix __builtin_bitreverse32 on 32-bit PowerPC

This is a backport from LLVM 11.  Before this fix, code using
__builtin_bitreverse32 was crashing SIGILL because clang-10 emitted a
64-bit rldicl/clrldi instruction.  The SIGILL only happened on 32-bit
cpus, not on the G5.  The code for LLVM 11 uses __builtin_bitreverse,
so clang-10 needs this fix to build clang-11.

https://github.com/llvm/llvm-project/commit/a5d161c119d5a
https://reviews.llvm.org/D77946

ok kettenis@



CVS: cvs.openbsd.org: src

2020-12-29 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/12/29 23:06:31

Modified files:
sys/arch/powerpc64/dev: opal.c 
sys/arch/powerpc64/include: cpu.h cpufunc.h trap.h 
sys/arch/powerpc64/powerpc64: cpu.c genassym.cf locore.S 
  machdep.c trap_subr.S 
sys/dev/ofw: fdt.c openfirm.h 

Log message:
Enter power-saving mode on POWER9 (ISA v3)

When opal(4) attaches, look in the device tree for a psscr value.  In
cpu_idle_cycle(), use this psscr value and the stop instruction to
wait for the next interrupt.  In mp kernels, cpu_unidle() now sends an
interrupt.  In "sysctl hw.sensors", the power and temperature sensors
from opalsens(4) may show lower values.

The cpu may exit stop at the system reset vector after losing user
registers.  If so, restore some registers.  For now, ignore deeper
stop states that would lose hypervisor registers.

Our mp kernel uses only the first hardware thread of each core.  Take
the extra threads from the firmware and stop them forever; this may
switch the core from SMT4 to single-thread mode and increase
performance.

partly by kettenis@, ok kettenis@



CVS: cvs.openbsd.org: src

2020-12-22 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/12/22 11:17:29

Modified files:
sys/arch/powerpc64/powerpc64: trap.c 

Log message:
Use SIGILL for the Facility Unavailable Interrupt in usermode.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-11-29 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/11/29 11:57:29

Modified files:
gnu/llvm/lld/ELF/Arch: PPC.cpp 
sys/arch/macppc/conf: Makefile.macppc 

Log message:
Teach lld to link the macppc kernel

Add R_PPC_ADDR24 to lld.  We need R_PPC_ADDR24 for absolute branches
"ba" and "bla" in locore.S in the kernel.

In Makefile.macppc, add a gapdummy (like in Makefile.powerpc64) to
avoid an lld error.  Also adapt a part of Makefile.i386, so my
powerpc64 can use clang and lld to build and link the macppc kernel.
(I didn't boot that kernel.)

My macppc can now build, link, and boot kernels with either ld.bfd or
ld.lld.  Beware that kernels linked with ld.lld have at least one
problem (wrong ) not yet fixed.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-11-28 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/11/28 12:49:30

Modified files:
sys/arch/macppc/macppc: locore.S ofwreal.S 
sys/arch/powerpc/include: asm.h 
sys/arch/powerpc/powerpc: setjmp.S 
sys/lib/libkern/arch/powerpc: ffs.S memmove.S 
lib/libc/arch/powerpc: SYS.h 
lib/libc/arch/powerpc/string: ffs.S memmove.S 
lib/libc/arch/powerpc/sys: sigpending.S sigprocmask.S 
   sigsuspend.S tfork_thread.S 
libexec/ld.so/powerpc: SYS.h 

Log message:
Add retguard to macppc kernel locore.S, ofwreal.S, setjmp.S

This changes RETGUARD_SETUP(ffs) to RETGUARD_SETUP(ffs, %r11, %r12)
and RETGUARD_CHECK(ffs) to RETGUARD_CHECK(ffs, %r11, %r12)
to show that r11 and r12 are in use between setup and check, and to
pick registers other than r11 and r12 in some kernel functions.

ok mortimer@ deraadt@



CVS: cvs.openbsd.org: src

2020-11-19 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/11/19 22:07:27

Modified files:
gnu/llvm/clang/lib/CodeGen: TargetInfo.cpp 

Log message:
Fix va_arg in C++, Objective-C on 32-bit powerpc

In the PPC32 SVR4 ABI, a va_list has copies of registers from the
function call. va_arg looked in the wrong registers for (the pointer
representation of) an object in Objective-C, and for some types in
C++. Fix va_arg to look in the general-purpose registers, not the
floating-point registers. Also fix va_arg for some C++ types, like a
member function pointer, that are aggregates for the ABI.

Anthony Richardby found the problem in Objective-C. Eli Friedman
suggested part of this fix.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47921
I have submitted this diff as https://reviews.llvm.org/D90329

ok kettenis@



CVS: cvs.openbsd.org: src

2020-10-26 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/10/26 19:26:53

Modified files:
sys/lib/libkern/arch/powerpc: ffs.S memmove.S 

Log message:
Retguared asm macros for powerpc libkern

This was in the macppc snap, but I forgot to include it in my last
commit "Retguard asm macros for powerpc libc, ld.so"



CVS: cvs.openbsd.org: src

2020-10-26 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/10/26 16:07:06

Modified files:
lib/libc/arch/powerpc: SYS.h 
lib/libc/arch/powerpc/string: ffs.S memmove.S 
lib/libc/arch/powerpc/sys: brk.S sbrk.S sigpending.S 
   sigprocmask.S sigsuspend.S 
   tfork_thread.S 
libexec/ld.so/powerpc: SYS.h 
sys/arch/powerpc/include: asm.h 

Log message:
Retguard asm macros for powerpc libc, ld.so

Add retguard to some, but not all, asm functions in libc.  Edit SYS.h
in libc to remove the PREFIX macros and add SYSENTRY (more like
aarch64 and powerpc64), so we can insert RETGUARD_SETUP after
SYSENTRY.  Some .S files in this commit don't get retguard, but do
stop using the old prefix macros.

Tested by deraadt@, who put this diff in a macppc snap.



CVS: cvs.openbsd.org: src

2020-10-17 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/10/17 19:29:43

Modified files:
gnu/llvm/llvm/lib/Target/PowerPC: PPCReturnProtectorLowering.cpp 

Log message:
Use all 64 bits of the RETGUARD cookie on powerpc64

Change the 64-bit target to use "ld" (load 64-bit doubleword) for the
cookie.  The 32-bit target stays with "lwz" (load 32-bit word).

ok mortimer@



CVS: cvs.openbsd.org: src

2020-10-03 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/10/03 00:22:20

Modified files:
sys/arch/macppc/stand: conf.c main.c 

Log message:
Increase CLAIM_LIMIT from 11M to 14M to make room for retguard

The kernel text will grow larger when retguard adds code to many
functions to check their return addresses.  The entire kernel
(including text, data, bss, symbol table, and ramdisk) must fit under
the CLAIM_LIMIT.  A kernel that overflows this limit may fail very
quickly, by causing a "DEFAULT CATCH!" error in Open Firmware.

Crank version to "1.10", so I can see whether the running ofwboot uses
the higher CLAIM_LIMIT.

ok deraadt@



CVS: cvs.openbsd.org: src

2020-10-02 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/10/02 23:58:52

Modified files:
distrib/powerpc64/iso: Makefile 

Log message:
Add bsd.mp to powerpc64's installXX.{img,iso}

ok deraadt@



CVS: cvs.openbsd.org: src

2020-09-22 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/09/22 21:03:12

Modified files:
sys/arch/powerpc64/dev: opal.c 
sys/arch/powerpc64/include: cpu.h intr.h 
sys/arch/powerpc64/powerpc64: cpu.c intr.c 

Log message:
Use an IPI, so hw.setperf affects all cores in the mp kernel.

Before, apm -A was speeding up only one core of my POWER9.
Now, apm -A speeds up all cores, so my parallel builds are faster.

I copy the idea from amd64 and i386: mp_setperf() sends an IPI to all
cpus; the interrupt handler calls ul_setperf().

ok deraadt@ kettenis@



CVS: cvs.openbsd.org: src

2020-09-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/09/10 14:28:14

Modified files:
gnu/llvm/clang/docs: ClangCommandLineReference.rst 
gnu/llvm/clang/include/clang/Basic: CodeGenOptions.def 
DiagnosticFrontendKinds.td 
DiagnosticGroups.td 
LangOptions.def TargetInfo.h 
gnu/llvm/clang/include/clang/Driver: Options.td 
gnu/llvm/clang/lib/Basic: TargetInfo.cpp 
gnu/llvm/clang/lib/Basic/Targets: SystemZ.h X86.h 
gnu/llvm/clang/lib/Frontend: CompilerInstance.cpp 
 CompilerInvocation.cpp 

Log message:
Disable strict floating point if not X86

Disable options like clang -fno-unsafe-math-optimizations for all
targets except X86 (and SystemZ).  This prevents a crash of clang,
reported by cwen@, in graphics/babl or emulators/mednafen for powerpc.

ok mortimer@

This change comes from llvm 11.x:
https://github.com/llvm/llvm-project/commit/d4ce862

Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets 
lacking support."

We currently have strict floating point/constrained floating point enabled
for all targets. Constrained SDAG nodes get converted to the regular ones
before reaching the target layer. In theory this should be fine.

However, the changes are exposed to users through multiple clang options
already in use in the field, and the changes are _completely_ _untested_
on almost all of our targets. Bugs have already been found, like
"https://bugs.llvm.org/show_bug.cgi?id=45274;.

This patch disables constrained floating point options in clang everywhere
except X86 and SystemZ. A warning will be printed when this happens.

Use the new -fexperimental-strict-floating-point flag to force allowing
strict floating point on hosts that aren't already marked as supporting
it (X86 and SystemZ).

Differential Revision: https://reviews.llvm.org/D80952



CVS: cvs.openbsd.org: src

2020-09-01 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/09/01 14:06:50

Modified files:
sys/arch/powerpc64/include: cpu.h 
sys/arch/powerpc64/powerpc64: machdep.c 

Log message:
Fix signotify() for powerpc64 bsd.mp

Copy signotify() from amd64, so that if proc *p is on another cpu, then
signotify(p) notifies the correct cpu.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-08-30 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/08/30 19:46:38

Modified files:
gnu/llvm/llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp 

Log message:
Delete my leftover comment.

This comment was from my commit of 2020-05-02,
> Don't make an illegal adde.  Avoids fatal error on PowerPC.

When we merged LLVM 10, we got upstream's fix for the illegal adde
problem, and this comment became the only difference in this file
between us and upstream.

Found by Brad Smith.



CVS: cvs.openbsd.org: src

2020-08-14 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/08/14 12:57:06

Modified files:
gnu/llvm/llvm/lib/Target/PowerPC: PPCISelLowering.cpp 
  PPCSubtarget.h 

Log message:
Remove local change to fix powerpc floating-point alignment

LLVM 10 includes a different fix (https://reviews.llvm.org/D71954), so
this change (by kettenis on 2019-02-18) is no longer needed.  Thanks to
Brad Smith for providing the removal diff.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-07-26 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/07/26 23:08:57

Modified files:
lib/libc/arch/powerpc64/sys: sbrk.S 

Log message:
Fix powerpc64's sbrk()

Initialize __curbrk = &_end.
It's a 64-bit pointer, so use ld/std instead of lwz/stw.

ok drahn@



CVS: cvs.openbsd.org: src

2020-07-17 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/07/17 14:15:43

Modified files:
lib/libc/arch/powerpc/gen: usertc.c 
sys/arch/macppc/include: timetc.h 
sys/arch/macppc/macppc: clock.c 

Log message:
Userland timecounter for macppc

Tested by cwen@ and myself.  Thanks to pirofti@ for creating the
userland timecounter feature.

ok kettenis@ pirofti@ deraadt@ cheloha@



CVS: cvs.openbsd.org: src

2020-07-16 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/07/16 19:36:41

Modified files:
sys/kern   : kern_tc.c 

Log message:
Read ogen from the other timehands; fixes tk_generation

If th0.th_generation == th1.th_generation when we update the user
timekeep page, then tk_generation doesn't change, so libc may
calculate the wrong time.  Now th0 and th1 share the sequence so
th0.th_generation != th1.th_generation.

ok kettenis@ cheloha@



CVS: cvs.openbsd.org: src

2020-07-10 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/07/10 17:22:48

Modified files:
sys/arch/powerpc64/dev: opal.c 
sys/arch/powerpc64/include: cpufunc.h 
sys/arch/powerpc64/powerpc64: cpu.c 

Log message:
Add hw.cpuspeed and hw.setperf

Get the list of Pstates from OPAL, and use special registers to
request a Pstate or check the current Pstate.  The turbo Pstates are
higher than the cpu's nominal speed, but the OCC's firmware should
throttle down the cpu if it would overheat.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-07-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/07/04 13:25:11

Modified files:
share/mk   : bsd.own.mk 

Log message:
Stop defining NOPIC on powerpc64.

ok kettenis@ drahn@



CVS: cvs.openbsd.org: src

2020-06-12 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/06/12 16:01:01

Modified files:
sys/arch/powerpc64/include: db_machdep.h pmap.h 
sys/arch/powerpc64/powerpc64: db_memrw.c db_trace.c locore.S 
  pmap.c syncicache.c trap.c 

Log message:
Teach powerpc64 ddb to x, w, break, step, trace.

Copy and adapt db_memrw.c from amd64, so ddb can read and write kernel
memory.  It can now insert breakpoints in the kernel text.  Change
__syncicache() to prevent an infinite loop when len isn't a multiple
of cacheline_size.

Get breakpoints and single-stepping to work.
Single-stepping uses msr bit PSL_SE (single-step trace enable).

Adapt db_trace.c db_stack_trace_print() from powerpc 32, but without
all its features.  For now, powerpc64 trace doesn't print function
arguments and doesn't recognize traps.

"go for it" kettenis@



CVS: cvs.openbsd.org: src

2020-06-06 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/06/06 15:01:30

Modified files:
share/man/man4/man4.macppc: aoa.4 snapper.4 
sys/arch/macppc/dev: aoa.c snapper.c 

Log message:
Move PowerBook5,4 audio from aoa(4) to snapper(4).

This adds the missing TAS3004 volume control.  Before, I put my ear
near the speaker (to hear audio), because I had no way to turn up the
volume.  Now, the default volume is much louder, so I use sndioctl(1)
to turn it down.

Check for the model string "PowerBook5,4".  This model's device tree
has compatible = "AOAKeylargo" for the audio, doesn't show the TAS3004
in the same way as other models.



CVS: cvs.openbsd.org: src

2020-06-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/06/04 16:33:17

Modified files:
gnu/llvm/lib/Target/PowerPC: PPCISelLowering.cpp 

Log message:
Set max atomic size for PowerPC.

32-bit PowerPC doesn't have instructions for lock-free atomic ops on
8-byte values, and needs libcalls like __atomic_fetch_add_8().  In
code like "_Atomic long long a; a++;", clang doesn't emit a libcall.
This was causing linker errors on symbols like __sync_fetch_and_add_8.

Now that LLVM knows the max atomic size, its AtomicExpandPass changes
these 8-byte ops into libcalls.

ok mortimer@



CVS: cvs.openbsd.org: src

2020-05-27 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/27 16:22:04

Modified files:
sys/arch/powerpc64/conf: Makefile.powerpc64 files.powerpc64 
sys/arch/powerpc64/include: _types.h db_machdep.h exec.h opal.h 
sys/arch/powerpc64/powerpc64: db_trace.c locore.S machdep.c 
  trap.c trap_subr.S 
Added files:
sys/arch/powerpc64/powerpc64: db_interface.c 

Log message:
Enter ddb at a trap instruction or with db_enter().

Tell make that trap_subr.S needs assym.h.
Fill in opal_cngetc() so I can type at the "ddb>" prompt.
Add enough code to trap_subr.S to "c" continue from ddb.
Give registers to ddb.
Try to load symbols from initrd.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-05-26 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/26 15:35:43

Modified files:
sys/ddb: db_elf.c 

Log message:
Stop requiring that .strtab has long alignment.

When ddb loads symbols, the .strtab contains char strings and doesn't
need long alignment.  Our bootloader provides long alignment, but I
started loading symbols on powerpc64 without our bootloader.

ok mpi@ guenther@ kettenis@



CVS: cvs.openbsd.org: src

2020-05-25 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/25 15:36:31

Modified files:
gnu/llvm/tools/clang/lib/Driver/ToolChains: Clang.cpp 

Log message:
PowerPC: optimize away the frame pointer.

clang defaulted to -fomit-frame-pointer when optimizing PowerPC code
for Linux and NetBSD.  Now do it for all systems, including OpenBSD.
This affects both 32-bit and powerpc64 code.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-05-21 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/21 19:11:04

Modified files:
sys/arch/powerpc64/powerpc64: db_disasm.c 

Log message:
Copy db_disasm.c from powerpc to powerpc64.

This includes my last change to decode the %{ds}(%{A}) operand
of ld, std instructions.

ok drahn@



CVS: cvs.openbsd.org: src

2020-05-21 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/21 18:33:45

Modified files:
sys/arch/powerpc/ddb: db_disasm.c 

Log message:
Decode the %{ds}(%{A}) operand of ld, std instructions.

I don't expect to see these 64-bit instructions in 32-bit kernels,
but I'm going to copy this code to powerpc64.

ok drahn@



CVS: cvs.openbsd.org: src

2020-05-17 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/17 17:27:45

Modified files:
sys/arch/powerpc64/conf: files.powerpc64 
sys/arch/powerpc64/include: cpu.h db_machdep.h 
sys/arch/powerpc64/powerpc64: locore.S 
Added files:
sys/arch/powerpc64/powerpc64: db_disasm.c db_memrw.c db_trace.c 

Log message:
Add enough stubs to allow "option DDB" to build.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-05-01 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/05/01 23:34:09

Modified files:
gnu/llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp 

Log message:
Don't make an illegal adde.  Avoids fatal error on PowerPC.

When the DAG truncates an ISD::ADDE node, DAGCombiner may optimize it
by making an adde with smaller operands.  PowerPC has i1 registers,
and may truncate an i32 adde to i1, but an i1 adde is not legal for
PowerPC, and the legalize-ops phase can't fix it.  This was causing
"fatal error: error in backend: Cannot select..."

cwen@ reported the error

ok mortimer@ kettenis@ deraadt@



CVS: cvs.openbsd.org: src

2020-04-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/04/04 08:06:21

Modified files:
lib/libunwind/src: Registers.hpp UnwindRegistersRestore.S 
   UnwindRegistersSave.S 

Log message:
Fix powerpc libunwind for cpus without altivec.

Defer saving the altivec registers until we need to access them (like
how arm defers saving the VFP registers).  This prevents a SIGILL on a
G3 cpu when code throws a C++ exception.

ok kettenis@



CVS: cvs.openbsd.org: src

2020-04-02 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/04/02 13:30:00

Modified files:
distrib/macppc/ramdisk: Makefile 

Log message:
use crunchgen -M on macppc; fixes build with clang

ok deraadt@



CVS: cvs.openbsd.org: src

2020-04-02 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/04/02 13:27:51

Modified files:
sys/arch/macppc/macppc: ofw_machdep.h ofwreal.S opendev.c 
openfirm.c 

Log message:
Make the OpenFirmware functions work with clang.

ofw_stack() was changing its caller's stack frame, but this stops
working when clang inlines the caller into another function.  Move the
stack-switching logic into openfirmware().  Now ofw_stack() becomes
ofw_msr() and only sets the msr.

ok deraadt@ kettenis@



CVS: cvs.openbsd.org: src

2020-03-06 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/03/06 14:14:20

Modified files:
distrib/miniroot: install.sub 

Log message:
Remove libLLVM.so.1.0



CVS: cvs.openbsd.org: src

2020-03-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/03/04 11:46:55

Modified files:
distrib/sets/lists/base: md.amd64 md.arm64 md.armv7 md.i386 
 md.loongson md.macppc md.octeon md.sgi 
 md.sparc64 

Log message:
sync versions of libLLVM libc++ libc++abi



CVS: cvs.openbsd.org: src

2020-03-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/03/04 11:45:44

Modified files:
gnu/usr.bin/clang/libLLVM: shlib_version 
lib/libcxx : shlib_version 
lib/libcxxabi  : shlib_version 

Log message:
crank major versions of libLLVM libc++ libc++abi

OpenBSD macppc builds these libs with clang.  Their ABI is changing
because of clang -msvr4-struct-return



CVS: cvs.openbsd.org: src

2020-03-04 Thread George Koehler
CVSROOT:/cvs
Module name:src
Changes by: gkoeh...@cvs.openbsd.org2020/03/04 11:44:39

Modified files:
gnu/llvm/tools/clang/include/clang/Driver: Options.td 
gnu/llvm/tools/clang/lib/CodeGen: TargetInfo.cpp 
gnu/llvm/tools/clang/lib/Driver/ToolChains: Clang.cpp 
gnu/llvm/tools/clang/lib/Frontend: CompilerInvocation.cpp 

Log message:
Switch powerpc clang to -msvr4-struct-return, like gcc.

Add these options from gcc to clang:
-maix-struct-return   # return all structs in memory
-msvr4-struct-return  # return small structs in r3/r4

ok mortimer@ jca@ deraadt@