Difference between revisions of "Page size"

From RCS Wiki
Jump to navigation Jump to search
(→‎Fedora: Update for Fedora 41)
 
(One intermediate revision by the same user not shown)
Line 47: Line 47:
 
Example commands to build and install a 4KiB kernel in Fedora (which defaults to 64KiB):
 
Example commands to build and install a 4KiB kernel in Fedora (which defaults to 64KiB):
  
  sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel grubby  
+
  sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel grubby
 
  fedpkg co -a kernel
 
  fedpkg co -a kernel
 
  cd kernel
 
  cd kernel
  git checkout -b f38 origin/f38
+
  git checkout -b f41 origin/f41
 
  sudo dnf builddep kernel.spec
 
  sudo dnf builddep kernel.spec
 
  echo "CONFIG_PPC_4K_PAGES=y" >> ./kernel-local
 
  echo "CONFIG_PPC_4K_PAGES=y" >> ./kernel-local
 
  echo "# CONFIG_PPC_64K_PAGES is not set" >> ./kernel-local
 
  echo "# CONFIG_PPC_64K_PAGES is not set" >> ./kernel-local
echo "CONFIG_ARCH_FORCE_MAX_ORDER=13" >> ./kernel-local
 
 
  sed -i "s/Release: %{pkg_release}/Release: %{pkg_release}.4KiB/" kernel.spec
 
  sed -i "s/Release: %{pkg_release}/Release: %{pkg_release}.4KiB/" kernel.spec
  fedpkg local
+
  fedpkg local --arch ppc64le --without configchecks
 
  sudo dnf install ./ppc64le/*.rpm
 
  sudo dnf install ./ppc64le/*.rpm
  
(Credit to [https://fedoraproject.org/wiki/Building_a_custom_kernel Fedora wiki], [https://blog.aloni.org/posts/how-to-easily-patch-fedora-packages/ Dan Aloni], and [https://www.talospace.com/2020/10/where-did-64k-page-size-come-from.html?showComment=1602055031282#c2531945329855814440 Skirmisher] for some of the above incantations.)
+
(Credit to [https://fedoraproject.org/wiki/Building_a_custom_kernel Fedora wiki], [https://blog.aloni.org/posts/how-to-easily-patch-fedora-packages/ Dan Aloni], [https://www.talospace.com/2020/10/where-did-64k-page-size-come-from.html?showComment=1602055031282#c2531945329855814440 Skirmisher], and [https://discussion.fedoraproject.org/t/customizing-kernel-configuration/122909/2 Thomas] for some of the above incantations.)

Latest revision as of 03:00, 1 December 2024

POWER supports both 4KiB and 64KiB page sizes; this is in contrast to x86, which supports only 4KiB.

Security

4KiB mode has a security advantage over 64KiB mode: 4KiB mode allows up to 33 bits of ASLR entropy, while 64KiB mode only allows up to 29 bits. This may make exploitation mildly more difficult in 4KiB mode.

Performance

64KiB mode yields performance improvements for some workloads, if sufficient RAM is available. However, 64KiB mode also incurs higher RAM usage, so users with limited RAM will see better performance in 4KiB mode. These benchmark results may provide an idea of what kind of performance impact to expect.

Porting Buggy Software

With rare exceptions (e.g. emulation), correctly written software will work in both 4KiB and 64KiB modes without issues. However, if software was only subject to QA testing on one page size, there is a nontrivial chance that it was written to rely on assumptions that only are accurate for that mode. Such breakage is most common in hardware drivers. In practice, this means that hardware drivers that were exclusively tested on x86 are likely to exhibit bugs in 64KiB mode, while some POWER-specific hardware drivers are likely to exhibit bugs in 4KiB mode.

The Hardware Compatibility List may be helpful in checking which page sizes your preferred hardware's drivers support, or finding hardware whose drivers support your preferred page size. For checking other software support, the Ports List may be helpful.

Emulation

User-mode emulators (e.g. Box86) work most reliably when the host and guest page size are the same. Some emulators are able to emulate a different page size, but doing so increases the complexity and decreases the accuracy of the emulation, which may or may not cause bugs. In practice, this means that if you are emulating x86 software, you will probably experience fewer bugs in 4KiB mode.

Virtual Machines

Virtual machine guests (in KVM-HV) can run in either page size, regardless of the host OS's page size. This can be a good approach if you need to run a specific software package that doesn't support your host OS's page size. Caveats:

  • If you're using a 64KiB guest that has a Radix MMU, you will need to add an extra flag if your host is 4KiB.
  • If you're using a 64KiB guest that has an HPT MMU, then your host must also be 64KiB.

Checking Your Page Size

You can check your kernel's page size with this command:

getconf PAGESIZE

Changing Your Page Size

You can build a kernel with your preferred page size via Linux's CONFIG_PPC_4K_PAGES and CONFIG_PPC_64K_PAGES options.

Debian

Debian packages both 4KiB and 64KiB kernels as of Linux 6.10:

  • For 4KiB, install linux-image-powerpc64le.
  • For 64KiB, install linux-image-powerpc64le-64k.

Fedora

Example commands to build and install a 4KiB kernel in Fedora (which defaults to 64KiB):

sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel grubby
fedpkg co -a kernel
cd kernel
git checkout -b f41 origin/f41
sudo dnf builddep kernel.spec
echo "CONFIG_PPC_4K_PAGES=y" >> ./kernel-local
echo "# CONFIG_PPC_64K_PAGES is not set" >> ./kernel-local
sed -i "s/Release: %{pkg_release}/Release: %{pkg_release}.4KiB/" kernel.spec
fedpkg local --arch ppc64le --without configchecks
sudo dnf install ./ppc64le/*.rpm

(Credit to Fedora wiki, Dan Aloni, Skirmisher, and Thomas for some of the above incantations.)