Windows on ARM devices

(Not to be confused with Windows Mobile devices)
Windows on ARM (Often abbreviated WoA) are a line of devices that were shipped with Windows as the operating system. Sometimes those devices are referred to as "Windows on Snapdragon" (WoS) as the majority is based on Qualcomm chipsets.
This page provides a general overview and common information for those devices in postmarketOS.
== Installation ==
=== Installation on USB ===
# Disable EFI secure boot.
# Follow Pmbootstrap page, do a SD card installation to USB.
=== Installation on internal storage ===
Once you have a pmOS installation booted from USB:
==== Devices with UFS or NVME ====
# Install pmbootstrap (apk add pmbootstrap).
# Perform pmbootstrap install --disk /dev/sdX.
==== Devices with EMMC ====
Compared to UFS devices where the OS has a dedicated LUN, or NVME devices, where the bootloader is stored on a separate chip, EMMC devices share bootloader setup similar to phones, where a set of partitions is dedicated for the UEFI and other things critical to boot.
One of the possible ways to install pmOS on such device would be to boot into pmOS usb install and overwrite "Windows" partition with root image, generated with pmbootstrap install --split, and overwrite the efi esp with the boot image. 
== Devices ==
=== Common issues and quirks ===
* It's generally unfeasible to use original vendor ACPI code shipped with the existing Qualcomm devices to boot Linux since significant part of the hardware information is baked into the windows drivers code, instead of the ACPI. Thus, the usual way of using Linux on these devices assumes booting with the Device Tree made for the device.
=== Virtualization support ===
Due to a quirkSecure-Launch and vendor lock-in overview: https://github.com/TravMurav/Qcom-Secure-Launch/ in firmware on Windows-on-Snapdragon devices it's impossible to use virtualization by default as the system boots in EL1. Windows uses special "Secure launch" mechanism to elevate to EL2 as part of the bootloader flow and gain virtualization support for hyper-v.
slbounce is an alternative "Secure launch" implementation that can allow one to boot Linux (or other OS) in EL2 and unlock virtualization. Unfortunately linux can't yet use all of the device features when running EL2 so, for example, things that rely on remoteprocs will not work. 
==== Prerequisites ====
* Make sure Windows reports virtualization as enabled;
* Get tcblaunch.exe from the windows install on your device. You can find it in C:\Windows\system32\tcblaunch.exe;
* Be able to boot into EFI Shell.
==== Setup ====
Clone and build slbounce.
$ git clone --recursive https://github.com/TravMurav/slbounce.git
$ git checkout switch-if-overlay
$ cd slbounce
$ make -j$(nproc)
$ make -j$(nproc) dtbs
Copy out/*.efi and your tcblaunch.exe to the root of your ESP (or a usb stick). Make sure tcblaunch.exe is in the root of the same disk as slbounce.efi and sltest.efi.
Check that your device is supported by slbounce: Reboot into EFI Shell and run sltest.efi:
fs0:\> sltest.efi tcblaunch.exe
Your device should show a green line on the top of the screen. Reboot it by holding the power button.
Generate a special EL2 dtb by applying overlays from slbounce to your device's dtb:
$ cd slbounce
# fdtoverlay -i /boot/sc7180-acer-aspire1.dtb -o /boot/sc7180-acer-aspire1-el2.dtb out/dtbo/sc7180-symbols.dtbo out/dtbo/sc7180-el2.dtbo
(Note that the order of overlays is meaningful)
Add a new boot option by copying existing one and changing the name and devicetree file and install slbounce to systemd-boot driver dir:
$ sudo cat /boot/loader/entries/pmos_el2.conf
title	 postmarketOS (EL2)
sort-key yyy-postmarketOS-el2
linux	 linux.efi
initrd	 initramfs
options efi=novamap,noruntime deferred_probe_timeout=30 console=tty0
devicetree sc7180-acer-aspire1-el2.dtb
$ sudo cat /boot/loader/loader.conf
default pmos.conf
timeout 1
$ sudo cp out/slbounce.efi /boot/EFI/systemd/drivers/slbounceaa64.efi
Now you should see two boot options on each boot, where EL2 boot option would allow you to use virtualization (however some other features of the device may be broken).
=== See also ===
* Non-distro-specific IRC room for Linux on ARM laptops: #aarch64-laptops on OFTC. Public archive.
== References ==