From: ebiederm@xmission.com (Eric W. Biederman)
To: venkatesh.pallipadi@intel.com
Cc: ak@muc.de, ebiederm@xmission.com, rdreier@cisco.com,
torvalds@linux-foundation.org, gregkh@suse.de, airlied@skynet.ie,
davej@redhat.com, mingo@elte.hu, tglx@linutronix.de,
hpa@zytor.com, akpm@linux-foundation.org, arjan@infradead.org,
jesse.barnes@intel.com, linux-kernel@vger.kernel.org,
Suresh Siddha <suresh.b.siddha@intel.com>
Subject: Re: [RFC PATCH 02/12] PAT 64b: Basic PAT implementation
Date: Thu, 13 Dec 2007 20:48:45 -0700 [thread overview]
Message-ID: <m1d4taq6le.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20071213235711.464325000@intel.com> (venkatesh pallipadi's message of "Thu, 13 Dec 2007 15:55:45 -0800")
venkatesh.pallipadi@intel.com writes:
> Originally based on a patch from Eric Biederman, but heavily changed.
>
> Forward port of pat-base.patch to x86 tree, with a bug fix.
> Code was using 'PCD|PWT' i.e., PAT3 for WC mapping. So set the WC mapping at
> correct PAT fields PA3/PA7.
Well that wasn't from my original tested patch. Grr.
> TBD: KEXEC and other CPU offline paths may need pat_shutdown()?
> Index: linux-2.6/arch/x86/mm/Makefile_64
> ===================================================================
> --- linux-2.6.orig/arch/x86/mm/Makefile_64 2007-12-11 03:30:34.000000000 -0800
> +++ linux-2.6/arch/x86/mm/Makefile_64 2007-12-11 03:42:08.000000000 -0800
> @@ -2,7 +2,7 @@
> # Makefile for the linux x86_64-specific parts of the memory manager.
> #
>
> -obj-y := init_64.o fault_64.o ioremap_64.o extable_64.o pageattr_64.o mmap_64.o
> +obj-y := init_64.o fault_64.o ioremap_64.o extable_64.o pageattr_64.o mmap_64.o
> pat.o
> obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
> obj-$(CONFIG_NUMA) += numa_64.o
> obj-$(CONFIG_K8_NUMA) += k8topology_64.o
> Index: linux-2.6/arch/x86/mm/pat.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6/arch/x86/mm/pat.c 2007-12-11 04:12:47.000000000 -0800
> @@ -0,0 +1,57 @@
> +/* Handle caching attributes in page tables (PAT) */
> +#include <linux/mm.h>
> +#include <linux/kernel.h>
> +#include <linux/rbtree.h>
> +#include <linux/gfp.h>
> +#include <asm/msr.h>
> +#include <asm/tlbflush.h>
> +#include <asm/processor.h>
> +
> +static u64 boot_pat_state;
> +
> +enum {
> + PAT_UC = 0, /* uncached */
> + PAT_WC = 1, /* Write combining */
> + PAT_WT = 4, /* Write Through */
> + PAT_WP = 5, /* Write Protected */
> + PAT_WB = 6, /* Write Back (default) */
> + PAT_UC_MINUS = 7, /* UC, but can be overriden by MTRR */
> +};
> +
> +#define PAT(x,y) ((u64)PAT_ ## y << ((x)*8))
> +
> +void __cpuinit pat_init(void)
> +{
> + /* Set PWT+PCD to Write-Combining. All other bits stay the same */
> + if (cpu_has_pat) {
> + u64 pat;
> + /* PTE encoding used in Linux:
> + PAT
> + |PCD
> + ||PWT
> + |||
> + 000 WB default
> + 010 UC_MINUS _PAGE_PCD
> + 011 WC _PAGE_WC
> + PAT bit unused */
> + pat = PAT(0,WB) | PAT(1,WT) | PAT(2,UC_MINUS) | PAT(3,WC) |
> + PAT(4,WB) | PAT(5,WT) | PAT(6,UC_MINUS) | PAT(7,WC);
I strongly object to this configuration.
The caching modes of interest are:
PAT_WB write-back or a close as the MTRRs will allow
used for WC today.
PAT_UC completely uncachable not overridable by MTRRs
and what we use today for pgprot_noncached
PAT_WC what isn't available for current use.
We should use:
> + pat = PAT(0,WB) | PAT(1,WT) | PAT(2,WC) | PAT(3,UC) |
> + PAT(4,WB) | PAT(5,WT) | PAT(6,WC) | PAT(7,UC);
Changing the UC- which currently allows write-combining if the MTRRs specify it,
to WC. This grandfathers in all of our current usage and changes the one
PAT type that could today and in legacy mode specify WC to really specify WC.
I don't know if we need to set the high half or not, that would depend
on the state of the PAT errata.
I do know we need to use the low 4 pat mappings to avoid most of the PAT
errata issues.
As for Andi's concern about modules playing games with the PAT mappings
if we don't redefine how we use the page table entries our exposure to
badly behaved modules more limited.
> + rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
> + wrmsrl(MSR_IA32_CR_PAT, pat);
> + __flush_tlb_all();
> + asm volatile("wbinvd");
> + }
> +}
> +
> +#undef PAT
> +
> +void pat_shutdown(void)
> +{
> + /* Restore CPU default pat state */
> + if (cpu_has_pat) {
> + wrmsrl(MSR_IA32_CR_PAT, boot_pat_state);
> + __flush_tlb_all();
> + asm volatile("wbinvd");
> + }
> +}
> +
Eric
next prev parent reply other threads:[~2007-12-14 3:52 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-13 23:55 [RFC PATCH 00/12] PAT 64b: PAT support for X86_64 venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 01/12] PAT 64b: Add cpu_shutdown() support venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 02/12] PAT 64b: Basic PAT implementation venkatesh.pallipadi
2007-12-14 0:42 ` Andi Kleen
2007-12-14 18:31 ` Venki Pallipadi
2007-12-18 4:50 ` Eric W. Biederman
2007-12-14 3:48 ` Eric W. Biederman [this message]
2007-12-14 4:23 ` Eric W. Biederman
2007-12-14 21:10 ` Siddha, Suresh B
2007-12-14 23:34 ` Siddha, Suresh B
2007-12-15 7:55 ` Ingo Molnar
2007-12-14 10:25 ` Andi Kleen
2007-12-14 19:45 ` H. Peter Anvin
2007-12-18 4:42 ` Eric W. Biederman
2007-12-14 21:06 ` Siddha, Suresh B
2007-12-13 23:55 ` [RFC PATCH 03/12] PAT 64b: drm driver changes for PAT venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 04/12] PAT 64b: reserve_mattr and free_mattr " venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 05/12] PAT 64b: pci mmap conlfict patch venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 06/12] PAT 64b: Add ioremap_wc support venkatesh.pallipadi
2007-12-14 4:17 ` Roland Dreier
2007-12-14 4:28 ` Eric W. Biederman
2007-12-14 4:32 ` Roland Dreier
2007-12-14 4:48 ` Eric W. Biederman
2007-12-14 21:40 ` Siddha, Suresh B
2007-12-14 23:19 ` Andi Kleen
2007-12-18 8:29 ` Eric W. Biederman
2007-12-13 23:55 ` [RFC PATCH 07/12] PAT 64b: dev mem chanegs for pat venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 08/12] PAT 64b: coherent mmap and sysfs bin ioctl venkatesh.pallipadi
2007-12-14 0:19 ` Greg KH
2007-12-14 0:35 ` David Miller
2007-12-14 6:34 ` Greg KH
2007-12-16 21:57 ` Paul Mackerras
2007-12-17 12:41 ` Andi Kleen
2007-12-18 4:30 ` Eric W. Biederman
2007-12-18 4:51 ` H. Peter Anvin
2007-12-18 9:35 ` Andi Kleen
2007-12-18 13:48 ` Eric W. Biederman
2007-12-14 0:43 ` Andi Kleen
2007-12-14 0:54 ` Jesse Barnes
2007-12-14 3:59 ` Eric W. Biederman
2007-12-14 6:02 ` Greg KH
2007-12-14 6:04 ` Eric W. Biederman
2007-12-14 10:19 ` Andi Kleen
2007-12-13 23:55 ` [RFC PATCH 09/12] PAT 64b: map only usable memory in identity mapping venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 10/12] PAT 64b: Make acpi use early map instead of assuming identity map venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 11/12] PAT 64b: devmem do not read pages not mapped in " venkatesh.pallipadi
2007-12-13 23:55 ` [RFC PATCH 12/12] PAT 64b: skip attr tracking for RAM venkatesh.pallipadi
2007-12-14 0:28 ` [RFC PATCH 00/12] PAT 64b: PAT support for X86_64 Dave Airlie
2007-12-14 22:00 ` Siddha, Suresh B
2007-12-14 22:27 ` Dave Airlie
2007-12-14 22:32 ` H. Peter Anvin
2007-12-14 22:37 ` Dave Airlie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1d4taq6le.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=airlied@skynet.ie \
--cc=ak@muc.de \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=davej@redhat.com \
--cc=gregkh@suse.de \
--cc=hpa@zytor.com \
--cc=jesse.barnes@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rdreier@cisco.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=venkatesh.pallipadi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome