-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added PXE boot support on QEMU Q35 #727
Open
kuqin12
wants to merge
15
commits into
microsoft:main
Choose a base branch
from
kuqin12:pxe_boot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−15
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7c723ca
added some option to make PXE boot possible
kuqin12 ee5bab9
Merge remote-tracking branch 'github/main' into pxe_boot
kuqin12 1801af0
Removed junk
kuqin12 cbb77a6
Disable image protection for oprom
kuqin12 76a765c
Added doc
kuqin12 4e7da9c
Fixing the doc
kuqin12 8a6c04b
Merge remote-tracking branch 'github/main' into pxe_boot
kuqin12 ca98a2a
Updated ipxe build instructions
kuqin12 55dadf8
Update to work with existing DFCI code
kuqin12 85f2853
Updated doc
kuqin12 04a5cf8
Disable image protection
kuqin12 6de1654
Added option rom for usage in sbsa...
kuqin12 e67c810
Move this to common folder
kuqin12 da9817f
Updated bootmgfw.efi...
kuqin12 b02c6ae
uncrustify
kuqin12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# PXE Boot Emulation | ||
|
||
PXE Boot is a standard feature to boot an agent via network. A detailed rundown can be found at this [Tianocore page](https://github.com/tianocore/tianocore.github.io/wiki/PXE). | ||
|
||
## PXE Boot Preparation | ||
|
||
QEMU supports TFTP server hosting, which allows us to PXE boot a QEMU VM. To do this, one would need a prepared PXE folder | ||
available to the QEMU launching instance. | ||
|
||
For more detailed information on preparing a folder for booting Windows PE PXE boot, please refer to the | ||
[Microsoft PXE server setup documentation](https://learn.microsoft.com/en-us/windows/deployment/configure-a-pxe-server-to-load-windows-pe). | ||
|
||
*Note*: when preparing for the BCD, please use the following command to point the correct boot loader to the following | ||
efi file (instead of the exe file as mentioned in the documentation): | ||
|
||
```bash | ||
bcdedit.exe /store c:\BCD /set {GUID1} path \windows\system32\winload.efi | ||
``` | ||
|
||
The boot file for TFTP offering should also be pointing to `bootmgfw.efi`, which needs to be copied from `mount\Windows\Boot\EFI\bootmgfw.efi` in the Windows PE image folder. | ||
|
||
### Configuring QEMU PXE Windows Boot on Linux Host | ||
|
||
Due to the lack of path normalization support on QEMU TFTP server, starting from the normal Windows PXE setup, the Windows PXE boot files need to be updated with the following tricks: | ||
|
||
- `BCD` file needs to be renamed to `Boot\BCD` | ||
- `boot.wim` file needs to be renamed to `\boot.wim` | ||
- `boot.sdi` file needs to be renamed to `\boot.sdi` | ||
- `bootmgfw.efi` file needs to be renamed to `\bootmgfw.efi` | ||
|
||
Then update the corresponding BCD settings to follow the new file names, i.e.: | ||
|
||
```txt | ||
Windows Boot Manager | ||
-------------------- | ||
identifier {bootmgr} | ||
description boot manager | ||
displayorder {Your Own GUID} | ||
timeout 30 | ||
|
||
Windows Boot Loader | ||
------------------- | ||
identifier {Your Own GUID} | ||
device ramdisk=[boot]\boot.wim,{ramdiskoptions} | ||
path \windows\system32\winload.efi | ||
description winpe boot image | ||
osdevice ramdisk=[boot]\boot.wim,{ramdiskoptions} | ||
systemroot \windows | ||
detecthal Yes | ||
winpe Yes | ||
|
||
Setup Ramdisk Options | ||
--------------------- | ||
identifier {ramdiskoptions} | ||
description Ramdisk options | ||
ramdisksdidevice boot | ||
ramdisksdipath \boot.sdi | ||
``` | ||
|
||
## Enable Local PXE Boot | ||
|
||
To enable the QEMU PXE boot option, please specify the following parameters, either through command line or through the | ||
`BuildConfig.conf` file: | ||
|
||
| Name | Usage | Example | | ||
| --- | --- | --- | | ||
| `LOCAL_PXE_BOOT` | Flag to enable PXE booting | `LOCAL_PXE_BOOT=TRUE` | | ||
| `PXE_FOLDER_PATH` | Folder path to the prepared PXE boot files | `PXE_FOLDER_PATH="D:\\Boot"` | | ||
| `PXE_BOOT_FILE` | File path to the initial download | `PXE_BOOT_FILE="bootmgfw.efi"` | | ||
| `PXE_OPTION_ROM` | File path to the initial download, required for SBSA PXE boot, see [instruction below](#customized-pxe-driver) | `PXE_BOOT_FILE="ipxe/src/bin-arm64-efi/808610d3.efirom"` | | ||
|
||
This will allow the QEMU to set up a TFTP server and reply a default boot file to download when PXE boot is requested. | ||
The network driver in this case is set to e1000. | ||
|
||
Once the system booted, the default boot option will land in the UEFI Shell. One can exit the UEFI shell and select the | ||
Boot Options from the boot menu and choose to PXE boot from there. | ||
|
||
![pxe_selected](Images/pxe_selected.png) | ||
|
||
## Troubleshooting Tips | ||
|
||
### Network Traffic | ||
|
||
QEMU has provided a way of collecting network traffic. To do so, one can append the following parameter to the QEMU launching | ||
command in [QemuRunner.py](../../../QemuQ35Pkg/Plugins/QemuRunner/QemuRunner.py#L88): | ||
|
||
```py | ||
"-object filter-dump,id=f1,netdev=net0,file=dump.dat" | ||
``` | ||
|
||
Where the `dump.dat`, of which name is subject to users' choice, is the file to store the network traffic. This file can | ||
be opened by Wireshark to analyze the network traffic. Please note that the `netdev` should match the NIC driver added for | ||
PXE boot. | ||
|
||
### Customized PXE Driver | ||
|
||
QEMU leverages iPXE as the NIC driver for its e1000 device. To customize the iPXE driver, i.e. in the case of updating the | ||
driver to enable NX flag and/or paging alignment, one can follow the steps below: | ||
|
||
- One can refer to the QEMU usage for building iPXE from their make file [here](https://github.com/qemu/qemu/blob/master/roms/Makefile). | ||
However, it is essentially doing the following, where the output *.efirom will be our target. Note that one will need | ||
EfiRom from our [BaseTools](https://github.com/microsoft/mu_basecore/tree/release/202302/BaseTools) for the below | ||
commands to work. For Q35, we enable e1000: | ||
|
||
```bash | ||
cd ipxe/src | ||
make veryclean | ||
make bin-x86_64-efi/8086100e.efidrv -j 4 CONFIG=qemu | ||
cd ../.. | ||
MU_BASECORE/BaseTools/Bin/Mu-Basetools_extdep/Linux-x86/EfiRom -f "0x8086" -i "0x100e" -l 0x02 -ec bin-x86_64-efi/8086100e.efidrv -o bin-x86_64-efi/8086100e.efirom | ||
``` | ||
|
||
- For SBSA, the e1000e is supported. However, this is not included with a default QEMU build. Thus the following commands can be used, | ||
assuming that the `GCC5_AARCH64_PREFIX` is already set during the SBSA UEFI build: | ||
|
||
```bash | ||
cd src | ||
make veryclean | ||
make bin-arm64-efi/808610d3.efidrv -j 4 CONFIG=qemu CROSS_COMPILE=${GCC5_AARCH64_PREFIX} | ||
/home/test/mu_tiano_platforms/MU_BASECORE/BaseTools/Bin/Mu-Basetools_extdep/Linux-x86/EfiRom -f "0x8086" -i "0x10d3" -l 0x02 -ec bin-arm64-efi/808610d3.efidrv -o bin-arm64-efi/808610d3.efirom | ||
${GCC5_AARCH64_PREFIX}objdump -d bin-arm64-efi/808610d3.efidrv.tmp > ../out_dism.log | ||
``` | ||
|
||
- Once we have our own NIC driver, to apply the new option rom to the QEMU launching instance, one can specify the following | ||
parameter in [QemuRunner.py](../../../QemuQ35Pkg/Plugins/QemuRunner/QemuRunner.py#L88) when configuring the netowork device: | ||
|
||
```py | ||
",romfile=<path_to_your_8086100e.efirom>" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot work around this for oprom... Open for other suggestions.