1 |
"Juliano Morais Barbosa" <barbosa@×××××××××××××××××.br> posted |
2 |
01a201c679e1$c73faf80$c902a8c0@t201, excerpted below, on Wed, 17 May 2006 |
3 |
15:43:09 -0300: |
4 |
|
5 |
> I have gentoo 2.6.16-gentoo-r1-Flexsolutions #1 SMP Thu Mar 30 08:21:07 BRT |
6 |
> 2006 x86_64 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux with |
7 |
> 4Gb of RAM but in top I see 3Gb, and the kernel don´t have option for High |
8 |
> Memory Option. |
9 |
|
10 |
The latter (lack of a kernel himem option) is because amd64 has a flat |
11 |
memory model, up thru some huge multi-terabyte number, anyway. |
12 |
|
13 |
What you are seeing isn't therefore a problem with the kernel, but due to |
14 |
certain hardware limitations and the BIOS config options that work around |
15 |
them (and one kernel option that's indirectly related). |
16 |
|
17 |
The problem is this: The old 32-bit PCI system was designed to work in |
18 |
32-bits (obviously), and as such can only directly address 32-bits of |
19 |
memory. As it happens, that's 4 gigabytes. For compatibility with those |
20 |
legacy PCI devices, there's a "memory hole" in the last quarter or half a |
21 |
gig below the 4-gig boundary, designed such that the address space in that |
22 |
hole is reserved for use by those legacy PCI devices, rather than for use |
23 |
as memory. |
24 |
|
25 |
If you remember the bad old days of MS-DOS and sub-megabyte memory, this |
26 |
memory hole is comparable to the 640K-1MB MS-DOS High Memory Area, which |
27 |
could only be used by device drivers and the like, and formed a hole |
28 |
between conventional memory (640K down) and the XMS or EMS memory living |
29 |
above a megabyte. Even if you weren't running an OS that was restricted |
30 |
to 640KB of conventional memory, you pretty much had to observe that hole, |
31 |
because that's where all the various hardware devices expected to be, and |
32 |
where the motherboards themselves were hard wired (MTRR and hardware cache |
33 |
control) to expect hardware access to be as well. |
34 |
|
35 |
Your BIOS should have two options that control how memory, once you get |
36 |
enough to be blocked by the memory hole (IOW, 4 gig), is presented to |
37 |
software. It's unfortunately rather difficult to take a look at the BIOS |
38 |
while I'm writing this and get the wording exactly right, but there should |
39 |
be an option that toggles between ignoring the hole, so part of your |
40 |
memory isn't accessible, and remapping the affected memory into the above |
41 |
4 GB area, effectively bringing it out from behind the PCI hardware |
42 |
address space overlay that would otherwise hide it. |
43 |
|
44 |
The second BIOS option again deals with MTRRs (which control hardware |
45 |
caching) and how they describe the memory hole space, either Contiguous, |
46 |
making no distinction between this space and memory (marking it cachable |
47 |
just as is normal memory), or Discrete, treating the area as distinct from |
48 |
memory (with a specific mapping marking it uncachable). There are a |
49 |
limited number of MTRRs and more of them are used up mapping it |
50 |
discrete/uncachable, but certain hardware will have issues if it's marked |
51 |
contiguous/cachable. I'd suggest experimenting with this one. |
52 |
|
53 |
Once you get the first BIOS option set correctly, you should be see all |
54 |
your memory. However, there's then a new problem. DMA transfers data |
55 |
efficiently between hardware on the bus and memory, but if that hardware |
56 |
can only see 32-bits (4 gigs) worth of memory, and you now have memory |
57 |
mapped above that, you now have memory that can't be directly addressed by |
58 |
DMA. |
59 |
|
60 |
This is where the kernel comes in. Authentic AMD AMD64 CPUs can take |
61 |
advantage of a feature in their hardware GART (Graphics Address Remapping |
62 |
Table) to use it as a hardware IOMMU (i/o memory management unit, |
63 |
basically a hardware memory remapper that allows DMA to access >4 gig as |
64 |
if it was below the barrier instead of above it) as well, not just for |
65 |
graphics, but for PCI bus hardware in general. Unfortunately, Intel CPUs |
66 |
implementing x86_64/amd64 don't have this hardware, so they must emulate |
67 |
it in software. When compiling for x86_64, however, there's a single |
68 |
kernel option that enabled both, handling it with the emulation on Intel, |
69 |
taking advantage of the hardware on true AMD64. In menuconfig, it's under |
70 |
"Processor Type and Features". The exact description of the option there |
71 |
has changed recently to make it clearer what it does. In 2.6.17-rcX (and |
72 |
IIRC 2.6.16, but not .15 or earlier, which used the earlier wording), the |
73 |
option is "K8 GART IOMMU support". You'll probably want this enabled. Note |
74 |
that with 2.6.16 and later, you'll almost certainly HAVE to have it |
75 |
enabled if you use SATA or SCSI, as their drivers will locate above the 4G |
76 |
boundary if there's memory up there to locate into, and at least in some |
77 |
instances, the hardware will only do 32-bit, so you'll kernel panic as it |
78 |
tries to load on boot, if you don't have that option on. (Kernel 2.6.15 |
79 |
and previous used software bounce-buffers for the SCSI drivers, and |
80 |
therefore libATA based SATA which uses SCSI, regardless. Of course, this |
81 |
eliminated many of the benefits of DMA, one reason they switched in 2.6.16 |
82 |
to going thru the GART/IOMMU where available. The lack of such hardware |
83 |
on Intel means they still use software bounce buffers, only now controlled |
84 |
by the IOMMU instead of the SCSI layer. Of course, this is one of the |
85 |
ways Intel's em64t solution is inferior to true amd64, but honestly, most |
86 |
won't see it as most aren't using 4 gig or greater memory yet anyway.) |
87 |
|
88 |
There's a couple more catches to it, however. The first one is back in |
89 |
BIOS again. I'm not sure if it affects all chipsets, but here at least, |
90 |
the AGP Fastwrite option is entirely incompatible with a working |
91 |
GART/IOMMU. I looked long and hard but never did find mention of that |
92 |
elsewhere, and only found out by accident when I happened to twiddle the |
93 |
IOMMU thing that never worked for me on, at the same time I twiddled the |
94 |
BIOS AGP Fastwrite option off, and found both the GART and the IOMMU now |
95 |
worked! |
96 |
|
97 |
The second catch has to do with slaveryware video drivers. Naturally, if |
98 |
you are running a slaveryware GART, you won't be using the one in the |
99 |
kernel, and won't be able to make use of the kernel's GART/IOMMU option. |
100 |
You'll have to look elsewhere for help in that case, as I know nothing |
101 |
about it, beyond having read a (possibly misinformed) comment by an NVidia |
102 |
user that their GART implementation didn't do the IOMMU stuff. |
103 |
|
104 |
-- |
105 |
Duncan - List replies preferred. No HTML msgs. |
106 |
"Every nonfree program has a lord, a master -- |
107 |
and if you use the program, he is your master." Richard Stallman |
108 |
|
109 |
-- |
110 |
gentoo-amd64@g.o mailing list |