diff options
author | jkim <jkim@FreeBSD.org> | 2012-03-30 16:32:41 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2012-03-30 16:32:41 +0000 |
commit | 6cd4f250111b610bf48172c9845d9bf88ea97fca (patch) | |
tree | d6edf2a74e4afa7f26c21a9acde6bf9099669d16 | |
parent | 07d4fd218fa5d503420c9ab5bade13ee89480e8e (diff) | |
download | FreeBSD-src-6cd4f250111b610bf48172c9845d9bf88ea97fca.zip FreeBSD-src-6cd4f250111b610bf48172c9845d9bf88ea97fca.tar.gz |
Work around Erratum 721 for AMD Family 10h and 12h processors.
"Under a highly specific and detailed set of internal timing conditions,
the processor may incorrectly update the stack pointer after a long series
of push and/or near-call instructions, or a long series of pop and/or
near-return instructions. The processor must be in 64-bit mode for this
erratum to occur."
MFC after: 3 days
-rw-r--r-- | sys/amd64/amd64/initcpu.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 02588af..3890551 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -79,6 +79,27 @@ SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD, SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD, &via_feature_xcrypt, 0, "VIA xcrypt feature available in CPU"); +static void +init_amd(void) +{ + + /* + * Work around Erratum 721 for Family 10h and 12h processors. + * These processors may incorrectly update the stack pointer + * after a long series of push and/or near-call instructions, + * or a long series of pop and/or near-return instructions. + * + * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf + * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf + */ + switch (CPUID_TO_FAMILY(cpu_id)) { + case 0x10: + case 0x12: + wrmsr(0xc0011029, rdmsr(0xc0011029) | 1); + break; + } +} + /* * Initialize special VIA features */ @@ -135,8 +156,14 @@ initializecpu(void) wrmsr(MSR_EFER, msr); pg_nx = PG_NX; } - if (cpu_vendor_id == CPU_VENDOR_CENTAUR) + switch (cpu_vendor_id) { + case CPU_VENDOR_AMD: + init_amd(); + break; + case CPU_VENDOR_CENTAUR: init_via(); + break; + } } void |