€•9}Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ#/translations/zh_CN/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/zh_TW/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/it_IT/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ja_JP/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ko_KR/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/pt_BR/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/sp_SP/arch/riscv/boot”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ=/var/lib/git/docbuild/linux/Documentation/arch/riscv/boot.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ/RISC-V Kernel Boot Requirements and Constraints”h]”hŒ/RISC-V Kernel Boot Requirements and Constraints”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ field_list”“”)”}”(hhh]”(hŒfield”“”)”}”(hhh]”(hŒ field_name”“”)”}”(hŒAuthor”h]”hŒAuthor”…””}”(hhéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhhäh³hÇh´KubhŒ field_body”“”)”}”(hŒ(Alexandre Ghiti ”h]”hŒ paragraph”“”)”}”(hhûh]”(hŒAlexandre Ghiti <”…””}”(hhÿh²hh³Nh´NubhŒ reference”“”)”}”(hŒalexghiti@rivosinc.com”h]”hŒalexghiti@rivosinc.com”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:alexghiti@rivosinc.com”uh1jhhÿubhŒ>”…””}”(hhÿh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khhùubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷hhäubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÇh´Khhßh²hubhã)”}”(hhh]”(hè)”}”(hŒDate”h]”hŒDate”…””}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj.h³hÇh´Kubhø)”}”(hŒ 23 May 2023 ”h]”hþ)”}”(hŒ 23 May 2023”h]”hŒ 23 May 2023”…””}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷hj.ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÇh´Khhßh²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhhÊh²hh³hÇh´Kubhþ)”}”(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]”(hŒá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 ”…””}”(hjch²hh³Nh´NubhŒliteral”“”)”}”(hŒ``early boot process``”h]”hŒearly boot process”…””}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjcubhŒI refers to any code that runs before the final virtual mapping is set up.”…””}”(hjch²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K hhÊh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒ'Pre-kernel Requirements and Constraints”h]”hŒ'Pre-kernel Requirements and Constraints”…””}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj…h²hh³hÇh´Kubhþ)”}”(hŒMThe RISC-V kernel expects the following of bootloaders and platform firmware:”h]”hŒMThe RISC-V kernel expects the following of bootloaders and platform firmware:”…””}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khj…h²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒRegister state”h]”hŒRegister state”…””}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj¤h²hh³hÇh´Kubhþ)”}”(hŒThe RISC-V kernel expects:”h]”hŒThe RISC-V kernel expects:”…””}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khj¤h²hubhŒ block_quote”“”)”}”(hŒs* ``$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”“”)”}”(hŒ2``$a0`` to contain the hartid of the current core.”h]”hþ)”}”(hjÒh]”(jl)”}”(hŒ``$a0``”h]”hŒ$a0”…””}”(hj×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjÔubhŒ+ to contain the hartid of the current core.”…””}”(hjÔh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KhjÐubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjËubjÏ)”}”(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]”(jl)”}”(hŒ``$a1``”h]”hŒ$a1”…””}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjùubhŒ4 to contain the address of the devicetree in memory.”…””}”(hjùh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Khjõubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjËubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jÉh³hÇh´KhjÅubah}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÇh´Khj¤h²hubeh}”(h]”Œregister-state”ah ]”h"]”Œregister state”ah$]”h&]”uh1hÈhj…h²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒ CSR state”h]”hŒ CSR state”…””}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj1h²hh³hÇh´Kubhþ)”}”(hŒThe RISC-V kernel expects:”h]”hŒThe RISC-V kernel expects:”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K hj1h²hubjÄ)”}”(hŒ8* ``$satp = 0``: the MMU, if present, must be disabled. ”h]”jÊ)”}”(hhh]”jÏ)”}”(hŒ6``$satp = 0``: the MMU, if present, must be disabled. ”h]”hþ)”}”(hŒ5``$satp = 0``: the MMU, if present, must be disabled.”h]”(jl)”}”(hŒ ``$satp = 0``”h]”hŒ $satp = 0”…””}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj[ubhŒ(: the MMU, if present, must be disabled.”…””}”(hj[h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K"hjWubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjTubah}”(h]”h ]”h"]”h$]”h&]”j!j"uh1jÉh³hÇh´K"hjPubah}”(h]”h ]”h"]”h$]”h&]”uh1jÃh³hÇh´K"hj1h²hubeh}”(h]”Œ csr-state”ah ]”h"]”Œ csr state”ah$]”h&]”uh1hÈhj…h²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒ%Reserved memory for resident firmware”h]”hŒ%Reserved memory for resident firmware”…””}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj‘h²hh³hÇh´K%ubhþ)”}”(hŒßThe 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]”hŒßThe 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.”…””}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K'hj‘h²hubeh}”(h]”Œ%reserved-memory-for-resident-firmware”ah ]”h"]”Œ%reserved memory for resident firmware”ah$]”h&]”uh1hÈhj…h²hh³hÇh´K%ubhÉ)”}”(hhh]”(hÎ)”}”(hŒKernel location”h]”hŒKernel location”…””}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj¸h²hh³hÇh´K,ubhþ)”}”(hŒ¼The 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]”hŒ¾The 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.”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K.hj¸h²hubeh}”(h]”Œkernel-location”ah ]”h"]”Œkernel location”ah$]”h&]”uh1hÈhj…h²hh³hÇh´K,ubhÉ)”}”(hhh]”(hÎ)”}”(hŒHardware description”h]”hŒHardware description”…””}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjßh²hh³hÇh´K3ubhþ)”}”(hŒNThe firmware can pass either a devicetree or ACPI tables to the RISC-V kernel.”h]”hŒNThe firmware can pass either a devicetree or ACPI tables to the RISC-V kernel.”…””}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K5hjßh²hubhþ)”}”(hŒ¹The 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]”(hŒYThe devicetree is either passed directly to the kernel from the previous stage using the ”…””}”(hjþh²hh³Nh´Nubjl)”}”(hŒ``$a1``”h]”hŒ$a1”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjþubhŒY register, or when booting with UEFI, it can be passed using the EFI configuration table.”…””}”(hjþh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K7hjßh²hubhþ)”}”(hŒèThe 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]”hŒìThe 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.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K;hjßh²hubeh}”(h]”Œhardware-description”ah ]”h"]”Œhardware description”ah$]”h&]”uh1hÈhj…h²hh³hÇh´K3ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ Kernel entry”h]”hŒ Kernel entry”…””}”(hj7h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj4h²hh³hÇh´K@ubhþ)”}”(hŒ8On SMP systems, there are 2 methods to enter the kernel:”h]”hŒ8On SMP systems, there are 2 methods to enter the kernel:”…””}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KBhj4h²hubjÊ)”}”(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]”(jl)”}”(hŒ``RISCV_BOOT_SPINWAIT``”h]”hŒRISCV_BOOT_SPINWAIT”…””}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjZubhX: 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.”…””}”(hjZh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KDhjVubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjSh²hh³hÇh´NubjÏ)”}”(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]”(jl)”}”(hŒ``Ordered booting``”h]”hŒOrdered booting”…””}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj€ubhX: 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.”…””}”(hj€h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KHhj|ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjSh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j!Œ-”uh1jÉh³hÇh´KDhj4h²hubeh}”(h]”Œ kernel-entry”ah ]”h"]”Œ kernel entry”ah$]”h&]”uh1hÈhj…h²hh³hÇh´K@ubhÉ)”}”(hhh]”(hÎ)”}”(hŒUEFI”h]”hŒUEFI”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj±h²hh³hÇh´KNubhÉ)”}”(hhh]”(hÎ)”}”(hŒUEFI memory map”h]”hŒUEFI memory map”…””}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÂh²hh³hÇh´KQubhþ)”}”(hŒiWhen booting with UEFI, the RISC-V kernel will use only the EFI memory map to populate the system memory.”h]”hŒiWhen booting with UEFI, the RISC-V kernel will use only the EFI memory map to populate the system memory.”…””}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KShjÂh²hubhþ)”}”(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]”(hŒ1The UEFI firmware must parse the subnodes of the ”…””}”(hjáh²hh³Nh´Nubjl)”}”(hŒ``/reserved-memory``”h]”hŒ/reserved-memory”…””}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjáubhŒh devicetree node and abide by the devicetree specification to convert the attributes of those subnodes (”…””}”(hjáh²hh³Nh´Nubjl)”}”(hŒ ``no-map``”h]”hŒno-map”…””}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjáubhŒ and ”…””}”(hjáh²hh³Nh´Nubjl)”}”(hŒ ``reusable``”h]”hŒreusable”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjáubhŒ†) into their correct EFI equivalent (refer to section “3.5.4 /reserved-memory and UEFI†of the devicetree specification v0.4-rc1).”…””}”(hjáh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KVhjÂh²hubeh}”(h]”Œuefi-memory-map”ah ]”h"]”Œuefi memory map”ah$]”h&]”uh1hÈhj±h²hh³hÇh´KQubhÉ)”}”(hhh]”(hÎ)”}”(hŒRISCV_EFI_BOOT_PROTOCOL”h]”hŒRISCV_EFI_BOOT_PROTOCOL”…””}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj-h²hh³hÇh´K]ubhþ)”}”(hŒ½When 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]”(hŒjWhen booting with UEFI, the EFI stub requires the boot hartid in order to pass it to the RISC-V kernel in ”…””}”(hj>h²hh³Nh´Nubjl)”}”(hŒ``$a1``”h]”hŒ$a1”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj>ubhŒL. The EFI stub retrieves the boot hartid using one of the following methods:”…””}”(hj>h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K_hj-h²hubjÊ)”}”(hhh]”(jÏ)”}”(hŒ,``RISCV_EFI_BOOT_PROTOCOL`` (**preferred**).”h]”hþ)”}”(hjch]”(jl)”}”(hŒ``RISCV_EFI_BOOT_PROTOCOL``”h]”hŒRISCV_EFI_BOOT_PROTOCOL”…””}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjeubhŒ (”…””}”(hjeh²hh³Nh´NubhŒstrong”“”)”}”(hŒ **preferred**”h]”hŒ preferred”…””}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jzhjeubhŒ).”…””}”(hjeh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kchjaubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhj^h²hh³hÇh´NubjÏ)”}”(hŒ5``boot-hartid`` devicetree subnode (**deprecated**). ”h]”hþ)”}”(hŒ4``boot-hartid`` devicetree subnode (**deprecated**).”h]”(jl)”}”(hŒ``boot-hartid``”h]”hŒ boot-hartid”…””}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjžubhŒ devicetree subnode (”…””}”(hjžh²hh³Nh´Nubj{)”}”(hŒ**deprecated**”h]”hŒ deprecated”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jzhjžubhŒ).”…””}”(hjžh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kdhjšubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhj^h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j!j¨uh1jÉh³hÇh´Kchj-h²hubhþ)”}”(hŒoAny new firmware must implement ``RISCV_EFI_BOOT_PROTOCOL`` as the devicetree based approach is deprecated now.”h]”(hŒ Any new firmware must implement ”…””}”(hjØh²hh³Nh´Nubjl)”}”(hŒ``RISCV_EFI_BOOT_PROTOCOL``”h]”hŒRISCV_EFI_BOOT_PROTOCOL”…””}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjØubhŒ4 as the devicetree based approach is deprecated now.”…””}”(hjØh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kfhj-h²hubeh}”(h]”Œriscv-efi-boot-protocol”ah ]”h"]”Œriscv_efi_boot_protocol”ah$]”h&]”uh1hÈhj±h²hh³hÇh´K]ubeh}”(h]”Œuefi”ah ]”h"]”Œuefi”ah$]”h&]”uh1hÈhj…h²hh³hÇh´KNubeh}”(h]”Œ'pre-kernel-requirements-and-constraints”ah ]”h"]”Œ'pre-kernel requirements and constraints”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒ'Early Boot Requirements and Constraints”h]”hŒ'Early Boot Requirements and Constraints”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´Kjubhþ)”}”(hŒPThe RISC-V kernel's early boot process operates under the following constraints:”h]”hŒRThe RISC-V kernel’s early boot process operates under the following constraints:”…””}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Klhjh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒEFI stub and devicetree”h]”hŒEFI stub and devicetree”…””}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj/h²hh³hÇh´Koubhþ)”}”(hŒÛWhen 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]”hŒßWhen 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@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kqhj/h²hubeh}”(h]”Œefi-stub-and-devicetree”ah ]”h"]”Œefi stub and devicetree”ah$]”h&]”uh1hÈhjh²hh³hÇh´KoubhÉ)”}”(hhh]”(hÎ)”}”(hŒVirtual mapping installation”h]”hŒVirtual mapping installation”…””}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjVh²hh³hÇh´Kvubhþ)”}”(hŒPThe installation of the virtual mapping is done in 2 steps in the RISC-V kernel:”h]”hŒPThe installation of the virtual mapping is done in 2 steps in the RISC-V kernel:”…””}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KxhjVh²hubhŒenumerated_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]”(jl)”}”(hŒ``setup_vm()``”h]”hŒ setup_vm()”…””}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj~ubhŒ( installs a temporary kernel mapping in ”…””}”(hj~h²hh³Nh´Nubjl)”}”(hŒ``early_pg_dir``”h]”hŒ early_pg_dir”…””}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj~ubhŒË 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 ”…””}”(hj~h²hh³Nh´Nubjl)”}”(hŒ``early_pg_dir``”h]”hŒ early_pg_dir”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhj~ubhŒJ page table is statically allocated (using only one table for each level).”…””}”(hj~h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kzhjzubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjwh²hh³hÇh´NubjÏ)”}”(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]”(jl)”}”(hŒ``setup_vm_final()``”h]”hŒsetup_vm_final()”…””}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjÈubhŒ% creates the final kernel mapping in ”…””}”(hjÈh²hh³Nh´Nubjl)”}”(hŒ``swapper_pg_dir``”h]”hŒswapper_pg_dir”…””}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjÈubhXM 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.”…””}”(hjÈh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K€hjÄubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjwh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1juhjVh²hh³hÇh´Kzubhþ)”}”(hX‘For ``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]”(hŒFor ”…””}”(hjh²hh³Nh´Nubjl)”}”(hŒ``virt_to_phys()``”h]”hŒvirt_to_phys()”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjubhŒ and ”…””}”(hjh²hh³Nh´Nubjl)”}”(hŒ``phys_to_virt()``”h]”hŒphys_to_virt()”…””}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjubhŒÊ 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 ”…””}”(hjh²hh³Nh´Nubjl)”}”(hŒ``setup_bootmem()``”h]”hŒsetup_bootmem()”…””}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjubhŒ‡ function in arch/riscv/mm/init.c). Any usage of those macros before the final virtual mapping is installed must be carefully examined.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K‡hjVh²hubeh}”(h]”Œvirtual-mapping-installation”ah ]”h"]”Œvirtual mapping installation”ah$]”h&]”uh1hÈhjh²hh³hÇh´KvubhÉ)”}”(hhh]”(hÎ)”}”(hŒDevicetree mapping via fixmap”h]”hŒDevicetree mapping via fixmap”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjSh²hh³hÇh´Kubhþ)”}”(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]”(hŒAs the ”…””}”(hjdh²hh³Nh´Nubjl)”}”(hŒ``reserved_mem``”h]”hŒ reserved_mem”…””}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjdubhŒ< array is initialized with virtual addresses established by ”…””}”(hjdh²hh³Nh´Nubjl)”}”(hŒ``setup_vm()``”h]”hŒ setup_vm()”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjdubhŒ+, and used with the mapping established by ”…””}”(hjdh²hh³Nh´Nubjl)”}”(hŒ``setup_vm_final()``”h]”hŒsetup_vm_final()”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjdubhŒ, the RISC-V kernel uses the fixmap region to map the devicetree. This ensures that the devicetree remains accessible by both virtual mappings.”…””}”(hjdh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K‘hjSh²hubeh}”(h]”Œdevicetree-mapping-via-fixmap”ah ]”h"]”Œdevicetree mapping via fixmap”ah$]”h&]”uh1hÈhjh²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒPre-MMU execution”h]”hŒPre-MMU execution”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj°h²hh³hÇh´K˜ubhþ)”}”(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:”…””}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´Kšhj°h²hubjÊ)”}”(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]”(jl)”}”(hŒ ``-fno-pie``”h]”hŒ-fno-pie”…””}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjÖubhŒ3: This is needed for relocatable kernels which use ”…””}”(hjÖh²hh³Nh´Nubjl)”}”(hŒ ``-fPIE``”h]”hŒ-fPIE”…””}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjÖubhŒl, since otherwise, any access to a global symbol would go through the GOT which is only relocated virtually.”…””}”(hjÖh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´KŸhjÒubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjÏh²hh³hÇh´NubjÏ)”}”(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]”(jl)”}”(hŒ``-mcmodel=medany``”h]”hŒ-mcmodel=medany”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jkhjubhŒo: Any access to a global symbol must be PC-relative to avoid any relocations to happen before the MMU is setup.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K¢hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjÏh²hh³hÇh´NubjÏ)”}”(hŒV*all* instrumentation must also be disabled (that includes KASAN, ftrace and others). ”h]”hþ)”}”(hŒU*all* instrumentation must also be disabled (that includes KASAN, ftrace and others).”h]”(hŒemphasis”“”)”}”(hŒ*all*”h]”hŒall”…””}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj4ubhŒP instrumentation must also be disabled (that includes KASAN, ftrace and others).”…””}”(hj4h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K¤hj0ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjÏh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j!j¨uh1jÉh³hÇh´KŸhj°h²hubhþ)”}”(hŒ¤As 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]”hŒ¤As 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.”…””}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hýh³hÇh´K§hj°h²hubeh}”(h]”Œpre-mmu-execution”ah ]”h"]”Œpre-mmu execution”ah$]”h&]”uh1hÈhjh²hh³hÇh´K˜ubeh}”(h]”Œ'early-boot-requirements-and-constraints”ah ]”h"]”Œ'early boot requirements and constraints”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´Kjubeh}”(h]”Œ/risc-v-kernel-boot-requirements-and-constraints”ah ]”h"]”Œ/risc-v kernel boot requirements and constraints”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j§Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jj~j j j.j+jŽj‹jµj²jÜjÙj1j.j®j«jjj*j'jýjújyjvjSjPjPjMj­jªjqjnuŒ nametypes”}”(j‰j ‰j.‰jމjµ‰j܉j1‰j®‰j‰j*‰jý‰jy‰jS‰jP‰j­‰jq‰uh}”(j~hÊj j…j+j¤j‹j1j²j‘jÙj¸j.jßj«j4jj±j'jÂjúj-jvjjPj/jMjVjªjSjnj°uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.