summaryrefslogtreecommitdiff
path: root/sys/arch/arm64/arm64
AgeCommit message (Collapse)Author
2020-08-17Panic on an attempt to access user-space unless it is done usingMark Kettenis
an "unpriviliged" load/store instruction. This makes sure we catch PAN violations and might even catch some incorrect user-space access cases on systems without PAN. ok drahn@, jsg@
2020-07-25Port over NetBSD's arm64 disassembler for DDB.tobhe
ok kettenis@, patrick@
2020-07-17Re-work intr_barrier(9) on arm64 to remove layer violation. So far wePatrick Wildt
have stored the struct cpu_info * in the wrapper around the interrupt handler cookie, but since we can have a few layers inbetween, this does not seem very nice. Instead have each and every interrupt controller provide a barrier function. This means that intr_barrier(9) will in the end be executed by the interrupt controller that actually wired the pin to a core. And that's the only place where the information is stored. ok kettenis@
2020-07-16Store struct cpu_info * in arm64's interrupt wrap. intr_barrier() canPatrick Wildt
already assume every cookie is wrapped and simply retrieve the pointer from it. It's a bit of a layer violation though, since only the intc should actually store that kind of information. This is good enough for now, but I'm already cooking up a diff to resolve this. ok dlg@
2020-07-16To be able to have intr_barrier() on arm64, we need to be able toPatrick Wildt
somehow gain access to the struct cpu_info * used to establish the interrupt. One possibility is to store the pointer in the cookie returned by the establish methods. A better way would be to ask the interrupt controller directly to do barrier. This means that all external facing interrupt establish functions need to wrap the cookie in a common way. We already do this for FDT-based interrupts. Also most PCI controllers already return the cookie from the FDT API, which is already wrapped. So arm64's acpi_intr_establish() and acpipci(4) now need to explicitly wrap it, since they call ic->ic_establish directly, which does not wrap. ok dlg@
2020-07-14Extend the interrupt API on arm64 and armv7 to be able to pass aroundPatrick Wildt
a struct cpu_info *. From a driver point of view the fdt_intr_establish_* API now also exist same functions with a *_cpu suffix. Internally the "old" functions now call their *_cpu counterparts, passing NULL as ci. NULL will be interpreted as primary CPU in the interrupt controller code. The internal framework for interrupt controllers has been changed so that the establish methods provided by an interrupt controller function always takes a struct cpu_info *. Some drivers, like imxgpio(4) and rkgpio(4), only have a single interrupt line for multiple pins. On those we simply disallow trying to establish an interrupt on a non-primary CPU, returning NULL. Since we do not have MP yet on armv7, all armv7 interrupt controllers do return NULL if an attempt is made to establish an interrupt on a different CPU. That said, so far there's no way this can happen. If we ever gain MP support, this is a reminder that the interrupt controller drivers have to be adjusted. Prompted by dlg@ ok kettenis@
2020-07-06IEEE1275 (Open Firmware) defines that parameter name strings can have aMark Kettenis
length of up to 31 characters. This limit is also present in the flattened device tree specification/ Unfortunately this limit isn't enforced by the tooling and there are systems in the wild that use longer strings. This includes the device trees used on POWER9 systems and has been seen on some ARM systems as well. So bump the buffer size from 32 bytes (31 + terminating NUL) to 64 bytes. Centrally define OFMAXPARAM to this value (in <dev/ofw/openfirm.h>) replacing the various OPROMMAXPARAM definition scattered around the tree to make sure the FDT implementation of OF_nextprop() uses the same buffer size as its consumers. Eliminate the static buffer in various openprom(4) implementations on FDT systems. Makes it possible to dump the full device tree on POWER9 systems using eeprom -p. ok deraadt@, visa@
2020-07-06wire up kstat(4)David Gwynne
"looks right" deraadt@
2020-06-05Implement cpu_rnd_messybits() as a read of the virtual counter xoredChristian Weisgerber
with a bit-reversed copy of itself. There is progressively less entropy in the higher bits of a counter than in the lower bits, so bit-reverse one half in order to extract maximal entropy. style fixes and ok kettenis@
2020-06-04Recognise Cortex-A78.Mark Kettenis
2020-05-31introduce "cpu_rnd_messybits" for use instead of nanotime in dev/rnd.c.David Gwynne
rnd.c uses nanotime to get access to some bits that change quickly between events that it can mix into the entropy pool. it doesn't use nanotime to get a monotonically increasing set or ordered and accurate timestamps, it just wants something with bits that change. there's been discussions for years about letting rnd use a clock that's super fast to read, but not necessarily accurate, but it wasn't until recently that i figured out it wasn't interested in time at all, so things like keeping a fast clock coherent between cpu cores or correct according to ntp is unecessary. this means we can just let rnd read the cycle counters on cpus and things will be fine. cpus with cycle counters that vary in their speed and arent kept consistent between cores may even be desirable in this context. so this is the first step in converting rnd.c to reading cycle counter. it copies the nanotime backend to each arch, and they can replace it with something MD as a second step later on. djm@ suggested rnd_messybytes, but we landed on cpu_rnd_messybits. thanks to visa for his eyes. ok deraadt@ visa@ deraadt@ says he will help handle any MD fallout that occurs.
2020-05-25Kill unused cdev_pc_init().Martin Pieuchot
ok kettenis@, visa@
2020-05-23Add a little bit of const-ness.Mark Kettenis
2020-05-17Look at the openbsd,boothowto property.Mark Kettenis
ok visa@
2020-05-17Add machdep.compatible.Mark Kettenis
ok jsg@
2020-05-16Make inittodr() and resettodr() MI.Mark Kettenis
ok deraadt@, mpi@, visa@ ok cheloha@ as well (would have preferred in new file for this code)
2020-05-13Match direct `seltrue' usages with a corresponding `seltrue_kqfilter'.Martin Pieuchot
This ensure spec_kqfilter() won't return an error when spec_poll() returns success for a given device. ok visa@
2020-05-11Initialize the timeval passed to todr_gettime() with the base time fromMark Kettenis
the file system such that implementations can use it to guess the right century. ok mpi@
2020-04-27Move inittodr() and resettodr() to the end of the file to easy move an MIMark Kettenis
implementation. ok mpi@
2020-04-26Sanitize inittodr()/resettodr() implementation.Mark Kettenis
- move implementations next to eachother in the same file - remove pointless call to resettodr() in inittodr() - use OpenBSD define to get a minimum plausible time - if RTC time is before minimum plausible time, reject it - don't print "clock gained N days" on ramdisk Hopefully this implementation can serve as a model for unification into an MI implementation. ok mpi@
2020-04-21Set DMA constraint based on the openbsd,dma-constraint property ifMark Kettenis
present. Make sure bus_dmamap_alloc(9) allocates memory that meets that constraint. ok patrick@
2020-04-18Sync existing stacktrace_save() implementationsVisa Hankala
Upgrade stacktrace_save() to stacktrace_save_at() on architectures where the latter is missing. Define stacktrace_save() as an inline function in header <sys/stacktrace.h> to reduce duplication of code. OK mpi@
2020-04-12Add support for the _CCA method. This method indicates whether DMA isMark Kettenis
cache-coherent or not. To implement this, acpi(4) gets two bus_dma tags and passes the appropriate one when attaching devices based on _CCA. On i386/amd64, where for all practical purpose DMA is always cache-coherent, the two tags are the same. But on arm64 they are distinct. ok patrick@
2020-04-03Fix incoherencies of errors returned by various *kqfilter routines.Martin Pieuchot
EOPNOTSUPP is returned when there's no "filterops" for a given fd. EINVAL when the requested filter isn't supported by the "filterops". ENXIO means the underlying device is no longer valid/present. ok visa@
2020-03-29Prevent stack trace saving from inspecting untrusted data. On amd64,Visa Hankala
arm64 and i386, the chain of call frames is continuous from kernel to userspace. The unwinder has to stop at the latest when it reaches the start of the kernel stack. OK mpi@
2020-03-19Remove an unnecessary type cast.Visa Hankala
OK kettenis@
2020-03-17Mark a few functions as .globl such that they show up with their nameMark Kettenis
in btreace(8) output. ok deraadt@, patrick@
2020-03-13improve comment about the speculation barrierTheo de Raadt
2020-03-13Add speciulation barrier after the last remaining naked ERET instruction.Mark Kettenis
While the barrier isn't really needed here, it doesn't hurt and having it there establishes a pattern for people to follow. idiomatic deraadt@
2020-03-11In the sigtramp the fallback SYS_exit always works, there is no reasonTheo de Raadt
to spin trying things. ok kettenis
2020-03-03Add support for the BUS_DMA_NOCACHE flag to bus_dmamem_mmap(9).Mark Kettenis
ok patrick@, jsg@
2020-03-03Fix bogus bus_dmamem_mmap(9) implementation.Mark Kettenis
ok patrick@, jsg@
2020-02-16Change arm64 system call ABI to skip two instructions. This allows us toMark Kettenis
insert a barrier after each system call to address a speculative execution issue discovered by Anthony Steinhauser. A change to insert two nop instructions after each system call instruction in crt0.o/libc/ld.so has been committed a few weeks ago, so the transition should go smoothly. However, old static binaries and binaries that roll their own syscalls (like go) will no longer work. Snapshot packages that work with the new syscall ABI are available (including a fixed go). Together with deraadt@ and guenther@ ok deraadt@
2020-02-02Reapply post-svc-sled in a repaired fashion. The SYS_sigreturn-relatedTheo de Raadt
sigcoderet label must point directly after the svc instruction, because the sigreturn() checks it as SROP mitigation, so place the sled after the label. tested by naddy
2020-02-02Back out previous "insert two nop instructions after svc instructionsChristian Weisgerber
for SYS_exit and SYS_sigreturn in the sigtramp"; init has trouble spawning processes.
2020-02-01Also insert two nop instructions after svc instructions for SYS_exitTheo de Raadt
and SYS_sigreturn in the sigtramp. As these control-flow into a jump or process termination, we never do the +8 dance over the instructions, however the speculation prevention (once these nops are replaced with a speculation barrier) is required. oversight noticed by Anthony Steinhauser.
2020-01-26Fix comment.Mark Kettenis
2020-01-26Fix spacing issue.Mark Kettenis
2020-01-23wire up pppac(4) to some majors on each arch.David Gwynne
i was lazy and just put them at the end of the existing set. fyi, i think major 51 is free on all archs if anyone is looking for another one. ok claudio@
2020-01-21Import dt(4) a driver and framework for Dynamic Profiling.Martin Pieuchot
The design is fairly simple: events, in the form of descriptors on a ring, are being produced in any kernel context and being consumed by a userland process reading /dev/dt. Code and hooks are all guarded under '#if NDT > 0' so this commit shouldn't introduce any change as long as dt(4) is disable in GENERIC. ok kettenis@, visa@, jasper@, deraadt@
2020-01-20Separate the stack trace saving interface from ddb. The saving does notVisa Hankala
require the debugger on most architectures, and the separation makes the code easier to use from other subsystems. The function definitions are still conditional to DDB. However, that should not matter for now. OK deraadt@, mpi@
2020-01-11fix dup #includeTheo de Raadt
from alex naumov
2020-01-06Print a few more registers when we hit a uvm_fault in the kernel.Mark Kettenis
2019-12-22Wire up ipmi(4).Mark Kettenis
ok deraadt@
2019-12-19Convert boolean_t/TRUE/FALSE to int/1/0 for coherency with the rest ofMartin Pieuchot
the kernel. ok patrick@
2019-12-17arm64 cpus speculatively execute instructions after ERET, and on someTheo de Raadt
processors not all microarchitectural side effects are abandoned, leading to spectre-like effects. This was fixed quietly and without responsible disclosure by ARM in linux mainline a year ago, but rediscovered independently by Anthony Steinhauser. ok patrick guenther kettenis comment to ARM: "Responsible Disclosure" doesn't mean "downplay at maximum to avoid damage to the bottom line", the responsibility aspect entails ensuring "all customers are aware of the defect". What happened here is indistinguishable from Intel's behaviour, and that's not the look you want.
2019-12-17Add fido(4), a HID driver for FIDO/U2F security keysReyk Floeter
While FIDO/U2F keys were already supported by the generic uhid(4) driver, this driver adds the first step to tighten the security of FIDO/U2F access. Specifically, users don't need read/write access to all USB/HID devices anymore and the driver also improves integration with pledge(2) and unveil(2): It is pledge-friendly because it doesn't require any ioctls to discover the device and unveil-friendly because it uses a single /dev/fido/* directory for its device nodes. It also allows to support FIDO/U2F in firefox without further weakening the "sandbox" of the browser. Firefox does not have a proper privsep design and many operations, such as U2F access, are handled directly by the main process. This means that the browser's "fat" main process needs direct read/write access to all USB HID devices, at least on other operating systems. With fido(4) we can support security keys in Firefox under OpenBSD without such a compromise. With this change, libfido2 stops using the ioctl to query the device vendor/product and just assumes "OpenBSD" "fido(4)" instead. The ioctl is still supported but there was no benefit in obtaining the vendor product or name; it also allows to use libfido2 under pledge. With feedback from deraadt@ and many others OK kettenis@ djm@ and jmc@ for the manpage bits
2019-12-13noone has gpr(4) devices.Theo de Raadt
2019-11-07Convert db_addr_t -> vaddr_t but leave the typedef for now.Martin Pieuchot
2019-11-07Substitute boolean_t/TRUE/FALSE by int/1/0.Martin Pieuchot
ok dlg@, jasper@