Skip to contentSkip to conversation

isa-applesmc: provide OSK forwarding on Apple hosts

PATCH Superseded Vladislav Yaroshchuk 1 participant 2 messages Dec 16, 2021 – Dec 24, 2021

v7 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 isa-applesmc: provide OSK forwarding on Apple hosts

On Apple hosts we can read AppleSMC OSK key directly from host's SMC and forward this value to QEMU Guest.

New 'hostosk' property is added:
-device isa-applesmc,hostosk=on
The property is set to 'on' by default for machine version > 6.2

Apple licence allows use and run up to two additional copies or instances of macOS operating system within virtual operating system environments on each Apple-branded computer that is already running the Apple Software, for purposes of:
* software development
* testing during software development
* using macOS Server
* personal, non-commercial use

Guest macOS requires AppleSMC with correct OSK. The most legal way to pass it to the Guest is to forward the key from host SMC without any value exposion.

Based on https://web.archive.org/web/20200103161737/osxbook.com/book/bonus/chapter7/tpmdrmmyth/

---
 hw/arm/virt.c              |   1 +
 hw/core/machine.c          |   5 ++
 hw/i386/pc_piix.c          |   1 +
 hw/i386/pc_q35.c           |   1 +
 hw/m68k/virt.c             |   1 +
 hw/misc/applesmc.c         | 123 ++++++++++++++++++++++++++++++++++++-
 hw/ppc/spapr.c             |   1 +
 hw/s390x/s390-virtio-ccw.c |   1 +
 include/hw/boards.h        |   3 +
 9 files changed, 135 insertions(+), 2 deletions(-)
hw/arm/virt.c +1 -0
index 6bce595aba..4d6b72fe6f 100644
@@ -2858,6 +2858,7 @@ type_init(machvirt_machine_init);
 
 static void virt_machine_6_2_options(MachineClass *mc)
 {
+    compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 DEFINE_VIRT_MACHINE_AS_LATEST(6, 2)
 
hw/core/machine.c +5 -0
index 53a99abc56..afa871378e 100644
@@ -37,6 +37,11 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-pci.h"
 
+GlobalProperty hw_compat_6_2[] = {
+    { "isa-applesmc", "hostosk", "off" }
+};
+const size_t hw_compat_6_2_len = G_N_ELEMENTS(hw_compat_6_2);
+
 GlobalProperty hw_compat_6_1[] = {
     { "vhost-user-vsock-device", "seqpacket", "off" },
     { "nvme-ns", "shared", "off" },
hw/i386/pc_piix.c +1 -0
index 223dd3e05d..1c2ab5222e 100644
@@ -420,6 +420,7 @@ static void pc_i440fx_6_2_machine_options(MachineClass *m)
     m->alias = "pc";
     m->is_default = true;
     pcmc->default_cpu_version = 1;
+    compat_props_add(m->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 
 DEFINE_I440FX_MACHINE(v6_2, "pc-i440fx-6.2", NULL,
hw/i386/pc_q35.c +1 -0
index e1e100316d..7186d736d3 100644
@@ -366,6 +366,7 @@ static void pc_q35_6_2_machine_options(MachineClass *m)
     pc_q35_machine_options(m);
     m->alias = "q35";
     pcmc->default_cpu_version = 1;
+    compat_props_add(m->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 
 DEFINE_Q35_MACHINE(v6_2, "pc-q35-6.2", NULL,
hw/m68k/virt.c +1 -0
index 0efa4a45c7..10281a81c5 100644
@@ -306,6 +306,7 @@ type_init(virt_machine_register_types)
 
 static void virt_machine_6_2_options(MachineClass *mc)
 {
+    compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 DEFINE_VIRT_MACHINE(6, 2, true)
 
hw/misc/applesmc.c +121 -2

154 lines not on this page · raw message

hw/ppc/spapr.c +1 -0
index 3b5fd749be..fefac898e6 100644
@@ -4671,6 +4671,7 @@ static void spapr_machine_latest_class_options(MachineClass *mc)
 static void spapr_machine_6_2_class_options(MachineClass *mc)
 {
     /* Defaults for the latest behaviour inherited from the base class */
+    compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 
 DEFINE_SPAPR_MACHINE(6_2, "6.2", true);
hw/s390x/s390-virtio-ccw.c +1 -0
index 653587ea62..3abb249c3d 100644
@@ -797,6 +797,7 @@ static void ccw_machine_6_2_instance_options(MachineState *machine)
 
 static void ccw_machine_6_2_class_options(MachineClass *mc)
 {
+    compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
 }
 DEFINE_CCW_MACHINE(6_2, "6.2", true);
 
include/hw/boards.h +3 -0
index 9c1c190104..b7b68471ff 100644
@@ -375,6 +375,9 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
+extern GlobalProperty hw_compat_6_2[];
+extern const size_t hw_compat_6_2_len;
+
 extern GlobalProperty hw_compat_6_1[];
 extern const size_t hw_compat_6_1_len;
 
Signature · 1 line
2.23.0