I've committed several improvements in amd64 these last days.
In chronological order, for the record: - I cleaned up the asm code and fixed several comments, which makes the boot process much easier to understand. - I fixed the alignment for the text segment, so that it can be covered by more large pages [1] - thereby reducing TLB contention. - I fixed a bug in the way the secondary CPUs are launched [2], which caused them to crash if they tried to access an X-less page. - I took rodata out of the text+rodata chunk, and put it in the data+bss+ PRELOADED_MODULES+BOOTSTRAP_TABLES chunk [3]. rodata was no longer large page optimized, and had RWX permissions. - I retook rodata out of the rodata+data+bss+PRELOADED_MODULES+ BOOTSTRAP_TABLES chunk, and made the kernel map it independently without the W permision [4]. - I made the kernel map rodata without the X permission, by using the NOX bit on its pages [5] (now that the secondary CPUs could handle that properly). - I took the data+bss chunk out of the data+bss+PRELOADED_MODULES+ BOOTSTRAP_TABLES chunk, and made the kernel map it independently without X permission [6]. - I made the kernel remap rodata and data+bss with large pages and proper permissions [7] - which reduces once again TLB contention. Now, the way the kernel image is mapped is more flexible, more secure and more performant. There are still several things to fix, and the same procedure needs to be applied in i386. If you have questions, comments, if you think something is wrong, or if you spot any mistakes, feel free to tell me about it. Also, if someone could review the last change, that would be nice. [1] http://mail-index.netbsd.org/source-changes/2016/05/07/msg074501.html [2] http://mail-index.netbsd.org/source-changes/2016/05/11/msg074613.html [3] http://mail-index.netbsd.org/source-changes/2016/05/12/msg074625.html [4] http://mail-index.netbsd.org/source-changes/2016/05/12/msg074627.html [5] http://mail-index.netbsd.org/source-changes/2016/05/12/msg074628.html [6] http://mail-index.netbsd.org/source-changes/2016/05/12/msg074632.html [7] http://mail-index.netbsd.org/source-changes/2016/05/13/msg074650.html