You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Force new lines by adding two space at the end of sentences.
- Properly format code blocks that are part of bullet points by indenting them by 8 spaces as per mkdocs requirements.
- Minor wording/punctuation fixes.
- Visually de-cluttered some parts of the doc.
- No actual content changes.
Signed-off-by: jaydee-coder <[email protected]>
Copy file name to clipboardExpand all lines: docs/SW-Hypervisor.md
+95-54Lines changed: 95 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,90 +7,131 @@ You can run either a development kernel obtained from Apple, in which case you w
7
7
You can use either your existing macOS install, or alternatively install a second copy of macOS.
8
8
9
9
To install a second copy of macOS you will need to complete a couple of steps:
10
-
1. Create a second Volume on your macOS partition:
11
-
`diskutil apfs addVolume disk4 APFS macOSTest -mountpoint /Volumes/macOSTest` Change disk4 and volume name (i.e macOSTest) for your particular system/preferences. _Note: Don't make this a system role or it will mess with your existing system (no valid users in 1TR)_
12
-
2. Download and install macOS. To download a specific version of macOS installer you can use the command
13
-
`softwareupdate --fetch-full-installer --full-installer-version 12.3` substituting 12.3 for whichever version you require. The installer will be found in the Applications folder. Copy it out of here if you want to save it, otherwise it deletes itself once you have installed once.
14
10
15
-
Unfortunately, Apple's CDN only keeps the full-installer package for a limited number of version, and doesn't have 12.3 anymore. Note: we are now at firmware version 13.5, which is available normally. You don't need to install 12.3.
11
+
1. Create a second Volume on your macOS partition:
Substitute `12.3` for whichever version you require. The installer will be found in the Applications folder. Copy it out of here if you want to save it, otherwise it deletes itself once you have installed once.
23
+
24
+
Unfortunately, Apple's CDN only keeps the full-installer package for a limited number of version, and doesn't have 12.3 anymore.
25
+
_Note: we are now at firmware version 13.5, which is available normally. You don't need to install 12.3._
16
26
17
27
### Using archived InstallAssistant.pkg
18
28
19
-
The Montery 12.3 InstallAssistant.pkg has been archived [here](https://archive.org/details/12.3-21-e-230-release), but trying to install by double-clicking installs an online version of the `Install macOS Monterey.app`, with a file size of about 40mb. When that run, that will install the latest version of macOS.
29
+
The Montery 12.3 InstallAssistant.pkg has been archived [here](https://archive.org/details/12.3-21-e-230-release), but trying to install by double-clicking installs an online version of the `Install macOS Monterey.app`, with a file size of about 40MB. When that file is run, it will install the latest version of macOS. However, installing it via the command line appears to do the correct thing:
20
30
21
-
But installing it via the command line appears to do the correct thing: `sudo installer -pkg 12.3\ 21E230\ \(Release\).pkg -target /`
4. Install [m1n1](m1n1-User-Guide.md) as custom boot object:
65
+
66
+
kmutil configure-boot \
67
+
-c build/m1n1.bin \
68
+
--raw \
69
+
--entry-point 2048 \
70
+
--lowest-virtual-address 0 \
71
+
-v /Volumes/macOSTest
54
72
55
73
## Starting the development kernel under the m1n1 hypervisor
56
74
57
-
1. Copy the kernelcache to your development machine
75
+
1. Copy the kernelcache to your development machine.
58
76
2. Copy the debug DWARF from `/Library/Developer/KDKs/KDK_<MACOS_VERSION>_<KDK_VERSION>.kdk/System/Library/Kernels/kernel.development.t8101.dSYM/Contents/Resources/DWARF/kernel.development.t8101`
Note: t8101 files(both kernel and dwarf symbols) are available starting with KDK for macOS 11.3. Marcan streams on booting macOs with hypervisor were done with 11.3. These notes have also been validated with macOS 11.5.2 and can get to login with wifi network on MacBookAir:
64
-
* Kernel version: uname -a => Darwin MacBook-Air.home 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64
Note: t8101 files (both kernel and dwarf symbols) are available starting with KDK for macOS 11.3. Marcan streams on booting macOs with hypervisor were done with 11.3.
85
+
These notes have also been validated with macOS 11.5.2 and can get to login with WiFi network on a MacBook Air:
86
+
87
+
- Kernel version:
88
+
```
89
+
$ uname -a
90
+
> Darwin MacBook-Air.home 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64
If you see the apple logo(rainbow version) and not the progress bar, this means you probably had a macOS panic early in the boot process.
68
-
This can come from a mismatch of macOS version between the kernel cache (kernel+extensions) and the macOS root fs.
69
-
To figure out where the boot process is stuck, you can start a serial utility like minicom/picocom and the like, with 115200 baud rate (something like picocom -b 115200 /dev/ttyACM1).
70
-
Be patient when you are booting, with one cpu and the hypervisor, depending on what you are tracing, it is slower than normal and it is expected.
98
+
If you see the apple logo (rainbow version) and not the progress bar, this means you probably had a macOS panic early in the boot process. This can come from a mismatch of macOS version between the kernel cache (kernel + extensions) and the macOS root FS.
99
+
To figure out where the boot process is stuck, you can start a serial utility like minicom/picocom and the like, with 115200 baud rate (something like `picocom -b 115200 /dev/ttyACM1`).
100
+
Be patient when you are booting with one cpu and the hypervisor. Depending on what you are tracing, it is slower than normal and it is expected.
71
101
72
-
Here are some numbers from some experiment with macOS 11.5.2 and m1n1 version commit bd5211909e36944cb376d66c909544ad23c203bc:
73
-
* From run_guest command launched(t0) to start loading kernel: 9s
74
-
* From t0 to login screen(without keyboard nor mouse cursor moving first): around 2min.
75
-
* With keyboard and mouse cursor moving: around 2min35s.
76
-
* From password entered to desktop and menu bar: around +2min.
102
+
Here are some numbers from some experiment with macOS `11.5.2` and m1n1 version commit `bd5211909e36944cb376d66c909544ad23c203bc`:
103
+
- From run_guest command launched (`t0`) to start loading kernel: 9s.
104
+
- From `t0` to login screen(without keyboard nor mouse cursor moving first): around 2min.
105
+
- With keyboard and mouse cursor moving: around 2min35s.
106
+
- From password entered to desktop and menu bar: around +2min.
77
107
78
108
## Running the stock macOS kernel from a macOS install
79
109
80
-
1. Boot into macOS
81
-
2. Find the `kernelcache`, it is at ```/System/Volumes/Preboot/(UUID)/boot/(long hash)/System/Library/Caches/com.apple.kernelcaches/kernelcache```
82
-
3. Make a copy of this file somewhere
83
-
4. Get (or build) a copy of img4tool (https://github.com/tihmstar/img4tool)
110
+
1. Boot into macOS.
111
+
2. Find the `kernelcache`, it is at `/System/Volumes/Preboot/(UUID)/boot/(long hash)/System/Library/Caches/com.apple.kernelcaches/kernelcache`
112
+
3. Make a copy of this file somewhere.
113
+
4. Get (or build) a copy of img4tool (https://github.com/tihmstar/img4tool).
84
114
5. Extract the im4p image:
85
-
```img4tool -e -p out.im4p kernelcache```
115
+
116
+
img4tool -e -p out.im4p kernelcache
117
+
86
118
6. Extract the machO from the im4p:
87
-
```img4tool -e -o kernel.macho out.im4p```
119
+
120
+
img4tool -e -o kernel.macho out.im4p
121
+
88
122
7. You can now run macOS in a similar manner as shown above (just no debug DWARF):
The hypervisor/m1n1 ABI is *not* stable. If you have installed a fresh m1n1 build as above, you can use `run_guest.py` directy to save some time. However, as soon as you update your m1n1 git tree, you *must* build the updated m1n1 and run `python tools/chainload.py -r ../build/m1n1.bin` before `run_guest.py`, to make sure the ABI is synced. Failure to do this will lead to random errors/crashes due to ABI mismatches.
130
+
The hypervisor/m1n1 ABI is *not* stable. If you have installed a fresh m1n1 build as above, you can use `run_guest.py` directy to save some time. However, as soon as you update your m1n1 git tree, you *must* build the updated m1n1 and run
131
+
```
132
+
python tools/chainload.py -r ../build/m1n1.bin
133
+
```
134
+
before `run_guest.py`, to make sure the ABI is synced. Failure to do this will lead to random errors/crashes due to ABI mismatches.
94
135
95
136
## Using GDB/LLDB
96
137
@@ -112,4 +153,4 @@ process connect unix-connect:///tmp/.m1n1-unix
112
153
Do not run hypervisor console commands interfering with GDB/LLDB, or they will be out-of-sync. For example, do not edit breakpoints from both of hypervisor console and GDB/LLDB at the same time.
113
154
114
155
# Sources
115
-
Source for the kernelcache creation: https://kernelshaman.blogspot.com/2021/02/building-xnu-for-macos-112-intel-apple.html
156
+
Source for the kernelcache creation: [https://kernelshaman.blogspot.com/2021/02/building-xnu-for-macos-112-intel-apple.html](https://kernelshaman.blogspot.com/2021/02/building-xnu-for-macos-112-intel-apple.html)
0 commit comments