On 10/22/21 12:38, Vladislav Yaroshchuk wrote: > On Apple hosts we can read AppleSMC OSK key directly from host's > SMC and forward this value to QEMU Guest. > > Usage: > `-device isa-applesmc,hostosk=on` > > Apple licence allows use and run up to two additional copies > or instances of macOS operating 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 http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/ > > Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2...@gmail.com> > --- > hw/misc/applesmc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 143 insertions(+), 1 deletion(-) > > diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c > index 1b9acaf1d3..6986ab0028 100644 > --- a/hw/misc/applesmc.c > +++ b/hw/misc/applesmc.c > @@ -38,6 +38,10 @@ > #include "qemu/timer.h" > #include "qom/object.h" > > +#if defined(__APPLE__) > +#include <IOKit/IOKitLib.h> > +#endif > + > /* #define DEBUG_SMC */ > > #define APPLESMC_DEFAULT_IOBASE 0x300 > @@ -108,6 +112,7 @@ struct AppleSMCState { > uint8_t data_len; > uint8_t data_pos; > uint8_t data[255]; > + char *hostosk_flag; > char *osk; > QLIST_HEAD(, AppleSMCData) data_def; > }; > @@ -312,9 +317,133 @@ static const MemoryRegionOps applesmc_err_io_ops = { > }, > }; > > +#if defined(__APPLE__) > +/* Based on http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/ */
404. Instead use https://web.archive.org/web/20200103161737/http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/ ?