aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/efidev
Commit message (Collapse)AuthorAgeFilesLines
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* efirt efi_enter(): Release acquired locks and restore FPU ownership ifKonstantin Belousov2019-06-031-1/+8
| | | | | | | | | | efi_arch_enter() returned an error. Submitted: Jan Martin Mikkelsen <janm@transactionware.com> MFC after: 1 week Notes: svn path=/head/; revision=348541
* Regularize the Netflix copyrightWarner Losh2019-02-041-1/+0
| | | | | | | | | | | | | | | Use recent best practices for Copyright form at the top of the license: 1. Remove all the All Rights Reserved clauses on our stuff. Where we piggybacked others, use a separate line to make things clear. 2. Use "Netflix, Inc." everywhere. 3. Use a single line for the copyright for grep friendliness. 4. Use date ranges in all places for our stuff. Approved by: Netflix Legal (who gave me the form), adrian@ (pmc files) Notes: svn path=/head/; revision=343755
* efirt: When present, attempt to use EFI runtime services to shutdownConrad Meyer2018-12-151-2/+38
| | | | | | | | | | PR: maybe related to 233998 (inconclusive at this time) Submitted by: byuu <byuu AT tutanota.com> (previous version) Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D18506 Notes: svn path=/head/; revision=342108
* Assign to correct structure members.Konstantin Belousov2018-09-041-3/+3
| | | | | | | | | | Reported by: cem from Coverity Sponsored by: The FreeBSD Foundation MFC after: 6 days Approved by: re (gjb) Notes: svn path=/head/; revision=338461
* Catch exceptions during EFI RT calls on amd64.Konstantin Belousov2018-09-021-49/+131
| | | | | | | | | | | | | | | | This appeared to be required to have EFI RT support and EFI RTC enabled by default, because there are too many reports of faulting calls on many different machines. The knob is added to leave the exceptions unhandled to allow to debug the actual bugs. Reviewed by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (rgrimes) Differential revision: https://reviews.freebsd.org/D16972 Notes: svn path=/head/; revision=338437
* Improve error messages from clock_if.m method failures.Konstantin Belousov2018-09-021-1/+2
| | | | | | | | | | | | | | | Print error message in verbose mode when CLOCK_SETTIME() clock_if.m method failed. For EFIRT RTC clock, add error code for the failure of CLOCK_GETTIME() report. Reviewed by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (rgrimes) Differential revision: https://reviews.freebsd.org/D16972 Notes: svn path=/head/; revision=338435
* Normalize use of semicolon with EFI_TIME_LOCK macros.Konstantin Belousov2018-09-021-7/+7
| | | | | | | | | | | Reviewed by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (rgrimes) Differential revision: https://reviews.freebsd.org/D16972 Notes: svn path=/head/; revision=338433
* efirt: Don't enter EFI context early, convert addrs to KVA insteadKyle Evans2018-08-041-19/+13
| | | | | | | | | | | | | | | | | efi_enter here was needed because efi_runtime dereference causes a fault outside of EFI context, due to runtime table living in runtime service space. This may cause problems early in boot, though, so instead access it by converting paddr to KVA for access. While here, remove the other direct PHYS_TO_DMAP calls and the explicit DMAP requirement from efidev. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16591 Notes: svn path=/head/; revision=337331
* Follow up to r336919 and r336921: s/efi.rt_disabled/efi.rt.disabled/Kyle Evans2018-07-301-1/+1
| | | | | | | | | | | The latter matches the rest of the tree better [0]. The UPDATING entry has been updated to reflect this, and the new tunable is now documented in loader(8) [1]. Reported by: imp [0], Shawn Webb [1] Notes: svn path=/head/; revision=336924
* efirt: Add tunable to allow disabling EFI Runtime ServicesKyle Evans2018-07-301-0/+8
| | | | | | | | | | | | | Leading up to enabling EFIRT in GENERIC, allow runtime services to be disabled with a new tunable: efi.rt_disabled. This makes it so that EFIRT can be disabled easily in case we run into some buggy UEFI implementation and fail to boot. Discussed with: imp, kib MFC after: 1 week Notes: svn path=/head/; revision=336919
* Make timespecadd(3) and friends publicAlan Somers2018-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725 Notes: svn path=/head/; revision=336914
* Add missing MODULE_VERSION() and MODULE_DEPEND().Ian Lepore2018-06-281-0/+2
| | | | Notes: svn path=/head/; revision=335766
* efidev: Drop a quick note in about efi_cfgtbl/efi_runtimeKyle Evans2018-03-231-0/+5
| | | | | | | | | There's no real annotation for it, so it's not immediately obvious to the unfamiliar that these pointers are to locations in the EFI runtime map unlike the system table pointer immediately above them. Notes: svn path=/head/; revision=331413
* Re-work efidev ordering to fix efirt preloaded by loader on amd64Kyle Evans2018-03-222-2/+3
| | | | | | | | | | | | | | | | | | | | | On amd64, efi_enter calls fpu_kern_enter(). This may not be called until fpuinitstate has been invoked, resulting in a kernel panic with efirt_load="YES" in loader.conf(5). Move fpuinitstate a little earlier in SI_SUB_DRIVERS so that we can squeeze efirt between it and efirtc at SI_SUB_DRIVERS, SI_ORDER_ANY. efidev must be after efirt and doesn't really need to be at SI_SUB_DEVFS, so drop it at SI_SUB_DRIVER, SI_ORDER_ANY. The not immediately obvious dependency of fpuinitstate by efirt has been noted in both places. Discussed with: kib, andrew Reported by: Jakob Alvermark <jakob@alvermark.net> X-MFC-With: r330868 Notes: svn path=/head/; revision=331365
* Enter into the EFI environment before dereferencing the runtime servicesAndrew Turner2018-03-221-0/+9
| | | | | | | | | | | pointer. This may be within the EFI address space and not the FreeBSD kernel address space. X-MFC-With: r330868 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=331361
* Check if the gettime runtime service is valid.Andrew Turner2018-03-201-0/+37
| | | | | | | | | | | | | | | | | | The U-Boot efi runtime service expects us to set the address map before calling any runtime services. It will then remap a few functions to their runtime version. One of these is the gettime function. If we call into this without having set a runtime map we get a page fault. Add a check to see if this is valid in efi_init() so we don't try to use the possibly invalid pointer. Reviewed by: imp, kevans (both previous version) X-MFC-With: r330868 Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14759 Notes: svn path=/head/; revision=331241
* Use EFI RTC capabilities info when registering, add bootverbose diagnostics.Ian Lepore2018-03-161-13/+65
| | | | | | | | | | | | | | | | | | | | Make some small improvements to the efirtc driver by obtaining the clock capabilities (resolution and whether the sub-second counters are reset) and using the info when registering the clock. When the hardware zeroes out the subsecond info on clock-set, schedule clock updates to happen just before top-of-second, so that the RTC time is closely in-sync with kernel time. Also, in the identify() routine, always add the driver if EFI runtime services are available, then decide in probe() whether to attach the driver or not. If not attaching and bootverbose is on, say why. All of this is basically to avoid "silent failure" -- if someone thinks there should be an efi rtc and it's not attaching, at least they can set bootverbose and maybe get a clue from the output. Differential Revision: https://reviews.freebsd.org/D14565 (timed out) Notes: svn path=/head/; revision=331068
* Correct minor typo in comment, efi_dmcap -> efi_tmcapKyle Evans2018-03-131-1/+1
| | | | Notes: svn path=/head/; revision=330844
* efirtc: Pass a dummy tmcap pointer to efi_get_time_lockedKyle Evans2018-03-131-1/+8
| | | | | | | | | | As noted in the comment, UEFI spec claims the capabilities pointer is optional, but some implementations will choke and attempt to dereference it without checking. This specific problem was found on a Lenovo Thinkpad X220 that would panic in efirtc_identify. Notes: svn path=/head/; revision=330843
* Add a function to retrieve the EFI realtime clock capabilities.Ian Lepore2018-03-011-3/+17
| | | | Notes: svn path=/head/; revision=330257
* Remove unused error return from API that cannot failConrad Meyer2018-02-231-7/+1
| | | | | | | | | | | | | | | | | | | No implementation of fpu_kern_enter() can fail, and it was causing needless error checking boilerplate and confusion. Change the return code to void to match reality. (This trivial change took nine days to land because of the commit hook on sys/dev/random. Please consider removing the hook or otherwise lowering the bar -- secteam never seems to have free time to review patches.) Reported by: Lachlan McIlroy <Lachlan.McIlroy AT isilon.com> Reviewed by: delphij Approved by: secteam (delphij) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14380 Notes: svn path=/head/; revision=329878
* Remove SFBUF_OPTIONAL_DIRECT_MAP and such hacks, replacing them across theNathan Whitehorn2018-01-191-0/+5
| | | | | | | | | | | | | | | | | | | kernel by PHYS_TO_DMAP() as previously present on amd64, arm64, riscv, and powerpc64. This introduces a new MI macro (PMAP_HAS_DMAP) that can be evaluated at runtime to determine if the architecture has a direct map; if it does not (or does) unconditionally and PMAP_HAS_DMAP is either 0 or 1, the compiler can remove the conditional logic. As part of this, implement PHYS_TO_DMAP() on sparc64 and mips64, which had similar things but spelled differently. 32-bit MIPS has a partial direct-map that maps poorly to this concept and is unchanged. Reviewed by: kib Suggestions from: marius, alc, kib Runtime tested on: amd64, powerpc64, powerpc, mips64 Notes: svn path=/head/; revision=328168
* Zero struct efi_tm before setting the needed values. We don't use the dstAndrew Turner2017-11-231-0/+1
| | | | | | | | | | or timezone fields so ensure these are set. Reported by: emaste Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=326121
* Add a driver for the EFI RTC. This uses the EFI Runtime Services to queryAndrew Turner2017-11-211-0/+151
| | | | | | | | | | | | | | | | | | | | | the system time. As we seem to only read this time on boot, and this is the only source of time on many arm64 machines we need to enable this by default there. As this is not always the case with U-Boot firmware, or when we have been booted from a non-UEFI environment we only enable the device driver when the Runtime Services are present and reading the time doesn't result in an error. PR: 212185 Reviewed by: imp, kib Tested by: emaste Relnotes: yes Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12650 Notes: svn path=/head/; revision=326066
* To prepare for adding EFI runtime services support on arm64 move theAndrew Turner2017-10-011-0/+388
| | | | | | | | | | | | machine independent parts of the existing code to a new file that can be shared between amd64 and arm64. Reviewed by: kib (previous version), imp Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12434 Notes: svn path=/head/; revision=324177
* Turns out to be even simpler to just not create /dev/efi if we don'tWarner Losh2017-08-081-13/+5
| | | | | | | have a efi runtime. Notes: svn path=/head/; revision=322279
* Fail to open efirt device when no EFI on system.Warner Losh2017-08-081-0/+13
| | | | | | | | | | | | | libefivar expects opening /dev/efi to indicate if the we can make efi runtime calls. With a null routine, it was always succeeding leading efi_variables_supported() to return the wrong value. Only succeed if we have an efi_runtime table. Also, while I'm hear, out of an abundance of caution, add a likely redundant check to make sure efi_systbl is not NULL before dereferencing it. I know it can't be NULL if efi_cfgtbl is non-NULL, but the compiler doesn't. Notes: svn path=/head/; revision=322278
* Do not try to create /dev/efi device node before devfs is initialized.Konstantin Belousov2016-10-161-14/+37
| | | | | | | | | | | | | | | | | | | | Split efirt.ko initialization into early stage where runtime services KPI environment is created, to be used e.g. for RTC, and the later devfs node creation stage, per module. Switch the efi device to use make_dev_s(9) instead of make_dev(9). At least, this gracefully handles the duplicated device name issue. Remove ARGSUSED comment from efidev_ioctl(), all unused arguments are annotated with __unused attribute. Reported by: ambrisko, O. Hartmann <ohartman@zedat.fu-berlin.de> Reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=307391
* Fix building on i386 and arm. But 'public domain' headers on the filesWarner Losh2016-10-131-9/+3
| | | | | | | | | | | with no creative content. Include "lost" changes from git: o Use /dev/efi instead of /dev/efidev o Remove redundant NULL checks. Submitted by: kib@, dim@, zbb@, emaste@ Notes: svn path=/head/; revision=307189
* Create /dev/efidev to provide an ioctl interface toWarner Losh2016-10-111-0/+199
userland. It supports userland interfaces to UEFI Runtime Services. This is indended to the the MI portion of EFI RuntimeServices support. Differential Revision: https://reviews.freebsd.org/D8128 Reviewed by: kib@, wblock@, Ganael Laplanche Notes: svn path=/head/; revision=307070