d|sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget#/translations/zh_CN/arch/riscv/bootmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/zh_TW/arch/riscv/bootmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/it_IT/arch/riscv/bootmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/ja_JP/arch/riscv/bootmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/ko_KR/arch/riscv/bootmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/sp_SP/arch/riscv/bootmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhh=/var/lib/git/docbuild/linux/Documentation/arch/riscv/boot.rsthKubhsection)}(hhh](htitle)}(h/RISC-V Kernel Boot Requirements and Constraintsh]h/RISC-V Kernel Boot Requirements and Constraints}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh field_list)}(hhh](hfield)}(hhh](h field_name)}(hAuthorh]hAuthor}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhKubh field_body)}(h(Alexandre Ghiti h]h paragraph)}(hhh](hAlexandre Ghiti <}(hhhhhNhNubh reference)}(halexghiti@rivosinc.comh]halexghiti@rivosinc.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:alexghiti@rivosinc.comuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hDateh]hDate}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhKubh)}(h 23 May 2023 h]h)}(h 23 May 2023h]h 23 May 2023}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj+ubah}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hX@This document describes what the RISC-V kernel expects from bootloaders and firmware, and also the constraints that any developer must have in mind when touching the early boot process. For the purposes of this document, the ``early boot process`` refers to any code that runs before the final virtual mapping is set up.h](hThis document describes what the RISC-V kernel expects from bootloaders and firmware, and also the constraints that any developer must have in mind when touching the early boot process. For the purposes of this document, the }(hjOhhhNhNubhliteral)}(h``early boot process``h]hearly boot process}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjOubhI refers to any code that runs before the final virtual mapping is set up.}(hjOhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hhh](h)}(h'Pre-kernel Requirements and Constraintsh]h'Pre-kernel Requirements and Constraints}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhjqhhhhhKubh)}(hMThe RISC-V kernel expects the following of bootloaders and platform firmware:h]hMThe RISC-V kernel expects the following of bootloaders and platform firmware:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjqhhubh)}(hhh](h)}(hRegister stateh]hRegister state}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hThe RISC-V kernel expects:h]hThe RISC-V kernel expects:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh block_quote)}(hs* ``$a0`` to contain the hartid of the current core. * ``$a1`` to contain the address of the devicetree in memory. h]h bullet_list)}(hhh](h list_item)}(h2``$a0`` to contain the hartid of the current core.h]h)}(hjh](jX)}(h``$a0``h]h$a0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh+ to contain the hartid of the current core.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h<``$a1`` to contain the address of the devicetree in memory. h]h)}(h;``$a1`` to contain the address of the devicetree in memory.h](jX)}(h``$a1``h]h$a1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh4 to contain the address of the devicetree in memory.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]bullet*uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubeh}(h]register-stateah ]h"]register stateah$]h&]uh1hhjqhhhhhKubh)}(hhh](h)}(h CSR stateh]h CSR state}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hThe RISC-V kernel expects:h]hThe RISC-V kernel expects:}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjhhubj)}(h8* ``$satp = 0``: the MMU, if present, must be disabled. h]j)}(hhh]j)}(h6``$satp = 0``: the MMU, if present, must be disabled. h]h)}(h5``$satp = 0``: the MMU, if present, must be disabled.h](jX)}(h ``$satp = 0``h]h $satp = 0}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjGubh(: the MMU, if present, must be disabled.}(hjGhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK"hjCubah}(h]h ]h"]h$]h&]uh1jhj@ubah}(h]h ]h"]h$]h&]j juh1jhhhK"hj<ubah}(h]h ]h"]h$]h&]uh1jhhhK"hjhhubeh}(h] csr-stateah ]h"] csr stateah$]h&]uh1hhjqhhhhhKubh)}(hhh](h)}(h%Reserved memory for resident firmwareh]h%Reserved memory for resident firmware}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj}hhhhhK%ubh)}(hThe RISC-V kernel must not map any resident memory, or memory protected with PMPs, in the direct mapping, so the firmware must correctly mark those regions as per the devicetree specification and/or the UEFI specification.h]hThe RISC-V kernel must not map any resident memory, or memory protected with PMPs, in the direct mapping, so the firmware must correctly mark those regions as per the devicetree specification and/or the UEFI specification.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hj}hhubeh}(h]%reserved-memory-for-resident-firmwareah ]h"]%reserved memory for resident firmwareah$]h&]uh1hhjqhhhhhK%ubh)}(hhh](h)}(hKernel locationh]hKernel location}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK,ubh)}(hThe RISC-V kernel expects to be placed at a PMD boundary (2MB aligned for rv64 and 4MB aligned for rv32). Note that the EFI stub will physically relocate the kernel if that's not the case.h]hThe RISC-V kernel expects to be placed at a PMD boundary (2MB aligned for rv64 and 4MB aligned for rv32). Note that the EFI stub will physically relocate the kernel if that’s not the case.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hjhhubeh}(h]kernel-locationah ]h"]kernel locationah$]h&]uh1hhjqhhhhhK,ubh)}(hhh](h)}(hHardware descriptionh]hHardware description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK3ubh)}(hNThe firmware can pass either a devicetree or ACPI tables to the RISC-V kernel.h]hNThe firmware can pass either a devicetree or ACPI tables to the RISC-V kernel.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjhhubh)}(hThe devicetree is either passed directly to the kernel from the previous stage using the ``$a1`` register, or when booting with UEFI, it can be passed using the EFI configuration table.h](hYThe devicetree is either passed directly to the kernel from the previous stage using the }(hjhhhNhNubjX)}(h``$a1``h]h$a1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubhY register, or when booting with UEFI, it can be passed using the EFI configuration table.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK7hjhhubh)}(hThe ACPI tables are passed to the kernel using the EFI configuration table. In this case, a tiny devicetree is still created by the EFI stub. Please refer to "EFI stub and devicetree" section below for details about this devicetree.h]hThe ACPI tables are passed to the kernel using the EFI configuration table. In this case, a tiny devicetree is still created by the EFI stub. Please refer to “EFI stub and devicetree” section below for details about this devicetree.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hjhhubeh}(h]hardware-descriptionah ]h"]hardware descriptionah$]h&]uh1hhjqhhhhhK3ubh)}(hhh](h)}(h Kernel entryh]h Kernel entry}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhK@ubh)}(h8On SMP systems, there are 2 methods to enter the kernel:h]h8On SMP systems, there are 2 methods to enter the kernel:}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKBhj hhubj)}(hhh](j)}(hX5``RISCV_BOOT_SPINWAIT``: the firmware releases all harts in the kernel, one hart wins a lottery and executes the early boot code while the other harts are parked waiting for the initialization to finish. This method is mostly used to support older firmwares without SBI HSM extension and M-mode RISC-V kernel.h]h)}(hX5``RISCV_BOOT_SPINWAIT``: the firmware releases all harts in the kernel, one hart wins a lottery and executes the early boot code while the other harts are parked waiting for the initialization to finish. This method is mostly used to support older firmwares without SBI HSM extension and M-mode RISC-V kernel.h](jX)}(h``RISCV_BOOT_SPINWAIT``h]hRISCV_BOOT_SPINWAIT}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjFubhX: the firmware releases all harts in the kernel, one hart wins a lottery and executes the early boot code while the other harts are parked waiting for the initialization to finish. This method is mostly used to support older firmwares without SBI HSM extension and M-mode RISC-V kernel.}(hjFhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKDhjBubah}(h]h ]h"]h$]h&]uh1jhj?hhhhhNubj)}(hX,``Ordered booting``: the firmware releases only one hart that will execute the initialization phase and then will start all other harts using the SBI HSM extension. The ordered booting method is the preferred booting method for booting the RISC-V kernel because it can support CPU hotplug and kexec. h]h)}(hX+``Ordered booting``: the firmware releases only one hart that will execute the initialization phase and then will start all other harts using the SBI HSM extension. The ordered booting method is the preferred booting method for booting the RISC-V kernel because it can support CPU hotplug and kexec.h](jX)}(h``Ordered booting``h]hOrdered booting}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjlubhX: the firmware releases only one hart that will execute the initialization phase and then will start all other harts using the SBI HSM extension. The ordered booting method is the preferred booting method for booting the RISC-V kernel because it can support CPU hotplug and kexec.}(hjlhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKHhjhubah}(h]h ]h"]h$]h&]uh1jhj?hhhhhNubeh}(h]h ]h"]h$]h&]j -uh1jhhhKDhj hhubeh}(h] kernel-entryah ]h"] kernel entryah$]h&]uh1hhjqhhhhhK@ubh)}(hhh](h)}(hUEFIh]hUEFI}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKNubh)}(hhh](h)}(hUEFI memory maph]hUEFI memory map}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKQubh)}(hiWhen booting with UEFI, the RISC-V kernel will use only the EFI memory map to populate the system memory.h]hiWhen booting with UEFI, the RISC-V kernel will use only the EFI memory map to populate the system memory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjhhubh)}(hXJThe UEFI firmware must parse the subnodes of the ``/reserved-memory`` devicetree node and abide by the devicetree specification to convert the attributes of those subnodes (``no-map`` and ``reusable``) into their correct EFI equivalent (refer to section "3.5.4 /reserved-memory and UEFI" of the devicetree specification v0.4-rc1).h](h1The UEFI firmware must parse the subnodes of the }(hjhhhNhNubjX)}(h``/reserved-memory``h]h/reserved-memory}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubhh devicetree node and abide by the devicetree specification to convert the attributes of those subnodes (}(hjhhhNhNubjX)}(h ``no-map``h]hno-map}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh and }(hjhhhNhNubjX)}(h ``reusable``h]hreusable}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh) into their correct EFI equivalent (refer to section “3.5.4 /reserved-memory and UEFI” of the devicetree specification v0.4-rc1).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKVhjhhubeh}(h]uefi-memory-mapah ]h"]uefi memory mapah$]h&]uh1hhjhhhhhKQubh)}(hhh](h)}(hRISCV_EFI_BOOT_PROTOCOLh]hRISCV_EFI_BOOT_PROTOCOL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK]ubh)}(hWhen booting with UEFI, the EFI stub requires the boot hartid in order to pass it to the RISC-V kernel in ``$a1``. The EFI stub retrieves the boot hartid using one of the following methods:h](hjWhen booting with UEFI, the EFI stub requires the boot hartid in order to pass it to the RISC-V kernel in }(hj*hhhNhNubjX)}(h``$a1``h]h$a1}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jWhj*ubhL. The EFI stub retrieves the boot hartid using one of the following methods:}(hj*hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK_hjhhubj)}(hhh](j)}(h,``RISCV_EFI_BOOT_PROTOCOL`` (**preferred**).h]h)}(hjOh](jX)}(h``RISCV_EFI_BOOT_PROTOCOL``h]hRISCV_EFI_BOOT_PROTOCOL}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjQubh (}(hjQhhhNhNubhstrong)}(h **preferred**h]h preferred}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjQubh).}(hjQhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKchjMubah}(h]h ]h"]h$]h&]uh1jhjJhhhhhNubj)}(h5``boot-hartid`` devicetree subnode (**deprecated**). h]h)}(h4``boot-hartid`` devicetree subnode (**deprecated**).h](jX)}(h``boot-hartid``h]h boot-hartid}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh devicetree subnode (}(hjhhhNhNubjg)}(h**deprecated**h]h deprecated}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKdhjubah}(h]h ]h"]h$]h&]uh1jhjJhhhhhNubeh}(h]h ]h"]h$]h&]j juh1jhhhKchjhhubh)}(hoAny new firmware must implement ``RISCV_EFI_BOOT_PROTOCOL`` as the devicetree based approach is deprecated now.h](h Any new firmware must implement }(hjhhhNhNubjX)}(h``RISCV_EFI_BOOT_PROTOCOL``h]hRISCV_EFI_BOOT_PROTOCOL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh4 as the devicetree based approach is deprecated now.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKfhjhhubeh}(h]riscv-efi-boot-protocolah ]h"]riscv_efi_boot_protocolah$]h&]uh1hhjhhhhhK]ubeh}(h]uefiah ]h"]uefiah$]h&]uh1hhjqhhhhhKNubeh}(h]'pre-kernel-requirements-and-constraintsah ]h"]'pre-kernel requirements and constraintsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h'Early Boot Requirements and Constraintsh]h'Early Boot Requirements and Constraints}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKjubh)}(hPThe RISC-V kernel's early boot process operates under the following constraints:h]hRThe RISC-V kernel’s early boot process operates under the following constraints:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKlhjhhubh)}(hhh](h)}(hEFI stub and devicetreeh]hEFI stub and devicetree}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKoubh)}(hWhen booting with UEFI, the devicetree is supplemented (or created) by the EFI stub with the same parameters as arm64 which are described at the paragraph "UEFI kernel support on ARM" in Documentation/arch/arm/uefi.rst.h]hWhen booting with UEFI, the devicetree is supplemented (or created) by the EFI stub with the same parameters as arm64 which are described at the paragraph “UEFI kernel support on ARM” in Documentation/arch/arm/uefi.rst.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKqhjhhubeh}(h]efi-stub-and-devicetreeah ]h"]efi stub and devicetreeah$]h&]uh1hhjhhhhhKoubh)}(hhh](h)}(hVirtual mapping installationh]hVirtual mapping installation}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjBhhhhhKvubh)}(hPThe installation of the virtual mapping is done in 2 steps in the RISC-V kernel:h]hPThe installation of the virtual mapping is done in 2 steps in the RISC-V kernel:}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKxhjBhhubhenumerated_list)}(hhh](j)}(hXl``setup_vm()`` installs a temporary kernel mapping in ``early_pg_dir`` which allows discovery of the system memory. Only the kernel text/data are mapped at this point. When establishing this mapping, no allocation can be done (since the system memory is not known yet), so ``early_pg_dir`` page table is statically allocated (using only one table for each level). h]h)}(hXk``setup_vm()`` installs a temporary kernel mapping in ``early_pg_dir`` which allows discovery of the system memory. Only the kernel text/data are mapped at this point. When establishing this mapping, no allocation can be done (since the system memory is not known yet), so ``early_pg_dir`` page table is statically allocated (using only one table for each level).h](jX)}(h``setup_vm()``h]h setup_vm()}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjjubh( installs a temporary kernel mapping in }(hjjhhhNhNubjX)}(h``early_pg_dir``h]h early_pg_dir}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjjubh which allows discovery of the system memory. Only the kernel text/data are mapped at this point. When establishing this mapping, no allocation can be done (since the system memory is not known yet), so }(hjjhhhNhNubjX)}(h``early_pg_dir``h]h early_pg_dir}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjjubhJ page table is statically allocated (using only one table for each level).}(hjjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKzhjfubah}(h]h ]h"]h$]h&]uh1jhjchhhhhNubj)}(hX``setup_vm_final()`` creates the final kernel mapping in ``swapper_pg_dir`` and takes advantage of the discovered system memory to create the linear mapping. When establishing this mapping, the kernel can allocate memory but cannot access it directly (since the direct mapping is not present yet), so it uses temporary mappings in the fixmap region to be able to access the newly allocated page table levels. h]h)}(hX``setup_vm_final()`` creates the final kernel mapping in ``swapper_pg_dir`` and takes advantage of the discovered system memory to create the linear mapping. When establishing this mapping, the kernel can allocate memory but cannot access it directly (since the direct mapping is not present yet), so it uses temporary mappings in the fixmap region to be able to access the newly allocated page table levels.h](jX)}(h``setup_vm_final()``h]hsetup_vm_final()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh% creates the final kernel mapping in }(hjhhhNhNubjX)}(h``swapper_pg_dir``h]hswapper_pg_dir}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubhXM and takes advantage of the discovered system memory to create the linear mapping. When establishing this mapping, the kernel can allocate memory but cannot access it directly (since the direct mapping is not present yet), so it uses temporary mappings in the fixmap region to be able to access the newly allocated page table levels.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjchhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jahjBhhhhhKzubh)}(hXFor ``virt_to_phys()`` and ``phys_to_virt()`` to be able to correctly convert direct mapping addresses to physical addresses, they need to know the start of the DRAM. This happens after step 1, right before step 2 installs the direct mapping (see ``setup_bootmem()`` function in arch/riscv/mm/init.c). Any usage of those macros before the final virtual mapping is installed must be carefully examined.h](hFor }(hjhhhNhNubjX)}(h``virt_to_phys()``h]hvirt_to_phys()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh and }(hjhhhNhNubjX)}(h``phys_to_virt()``h]hphys_to_virt()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh to be able to correctly convert direct mapping addresses to physical addresses, they need to know the start of the DRAM. This happens after step 1, right before step 2 installs the direct mapping (see }(hjhhhNhNubjX)}(h``setup_bootmem()``h]hsetup_bootmem()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh function in arch/riscv/mm/init.c). Any usage of those macros before the final virtual mapping is installed must be carefully examined.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjBhhubeh}(h]virtual-mapping-installationah ]h"]virtual mapping installationah$]h&]uh1hhjhhhhhKvubh)}(hhh](h)}(hDevicetree mapping via fixmaph]hDevicetree mapping via fixmap}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj?hhhhhKubh)}(hX/As the ``reserved_mem`` array is initialized with virtual addresses established by ``setup_vm()``, and used with the mapping established by ``setup_vm_final()``, the RISC-V kernel uses the fixmap region to map the devicetree. This ensures that the devicetree remains accessible by both virtual mappings.h](hAs the }(hjPhhhNhNubjX)}(h``reserved_mem``h]h reserved_mem}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjPubh< array is initialized with virtual addresses established by }(hjPhhhNhNubjX)}(h``setup_vm()``h]h setup_vm()}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjPubh+, and used with the mapping established by }(hjPhhhNhNubjX)}(h``setup_vm_final()``h]hsetup_vm_final()}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjPubh, the RISC-V kernel uses the fixmap region to map the devicetree. This ensures that the devicetree remains accessible by both virtual mappings.}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubeh}(h]devicetree-mapping-via-fixmapah ]h"]devicetree mapping via fixmapah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hPre-MMU executionh]hPre-MMU execution}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXA few pieces of code need to run before even the first virtual mapping is established. These are the installation of the first virtual mapping itself, patching of early alternatives and the early parsing of the kernel command line. That code must be very carefully compiled as:h]hXA few pieces of code need to run before even the first virtual mapping is established. These are the installation of the first virtual mapping itself, patching of early alternatives and the early parsing of the kernel command line. That code must be very carefully compiled as:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j)}(h``-fno-pie``: This is needed for relocatable kernels which use ``-fPIE``, since otherwise, any access to a global symbol would go through the GOT which is only relocated virtually.h]h)}(h``-fno-pie``: This is needed for relocatable kernels which use ``-fPIE``, since otherwise, any access to a global symbol would go through the GOT which is only relocated virtually.h](jX)}(h ``-fno-pie``h]h-fno-pie}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubh3: This is needed for relocatable kernels which use }(hjhhhNhNubjX)}(h ``-fPIE``h]h-fPIE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubhl, since otherwise, any access to a global symbol would go through the GOT which is only relocated virtually.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h``-mcmodel=medany``: Any access to a global symbol must be PC-relative to avoid any relocations to happen before the MMU is setup.h]h)}(h``-mcmodel=medany``: Any access to a global symbol must be PC-relative to avoid any relocations to happen before the MMU is setup.h](jX)}(h``-mcmodel=medany``h]h-mcmodel=medany}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jWhjubho: Any access to a global symbol must be PC-relative to avoid any relocations to happen before the MMU is setup.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hV*all* instrumentation must also be disabled (that includes KASAN, ftrace and others). h]h)}(hU*all* instrumentation must also be disabled (that includes KASAN, ftrace and others).h](hemphasis)}(h*all*h]hall}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1j$hj ubhP instrumentation must also be disabled (that includes KASAN, ftrace and others).}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]j juh1jhhhKhjhhubh)}(hAs using a symbol from a different compilation unit requires this unit to be compiled with those flags, we advise, as much as possible, not to use external symbols.h]hAs using a symbol from a different compilation unit requires this unit to be compiled with those flags, we advise, as much as possible, not to use external symbols.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]pre-mmu-executionah ]h"]pre-mmu executionah$]h&]uh1hhjhhhhhKubeh}(h]'early-boot-requirements-and-constraintsah ]h"]'early boot requirements and constraintsah$]h&]uh1hhhhhhhhKjubeh}(h]/risc-v-kernel-boot-requirements-and-constraintsah ]h"]/risc-v kernel boot requirements and constraintsah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jmjjjjjjjzjwjjjjjjjjjjjjjjjejbj?j<j<j9jjj]jZu nametypes}(jmjjjzjjjjjjjjej?j<jj]uh}(jjhjjqjjjwjjj}jjjjjj jjjjjjjbjj<jj9jBjj?jZju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.