aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/acpica/acpi_wakeup.c
Commit message (Collapse)AuthorAgeFilesLines
* power: Add stype parameter in power_suspend/resume eventhandlersAymeric Wibo2025-10-061-2/+2
| | | | | | | | | | Add enum sleep_type stype parameter in power_suspend/resume event handlers, as with the introduction of s2idle there are more than one type of suspend. Reviewed by: bz Approved by: bz Sponsored by: The FreeBSD Foundation
* amd64: Remove support for "nooptions SMP"Mark Johnston2025-07-211-18/+0
| | | | | | | | | | | It does not appear to get much, if any, testing, and doesn't seem to be worth the maintenance overhead. Virtually all amd64 hardware has multiple cores. The CPU and memory usage overhead of the SMP option in single-vCPU VMs is quite marginal and not worth maintaining. Reviewed by: alc (pmap.c), kib Differential Revision: https://reviews.freebsd.org/D51403 Differential Revision: https://reviews.freebsd.org/D51345
* vmm: Correctly suspend and resume the vmm driver.Joshua Rogers2024-11-291-0/+3
| | | | | | | | | | | | | | | Previously, VMXON would be executed on a resume, contrary to proper initalization. The contents of MSR_IA32_FEATURE_CONTROL may be lost on suspension, therefore must be restored. Likewise, the VMX Enable bit may be cleared upon suspend, requiring it to be re-set. Concretely disable VMX on suspend, and re-enable it on resume. Note: any IOMMU context will remain lost for any enabled vmm devices. Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu> Reviewed by: jhb,imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1419
* Deprecate contigfree(9) in favour of free(9)Bjoern A. Zeeb2024-07-261-2/+1
| | | | | | | | | | | | | | | As of 9e6544dd6e02c46b805d11ab925c4f3b18ad7a4b contigfree(9) is no longer needed and should not be used anymore. We leave a wrapper for 3rd party code in at least 15.x but remove (almost) all other cases from the tree. This leaves one use of contigfree(9) untouched; that was the original trigger for 9e6544dd6e02 and is handled in D45813 (to be committed seperately later). Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Tested by: pho (10h stress test run) Differential Revision: https://reviews.freebsd.org/D46099
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* x86: AMD Zen2: Zenbleed chicken bit mitigationOlivier Certner2023-10-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applies only to bare-metal Zen2 processors. The system currently automatically applies it to all of them. Tunable/sysctl 'machdep.mitigations.zenbleed.enable' can be used to forcibly enable or disable the mitigation at boot or run-time. Possible values are: 0: Mitigation disabled 1: Mitigation enabled 2: Run the automatic determination. Currently, value 2 is the default and has identical effect as value 1. This might change in the future if we choose to take into account microcode revisions in the automatic determination process. The tunable/sysctl value is simply ignored on non-applicable CPU models, which is useful to apply the same configuration on a set of machines that do not all have Zen2 processors. Trying to set it to any integer value not listed above is silently equivalent to setting it to value 2 (automatic determination). The current mitigation state can be queried through sysctl 'machdep.mitigations.zenbleed.state', which returns "Not applicable", "Mitigation enabled" or "Mitigation disabled". Note that this state is not guaranteed to be accurate in case of intervening modifications of the corresponding chicken bit directly via cpuctl(4) (this includes the cpucontrol(8) utility). Resetting the desired policy through 'machdep.mitigations.zenbleed.enable' (possibly to its current value) will reset the hardware state and ensure that the reported state is again coherent with it. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41817
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* amd64 wakeup: recalculate mitigations after APICs are wokenKonstantin Belousov2023-03-291-5/+7
| | | | | | | | | | | APICs are needed to broadcast IPIs for MSR writes. PR: 270489 Reviewed by: dchagin, emaste, jhb Tested by: dchagin, manu Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39302
* acpi_wakeup.c: apply the reviewer' editorial corrections to the comment text.Konstantin Belousov2023-03-181-2/+2
| | | | | | Fixes: 02904a06c76be857307b78184863654b9e7b88ab MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39146
* amd64: properly recalculate mitigations knobs after resumeKonstantin Belousov2023-03-181-0/+14
| | | | | | | | | | | | | | | | | | Revision r333125 AKA 986c4ca38772f72 forced clear cpu_stdext_feature3 on suspend, since at that time microcode update was not reloaded early on resume. Then, revision 050f5a8405c63 started re-reading cpu_stdext_feature3 again. Since modern CPUs do not require mitigations from the Skylake era, this went unnoticed for some time. Keep zeroing cpu_stdext_feature3 on suspend, but re-read it in more controlled way on resume after microcode is reloaded, and recalculate active workarounds based on actual microcode capabilities. Reported and tested by: romain Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39146
* amd64 acpi_wakeup.c: fix typoKonstantin Belousov2023-03-171-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days
* amd64 wakeup: rework trampoline page allocationKonstantin Belousov2021-09-131-35/+44
| | | | | | | | | | | | | There is no need to restrict trampoline page table to low 1M, it should work with any pages below 4G. Only wakeup code itself should be below 1M. Do not waste level 5 page when LA48 mode is used. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31931
* x86: duplicate acpi_wakeup.c per i386 and amd64Konstantin Belousov2021-09-131-0/+440
| | | | | | | | | | | The file as is is the maze of #ifdef passages, all slightly different. Divorcing i386 and amd64 version actually makes changing the code easier, also no changes for i386 are planned. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31931
* Add x86/acpica/acpi_wakeup.c for amd64 and i386. Difference ofMitsuru IWASAKI2012-06-091-424/+0
| | | | | | | | | | | | | | | | | | | | | | | | | suspend/resume procedures are minimized among them. common: - Add global cpuset suspended_cpus to indicate APs are suspended/resumed. - Remove acpi_waketag and acpi_wakemap from acpivar.h (no longer used). - Add some variables in acpi_wakecode.S in order to minimize the difference among amd64 and i386. - Disable load_cr3() because now CR3 is restored in resumectx(). amd64: - Add suspend/resume related members (such as MSR) in PCB. - Modify savectx() for above new PCB members. - Merge acpi_switch.S into cpu_switch.S as resumectx(). i386: - Merge(and remove) suspendctx() into savectx() in order to match with amd64 code. Reviewed by: attilio@, acpi@ Notes: svn path=/head/; revision=236772
* Consistently use ACPI_SUCCESS() and ACPI_FAILURE() macros wherever possible.Jung-uk Kim2012-06-011-2/+1
| | | | Notes: svn path=/head/; revision=236424
* Tidy up code clutter in SMP case a bit. No functional change.Jung-uk Kim2012-06-011-10/+6
| | | | Notes: svn path=/head/; revision=236419
* Call AcpiSetFirmwareWakingVector() with interrupt disabled for consistency.Jung-uk Kim2012-06-011-2/+2
| | | | Notes: svn path=/head/; revision=236414
* Improve style(9) in the previous commit.Jung-uk Kim2012-06-011-3/+3
| | | | Notes: svn path=/head/; revision=236409
* Call AcpiLeaveSleepStatePrep() in interrupt disabled contextMitsuru IWASAKI2012-06-011-38/+47
| | | | | | | | | | | | | | | | | | | | | (described in ACPICA source code). - Move intr_disable() and intr_restore() from acpi_wakeup.c to acpi.c and call AcpiLeaveSleepStatePrep() in interrupt disabled context. - Add acpi_wakeup_machdep() to execute wakeup MD procedures and call it twice in interrupt disabled/enabled context (ia64 version is just dummy). - Rename wakeup_cpus variable in acpi_sleep_machdep() to suspcpus in order to be shared by acpi_sleep_machdep() and acpi_wakeup_machdep(). - Move identity mapping related code to acpi_install_wakeup_handler() (i386 version) for preparation of x86/acpica/acpi_wakeup.c (MFC candidate). Reviewed by: jkim@ MFC after: 2 days Notes: svn path=/head/; revision=236403
* Re-initialize model-specific MSRs when we resume CPUs.Jung-uk Kim2012-03-301-0/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=233704
* Merge ACPICA 20120320.Jung-uk Kim2012-03-201-1/+1
| | | | Notes: svn path=/head/; revision=233250
* Fix another witness panic. We cannot enter critical section at all becauseJung-uk Kim2012-03-201-2/+3
| | | | | | | | | | | AcpiEnterSleepState() executes (optional) _GTS method since ACPICA 20120215 (r231844). To evaluate the method, we need malloc(9), which may sleep. Reported by: bschmidt MFC after: 3 days Notes: svn path=/head/; revision=233249
* Fix a witness panic introduced in r231797.Jung-uk Kim2012-03-191-2/+2
| | | | | | | | | | Reported by: bschmidt Reviewed by: jhb Pointy hat to: jkim MFC after: 3 days Notes: svn path=/head/; revision=233208
* Refine r231791. Install the resume event handler unconditionally.Jung-uk Kim2012-02-161-18/+11
| | | | Notes: svn path=/head/; revision=231840
* Clean up RFLAG and CR3 register handling and nearby comments. For BSP, useJung-uk Kim2012-02-151-13/+4
| | | | | | | | | | | spinlock_enter()/spinlock_exit() to save/restore RFLAGS. We know interrupt is disabled when returning from S3. For AP, we do not have to save/restore it because IRET will do it for us any way. Do not save CR3 locally because savectx() does it and BSP does not have to switch to kernel map for amd64. Change contigmalloc(9) flag while I am in the neighborhood. Notes: svn path=/head/; revision=231797
* Set up an event handler to turn off speaker if user requested it. SpeakerJung-uk Kim2012-02-151-7/+22
| | | | | | | | will stop beeping after all device drivers are resumed. Use proper API to "acquire" and "release" PIC timer2 for consistency and correctness. Notes: svn path=/head/; revision=231791
* Reset clock after atrtc(4) is properly resumed.Jung-uk Kim2012-02-081-1/+0
| | | | Notes: svn path=/head/; revision=231227
* Fix a function prototype to reflect reality. No functional change.Jung-uk Kim2012-02-031-1/+1
| | | | Notes: svn path=/head/; revision=230957
* - Restore XCR0 before restoring extended FPU states.Jung-uk Kim2012-01-311-1/+2
| | | | | | | | | - Update my copyright dates. Reviewed by: kib Notes: svn path=/head/; revision=230830
* Add support for the extended FPU states on amd64, both for nativeKonstantin Belousov2012-01-211-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 64bit and 32bit ABIs. As a side-effect, it enables AVX on capable CPUs. In particular: - Query the CPU support for XSAVE, list of the supported extensions and the required size of FPU save area. The hw.use_xsave tunable is provided for disabling XSAVE, and hw.xsave_mask may be used to select the enabled extensions. - Remove the FPU save area from PCB and dynamically allocate the (run-time sized) user save area on the top of the kernel stack, right above the PCB. Reorganize the thread0 PCB initialization to postpone it after BSP is queried for save area size. - The dumppcb, stoppcbs and susppcbs now do not carry the FPU state as well. FPU state is only useful for suspend, where it is saved in dynamically allocated suspfpusave area. - Use XSAVE and XRSTOR to save/restore FPU state, if supported and enabled. - Define new mcontext_t flag _MC_HASFPXSTATE, indicating that mcontext_t has a valid pointer to out-of-struct extended FPU state. Signal handlers are supplied with stack-allocated fpu state. The sigreturn(2) and setcontext(2) syscall honour the flag, allowing the signal handlers to inspect and manipilate extended state in the interrupted context. - The getcontext(2) never returns extended state, since there is no place in the fixed-sized mcontext_t to place variable-sized save area. And, since mcontext_t is embedded into ucontext_t, makes it impossible to fix in a reasonable way. Instead of extending getcontext(2) syscall, provide a sysarch(2) facility to query extended FPU state. - Add ptrace(2) support for getting and setting extended state; while there, implement missed PT_I386_{GET,SET}XMMREGS for 32bit binaries. - Change fpu_kern KPI to not expose struct fpu_kern_ctx layout to consumers, making it opaque. Internally, struct fpu_kern_ctx now contains a space for the extended state. Convert in-kernel consumers of fpu_kern KPI both on i386 and amd64. First version of the support for AVX was submitted by Tim Bird <tim.bird am sony com> on behalf of Sony. This version was written from scratch. Tested by: pho (previous version), Yamagi Burmeister <lists yamagi org> MFC after: 1 month Notes: svn path=/head/; revision=230426
* Remove the usage of pc_other_cpus from amd64.Attilio Rao2011-06-211-1/+2
| | | | | | | Tested by: pluknet Notes: svn path=/projects/largeSMP/; revision=223363
* Commit the support for removing cpumask_t and replacing it directly withAttilio Rao2011-05-051-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cpuset_t objects. That is going to offer the underlying support for a simple bump of MAXCPU and then support for number of cpus > 32 (as it is today). Right now, cpumask_t is an int, 32 bits on all our supported architecture. cpumask_t on the other side is implemented as an array of longs, and easilly extendible by definition. The architectures touched by this commit are the following: - amd64 - i386 - pc98 - arm - ia64 - XEN while the others are still missing. Userland is believed to be fully converted with the changes contained here. Some technical notes: - This commit may be considered an ABI nop for all the architectures different from amd64 and ia64 (and sparc64 in the future) - per-cpu members, which are now converted to cpuset_t, needs to be accessed avoiding migration, because the size of cpuset_t should be considered unknown - size of cpuset_t objects is different from kernel and userland (this is primirally done in order to leave some more space in userland to cope with KBI extensions). If you need to access kernel cpuset_t from the userland please refer to example in this patch on how to do that correctly (kgdb may be a good source, for example). - Support for other architectures is going to be added soon - Only MAXCPU for amd64 is bumped now The patch has been tested by sbruno and Nicholas Esborn on opteron 4 x 12 pack CPUs. More testing on big SMP is expected to came soon. pluknet tested the patch with his 8-ways on both amd64 and i386. Tested by: pluknet, sbruno, gianni, Nicholas Esborn Reviewed by: jeff, jhb, sbruno Notes: svn path=/projects/largeSMP/; revision=221499
* Reinitialize PAT MSR via pmap_init_pat() while resuming. This function doesJung-uk Kim2010-11-231-1/+1
| | | | | | | better job since r215703 and it is safer now. Notes: svn path=/head/; revision=215753
* Move <machine/apicreg.h> to <x86/apicreg.h>.John Baldwin2010-11-011-1/+1
| | | | Notes: svn path=/head/; revision=214631
* Move the <machine/mca.h> header to <x86/mca.h>.John Baldwin2010-11-011-1/+1
| | | | Notes: svn path=/head/; revision=214630
* Reset switchtime to zero rather than the current CPU ticker (TSC) value.Jung-uk Kim2010-08-131-2/+2
| | | | | | | | | It is more appropriate in this context because TSC MSR is reset to zero when the CPU is restarted from S3 and above. Move acpi_resync_clock() back to where it was before r211202. It does not make a difference any more. Notes: svn path=/head/; revision=211292
* Reset switchtime and switchticks after resynchronizing the system clock.Jung-uk Kim2010-08-121-1/+3
| | | | | | | | This should fix weird runtime problem after resume on amd64. It also fixes "calcru: runtime went backwards" warnings with bootverbose. Notes: svn path=/head/; revision=211202
* Remove unnecessary casting and simplify code. We are not there yet. ;-)Jung-uk Kim2010-08-061-3/+1
| | | | Notes: svn path=/head/; revision=210942
* Correct argument order of acpi_restorecpu(), which was forgotten in r210804.Jung-uk Kim2010-08-061-1/+1
| | | | Notes: svn path=/head/; revision=210940
* - Merge savectx2() with savectx() and struct xpcb with struct pcb. [1]Jung-uk Kim2010-08-021-14/+13
| | | | | | | | | | | | | | | | | savectx() is only used for panic dump (dumppcb) and kdb (stoppcbs). Thus, saving additional information does not hurt and it may be even beneficial. Unfortunately, struct pcb has grown larger to accommodate more data. Move 512-byte long pcb_user_save to the end of struct pcb while I am here. - savectx() now saves FPU state unconditionally and copy it to the PCB of FPU thread if necessary. This gives panic dump and kdb a chance to take a look at the current FPU state even if the FPU is "supposedly" not used. - Resuming CPU now unconditionally reinitializes FPU. If the saved FPU state was irrelevant, it could be in an unknown state. Suggested by: bde [1] Notes: svn path=/head/; revision=210777
* Re-implement FPU suspend/resume for amd64. This removes superfluous usesJung-uk Kim2010-07-261-5/+0
| | | | | | | | | | of critical_enter(9) and critical_exit(9) by fpugetregs() and fpusetregs(). Also, we do not touch PCB flags any more. MFC after: 1 month Notes: svn path=/head/; revision=210514
* Restore the machine check register banks on resume. For banks beingJohn Baldwin2010-06-151-0/+2
| | | | | | | | | | monitored via CMCI, reset the interrupt threshold to 1 on resume. Reviewed by: jkim MFC after: 2 weeks Notes: svn path=/head/; revision=209212
* Fix ACPI suspend/resume on amd64, which was broken since r208833.Jung-uk Kim2010-06-141-1/+1
| | | | | | | We need actual storage for FPU state to save and restore. Notes: svn path=/head/; revision=209174
* Introduce the x86 kernel interfaces to allow kernel code to useKonstantin Belousov2010-06-051-1/+1
| | | | | | | | | | | | | | | | | | | FPU/SSE hardware. Caller should provide a save area that is chained into the stack of the areas; pcb save_area for usermode FPU state is on top. The pcb now contains a pointer to the current FPU saved area, used during FPUDNA handling and context switches. There is also a facility to allow the kernel thread to use pcb save_area. Change the dreaded warnings "npxdna in kernel mode!" into the panics when FPU usage is not registered. KPI discussed with: fabient Tested by: pho, fabient Hardware provided by: Sentex Communications MFC after: 1 month Notes: svn path=/head/; revision=208833
* Tweak memory allocation for amd64 suspend/resume CPU context.Jung-uk Kim2009-11-041-16/+14
| | | | Notes: svn path=/head/; revision=198931
* Clean up amd64 suspend/resume code.Jung-uk Kim2009-10-081-27/+22
| | | | | | | | | | | - Allocate memory for wakeup code after ACPI bus is attached. The early memory allocation hack was inherited from i386 but amd64 does not need it. - Exclude real mode IVT and BDA explicitly. Improve comments about memory allocation and reason for the exclusions. It is a no-op in reality, though. - Remove an unnecessary CLD from wakeup code and re-align. Notes: svn path=/head/; revision=197863
* Import ACPICA 20090521.Jung-uk Kim2009-06-051-1/+2
| | | | Notes: svn path=/head/; revision=193530
* Chase GDT layout changes and unbreak suspend/resume on amd64.Jung-uk Kim2009-04-021-18/+0
| | | | Notes: svn path=/head/; revision=190635
* - Clean up suspend/resume code for amd64.Jung-uk Kim2009-03-231-8/+5
| | | | | | | | | | | - Call acpi_resync_clock() to reset system time before hardclock is ready to tick. Note we assume the current timecounter hardware and RTC are already available for read operation. Tested by: mav Notes: svn path=/head/; revision=190341