(最新版はこちらをご覧ください: https://zenn.dev/orimanabu/articles/rosetta-libkrun)
Appleは、Linux用のRosettaバイナリを提供しています。 これを使うと、Apple Silicon上のmacOS上で稼働するaarch64 Linux仮想マシン上で、x86_64バイナリを実行できるようになります[^1]。
Rosettaは、実行環境がVirtualization.framework(Apple純正のVMM用フレームワーク)を使った仮想環境かをチェックしており、そうでなければ実行できないらしく、 そのチェックは「rosettaバイナリに謎のioctl(2)を発行して、特定の文字列が返ってくること」を確認しているようです[^2]。
以下、その様子を再現してみたメモです。