惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
V2EX - 技术
V2EX - 技术
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
S
Schneier on Security
I
InfoQ
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The GitHub Blog
The GitHub Blog
S
Security @ Cisco Blogs
O
OpenAI News
W
WeLiveSecurity
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
Cloudbric
Cloudbric
The Last Watchdog
The Last Watchdog
The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
NISL@THU
NISL@THU
T
Tailwind CSS Blog
V
Visual Studio Blog
PCI Perspectives
PCI Perspectives
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
D
DataBreaches.Net
B
Blog RSS Feed
N
News and Events Feed by Topic
N
News and Events Feed by Topic
H
Heimdal Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
Latest news
Latest news
V
Vulnerabilities – Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
V
V2EX
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Register - Security
The Register - Security
Help Net Security
Help Net Security

Whexy Blog

We lost the AIxCC. So, what now? Arm VMM with Apple's Hypervisor Framework Driving WaveShare E‐Paper Display with a Raspberry Pi Pico in MicroPython Use cgroup v2 inside docker containers Annual Hit Piece: Fuzzing Top Conference Paper Debunking Report Solving SSH Key Login Issues on Synology NAS Can SSD Cache Improve Synology NAS Write Speeds? Virtualization is all you need Running Windows Games on Mac Without Virtual Machines Tears of the Kingdom: End of an Era Anonymous CDN Traffic Relay Self-host Relay Service with CDN Home Networking Solution Building Your Own Blog System Connecting Smart Devices to SUSTech Campus Network Function Color Theory Stop Forkin' Around: Faster Creating of Large Processes on Linux PMU Interrupts: How to handle them Asynchronous Mutex Alligator In Vest - My first research work Experience Using Several Plugins in Complex LaTeX Projects Variance in Rust Understanding Rust Generic Traits SUSTeam: Ultimate Gaming Platform Inline Assembly Language in C React Learning Notes Building a School Bus Schedule App for Apple Watch 12307 Train Ticket Purchase Platform Sakai and Local Folder Synchronization Building a Super Simple OpenJudge in Two Nights Setting Up Remote Backup for macOS Shell Script for Automatically Logging into SUSTech Campus Network Building a Movie Streaming System in the Dorm
Using QEMU to run Linux images on M1 Macbook
Whexy · 2021-08-16 · via Whexy Blog

As a student who is fond of system programming, I always want to develop Linux kernel directly on the M1 Macbook without nested VMs. This blog is a set-up Coding of the developing environment. The target is to run a Linux kernel in the QEMU on macOS with Apple Silicon.

The M1 is great and blah, blah, blah… but can it run Crisis? Eh.. I mean, QEMU?

Run Natively

Currently (24-Aug-2021), simply using brew install qemu won't work for M1 macOS. This situation may change in the future.

In this Coding, we are going to build the native version of QEMU running on macOS with M1 Apple Silicon.

Patch

My solution is to build QEMU by my own. Some blogs early this year 1 put that the QEMU doesn't support hypervisor framework (hvf) in M1, thus it should be patched with Hypervisor framework written by @_AlexGraf.

Things are changing everyday. Now the main branch has merged some hvf patches, while still not fully support Apple Silicon. Here we use QEMU 6.0 (which is the newest stable version in 24-Aug-2021), and use Alexander Graf's patch v8.

Building instructions

I got the latest QEMU git in GitHub. To build the qemu, first install the requirement.

brew install ninja pkgconfig glib pixman
  1. Clone the Git repo and checkout to the stable 6.0.0 version
git clone https://github.com/qemu/qemu
cd qemu
git checkout 3c93dfa42c394fdd55684f2fbf24cf2f39b97d47
  1. Patch
curl https://patchew.org/QEMU/20210519202253.76782-1-agraf@csgraf.de/mbox | git am
  1. Do auto configure and build
mkdir build && cd build
../configure --target-list=aarch64-softmmu
make -j8

Unlike the blogs written earlier this year, the only argument is just --target-list=aarch64-softmmu. Don't put --enbale-hvf or --disable-gnutls to it.

  1. Install QEMU

Now we have the qemu-system-aarch64 binary, and we can run it with qemu-system-aarch64 --version to see if it's ready.

❯ qemu-system-aarch64 --version
QEMU emulator version 6.0.50 (v6.0.0-1407-g44242f6937)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

To test if QEMU actually works on the laptop, I download Ubuntu Server 20.04 (aarch64). The following is a shell to run the VM.

#!/bin/sh
qemu-system-aarch64 \
    -accel hvf \
    -m 2048 \
    -cpu cortex-a57 -M virt,highmem=off  \
    -drive file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
    -drive file=ovmf_vars.fd,if=pflash,format=raw \
    -serial telnet::4444,server,nowait \
    -drive if=none,file=disk.qcow2,format=qcow2,id=hd0 \
    -device virtio-blk-device,drive=hd0,serial="dummyserial" \
    -device virtio-net-device,netdev=net0 \
    -netdev user,id=net0 \
    -vga none -device ramfb \
    -cdrom ubuntu-20.04.2-live-server-arm64.iso \
    -device usb-ehci -device usb-kbd -device usb-mouse -usb \
    -monitor stdio

I actually encounter many problems when installing QEMU. Here is what you might want to do.

  • It's suggested to use gcc-11 instead of apple clang (cc). Install gcc with homebrew first. However, I successfully build QEMU with apple clang.
  • Pay attension to the auto config. It will display the infomation whether a feature is enabled or disabled.
  • Use qemu-system-aarch64 -accel help to check if your QEMU supports hvf. If not, there are some problems when patching.
  1. Linux Desktop on Apple Silicon/M1 in Practice; 在 M1 上用 QEMU 运行 Debian 虚拟机; etc. ↩

© LICENSED UNDER CC BY-NC-SA 4.0