Commit Graph

53 Commits

Author SHA1 Message Date
ad 570e015d07 - Recalibrate the APIC timer using the TSC, once the TSC has in turn been
recalibrated using the HPET.  This gets the clock interrupt firing more
  closely to HZ.

- Undo change with recent Xen merge and go back to starting the clocks in
  initclocks() on the boot CPU, and in cpu_hatch() on secondary CPUs.

- On reflection don't use HPET delay any more, it works very well but means
  going over the bus.  It's enough to use HPET to calibrate the TSC and
  APIC.

Tested on amd64 native, xen and xen PVH.
2020-05-21 21:12:30 +00:00
chs 5d4d9a2027 remove some unnecessary includes of internal UVM headers. 2020-02-22 19:49:11 +00:00
maxv 560337f76b Rewrite the FPU code on x86. This greatly simplifies the logic and removes
the dependency on IPL_HIGH. NVMM is updated accordingly. Posted on
port-amd64 a week ago.

Bump the kernel version to 9.99.16.
2019-10-12 06:31:03 +00:00
jmcneill 2b33f18bc8 The second parameter to AcpiSetFirmwareWakingVector sets the
X_Firmware_Waking_Vector field (where supported), which will cause firmware
to resume in protected mode. Since our wake code assumes real mode, always
set X_Firmware_Waking_Vector to 0.
2019-06-17 16:34:02 +00:00
maxv 3eef1a860c Initialize the errata MSRs when waking up, otherwise they are clear and
we're re-enabling certain CPU bugs.
2017-09-23 10:38:59 +00:00
maxv f54b02d72d Reinitialize the PAT MSR when waking up, otherwise the write-combined
pages become write-through.
2017-09-23 10:00:00 +00:00
maya 04676939ae Remove unused macro 2017-09-19 01:22:14 +00:00
maxv 23b508113d Save and restore xcr0 when doing ACPI sleeps. Should fix PR/49174. 2017-08-10 13:13:03 +00:00
maxv 21053717d0 There is a huge fpu synchronization issue here.
When the remote CPUs receive the ACPI sleep IPI, they do not save the fpu
state of the lwp they are executing. The problem is, when waking up they
reinitialize the registers of their local fpu and go back to their lwp
directly. Therefore, if an lwp is interrupted while storing data in an fpu
register, that data gets overwritten, which basically means the lwp is
likely to go crazy when resuming execution.

Fix this by simply saving the fpu state correctly. This way when going to
sleep the state is stored in the lwp's pcb and CR0_TS is set, so the next
time the lwp wants to use the fpu we'll get a dna, and the state will be
restored as expected.

While here, don't forget to reenable interrupts (and the spl) if an error
occurs.
2016-10-20 16:05:04 +00:00
maxv 72c89a7fde Reload the MSRs on the original cpu on i386 - looks like I forgot this part
in my rev1.41. Technically it does not change anything, since the only MSR
is NOX and it is already reloaded in the trampoline.
2016-10-20 14:06:18 +00:00
skrll dfeefb1044 Don't include sys/cdefs.h and __KERNEL_RSCID twice... once is enough. 2016-10-07 10:58:03 +00:00
maya ea5e1f9b0e use a value of hw.acpi.sleep.vbios that might actually
work for any real hardware suspend.

stop dragging feet through the ground in PR kern/50781
2016-09-20 08:38:55 +00:00
maxv 079335f30f Call cpu_init_msrs on i386 when waking up. Currently it does not change
anything, since MSR_EFER is already enabled earlier. But if we add new
MSRs in the future, we will want them when waking up as well.
2016-07-27 13:04:28 +00:00
maxv d93fe1fd9b The MSR EFER state is not saved and restored when sleeping on i386. On PAE,
the CPU crashes right after waking up, since it needs to access NOX-ed
pages, which are to be enabled in an MSR.

Fix this by properly saving and restoring the EFER MSR. It's a little
tricky since the wakeup code uses %edx, but rdmsr overwrites it. We just
save it in %esi.

Now, the CPU sleeps properly on PAE kernels.
2016-07-24 14:09:22 +00:00
christos b5644fd55b dup the argument of the wakeup vector. XXX: is that correct? 2015-08-18 10:42:41 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
dsl 480bf53618 Add explicit #include <x86/fpu.h> instead of relying on pcb.h including it. 2014-02-19 21:23:01 +00:00
dsl 742d777c6d Move sys/arch/amd64/amd64/fpu.c and sys/arch/amd64/include/fpu.h
into sys/arch/x86 in preparation for using the same code for i386.
2014-02-11 20:17:16 +00:00
dsl 51a0d6b173 Remove support for 'external' floating point units and the MS-DOS
compatible method of handling floating point exceptions.
Make kernel support for teh fpu non-optional (486SX should still work).
Only 386 cpus support external fpu, and i386 support was removed years ago.
This means that the npx code no longer uses port 0xf0 or interupt 13.
All the "npx at isa" lines go from the configs, arch/i386/isa/npx.c
  is now mandatory for all i386 kernels.
I've renamed npxinit() to fpuinit() and npxinit_cpu() to fpuinit_cpu()
  to match the very similar amd64 functions.
The fpu of the boot cpu is now initialised by a direct call from
  cpu_configure(), this enables FP emulation for a 486SX.
  (for amd64 the cr0 values are set in locore.S and similar).
This fixes a long-standing bug in linux_setregs() - which did not
  save the fpu regsiters if they were active.
I've test booted a single cpu i386 kernel (using anita).
amd64 builds - none of teh changes should affect it.
The i386 XEN kernels build, but I'm not sure where they set cr0, and
  it might have got lost!
2014-01-26 19:16:16 +00:00
christos f0ceb57840 revert fpu/pcu changes until we figure out what's wrong; they cause random
freezes
2013-12-01 01:05:16 +00:00
drochner 23780ff8df Use the MI "pcu" framework for bookkeeping of npx/fpu states on x86.
This reduces the amount of MD code enormously, and makes it easier
to implement support for newer CPU features which require more fpu
state, or for fpu usage by the kernel.
For access to FPU state across CPUs, an xcall kthread is used now
rather than a dedicated IPI.
No user visible changes intended.
2013-10-23 20:18:50 +00:00
jakllsch d4db18a6af It turns out we're actually waiting for other processors to be unbusy, not busy.
Unbreaks ACPI suspend on uniprocessor.  Probably fixes unnoticed bugs on MP.
Needs pullup to netbsd-6.
2012-08-26 01:04:03 +00:00
rmind 0c79472223 - Convert x86 MD code, mainly pmap(9) e.g. TLB shootdown code, to use
kcpuset(9) and thus replace hardcoded CPU bitmasks.  This removes the
  limitation of maximum CPUs.

- Support up to 256 CPUs on amd64 architecture by default.

Bug fixes, improvements, completion of Xen part and testing on 64-core
AMD Opteron(tm) Processor 6282 SE (also, as Xen HVM domU with 128 CPUs)
by Manuel Bouyer.
2012-04-20 22:23:24 +00:00
jruoho 0addcacfb8 Now that 6.0 is branched, remove the ACPI-related sysctl nodes in machdep. 2012-04-10 13:48:24 +00:00
dyoung 391925c74f #include <sys/bus.h> instead of <machine/bus.h>. 2011-07-01 18:21:31 +00:00
jruoho 7cfe5d0423 Explicitly re-enable the SCI interrupt when the wakeup starts (and before
interrupts are enabled). A workaround for a BIOS bug. Fixes the interrupt
storm reported by Taylor R. Campbell in PR # 44581.
2011-02-16 18:55:50 +00:00
jruoho 55bd26d109 Add a comment. 2011-01-13 03:45:38 +00:00
jruoho b99cdd8ef8 Move the ACPI sleep-specific sysctl variables to hw.acpi.sleep. The old
machdep-variables are provided for backwards compatibility (eventually these
should be removed). All ACPI sysctl variables are now under hw.acpi.
2010-12-31 09:19:43 +00:00
jruoho 18bb71aebc Remove the custom enter_s4_with_bios(). Use ACPICA's native
AcpiEnterSleepStateS4bios() instead. Minimum functional change.

ok jmcneill@
2010-07-29 11:40:08 +00:00
jruoho c0c31ce929 Use acpi_eval_set_integer(), KNF. No functional change. 2010-07-28 18:10:31 +00:00
jruoho 75373338c1 UINT32 -> uint32_t; UINT8 -> uint8_t. 2010-04-14 19:32:35 +00:00
jruoho 56bdff1846 Use CTLTYPE_BOOL. 2010-04-11 09:52:09 +00:00
jruoho 0f58ad7ae9 Use native functions instead of polluting the namespace with ACPICA-macros. 2010-02-28 13:56:49 +00:00
cegger 9480c51b04 Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
2009-11-07 07:27:40 +00:00
cegger 62cf489d8e kill extra whitespaces
reviewed by tsutsui@
2009-10-26 19:16:54 +00:00
joerg 292e598a25 Be a bit more noisy by telling the user VGA_POST is missing in the
kernel config when trying machdep.acpi_vbios_reset=2.
2009-09-02 15:42:31 +00:00
joerg 12cda29892 Don't allow machdep.acpi_vbios_reset=2 if option VGA_POST is missing. 2009-09-02 15:25:07 +00:00
jmcneill b585cf85b2 Pass the VBE mode number from the bootloader to the kernel, and then
make the ACPI wakecode aware of it. Restore the desired VBE mode on resume
when acpi_vbios_reset=1, so suspend/resume with genfb console will work.
2009-08-24 02:15:46 +00:00
jmcneill b0fb7abfad Switch to ACPICA 20090730, and update for API changes. 2009-08-18 16:41:02 +00:00
drochner bf4f01a782 Rearrange TSC inter-CPU synchronization code so that the gory details
are dealt with in x86/tsc.c and callers don't have to care that much.
Also add some comments and make some variables static.
approved by ad (a while ago)
2009-03-27 19:53:19 +00:00
cegger e2cb85904d bcopy -> memcpy 2009-03-18 17:06:41 +00:00
drochner 7ad644e970 sync TSC on resume (because CPUs were switched off in the meantime),
otherwise we get diverging timecounters leading to eg the monotonic
clock jump backwards
(pullup candidate)
2009-02-26 19:49:15 +00:00
joerg a5be52d405 On resum-from-RAM explicitly restore PCI link device state before
reenabling interrupts. At least one BIOS doesn't do this automatically
as reported by Christoph Egger.
2008-11-17 23:29:49 +00:00
joerg 916a606f2a Explicitly disable all GPEs and clear fixed events before enabling
interrupts. This is the first part of PR 38683.
2008-09-23 14:54:23 +00:00
jmcneill 13e32ea2ea Revert previous. 2008-09-19 11:15:50 +00:00
jmcneill b1cb1c6dcb PR# 38683 - T61 cannot suspend with recent kernels
Don't restore spl until after AcpiLeaveSleepState.
2008-09-10 03:56:12 +00:00
joerg 0b2a6aef84 machdep.acpi_vbios_reset = 2 --> vga_pci_resume will use x86emu to do a
POST when options VGA_POST is present.
2008-07-31 14:05:05 +00:00
ad f674d9678b Share cpu.h between the x86 ports. 2008-05-11 15:32:20 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
jmcneill 8843b0cbbb Disable machdep.acpi_beep_on_reset by default. 2008-04-03 10:20:18 +00:00