Commit Graph

3298 Commits

Author SHA1 Message Date
skrll d40146f873 Convert the l2->l_md.md_astpending assignments into KASSERTs.
l_md is zeroised by lwp_create with

         memset(&l2->l_startzero, 0, sizeof(*l2) -
                    offsetof(lwp_t, l_startzero));
2023-10-06 11:53:26 +00:00
ad 68fa584377 Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
2023-10-05 19:41:03 +00:00
ad a355028fa4 Eliminate l->l_ncsw and l->l_nivcsw. From memory think they were added
before we had per-LWP struct rusage; the same is now tracked there.
2023-10-04 20:28:05 +00:00
christos 5652437218 protect against multiple inclusion 2023-09-16 13:37:10 +00:00
ad e5d38798d7 tsc_get_timecount(): cover the backwards check by DIAGNOSTIC since it has
proven the point by now.
2023-09-09 18:37:03 +00:00
riastradh 77901f27b5 xen: Provide definitions or ifdefs to make drm build in XEN3_DOM0.
No idea if it works, but it builds now.

PR port-xen/49330
2023-08-25 08:05:18 +00:00
msaitoh 3001bf9234 Update /proc/cpuinfo.
- Move "ssbd" to an unused Linux mapping.
 - Update unused Linux mappings.
2023-08-07 09:27:14 +00:00
msaitoh 690f64d68b Fix detection of availability of MSI/MSI-X on some systems.
Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.
2023-08-07 06:23:39 +00:00
riastradh 762dda02dd xen: Report when hardclock jump exceeds timecounter(9) limit. 2023-08-01 19:36:57 +00:00
mrg ae65bbf7c0 x86: make the CPUID list for errata be far less confusing
the 0x80000001 CPUID result needs some parsing to match against
actual family/model/stepping values.  4-bit 'family' values of
15 or 6 change how to parse the 4-bit extended model and 8-bit
extended family value - for family 6 or 15, the extended model
bits (4) are concatenated with the base 4-bits to create an
8-bit value, and for family 15, the family value is addition
of the family value and the 8-bit extended-family value, giving
a range of 0 to 15 + 0xff aka 270.

use a CPUREV(family, model, stepping) macro that builds the
relevant bit-representation of a CPUID, making it far easier
to understand what each entry means, and to add new ones too.

i have confirmed that the emitted cpurevs[] array has the same
values before/after this change, ie, NFCI or observed.
2023-07-28 05:02:13 +00:00
msaitoh 1b9c9e4ea1 Add Zen4 Phoenix support. 2023-07-28 02:28:33 +00:00
msaitoh b39e984dd8 Add Zen2 Mendocino APU support. 2023-07-28 02:05:26 +00:00
msaitoh f2d8fd5032 Add Zen4 Ryzen "Phoenix" support. 2023-07-28 00:11:15 +00:00
msaitoh 3a03d8aff6 Add AMD IBPB_RET and BusLockThreshold. 2023-07-27 00:34:07 +00:00
riastradh fcc4e284a5 x86/pmap: Print quantities in failed assertions in pmap_load. 2023-07-26 21:45:28 +00:00
mrg c26e77ddaa fix the cpuids for the zen2 client CPUs.
i'm not exactly how i came up with the values i had, though one
of them was still valid and matched my test systems.

XXX: pullup-*
2023-07-26 00:19:04 +00:00
mrg fae28649cb x86: turn off zenbleed chicken bit on Zen2 cpus.
this is based upon Taylor's original work.  i just made the list
of CPUs to run on correct as i could determine.  (also, add some
Zen3 and Zen4 cpuids not yet used by any errata.)

(might be nice to have a better way to expression revision ranges
rather than specific cpuid matches, eg, 0x30-0x4f models in a cpu
family, etc.)

tested on ryzen 3600, and a ported zenbleed PoC that no longer
shows any obtained text.  (a similar module-version of it stopped
the PoC on a ryzen 3950x without having to reboot.)

https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7008.html
https://lock.cmpxchg8b.com/zenbleed.html
2023-07-25 01:09:05 +00:00
riastradh 170e57918e x86/errata.c: Only say the errata revision search for cpu0. 2023-07-24 23:42:00 +00:00
riastradh 681441f85c x86/errata.c: Say what revision we're searching for. 2023-07-24 22:21:08 +00:00
riastradh 67ea782769 x86/errata.c: Link to original AMD errata guide.
This one is no longer updated; need to link to newer ones for
individual families too.  That's where all the cryptic nomenclature
comes from here.
2023-07-24 22:20:53 +00:00
riastradh 4bbd915466 x86/fpu: In kernel mode fpu traps, print the instruction pointer. 2023-07-18 12:34:25 +00:00
riastradh e5bb5c65ba x86: Sprinkle extensive commentary about %fs/%gs initialization.
Plus some other side quests like the three-stage GDT metamorphosis
lifecycle.

No functional change intended.
2023-07-16 19:55:43 +00:00
riastradh 93889e4a72 xen: Record event when local view of timecounter is behind global. 2023-07-13 13:34:15 +00:00
riastradh a37b57a44d Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex.  Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT.  Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.
2023-07-13 12:06:20 +00:00
msaitoh ef9eb41389 coretemp(4): Change limits of Tjmax.
- Change the lower limit from 70 to 60. At least, some BIOSes can change
   the value down to 62.
 - Change the upper limit from 110 to 120. At least, some BIOSes can change
   the value up to 115.
 - Print error message when rdmsr(TEMPERATURE_TARGET) failed.
 - When Tjmax exceeded the limit, print warning message and use the value
   as it is.
2023-07-13 09:12:23 +00:00
riastradh a884545629 machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.
Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h.  And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.
2023-07-12 12:50:12 +00:00
rin fb9e2578de Make PCI_ADDR_FIXUP depended on PCI_BUS_FIXUP.
It is no-op if PCI_BUS_FIXUP is missing.
2023-06-14 01:27:47 +00:00
riastradh ad8e3babd1 efi(4): Implement EFIIOC_GET_TABLE on x86.
PR kern/57076

XXX pullup-10
2023-05-22 16:28:07 +00:00
riastradh 300b116152 efi(4): Move error macros to efi.h.
PR kern/57076

XXX pullup-10
2023-05-22 16:27:48 +00:00
andvar a4d536841f s/requied/required/ in comments (likely grammar should be also improved in the
future).
2023-05-13 11:27:10 +00:00
riastradh b63b081b04 x86/imc(4): Use config_detach_children. 2023-05-10 00:07:49 +00:00
riastradh f653f1027c ichlpcib(4): Use config_detach_children.
Delete a lot of unnecessary code with broken error branches involving
config_detach which have probably seldom if ever been exercised.

No substantive functional change intended.  Low risk because
ichlpcib(4) is not a removable device, so you have to go out of your
way to exercise detach.
2023-05-09 23:11:09 +00:00
riastradh 041c9795a9 ichlpcib(4): KNF. No functional change intended. 2023-05-09 23:10:11 +00:00
riastradh 1d6f2ebdcc ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.
TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4).  On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand.  (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
2023-04-12 06:39:15 +00:00
riastradh 7eb9e43093 x86: Omit needless membar_sync in intr_disestablish_xcall.
Details in comments.
2023-04-11 13:11:01 +00:00
msaitoh 2af65ea393 Fix compile error. 2023-04-11 06:42:30 +00:00
msaitoh 8049c07d6d Add CPUID 0x07 %ecx bit 24 BUS_LOCK_DETECT. 2023-04-11 02:44:06 +00:00
msaitoh fb4f16865d Add Intel lam and AMD vnmi. 2023-04-11 02:42:15 +00:00
riastradh c3a044b881 x86/bus_dma.c: Sprinkle KASSERTMSG. 2023-03-28 19:55:42 +00:00
andvar ab7b35f350 s/Predective/Predictive/ and s/dedected/detected/ in comments. 2023-03-25 21:47:10 +00:00
bouyer 696711b54b Allow a PVH dom0 to use VGA as console: make xen_pvh_consinit() return 1 if
it handles the console and 0 otherwise (especially when console=tty0 or
console=pc is present on the command line).
In consinit() fallback to native console selection if xen_pvh_consinit()
returns 0.
2023-03-24 12:28:42 +00:00
bouyer 3b2582233e mpacpi_config_cpu(): Xen with a PVH dom0 reports x2apic->LocalApicId
below 0xff, which causes a panic later because no CPUs are attached.
Accept the bogus LocalApicId value for VM_GUEST_XENPVH.
2023-03-24 12:25:28 +00:00
riastradh a4ca83ca25 x86/fpu: Align savefpu to 64 bytes in fpuinit_mxcsr_mask.
16 bytes is not enough.

(Is this why it never worked on Xen some years back?  Got lucky and
accidentally had 64-byte alignment on native x86, but not in the call
stack in Xen?)

XXX pullup-10
2023-03-03 14:40:16 +00:00
riastradh f9112e4de0 x86: Call fpuinit_mxcsr_mask only once.
No need to call it again and again on the secondary CPUs to compute
what should be the same mxcsr mask.  (If it's not, we have deeper
problems!)
2023-03-03 14:40:00 +00:00
riastradh 32723a3bac Revert "x86: Add kthread_fpu_enter/exit support, take two."
kthread_fpu_enter/exit changes broke some hardware, unclear why, to
investigate before fixing and reapplying these changes.
2023-03-03 14:32:48 +00:00
riastradh 1a7b1b3e34 Revert "x86/fpu.c: Sprinkle KNF."
kthread_fpu_enter/exit changes broke some hardware, unclear why, to
investigate before fixing and reapplying these changes.
2023-03-03 14:32:38 +00:00
riastradh 0ddb09c5c9 x86/fpu.c: Sprinkle KNF.
No functional change intended.
2023-02-25 18:28:57 +00:00
riastradh 0dafb3bd57 x86: Add kthread_fpu_enter/exit support, take two.
This time, make sure to restore the FPU state when switching to a
kthread in the middle of kthread_fpu_enter/exit.

This adds a single predicted-taken branch for the case of kthreads
that are not in kthread_fpu_enter/exit, so it incurs a penalty only
for threads that actually use it.  Since it avoids FPU state
switching in kthreads that do use the FPU, namely cgd worker threads,
this should be a net performance win on systems using it and have
negligible impact otherwise.

XXX pullup-10
2023-02-25 18:04:42 +00:00
riastradh 0a4b6dc8b4 x86: Label boolean is_64bit argument to fpu_area_restore.
No functional change intended.
2023-02-25 18:04:25 +00:00
riastradh a89583ca1c x86: Mitigate MXCSR Configuration Dependent Timing in kernel FPU use.
In fpu_kern_enter, make sure all the MXCSR exception status bits are
set when we start using the FPU, so that instructions which exhibit
MCDT are unaffected by it.

While here, zero all the other FPU registers in fpu_kern_enter.

In principle we could skip this step on future CPUs that fix the MCDT
bug, but there's probably not much benefit -- workloads that do a lot
of crypto in the kernel are probably better off using
kthread_fpu_enter or WQ_FPU to skip the fpu_kern_enter/leave cycles
in the first place.

For details, see:
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html
2023-02-25 13:57:37 +00:00