<div dir="ltr">Good find Pramod,<div><br></div><div>I did see that there is also some reference to the AMD x68_64 architecture page that limits the physical address to be 52-bit max and the virtual address to be 48-bits[1]. </div>
<div class="gmail_extra"><br>[1] <a href="http://developer.amd.com/wordpress/media/2012/10/24593_APM_v2.pdf">http://developer.amd.com/wordpress/media/2012/10/24593_APM_v2.pdf</a> - pages 118-120</div><div class="gmail_extra">
<br><div class="gmail_quote">On Fri, Mar 7, 2014 at 12:14 AM, pramod gurav <span dir="ltr">&lt;<a href="mailto:pramod.gurav.etc@gmail.com" target="_blank">pramod.gurav.etc@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5">On Thu, Mar 6, 2014 at 11:18 PM, Subramaniam Appadodharana<br>
&lt;<a href="mailto:c.a.subramaniam@gmail.com">c.a.subramaniam@gmail.com</a>&gt; wrote:<br>
&gt; Jeff/Pramod,<br>
&gt;<br>
&gt; I think what Pramod mentioned is partly right. However, I do not have more<br>
&gt; info on that yet. Will get back after some more digging in. For kernel<br>
&gt; memory<br>
&gt; addresses you can do,<br>
&gt;<br>
&gt; sudo cat /proc/vmallocinfo<br>
&gt;<br>
&gt; This is in line with what Jeff mentioned. I will check why the upper 16 bits<br>
&gt; are set to 1.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Mar 6, 2014 at 11:13 AM, Jeff Haran &lt;<a href="mailto:Jeff.Haran@citrix.com">Jeff.Haran@citrix.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt; -----Original Message-----<br>
&gt;&gt; &gt; From: pramod gurav [mailto:<a href="mailto:pramod.gurav.etc@gmail.com">pramod.gurav.etc@gmail.com</a>]<br>
&gt;&gt; &gt; Sent: Thursday, March 06, 2014 12:56 AM<br>
&gt;&gt; &gt; To: Jeff Haran<br>
&gt;&gt; &gt; Cc: priyaranjan; kernelnewbies<br>
&gt;&gt; &gt; Subject: Re: Linux MM : virtual memory address space<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Wed, Mar 5, 2014 at 12:39 AM, Jeff Haran &lt;<a href="mailto:Jeff.Haran@citrix.com">Jeff.Haran@citrix.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; From: <a href="mailto:kernelnewbies-bounces@kernelnewbies.org">kernelnewbies-bounces@kernelnewbies.org</a><br>
&gt;&gt; &gt; &gt; [mailto:<a href="mailto:kernelnewbies-bounces@kernelnewbies.org">kernelnewbies-bounces@kernelnewbies.org</a>] On Behalf Of pramod<br>
&gt;&gt; &gt; &gt; gurav<br>
&gt;&gt; &gt; &gt; Sent: Monday, March 03, 2014 11:33 PM<br>
&gt;&gt; &gt; &gt; To: priyaranjan<br>
&gt;&gt; &gt; &gt; Cc: kernelnewbies<br>
&gt;&gt; &gt; &gt; Subject: Re: Linux MM : virtual memory address space<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; On Mon, Mar 3, 2014 at 11:52 PM, priyaranjan<br>
&gt;&gt; &gt; &gt; &lt;<a href="mailto:priyaranjan45678@gmail.com">priyaranjan45678@gmail.com</a>&gt;<br>
&gt;&gt; &gt; &gt; wrote:<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; I was going through <a href="http://linux-mm.org/HighMemory" target="_blank">http://linux-mm.org/HighMemory</a><br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &quot;Currently the 32 bit x86 architecture is the most popular type of<br>
&gt;&gt; &gt; &gt; computer.<br>
&gt;&gt; &gt; &gt; In this architecture, traditionally the Linux kernel has split the 4GB<br>
&gt;&gt; &gt; &gt; of<br>
&gt;&gt; &gt; &gt; virtual memory address space into 3GB for user programs and 1GB for<br>
&gt;&gt; &gt; &gt; the<br>
&gt;&gt; &gt; &gt; kernel&quot;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; What about 64-bit system? Where does the code lie in linux kernel for<br>
&gt;&gt; &gt; &gt; the<br>
&gt;&gt; &gt; &gt; check?<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Is there any latest and updated memory management documentation for<br>
&gt;&gt; &gt; &gt; Linux<br>
&gt;&gt; &gt; &gt; kernel?<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Regards,<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Priyaranjan<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Priyaranjan,<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; As below link suggests:<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; <a href="http://users.nccs.gov/~fwang2/linux/lk_addressing.txt" target="_blank">http://users.nccs.gov/~fwang2/linux/lk_addressing.txt</a><br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Also read this blog written in chinese:<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; <a href="http://adam8157.info/blog/2012/07/linux-x86-64-vm/" target="_blank">http://adam8157.info/blog/2012/07/linux-x86-64-vm/</a><br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; on 64 bit arch the virtual address space is huge (2 to thr power of<br>
&gt;&gt; &gt; &gt; 64). So<br>
&gt;&gt; &gt; &gt; the overhead of translating the virtual addresses will be high. TO<br>
&gt;&gt; &gt; &gt; avoid<br>
&gt;&gt; &gt; &gt; this only lower 48 bits are used to form virtual addresses.<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; I believe this statement about only the lower 48 bits being used it<br>
&gt;&gt; &gt; &gt; not<br>
&gt;&gt; &gt; &gt; correct. That would imply that the upper 16 bits of all virtual<br>
&gt;&gt; &gt; &gt; addresses on<br>
&gt;&gt; &gt; &gt; x86_64 would be the same, which is clearly not the case since the<br>
&gt;&gt; &gt; &gt; upper 16<br>
&gt;&gt; &gt; &gt; bits of user space vas are all 0s yet the upper 16 bits of kernel<br>
&gt;&gt; &gt; &gt; space vas<br>
&gt;&gt; &gt; &gt; are all 1s.<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Jeff Haran<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; Hi Jeff,<br>
&gt;&gt; &gt; Just noticed a line in /proc/cpuinfo on my 64 bit linux Machine which<br>
&gt;&gt; &gt; is:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --&gt; address sizes : 36 bits physical, 48 bits virtual<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; This should confirm the statement that, only lower 48 bits are used<br>
&gt;&gt; &gt; for virtual address space on a 64 it arch.<br>
&gt;&gt; &gt; And about upper 16 bits in kernel being 1s in the address range shown<br>
&gt;&gt; &gt; in the link, I think they are not correct.<br>
&gt;&gt;<br>
&gt;&gt; All I can suggest is that you take a kernel and modify it to prink() the<br>
&gt;&gt; virtual address of some kernel data structure (or write a module to do the<br>
&gt;&gt; same) and see for yourself. At least on the x86_64 systems I use, the<br>
&gt;&gt; address of for example a struct sk_buff, which is allocated from a kmem<br>
&gt;&gt; cache, is in the upper end of the 64 bit address range. The top 16 bits are<br>
&gt;&gt; all 1s. Always. This is running recent Redhat EL6, but I believe the same<br>
&gt;&gt; will be true for kernels from <a href="http://kernel.org" target="_blank">kernel.org</a>.<br>
&gt;&gt;<br>
&gt;&gt; Jeff Haran<br>
&gt;&gt;<br>
&gt;&gt;<br>
<br>
</div></div>Jeff, Subbu,<br>
<br>
Please refer to the wiki page here,<br>
<a href="http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details" target="_blank">http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details</a><br>
<br>
This talks about something like canonical form of addresses. A quote<br>
in the page says, &quot; Canonical form addresses run from 0 through<br>
00007FFF&#39;FFFFFFFF, and from FFFF8000&#39;00000000 through<br>
FFFFFFFF&#39;FFFFFFFF, for a total of 256 TB of usable virtual address<br>
space&quot;.<br>
<br>
Possibly this is the reason we are getting all upper 16 bits in 1s for<br>
kernel virtual address space. which means kernel virtual address space<br>
range on 64 bit arch is  FFFF8000&#39;00000000 - FFFFFFFF&#39;FFFFFFFF which<br>
higher part of 256 TB vurtual address space.  But for user space it is<br>
lower half of 256TB. You need not write a code for this. You ca just<br>
cat memory maps of any process running in system. Example:<br>
<br>
gpramod@localhost:$ sudo cat /proc/1/maps<br>
<br>
First part is user process mapped in user space virtual address space:<br>
7faf6de70000-7faf6de7c000 r-xp 00000000 08:05 2102384<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_files-2.15.so" target="_blank">libnss_files-2.15.so</a><br>
7faf6de7c000-7faf6e07b000 ---p 0000c000 08:05 2102384<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_files-2.15.so" target="_blank">libnss_files-2.15.so</a><br>
7faf6e07b000-7faf6e07c000 r--p 0000b000 08:05 2102384<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_files-2.15.so" target="_blank">libnss_files-2.15.so</a><br>
7faf6e07c000-7faf6e07d000 rw-p 0000c000 08:05 2102384<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_files-2.15.so" target="_blank">libnss_files-2.15.so</a><br>
7faf6e07d000-7faf6e087000 r-xp 00000000 08:05 2102388<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_nis-2.15.so" target="_blank">libnss_nis-2.15.so</a><br>
7faf6e087000-7faf6e287000 ---p 0000a000 08:05 2102388<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_nis-2.15.so" target="_blank">libnss_nis-2.15.so</a><br>
7faf6e287000-7faf6e288000 r--p 0000a000 08:05 2102388<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_nis-2.15.so" target="_blank">libnss_nis-2.15.so</a><br>
7faf6e288000-7faf6e289000 rw-p 0000b000 08:05 2102388<br>
  /lib/x86_64-linux-gnu/<a href="http://libnss_nis-2.15.so" target="_blank">libnss_nis-2.15.so</a><br>
7faf6e289000-7faf6e2a0000 r-xp 00000000 08:05 2102400<br>
  /lib/x86_64-linux-gnu/<a href="http://libnsl-2.15.so" target="_blank">libnsl-2.15.so</a><br>
.<br>
.<br>
.<br>
.<br>
.<br>
.<br>
(Last part is Kernel process (system calls) mapped in Kernel virtual<br>
address space:)<br>
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0<br>
  [vsyscall]<br>
<br>
So what you said is correct about the upper 16 bits being 1s. It also<br>
verifies the &quot;48 bits for virtual address space&quot; theory as well.<br>
<div class="im"><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Kernelnewbies mailing list<br>
&gt;&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt;&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div><div class=""><div class="h5">--<br>
Thanks and Regards<br>
Pramod<br>
</div></div></blockquote></div><br></div></div>