LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Support for i386 PATs
@ 2007-01-27  9:20 Thomas Hellström
  2007-01-27  9:33 ` Avi Kivity
  2007-01-28 21:48 ` Dave Jones
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Hellström @ 2007-01-27  9:20 UTC (permalink / raw)
  To: Linux Kernel

Hi!

Does anybody have a strong opinion against adding support for
i386 Page Attribute Tables?

The main benefit would be that one can have write-combining memory
regions without setting up MTRRs. This will come in handy for a
device we're working with where the device driver needs to allocate the
display memory directly from system memory, and it may be difficult to fit
the mtrr alignment constraints.

Outline:
The PAT may be set up at boot time with fixed backwards-compatible
memory types for the different PAT entries + defines like the following:

#define _PAGE_PAT_WB   xxx
#define _PAGE_PAT_WT   xxx
#define _PAGE_PAT_UC0 xxx
#define _PAGE_PAT_UC1 xxx
#define _PAGE_PAT_WC   xxx

which can be used in parallel with the old _PAGE_PWT and _PAGE_PCD bits.

The idea is that new memory types, WC for example, will use the pat entries
7 downto 4, whereas 0-3 are left to boot setting to maintain backwards 
compatibility.

Issues:
1) The _PAGE_BIT_PAT will be the same as _PAGE_PSE, and _PAGE_PROTNONE.
As I understand it, _PAGE_PROTNONE is not used when the page is present, 
so this might not be an issue.
What about _PAGE_PSE?

2) The PATs need to be setup for each processor just after system boot.
Where is the best place to do this?

/Thomas Hellström



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Support for i386 PATs
  2007-01-27  9:20 Support for i386 PATs Thomas Hellström
@ 2007-01-27  9:33 ` Avi Kivity
  2007-01-28 21:48 ` Dave Jones
  1 sibling, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2007-01-27  9:33 UTC (permalink / raw)
  To: Thomas Hellström; +Cc: Linux Kernel

Thomas Hellström wrote:
> Hi!
>
> Does anybody have a strong opinion against adding support for
> i386 Page Attribute Tables?
>
> The main benefit would be that one can have write-combining memory
> regions without setting up MTRRs. This will come in handy for a
> device we're working with where the device driver needs to allocate the
> display memory directly from system memory, and it may be difficult to 
> fit
> the mtrr alignment constraints.

An additional benefit if that you can easily run out of mtrrs.  My home 
machine boots with all 8 mtrrs used, leaving none for the G965 
graphics.  I have to compress two mtrrs into one in order to get decent 
performance.

>
> Outline:
> The PAT may be set up at boot time with fixed backwards-compatible
> memory types for the different PAT entries + defines like the following:
>
> #define _PAGE_PAT_WB   xxx
> #define _PAGE_PAT_WT   xxx
> #define _PAGE_PAT_UC0 xxx
> #define _PAGE_PAT_UC1 xxx
> #define _PAGE_PAT_WC   xxx
>
> which can be used in parallel with the old _PAGE_PWT and _PAGE_PCD bits.
>
> The idea is that new memory types, WC for example, will use the pat 
> entries
> 7 downto 4, whereas 0-3 are left to boot setting to maintain backwards 
> compatibility.
>
> Issues:
> 1) The _PAGE_BIT_PAT will be the same as _PAGE_PSE, and _PAGE_PROTNONE.
> As I understand it, _PAGE_PROTNONE is not used when the page is 
> present, so this might not be an issue.
> What about _PAGE_PSE?

pse pages place the pat bit in bit 12, you will need to account for that.



-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Support for i386 PATs
  2007-01-27  9:20 Support for i386 PATs Thomas Hellström
  2007-01-27  9:33 ` Avi Kivity
@ 2007-01-28 21:48 ` Dave Jones
  2007-01-30 15:50   ` Thomas Hellström
  1 sibling, 1 reply; 6+ messages in thread
From: Dave Jones @ 2007-01-28 21:48 UTC (permalink / raw)
  To: Thomas Hellström; +Cc: Linux Kernel

On Sat, Jan 27, 2007 at 10:20:18AM +0100, Thomas Hellström wrote:
 > Hi!
 > 
 > Does anybody have a strong opinion against adding support for
 > i386 Page Attribute Tables?

It pops up about once a year, everyone agrees it'd be a good idea,
and then nothing happens.  Last year, I started picking over
Terrence Ripperda's original implementation, but that needs a bit
of work. (http://lkml.org/lkml/2005/5/12/187)
Whoa, two years even.  Time flies.

		Dave

-- 
http://www.codemonkey.org.uk

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Support for i386 PATs
  2007-01-28 21:48 ` Dave Jones
@ 2007-01-30 15:50   ` Thomas Hellström
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Hellström @ 2007-01-30 15:50 UTC (permalink / raw)
  To: Dave Jones, Thomas Hellström, Linux Kernel

Dave Jones wrote:
> On Sat, Jan 27, 2007 at 10:20:18AM +0100, Thomas Hellström wrote:
>  > Hi!
>  > 
>  > Does anybody have a strong opinion against adding support for
>  > i386 Page Attribute Tables?
>
> It pops up about once a year, everyone agrees it'd be a good idea,
> and then nothing happens.  Last year, I started picking over
> Terrence Ripperda's original implementation, but that needs a bit
> of work. (http://lkml.org/lkml/2005/5/12/187)
> Whoa, two years even.  Time flies.
>
> 		Dave
>
>   
Ah.
This might explain why nothing happens :).

I had something much simpler in mind.
Just the basic PAT setup and some new pgprot_ types which affected 
drivers could use directly.

Like in(drivers/char/drm/drm_vm.c) where ia64 has a 
pgprot_writecombine() function.

/Thomas





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Support for i386 PATs
  2007-01-27 10:59 Mikael Pettersson
@ 2007-01-28  7:54 ` H. Peter Anvin
  0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2007-01-28  7:54 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: linux-kernel, thomas

Mikael Pettersson wrote:
> 
> 3) Many Intel processors, including at least most P6s and probably
> also some P4s, have an erratum which effectively halves the number
> of available PAT entries, forcing an OS to make the low 4 and upper
> 4 PAT entries identical.
> 
> I don't know if 4 PAT types suffice for the kinds of uses people
> have in mind. But support for PAT would either have to restrict
> itself to only 4 PAT types, or ensure that it is only enabled on
> new enough processors where it actually works.
> 
> You will need to read all available Intel errata sheets (spec updates)
> to determine which processors are affected and which are OK.
> 

There aren't really that many useful caching types, so it probably 
doesn't matter all that much.

The types that matters most are WB, WC, and UC.  The fourth one could be 
WT, or it could be UC- (however, UC- can *always* be emulated by simply 
having the kernel being aware of the MTRR settings.)

	-hpa


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Support for i386 PATs
@ 2007-01-27 10:59 Mikael Pettersson
  2007-01-28  7:54 ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Pettersson @ 2007-01-27 10:59 UTC (permalink / raw)
  To: linux-kernel, thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

On Sat, 27 Jan 2007 10:20:18 +0100, Thomas Hellström wrote:
> Does anybody have a strong opinion against adding support for
> i386 Page Attribute Tables?
...
> Issues:
> 1) The _PAGE_BIT_PAT will be the same as _PAGE_PSE, and _PAGE_PROTNONE.
> As I understand it, _PAGE_PROTNONE is not used when the page is present, 
> so this might not be an issue.
> What about _PAGE_PSE?
> 
> 2) The PATs need to be setup for each processor just after system boot.
> Where is the best place to do this?

3) Many Intel processors, including at least most P6s and probably
also some P4s, have an erratum which effectively halves the number
of available PAT entries, forcing an OS to make the low 4 and upper
4 PAT entries identical.

I don't know if 4 PAT types suffice for the kinds of uses people
have in mind. But support for PAT would either have to restrict
itself to only 4 PAT types, or ensure that it is only enabled on
new enough processors where it actually works.

You will need to read all available Intel errata sheets (spec updates)
to determine which processors are affected and which are OK.

/Mikael

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-30 15:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-27  9:20 Support for i386 PATs Thomas Hellström
2007-01-27  9:33 ` Avi Kivity
2007-01-28 21:48 ` Dave Jones
2007-01-30 15:50   ` Thomas Hellström
2007-01-27 10:59 Mikael Pettersson
2007-01-28  7:54 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).