2005-04-16 15:20:36 -07:00
|
|
|
/* Generic MTRR (Memory Type Range Register) driver.
|
|
|
|
|
|
|
|
Copyright (C) 1997-2000 Richard Gooch
|
|
|
|
Copyright (c) 2002 Patrick Mochel
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
Richard Gooch may be reached by email at rgooch@atnf.csiro.au
|
|
|
|
The postal address is:
|
|
|
|
Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
|
|
|
|
|
|
|
|
Source: "Pentium Pro Family Developer's Manual, Volume 3:
|
|
|
|
Operating System Writer's Guide" (Intel document number 242692),
|
|
|
|
section 11.11.7
|
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
This was cleaned and made readable by Patrick Mochel <mochel@osdl.org>
|
|
|
|
on 6-7 March 2002.
|
|
|
|
Source: Intel Architecture Software Developers Manual, Volume 3:
|
2005-04-16 15:20:36 -07:00
|
|
|
System Programming Guide; Section 9.11. (1997 edition - PPro).
|
|
|
|
*/
|
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
#include <linux/types.h> /* FIXME: kvm_para.h needs this */
|
|
|
|
|
2010-07-30 11:46:42 -07:00
|
|
|
#include <linux/stop_machine.h>
|
2009-07-04 07:56:28 +05:30
|
|
|
#include <linux/kvm_para.h>
|
|
|
|
#include <linux/uaccess.h>
|
2016-07-13 20:19:01 -04:00
|
|
|
#include <linux/export.h>
|
2009-07-04 07:56:28 +05:30
|
|
|
#include <linux/mutex.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/init.h>
|
2009-07-04 07:56:28 +05:30
|
|
|
#include <linux/sort.h>
|
|
|
|
#include <linux/cpu.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/smp.h>
|
2011-03-23 22:15:54 +01:00
|
|
|
#include <linux/syscore_ops.h>
|
2018-05-22 09:50:53 -07:00
|
|
|
#include <linux/rcupdate.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2022-11-02 08:47:00 +01:00
|
|
|
#include <asm/cacheinfo.h>
|
2016-01-26 22:12:04 +01:00
|
|
|
#include <asm/cpufeature.h>
|
2017-01-27 10:27:10 +01:00
|
|
|
#include <asm/e820/api.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/mtrr.h>
|
|
|
|
#include <asm/msr.h>
|
2019-11-20 15:33:57 +01:00
|
|
|
#include <asm/memtype.h>
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#include "mtrr.h"
|
|
|
|
|
x86/cpu: KVM: Add common defines for architectural memory types (PAT, MTRRs, etc.)
Add defines for the architectural memory types that can be shoved into
various MSRs and registers, e.g. MTRRs, PAT, VMX capabilities MSRs, EPTPs,
etc. While most MSRs/registers support only a subset of all memory types,
the values themselves are architectural and identical across all users.
Leave the goofy MTRR_TYPE_* definitions as-is since they are in a uapi
header, but add compile-time assertions to connect the dots (and sanity
check that the msr-index.h values didn't get fat-fingered).
Keep the VMX_EPTP_MT_* defines so that it's slightly more obvious that the
EPTP holds a single memory type in 3 of its 64 bits; those bits just
happen to be 2:0, i.e. don't need to be shifted.
Opportunistically use X86_MEMTYPE_WB instead of an open coded '6' in
setup_vmcs_config().
No functional change intended.
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Kai Huang <kai.huang@intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20240605231918.2915961-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-06-05 16:19:09 -07:00
|
|
|
static_assert(X86_MEMTYPE_UC == MTRR_TYPE_UNCACHABLE);
|
|
|
|
static_assert(X86_MEMTYPE_WC == MTRR_TYPE_WRCOMB);
|
|
|
|
static_assert(X86_MEMTYPE_WT == MTRR_TYPE_WRTHROUGH);
|
|
|
|
static_assert(X86_MEMTYPE_WP == MTRR_TYPE_WRPROT);
|
|
|
|
static_assert(X86_MEMTYPE_WB == MTRR_TYPE_WRBACK);
|
|
|
|
|
2013-05-13 23:58:40 +00:00
|
|
|
/* arch_phys_wc_add returns an MTRR register index plus this offset. */
|
|
|
|
#define MTRR_TO_PHYS_WC_OFFSET 1000
|
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
u32 num_var_ranges;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-10-09 16:01:52 +08:00
|
|
|
unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];
|
2023-05-02 14:09:26 +02:00
|
|
|
DEFINE_MUTEX(mtrr_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-01-31 20:16:34 +01:00
|
|
|
const struct mtrr_ops *mtrr_if;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Returns non-zero if we have the write-combining memory type */
|
|
|
|
static int have_wrcomb(void)
|
|
|
|
{
|
|
|
|
struct pci_dev *dev;
|
2009-07-04 07:56:28 +05:30
|
|
|
|
|
|
|
dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL);
|
|
|
|
if (dev != NULL) {
|
|
|
|
/*
|
|
|
|
* ServerWorks LE chipsets < rev 6 have problems with
|
|
|
|
* write-combining. Don't allow it and leave room for other
|
|
|
|
* chipsets to be tagged
|
|
|
|
*/
|
2005-04-16 15:20:36 -07:00
|
|
|
if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
|
2011-07-01 22:42:08 +04:00
|
|
|
dev->device == PCI_DEVICE_ID_SERVERWORKS_LE &&
|
|
|
|
dev->revision <= 5) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_info("Serverworks LE rev < 6 detected. Write-combining disabled.\n");
|
2011-07-01 22:42:08 +04:00
|
|
|
pci_dev_put(dev);
|
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
/*
|
|
|
|
* Intel 450NX errata # 23. Non ascending cacheline evictions to
|
|
|
|
* write combining memory may resulting in data corruption
|
|
|
|
*/
|
2005-04-16 15:20:36 -07:00
|
|
|
if (dev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_info("Intel 450NX MMC detected. Write-combining disabled.\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
pci_dev_put(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
pci_dev_put(dev);
|
2009-07-04 07:56:28 +05:30
|
|
|
}
|
|
|
|
return mtrr_if->have_wrcomb ? mtrr_if->have_wrcomb() : 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __init init_table(void)
|
|
|
|
{
|
|
|
|
int i, max;
|
|
|
|
|
|
|
|
max = num_var_ranges;
|
|
|
|
for (i = 0; i < max; i++)
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
mtrr_usage_table[i] = 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct set_mtrr_data {
|
|
|
|
unsigned long smp_base;
|
|
|
|
unsigned long smp_size;
|
|
|
|
unsigned int smp_reg;
|
|
|
|
mtrr_type smp_type;
|
|
|
|
};
|
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
/**
|
2011-06-23 11:19:29 -07:00
|
|
|
* mtrr_rendezvous_handler - Work done in the synchronization handler. Executed
|
|
|
|
* by all the CPUs.
|
2010-03-05 09:52:52 -08:00
|
|
|
* @info: pointer to mtrr configuration data
|
2009-07-04 07:56:28 +05:30
|
|
|
*
|
|
|
|
* Returns nothing.
|
|
|
|
*/
|
2011-06-23 11:19:29 -07:00
|
|
|
static int mtrr_rendezvous_handler(void *info)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct set_mtrr_data *data = info;
|
|
|
|
|
2022-11-02 08:47:09 +01:00
|
|
|
mtrr_if->set(data->smp_reg, data->smp_base,
|
|
|
|
data->smp_size, data->smp_type);
|
2010-07-30 11:46:42 -07:00
|
|
|
return 0;
|
2007-11-09 22:39:38 +01:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
static inline int types_compatible(mtrr_type type1, mtrr_type type2)
|
|
|
|
{
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
return type1 == MTRR_TYPE_UNCACHABLE ||
|
|
|
|
type2 == MTRR_TYPE_UNCACHABLE ||
|
|
|
|
(type1 == MTRR_TYPE_WRTHROUGH && type2 == MTRR_TYPE_WRBACK) ||
|
|
|
|
(type1 == MTRR_TYPE_WRBACK && type2 == MTRR_TYPE_WRTHROUGH);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/**
|
|
|
|
* set_mtrr - update mtrrs on all processors
|
|
|
|
* @reg: mtrr in question
|
|
|
|
* @base: mtrr base
|
|
|
|
* @size: mtrr size
|
|
|
|
* @type: mtrr type
|
|
|
|
*
|
|
|
|
* This is kinda tricky, but fortunately, Intel spelled it out for us cleanly:
|
2009-07-04 07:56:28 +05:30
|
|
|
*
|
2010-07-30 11:46:42 -07:00
|
|
|
* 1. Queue work to do the following on all processors:
|
2005-04-16 15:20:36 -07:00
|
|
|
* 2. Disable Interrupts
|
2009-07-04 07:56:28 +05:30
|
|
|
* 3. Wait for all procs to do so
|
2005-04-16 15:20:36 -07:00
|
|
|
* 4. Enter no-fill cache mode
|
|
|
|
* 5. Flush caches
|
|
|
|
* 6. Clear PGE bit
|
|
|
|
* 7. Flush all TLBs
|
|
|
|
* 8. Disable all range registers
|
|
|
|
* 9. Update the MTRRs
|
|
|
|
* 10. Enable all range registers
|
|
|
|
* 11. Flush all TLBs and caches again
|
|
|
|
* 12. Enter normal cache mode and reenable caching
|
2009-07-04 07:56:28 +05:30
|
|
|
* 13. Set PGE
|
2005-04-16 15:20:36 -07:00
|
|
|
* 14. Wait for buddies to catch up
|
|
|
|
* 15. Enable interrupts.
|
2009-07-04 07:56:28 +05:30
|
|
|
*
|
2011-06-23 11:19:29 -07:00
|
|
|
* What does that mean for us? Well, stop_machine() will ensure that
|
|
|
|
* the rendezvous handler is started on each CPU. And in lockstep they
|
|
|
|
* do the state transition of disabling interrupts, updating MTRR's
|
|
|
|
* (the CPU vendors may each do it differently, so we call mtrr_if->set()
|
|
|
|
* callback and let them take care of it.) and enabling interrupts.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
* Note that the mechanism is the same for UP systems, too; all the SMP stuff
|
|
|
|
* becomes nops.
|
|
|
|
*/
|
2023-05-02 14:09:22 +02:00
|
|
|
static void set_mtrr(unsigned int reg, unsigned long base, unsigned long size,
|
|
|
|
mtrr_type type)
|
2017-08-15 13:03:47 +02:00
|
|
|
{
|
|
|
|
struct set_mtrr_data data = { .smp_reg = reg,
|
|
|
|
.smp_base = base,
|
|
|
|
.smp_size = size,
|
|
|
|
.smp_type = type
|
|
|
|
};
|
|
|
|
|
|
|
|
stop_machine_cpuslocked(mtrr_rendezvous_handler, &data, cpu_online_mask);
|
2023-05-02 14:09:26 +02:00
|
|
|
|
|
|
|
generic_rebuild_map();
|
2017-08-15 13:03:47 +02:00
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/**
|
2009-07-04 07:56:28 +05:30
|
|
|
* mtrr_add_page - Add a memory type region
|
|
|
|
* @base: Physical base address of region in pages (in units of 4 kB!)
|
|
|
|
* @size: Physical size of region in pages (4 kB)
|
|
|
|
* @type: Type of MTRR desired
|
|
|
|
* @increment: If this is true do usage counting on the region
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* Memory type region registers control the caching on newer Intel and
|
|
|
|
* non Intel processors. This function allows drivers to request an
|
|
|
|
* MTRR is added. The details and hardware specifics of each processor's
|
|
|
|
* implementation are hidden from the caller, but nevertheless the
|
|
|
|
* caller should expect to need to provide a power of two size on an
|
|
|
|
* equivalent power of two boundary.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* If the region cannot be added either because all regions are in use
|
|
|
|
* or the CPU cannot support it a negative value is returned. On success
|
|
|
|
* the register number for this entry is returned, but should be treated
|
|
|
|
* as a cookie only.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* On a multiprocessor machine the changes are made to all processors.
|
|
|
|
* This is required on x86 by the Intel processors.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* The available types are
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_UNCACHABLE - No caching
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRBACK - Write data back in bursts whenever
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* BUGS: Needs a quiet flag for the cases where drivers do not mind
|
|
|
|
* failures and do not wish system log messages to be sent.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
2009-07-04 07:56:28 +05:30
|
|
|
int mtrr_add_page(unsigned long base, unsigned long size,
|
2008-01-30 13:30:31 +01:00
|
|
|
unsigned int type, bool increment)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2009-07-04 07:56:28 +05:30
|
|
|
unsigned long lbase, lsize;
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
int i, replace, error;
|
2005-04-16 15:20:36 -07:00
|
|
|
mtrr_type ltype;
|
|
|
|
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
if (!mtrr_enabled())
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENXIO;
|
2009-07-04 07:56:28 +05:30
|
|
|
|
|
|
|
error = mtrr_if->validate_add_page(base, size, type);
|
|
|
|
if (error)
|
2005-04-16 15:20:36 -07:00
|
|
|
return error;
|
|
|
|
|
|
|
|
if (type >= MTRR_NUM_TYPES) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("type: %u invalid\n", type);
|
2005-04-16 15:20:36 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-07-04 07:56:28 +05:30
|
|
|
/* If the type is WC, check that this processor supports it */
|
2005-04-16 15:20:36 -07:00
|
|
|
if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("your processor doesn't support write-combining\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
if (!size) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("zero sized request\n");
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
x86: Fix /proc/mtrr with base/size more than 44bits
On one sytem that mtrr range is more then 44bits, in dmesg we have
[ 0.000000] MTRR default type: write-back
[ 0.000000] MTRR fixed ranges enabled:
[ 0.000000] 00000-9FFFF write-back
[ 0.000000] A0000-BFFFF uncachable
[ 0.000000] C0000-DFFFF write-through
[ 0.000000] E0000-FFFFF write-protect
[ 0.000000] MTRR variable ranges enabled:
[ 0.000000] 0 [000080000000-0000FFFFFFFF] mask 3FFF80000000 uncachable
[ 0.000000] 1 [380000000000-38FFFFFFFFFF] mask 3F0000000000 uncachable
[ 0.000000] 2 [000099000000-000099FFFFFF] mask 3FFFFF000000 write-through
[ 0.000000] 3 [00009A000000-00009AFFFFFF] mask 3FFFFF000000 write-through
[ 0.000000] 4 [381FFA000000-381FFBFFFFFF] mask 3FFFFE000000 write-through
[ 0.000000] 5 [381FFC000000-381FFC0FFFFF] mask 3FFFFFF00000 write-through
[ 0.000000] 6 [0000AD000000-0000ADFFFFFF] mask 3FFFFF000000 write-through
[ 0.000000] 7 [0000BD000000-0000BDFFFFFF] mask 3FFFFF000000 write-through
[ 0.000000] 8 disabled
[ 0.000000] 9 disabled
but /proc/mtrr report wrong:
reg00: base=0x080000000 ( 2048MB), size= 2048MB, count=1: uncachable
reg01: base=0x80000000000 (8388608MB), size=1048576MB, count=1: uncachable
reg02: base=0x099000000 ( 2448MB), size= 16MB, count=1: write-through
reg03: base=0x09a000000 ( 2464MB), size= 16MB, count=1: write-through
reg04: base=0x81ffa000000 (8519584MB), size= 32MB, count=1: write-through
reg05: base=0x81ffc000000 (8519616MB), size= 1MB, count=1: write-through
reg06: base=0x0ad000000 ( 2768MB), size= 16MB, count=1: write-through
reg07: base=0x0bd000000 ( 3024MB), size= 16MB, count=1: write-through
reg08: base=0x09b000000 ( 2480MB), size= 16MB, count=1: write-combining
so bit 44 and bit 45 get cut off.
We have problems in arch/x86/kernel/cpu/mtrr/generic.c::generic_get_mtrr().
1. for base, we miss cast base_lo to 64bit before shifting.
Fix that by adding u64 casting.
2. for size, it only can handle 44 bits aka 32bits + page_shift
Fix that with 64bit mask instead of 32bit mask_lo, then range could be
more than 44bits.
At the same time, we need to update size_or_mask for old cpus that does
support cpuid 0x80000008 to get phys_addr. Need to set high 32bits
to all 1s, otherwise will not get correct size for them.
Also fix mtrr_add_page: it should check base and (base + size - 1)
instead of base and size, as base and size could be small but
base + size could bigger enough to be out of boundary. We can
use boot_cpu_data.x86_phys_bits directly to avoid size_or_mask.
So When are we going to have size more than 44bits? that is 16TiB.
after patch we have right ouput:
reg00: base=0x080000000 ( 2048MB), size= 2048MB, count=1: uncachable
reg01: base=0x380000000000 (58720256MB), size=1048576MB, count=1: uncachable
reg02: base=0x099000000 ( 2448MB), size= 16MB, count=1: write-through
reg03: base=0x09a000000 ( 2464MB), size= 16MB, count=1: write-through
reg04: base=0x381ffa000000 (58851232MB), size= 32MB, count=1: write-through
reg05: base=0x381ffc000000 (58851264MB), size= 1MB, count=1: write-through
reg06: base=0x0ad000000 ( 2768MB), size= 16MB, count=1: write-through
reg07: base=0x0bd000000 ( 3024MB), size= 16MB, count=1: write-through
reg08: base=0x09b000000 ( 2480MB), size= 16MB, count=1: write-combining
-v2: simply checking in mtrr_add_page according to hpa.
[ hpa: This probably wants to go into -stable only after having sat in
mainline for a bit. It is not a regression. ]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1371162815-29931-1-git-send-email-yinghai@kernel.org
Cc: <stable@vger.kernel.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-06-13 15:33:35 -07:00
|
|
|
if ((base | (base + size - 1)) >>
|
|
|
|
(boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("base or size exceeds the MTRR width\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = -EINVAL;
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
replace = -1;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-07-07 17:56:38 -07:00
|
|
|
/* No CPU hotplug when we change MTRR entries */
|
2021-08-03 16:15:50 +02:00
|
|
|
cpus_read_lock();
|
2009-07-04 07:56:28 +05:30
|
|
|
|
|
|
|
/* Search for existing MTRR */
|
2006-03-26 01:37:14 -08:00
|
|
|
mutex_lock(&mtrr_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
for (i = 0; i < num_var_ranges; ++i) {
|
|
|
|
mtrr_if->get(i, &lbase, &lsize, <ype);
|
2009-07-04 07:56:28 +05:30
|
|
|
if (!lsize || base > lbase + lsize - 1 ||
|
|
|
|
base + size - 1 < lbase)
|
2005-04-16 15:20:36 -07:00
|
|
|
continue;
|
2009-07-04 07:56:28 +05:30
|
|
|
/*
|
|
|
|
* At this point we know there is some kind of
|
|
|
|
* overlap/enclosure
|
|
|
|
*/
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
if (base < lbase || base + size - 1 > lbase + lsize - 1) {
|
2009-07-04 07:56:28 +05:30
|
|
|
if (base <= lbase &&
|
|
|
|
base + size - 1 >= lbase + lsize - 1) {
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
/* New region encloses an existing region */
|
|
|
|
if (type == ltype) {
|
|
|
|
replace = replace == -1 ? i : -2;
|
|
|
|
continue;
|
2009-07-04 07:56:28 +05:30
|
|
|
} else if (types_compatible(type, ltype))
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
continue;
|
|
|
|
}
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("0x%lx000,0x%lx000 overlaps existing 0x%lx000,0x%lx000\n", base, size, lbase,
|
2009-07-04 07:56:28 +05:30
|
|
|
lsize);
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
/* New region is enclosed by an existing region */
|
2005-04-16 15:20:36 -07:00
|
|
|
if (ltype != type) {
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
if (types_compatible(type, ltype))
|
2005-04-16 15:20:36 -07:00
|
|
|
continue;
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("type mismatch for %lx000,%lx000 old: %s new: %s\n",
|
2009-07-04 07:56:28 +05:30
|
|
|
base, size, mtrr_attrib_to_str(ltype),
|
|
|
|
mtrr_attrib_to_str(type));
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (increment)
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
++mtrr_usage_table[i];
|
2005-04-16 15:20:36 -07:00
|
|
|
error = i;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
/* Search for an empty MTRR */
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
i = mtrr_if->get_free_region(base, size, replace);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (i >= 0) {
|
2023-05-02 14:09:22 +02:00
|
|
|
set_mtrr(i, base, size, type);
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
if (likely(replace < 0)) {
|
|
|
|
mtrr_usage_table[i] = 1;
|
|
|
|
} else {
|
|
|
|
mtrr_usage_table[i] = mtrr_usage_table[replace];
|
2008-01-30 13:30:31 +01:00
|
|
|
if (increment)
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
mtrr_usage_table[i]++;
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
if (unlikely(replace != i)) {
|
2023-05-02 14:09:22 +02:00
|
|
|
set_mtrr(replace, 0, 0, 0);
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
mtrr_usage_table[replace] = 0;
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
}
|
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
} else {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_info("no more MTRRs available\n");
|
2009-07-04 07:56:28 +05:30
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
error = i;
|
|
|
|
out:
|
2006-03-26 01:37:14 -08:00
|
|
|
mutex_unlock(&mtrr_mutex);
|
2021-08-03 16:15:50 +02:00
|
|
|
cpus_read_unlock();
|
2005-04-16 15:20:36 -07:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-06-23 00:08:35 -07:00
|
|
|
static int mtrr_check(unsigned long base, unsigned long size)
|
|
|
|
{
|
|
|
|
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("size and base must be multiples of 4 kiB\n");
|
2023-05-31 19:23:34 +02:00
|
|
|
Dprintk("size: 0x%lx base: 0x%lx\n", size, base);
|
2005-06-23 00:08:35 -07:00
|
|
|
dump_stack();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/**
|
2009-07-04 07:56:28 +05:30
|
|
|
* mtrr_add - Add a memory type region
|
|
|
|
* @base: Physical base address of region
|
|
|
|
* @size: Physical size of region
|
|
|
|
* @type: Type of MTRR desired
|
|
|
|
* @increment: If this is true do usage counting on the region
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* Memory type region registers control the caching on newer Intel and
|
|
|
|
* non Intel processors. This function allows drivers to request an
|
|
|
|
* MTRR is added. The details and hardware specifics of each processor's
|
|
|
|
* implementation are hidden from the caller, but nevertheless the
|
|
|
|
* caller should expect to need to provide a power of two size on an
|
|
|
|
* equivalent power of two boundary.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* If the region cannot be added either because all regions are in use
|
|
|
|
* or the CPU cannot support it a negative value is returned. On success
|
|
|
|
* the register number for this entry is returned, but should be treated
|
|
|
|
* as a cookie only.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* On a multiprocessor machine the changes are made to all processors.
|
|
|
|
* This is required on x86 by the Intel processors.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* The available types are
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_UNCACHABLE - No caching
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRBACK - Write data back in bursts whenever
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRCOMB - Write data back soon but allow bursts
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* %MTRR_TYPE_WRTHROUGH - Cache reads but not writes
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* BUGS: Needs a quiet flag for the cases where drivers do not mind
|
|
|
|
* failures and do not wish system log messages to be sent.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
2009-07-04 07:56:28 +05:30
|
|
|
int mtrr_add(unsigned long base, unsigned long size, unsigned int type,
|
|
|
|
bool increment)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
if (!mtrr_enabled())
|
|
|
|
return -ENODEV;
|
2005-06-23 00:08:35 -07:00
|
|
|
if (mtrr_check(base, size))
|
2005-04-16 15:20:36 -07:00
|
|
|
return -EINVAL;
|
|
|
|
return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
|
|
|
|
increment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-04 07:56:28 +05:30
|
|
|
* mtrr_del_page - delete a memory type region
|
|
|
|
* @reg: Register returned by mtrr_add
|
|
|
|
* @base: Physical base address
|
|
|
|
* @size: Size of region
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* If register is supplied then base and size are ignored. This is
|
|
|
|
* how drivers should call it.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* Releases an MTRR region. If the usage count drops to zero the
|
|
|
|
* register is freed and the region returns to default state.
|
|
|
|
* On success the register is returned, on failure a negative error
|
|
|
|
* code.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
int mtrr_del_page(int reg, unsigned long base, unsigned long size)
|
|
|
|
{
|
|
|
|
int i, max;
|
|
|
|
mtrr_type ltype;
|
[PATCH] i386: fix MTRR code
Until not so long ago, there were system log messages pointing to
inconsistent MTRR setup of the video frame buffer caused by the way vesafb
and X worked. While vesafb was fixed meanwhile, I believe fixing it there
only hides a shortcoming in the MTRR code itself, in that that code is not
symmetric with respect to the ordering of attempts to set up two (or more)
regions where one contains the other. In the current shape, it permits
only setting up sub-regions of pre-exisiting ones. The patch below makes
this symmetric.
While working on that I noticed a few more inconsistencies in that code,
namely
- use of 'unsigned int' for sizes in many, but not all places (the patch
is converting this to use 'unsigned long' everywhere, which specifically
might be necessary for x86-64 once a processor supporting more than 44
physical address bits would become available)
- the code to correct inconsistent settings during secondary processor
startup tried (if necessary) to correct, among other things, the value
in IA32_MTRR_DEF_TYPE, however the newly computed value would never get
used (i.e. stored in the respective MSR)
- the generic range validation code checked that the end of the
to-be-added range would be above 1MB; the value checked should have been
the start of the range
- when contained regions are detected, previously this was allowed only
when the old region was uncacheable; this can be symmetric (i.e. the new
region can also be uncacheable) and even further as per Intel's
documentation write-trough and write-back for either region is also
compatible with the respective opposite in the other
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
2006-12-07 02:14:09 +01:00
|
|
|
unsigned long lbase, lsize;
|
2005-04-16 15:20:36 -07:00
|
|
|
int error = -EINVAL;
|
|
|
|
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
if (!mtrr_enabled())
|
|
|
|
return -ENODEV;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
max = num_var_ranges;
|
2005-07-07 17:56:38 -07:00
|
|
|
/* No CPU hotplug when we change MTRR entries */
|
2021-08-03 16:15:50 +02:00
|
|
|
cpus_read_lock();
|
2006-03-26 01:37:14 -08:00
|
|
|
mutex_lock(&mtrr_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (reg < 0) {
|
|
|
|
/* Search for existing MTRR */
|
|
|
|
for (i = 0; i < max; ++i) {
|
|
|
|
mtrr_if->get(i, &lbase, &lsize, <ype);
|
|
|
|
if (lbase == base && lsize == size) {
|
|
|
|
reg = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reg < 0) {
|
2023-05-31 19:23:34 +02:00
|
|
|
Dprintk("no MTRR for %lx000,%lx000 found\n", base, size);
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reg >= max) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("register: %d too big\n", reg);
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
mtrr_if->get(reg, &lbase, &lsize, <ype);
|
|
|
|
if (lsize < 1) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("MTRR %d not used\n", reg);
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
if (mtrr_usage_table[reg] < 1) {
|
2018-05-10 08:45:31 -07:00
|
|
|
pr_warn("reg: %d has count=0\n", reg);
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all
available RAM, meaning the last few megs (or even gigs) of memory will be
marked uncached. Since Linux tends to allocate from high memory addresses
first, this causes the machine to be unusably slow as soon as the kernel
starts really using memory (i.e. right around init time).
This patch works around the problem by scanning the MTRRs at boot and
figuring out whether the current end_pfn value (setup by early e820 code)
goes beyond the highest WB MTRR range, and if so, trimming it to match. A
fairly obnoxious KERN_WARNING is printed too, letting the user know that
not all of their memory is available due to a likely BIOS bug.
Something similar could be done on i386 if needed, but the boot ordering
would be slightly different, since the MTRR code on i386 depends on the
boot_cpu_data structure being setup.
This patch fixes a bug in the last patch that caused the code to run on
non-Intel machines (AMD machines apparently don't need it and it's untested
on other non-Intel machines, so best keep it off).
Further enhancements and fixes from:
Yinghai Lu <Yinghai.Lu@Sun.COM>
Andi Kleen <ak@suse.de>
Signed-off-by: Jesse Barnes <jesse.barnes@intel.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:33:18 +01:00
|
|
|
if (--mtrr_usage_table[reg] < 1)
|
2023-05-02 14:09:22 +02:00
|
|
|
set_mtrr(reg, 0, 0, 0);
|
2005-04-16 15:20:36 -07:00
|
|
|
error = reg;
|
|
|
|
out:
|
2006-03-26 01:37:14 -08:00
|
|
|
mutex_unlock(&mtrr_mutex);
|
2021-08-03 16:15:50 +02:00
|
|
|
cpus_read_unlock();
|
2005-04-16 15:20:36 -07:00
|
|
|
return error;
|
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/**
|
2009-07-04 07:56:28 +05:30
|
|
|
* mtrr_del - delete a memory type region
|
|
|
|
* @reg: Register returned by mtrr_add
|
|
|
|
* @base: Physical base address
|
|
|
|
* @size: Size of region
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* If register is supplied then base and size are ignored. This is
|
|
|
|
* how drivers should call it.
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* Releases an MTRR region. If the usage count drops to zero the
|
|
|
|
* register is freed and the region returns to default state.
|
|
|
|
* On success the register is returned, on failure a negative error
|
|
|
|
* code.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
2009-07-04 07:56:28 +05:30
|
|
|
int mtrr_del(int reg, unsigned long base, unsigned long size)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
if (!mtrr_enabled())
|
|
|
|
return -ENODEV;
|
2005-06-23 00:08:35 -07:00
|
|
|
if (mtrr_check(base, size))
|
2005-04-16 15:20:36 -07:00
|
|
|
return -EINVAL;
|
|
|
|
return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
|
|
|
|
}
|
|
|
|
|
2013-05-13 23:58:40 +00:00
|
|
|
/**
|
|
|
|
* arch_phys_wc_add - add a WC MTRR and handle errors if PAT is unavailable
|
|
|
|
* @base: Physical base address
|
|
|
|
* @size: Size of region
|
|
|
|
*
|
|
|
|
* If PAT is available, this does nothing. If PAT is unavailable, it
|
|
|
|
* attempts to add a WC MTRR covering size bytes starting at base and
|
|
|
|
* logs an error if this fails.
|
|
|
|
*
|
2015-05-26 10:28:12 +02:00
|
|
|
* The called should provide a power of two size on an equivalent
|
|
|
|
* power of two boundary.
|
|
|
|
*
|
2013-05-13 23:58:40 +00:00
|
|
|
* Drivers must store the return value to pass to mtrr_del_wc_if_needed,
|
|
|
|
* but drivers should not try to interpret that return value.
|
|
|
|
*/
|
|
|
|
int arch_phys_wc_add(unsigned long base, unsigned long size)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2015-05-26 10:28:15 +02:00
|
|
|
if (pat_enabled() || !mtrr_enabled())
|
2013-05-13 23:58:40 +00:00
|
|
|
return 0; /* Success! (We don't need to do anything.) */
|
|
|
|
|
|
|
|
ret = mtrr_add(base, size, MTRR_TYPE_WRCOMB, true);
|
|
|
|
if (ret < 0) {
|
|
|
|
pr_warn("Failed to add WC MTRR for [%p-%p]; performance may suffer.",
|
|
|
|
(void *)base, (void *)(base + size - 1));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return ret + MTRR_TO_PHYS_WC_OFFSET;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(arch_phys_wc_add);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* arch_phys_wc_del - undoes arch_phys_wc_add
|
|
|
|
* @handle: Return value from arch_phys_wc_add
|
|
|
|
*
|
|
|
|
* This cleans up after mtrr_add_wc_if_needed.
|
|
|
|
*
|
|
|
|
* The API guarantees that mtrr_del_wc_if_needed(error code) and
|
|
|
|
* mtrr_del_wc_if_needed(0) do nothing.
|
|
|
|
*/
|
|
|
|
void arch_phys_wc_del(int handle)
|
|
|
|
{
|
|
|
|
if (handle >= 1) {
|
|
|
|
WARN_ON(handle < MTRR_TO_PHYS_WC_OFFSET);
|
|
|
|
mtrr_del(handle - MTRR_TO_PHYS_WC_OFFSET, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(arch_phys_wc_del);
|
|
|
|
|
|
|
|
/*
|
2015-05-26 10:28:13 +02:00
|
|
|
* arch_phys_wc_index - translates arch_phys_wc_add's return value
|
2013-05-13 23:58:40 +00:00
|
|
|
* @handle: Return value from arch_phys_wc_add
|
|
|
|
*
|
|
|
|
* This will turn the return value from arch_phys_wc_add into an mtrr
|
|
|
|
* index suitable for debugging.
|
|
|
|
*
|
|
|
|
* Note: There is no legitimate use for this function, except possibly
|
|
|
|
* in printk line. Alas there is an illegitimate use in some ancient
|
|
|
|
* drm ioctls.
|
|
|
|
*/
|
2015-05-26 10:28:13 +02:00
|
|
|
int arch_phys_wc_index(int handle)
|
2013-05-13 23:58:40 +00:00
|
|
|
{
|
|
|
|
if (handle < MTRR_TO_PHYS_WC_OFFSET)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return handle - MTRR_TO_PHYS_WC_OFFSET;
|
|
|
|
}
|
2015-05-26 10:28:13 +02:00
|
|
|
EXPORT_SYMBOL_GPL(arch_phys_wc_index);
|
2013-05-13 23:58:40 +00:00
|
|
|
|
2009-03-11 20:07:39 -07:00
|
|
|
int __initdata changed_by_mtrr_cleanup;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/**
|
2023-05-02 14:09:16 +02:00
|
|
|
* mtrr_bp_init - initialize MTRRs on the boot CPU
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
2009-07-04 07:56:28 +05:30
|
|
|
* This needs to be called early; before any of the other CPUs are
|
2005-04-16 15:20:36 -07:00
|
|
|
* initialized (i.e. before smp_init()).
|
|
|
|
*/
|
2007-07-21 17:10:39 +02:00
|
|
|
void __init mtrr_bp_init(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2023-05-02 14:09:18 +02:00
|
|
|
bool generic_mtrrs = cpu_feature_enabled(X86_FEATURE_MTRR);
|
2022-12-05 09:04:33 +01:00
|
|
|
const char *why = "(not available)";
|
2023-05-02 14:09:21 +02:00
|
|
|
unsigned long config, dummy;
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2023-05-02 14:09:17 +02:00
|
|
|
phys_hi_rsvd = GENMASK(31, boot_cpu_data.x86_phys_bits - 32);
|
2008-04-29 03:52:33 -07:00
|
|
|
|
2023-05-02 14:09:18 +02:00
|
|
|
if (!generic_mtrrs && mtrr_state.enabled) {
|
|
|
|
/*
|
|
|
|
* Software overwrite of MTRR state, only for generic case.
|
|
|
|
* Note that X86_FEATURE_MTRR has been reset in this case.
|
|
|
|
*/
|
|
|
|
init_table();
|
2023-05-02 14:09:26 +02:00
|
|
|
mtrr_build_map();
|
2023-05-02 14:09:18 +02:00
|
|
|
pr_info("MTRRs set to read-only\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-02 14:09:23 +02:00
|
|
|
if (generic_mtrrs)
|
2005-04-16 15:20:36 -07:00
|
|
|
mtrr_if = &generic_mtrr_ops;
|
2023-05-02 14:09:23 +02:00
|
|
|
else
|
|
|
|
mtrr_set_if();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2022-11-02 08:47:07 +01:00
|
|
|
if (mtrr_enabled()) {
|
2023-05-02 14:09:21 +02:00
|
|
|
/* Get the number of variable MTRR ranges. */
|
|
|
|
if (mtrr_if == &generic_mtrr_ops)
|
|
|
|
rdmsr(MSR_MTRRcap, config, dummy);
|
|
|
|
else
|
|
|
|
config = mtrr_if->var_regs;
|
|
|
|
num_var_ranges = config & MTRR_CAP_VCNT;
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
init_table();
|
2022-11-02 08:47:00 +01:00
|
|
|
if (mtrr_if == &generic_mtrr_ops) {
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
/* BIOS may override */
|
2022-11-02 08:47:07 +01:00
|
|
|
if (get_mtrr_state()) {
|
2022-11-02 08:47:10 +01:00
|
|
|
memory_caching_control |= CACHE_MTRR;
|
2023-05-02 14:09:16 +02:00
|
|
|
changed_by_mtrr_cleanup = mtrr_cleanup();
|
2023-05-02 14:09:26 +02:00
|
|
|
mtrr_build_map();
|
2022-11-02 08:47:07 +01:00
|
|
|
} else {
|
|
|
|
mtrr_if = NULL;
|
2022-12-05 09:04:33 +01:00
|
|
|
why = "by BIOS";
|
2008-05-02 02:40:22 -07:00
|
|
|
}
|
2008-04-29 03:52:33 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
|
2022-11-02 08:47:10 +01:00
|
|
|
if (!mtrr_enabled())
|
2022-12-05 09:04:33 +01:00
|
|
|
pr_info("MTRRs disabled %s\n", why);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
[PATCH] x86: Save the MTRRs of the BSP before booting an AP
Applied fix by Andew Morton:
http://lkml.org/lkml/2007/4/8/88 - Fix `make headers_check'.
AMD and Intel x86 CPU manuals state that it is the responsibility of
system software to initialize and maintain MTRR consistency across
all processors in Multi-Processing Environments.
Quote from page 188 of the AMD64 System Programming manual (Volume 2):
7.6.5 MTRRs in Multi-Processing Environments
"In multi-processing environments, the MTRRs located in all processors must
characterize memory in the same way. Generally, this means that identical
values are written to the MTRRs used by the processors." (short omission here)
"Failure to do so may result in coherency violations or loss of atomicity.
Processor implementations do not check the MTRR settings in other processors
to ensure consistency. It is the responsibility of system software to
initialize and maintain MTRR consistency across all processors."
Current Linux MTRR code already implements the above in the case that the
BIOS does not properly initialize MTRRs on the secondary processors,
but the case where the fixed-range MTRRs of the boot processor are changed
after Linux started to boot, before the initialsation of a secondary
processor, is not handled yet.
In this case, secondary processors are currently initialized by Linux
with MTRRs which the boot processor had very early, when mtrr_bp_init()
did run, but not with the MTRRs which the boot processor uses at the
time when that secondary processors is actually booted,
causing differing MTRR contents on the secondary processors.
Such situation happens on Acer Ferrari 1000 and 5000 notebooks where the
BIOS enables and sets AMD-specific IORR bits in the fixed-range MTRRs
of the boot processor when it transitions the system into ACPI mode.
The SMI handler of the BIOS does this in SMM, entered while Linux ACPI
code runs acpi_enable().
Other occasions where the SMI handler of the BIOS may change bits in
the MTRRs could occur as well. To initialize newly booted secodary
processors with the fixed-range MTRRs which the boot processor uses
at that time, this patch saves the fixed-range MTRRs of the boot
processor before new secondary processors are started. When the
secondary processors run their Linux initialisation code, their
fixed-range MTRRs will be updated with the saved fixed-range MTRRs.
If CONFIG_MTRR is not set, we define mtrr_save_state
as an empty statement because there is nothing to do.
Possible TODOs:
*) CPU-hotplugging outside of SMP suspend/resume is not yet tested
with this patch.
*) If, even in this case, an AP never runs i386/do_boot_cpu or x86_64/cpu_up,
then the calls to mtrr_save_state() could be replaced by calls to
mtrr_save_fixed_ranges(NULL) and mtrr_save_state() would not be
needed.
That would need either verification of the CPU-hotplug code or
at least a test on a >2 CPU machine.
*) The MTRRs of other running processors are not yet checked at this
time but it might be interesting to syncronize the MTTRs of all
processors before booting. That would be an incremental patch,
but of rather low priority since there is no machine known so
far which would require this.
AK: moved prototypes on x86-64 around to fix warnings
Signed-off-by: Bernhard Kaindl <bk@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Dave Jones <davej@codemonkey.org.uk>
2007-05-02 19:27:17 +02:00
|
|
|
/**
|
2020-10-23 18:32:53 +02:00
|
|
|
* mtrr_save_state - Save current fixed-range MTRR state of the first
|
|
|
|
* cpu in cpu_online_mask.
|
[PATCH] x86: Save the MTRRs of the BSP before booting an AP
Applied fix by Andew Morton:
http://lkml.org/lkml/2007/4/8/88 - Fix `make headers_check'.
AMD and Intel x86 CPU manuals state that it is the responsibility of
system software to initialize and maintain MTRR consistency across
all processors in Multi-Processing Environments.
Quote from page 188 of the AMD64 System Programming manual (Volume 2):
7.6.5 MTRRs in Multi-Processing Environments
"In multi-processing environments, the MTRRs located in all processors must
characterize memory in the same way. Generally, this means that identical
values are written to the MTRRs used by the processors." (short omission here)
"Failure to do so may result in coherency violations or loss of atomicity.
Processor implementations do not check the MTRR settings in other processors
to ensure consistency. It is the responsibility of system software to
initialize and maintain MTRR consistency across all processors."
Current Linux MTRR code already implements the above in the case that the
BIOS does not properly initialize MTRRs on the secondary processors,
but the case where the fixed-range MTRRs of the boot processor are changed
after Linux started to boot, before the initialsation of a secondary
processor, is not handled yet.
In this case, secondary processors are currently initialized by Linux
with MTRRs which the boot processor had very early, when mtrr_bp_init()
did run, but not with the MTRRs which the boot processor uses at the
time when that secondary processors is actually booted,
causing differing MTRR contents on the secondary processors.
Such situation happens on Acer Ferrari 1000 and 5000 notebooks where the
BIOS enables and sets AMD-specific IORR bits in the fixed-range MTRRs
of the boot processor when it transitions the system into ACPI mode.
The SMI handler of the BIOS does this in SMM, entered while Linux ACPI
code runs acpi_enable().
Other occasions where the SMI handler of the BIOS may change bits in
the MTRRs could occur as well. To initialize newly booted secodary
processors with the fixed-range MTRRs which the boot processor uses
at that time, this patch saves the fixed-range MTRRs of the boot
processor before new secondary processors are started. When the
secondary processors run their Linux initialisation code, their
fixed-range MTRRs will be updated with the saved fixed-range MTRRs.
If CONFIG_MTRR is not set, we define mtrr_save_state
as an empty statement because there is nothing to do.
Possible TODOs:
*) CPU-hotplugging outside of SMP suspend/resume is not yet tested
with this patch.
*) If, even in this case, an AP never runs i386/do_boot_cpu or x86_64/cpu_up,
then the calls to mtrr_save_state() could be replaced by calls to
mtrr_save_fixed_ranges(NULL) and mtrr_save_state() would not be
needed.
That would need either verification of the CPU-hotplug code or
at least a test on a >2 CPU machine.
*) The MTRRs of other running processors are not yet checked at this
time but it might be interesting to syncronize the MTTRs of all
processors before booting. That would be an incremental patch,
but of rather low priority since there is no machine known so
far which would require this.
AK: moved prototypes on x86-64 around to fix warnings
Signed-off-by: Bernhard Kaindl <bk@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Dave Jones <davej@codemonkey.org.uk>
2007-05-02 19:27:17 +02:00
|
|
|
*/
|
|
|
|
void mtrr_save_state(void)
|
|
|
|
{
|
2012-11-13 11:32:48 -08:00
|
|
|
int first_cpu;
|
|
|
|
|
2024-08-07 17:02:44 -07:00
|
|
|
if (!mtrr_enabled() || !mtrr_state.have_fixed)
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
return;
|
|
|
|
|
2012-11-13 11:32:48 -08:00
|
|
|
first_cpu = cpumask_first(cpu_online_mask);
|
|
|
|
smp_call_function_single(first_cpu, mtrr_save_fixed_ranges, NULL, 1);
|
[PATCH] x86: Save the MTRRs of the BSP before booting an AP
Applied fix by Andew Morton:
http://lkml.org/lkml/2007/4/8/88 - Fix `make headers_check'.
AMD and Intel x86 CPU manuals state that it is the responsibility of
system software to initialize and maintain MTRR consistency across
all processors in Multi-Processing Environments.
Quote from page 188 of the AMD64 System Programming manual (Volume 2):
7.6.5 MTRRs in Multi-Processing Environments
"In multi-processing environments, the MTRRs located in all processors must
characterize memory in the same way. Generally, this means that identical
values are written to the MTRRs used by the processors." (short omission here)
"Failure to do so may result in coherency violations or loss of atomicity.
Processor implementations do not check the MTRR settings in other processors
to ensure consistency. It is the responsibility of system software to
initialize and maintain MTRR consistency across all processors."
Current Linux MTRR code already implements the above in the case that the
BIOS does not properly initialize MTRRs on the secondary processors,
but the case where the fixed-range MTRRs of the boot processor are changed
after Linux started to boot, before the initialsation of a secondary
processor, is not handled yet.
In this case, secondary processors are currently initialized by Linux
with MTRRs which the boot processor had very early, when mtrr_bp_init()
did run, but not with the MTRRs which the boot processor uses at the
time when that secondary processors is actually booted,
causing differing MTRR contents on the secondary processors.
Such situation happens on Acer Ferrari 1000 and 5000 notebooks where the
BIOS enables and sets AMD-specific IORR bits in the fixed-range MTRRs
of the boot processor when it transitions the system into ACPI mode.
The SMI handler of the BIOS does this in SMM, entered while Linux ACPI
code runs acpi_enable().
Other occasions where the SMI handler of the BIOS may change bits in
the MTRRs could occur as well. To initialize newly booted secodary
processors with the fixed-range MTRRs which the boot processor uses
at that time, this patch saves the fixed-range MTRRs of the boot
processor before new secondary processors are started. When the
secondary processors run their Linux initialisation code, their
fixed-range MTRRs will be updated with the saved fixed-range MTRRs.
If CONFIG_MTRR is not set, we define mtrr_save_state
as an empty statement because there is nothing to do.
Possible TODOs:
*) CPU-hotplugging outside of SMP suspend/resume is not yet tested
with this patch.
*) If, even in this case, an AP never runs i386/do_boot_cpu or x86_64/cpu_up,
then the calls to mtrr_save_state() could be replaced by calls to
mtrr_save_fixed_ranges(NULL) and mtrr_save_state() would not be
needed.
That would need either verification of the CPU-hotplug code or
at least a test on a >2 CPU machine.
*) The MTRRs of other running processors are not yet checked at this
time but it might be interesting to syncronize the MTTRs of all
processors before booting. That would be an incremental patch,
but of rather low priority since there is no machine known so
far which would require this.
AK: moved prototypes on x86-64 around to fix warnings
Signed-off-by: Bernhard Kaindl <bk@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Dave Jones <davej@codemonkey.org.uk>
2007-05-02 19:27:17 +02:00
|
|
|
}
|
|
|
|
|
2023-05-02 14:09:23 +02:00
|
|
|
static int __init mtrr_init_finalize(void)
|
2005-07-07 17:56:38 -07:00
|
|
|
{
|
2023-05-02 14:09:26 +02:00
|
|
|
/*
|
2024-12-02 09:31:39 +02:00
|
|
|
* Map might exist if guest_force_mtrr_state() has been called or if
|
2023-05-02 14:09:26 +02:00
|
|
|
* mtrr_enabled() returns true.
|
|
|
|
*/
|
|
|
|
mtrr_copy_map();
|
|
|
|
|
x86/mm/mtrr: Generalize runtime disabling of MTRRs
It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
up with a system with MTRR functionality disabled but PAT
functionality enabled. This can happen, for instance, when the
Xen hypervisor is used where MTRRs are not supported but PAT is.
This can happen on Linux as of commit
47591df50512 ("xen: Support Xen pv-domains using PAT")
by Juergen, introduced in v3.19.
Technically, we should assume the proper CPU bits would be set
to disable MTRRs but we can't always rely on this. At least on
the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
X86_FEATURE_CYRIX_ARR for instance.
Roger Pau Monné has clarified though that although this is
technically true we will never support PVH on these CPU types so
Xen has no need to disable these bits on those systems. As per
Roger, AMD K6, Centaur and VIA chips don't have the necessary
hardware extensions to allow running PVH guests [1].
As per Toshi it is also possible for the BIOS to disable MTRR
support, in such cases get_mtrr_state() would update the MTRR
state as per the BIOS, we need to propagate this information as
well.
x86 MTRR code relies on quite a bit of checks for mtrr_if being
set to check to see if MTRRs did get set up. Instead, lets
provide a generic getter for that. This also adds a few checks
where they were not before which could potentially safeguard
ourselves against incorrect usage of MTRR where this was not
desirable.
Where possible match error codes as if MTRRs were disabled on
arch/x86/include/asm/mtrr.h.
Lastly, since disabling MTRRs can happen at run time and we
could end up with PAT enabled, best record now in our logs when
MTRRs are disabled.
[0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.html
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Stefan Bader <stefan.bader@canonical.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Ville Syrjälä <syrjala@sci.fi>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: bhelgaas@google.com
Cc: david.vrabel@citrix.com
Cc: jbeulich@suse.com
Cc: konrad.wilk@oracle.com
Cc: venkatesh.pallipadi@intel.com
Cc: ville.syrjala@linux.intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-26 10:28:14 +02:00
|
|
|
if (!mtrr_enabled())
|
2005-07-07 17:56:38 -07:00
|
|
|
return 0;
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2022-11-02 08:47:00 +01:00
|
|
|
if (memory_caching_control & CACHE_MTRR) {
|
2008-05-02 02:40:22 -07:00
|
|
|
if (!changed_by_mtrr_cleanup)
|
2008-04-29 03:52:33 -07:00
|
|
|
mtrr_state_warn();
|
2009-07-04 07:56:28 +05:30
|
|
|
return 0;
|
2005-07-07 17:56:38 -07:00
|
|
|
}
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2023-05-02 14:09:23 +02:00
|
|
|
mtrr_register_syscore();
|
2009-07-04 07:56:28 +05:30
|
|
|
|
2005-07-07 17:56:38 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2023-05-02 14:09:23 +02:00
|
|
|
subsys_initcall(mtrr_init_finalize);
|