From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 36/40] Revert "hw/misc: applesmc: use host osk as default on macs"
Date: Wed, 13 Oct 2021 11:07:24 +0200 [thread overview]
Message-ID: <20211013090728.309365-37-pbonzini@redhat.com> (raw)
In-Reply-To: <20211013090728.309365-1-pbonzini@redhat.com>
This reverts commit 93ddefbc3c909bb6c3b76086f1dfc8ad98dd3725.
The commit included code under the APSL 2.0, which is incompatible
with the GPL v2.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/misc/applesmc.c | 192 +--------------------------------------------
1 file changed, 1 insertion(+), 191 deletions(-)
diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c
index cec247b5ee..1b9acaf1d3 100644
--- a/hw/misc/applesmc.c
+++ b/hw/misc/applesmc.c
@@ -38,171 +38,6 @@
#include "qemu/timer.h"
#include "qom/object.h"
-#if defined(__APPLE__) && defined(__MACH__)
-#include <IOKit/IOKitLib.h>
-
-enum {
- kSMCSuccess = 0x00,
- kSMCKeyNotFound = 0x84
-};
-
-enum {
- kSMCUserClientOpen = 0x00,
- kSMCUserClientClose = 0x01,
- kSMCHandleYPCEvent = 0x02,
- kSMCReadKey = 0x05,
- kSMCGetKeyInfo = 0x09
-};
-
-typedef struct SMCVersion {
- uint8_t major;
- uint8_t minor;
- uint8_t build;
- uint8_t reserved;
- uint16_t release;
-} SMCVersion;
-
-typedef struct SMCPLimitData {
- uint16_t version;
- uint16_t length;
- uint32_t cpuPLimit;
- uint32_t gpuPLimit;
- uint32_t memPLimit;
-} SMCPLimitData;
-
-typedef struct SMCKeyInfoData {
- IOByteCount dataSize;
- uint32_t dataType;
- uint8_t dataAttributes;
-} SMCKeyInfoData;
-
-typedef struct {
- uint32_t key;
- SMCVersion vers;
- SMCPLimitData pLimitData;
- SMCKeyInfoData keyInfo;
- uint8_t result;
- uint8_t status;
- uint8_t data8;
- uint32_t data32;
- uint8_t bytes[32];
-} SMCParamStruct;
-
-static IOReturn smc_call_struct_method(uint32_t selector,
- SMCParamStruct *inputStruct,
- SMCParamStruct *outputStruct)
-{
- IOReturn ret;
-
- size_t inputStructCnt = sizeof(SMCParamStruct);
- size_t outputStructCnt = sizeof(SMCParamStruct);
-
- io_service_t smcService = IO_OBJECT_NULL;
- io_connect_t smcConnect = IO_OBJECT_NULL;
-
- smcService = IOServiceGetMatchingService(kIOMasterPortDefault,
- IOServiceMatching("AppleSMC"));
- if (smcService == IO_OBJECT_NULL) {
- ret = kIOReturnNotFound;
- goto exit;
- }
-
- ret = IOServiceOpen(smcService, mach_task_self(), 1, &smcConnect);
- if (ret != kIOReturnSuccess) {
- smcConnect = IO_OBJECT_NULL;
- goto exit;
- }
- if (smcConnect == IO_OBJECT_NULL) {
- ret = kIOReturnError;
- goto exit;
- }
-
- ret = IOConnectCallMethod(smcConnect, kSMCUserClientOpen,
- NULL, 0, NULL, 0,
- NULL, NULL, NULL, NULL);
- if (ret != kIOReturnSuccess) {
- goto exit;
- }
-
- ret = IOConnectCallStructMethod(smcConnect, selector,
- inputStruct, inputStructCnt,
- outputStruct, &outputStructCnt);
-
-exit:
- if (smcConnect != IO_OBJECT_NULL) {
- IOConnectCallMethod(smcConnect, kSMCUserClientClose,
- NULL, 0, NULL, 0, NULL,
- NULL, NULL, NULL);
- IOServiceClose(smcConnect);
- }
-
- return ret;
-}
-
-static IOReturn smc_read_key(uint32_t key,
- uint8_t *bytes,
- IOByteCount *dataSize)
-{
- IOReturn ret;
-
- SMCParamStruct inputStruct;
- SMCParamStruct outputStruct;
-
- if (key == 0 || bytes == NULL) {
- ret = kIOReturnCannotWire;
- goto exit;
- }
-
- /* determine key's data size */
- memset(&inputStruct, 0, sizeof(SMCParamStruct));
- inputStruct.data8 = kSMCGetKeyInfo;
- inputStruct.key = key;
-
- memset(&outputStruct, 0, sizeof(SMCParamStruct));
- ret = smc_call_struct_method(kSMCHandleYPCEvent, &inputStruct, &outputStruct);
- if (ret != kIOReturnSuccess) {
- goto exit;
- }
- if (outputStruct.result == kSMCKeyNotFound) {
- ret = kIOReturnNotFound;
- goto exit;
- }
- if (outputStruct.result != kSMCSuccess) {
- ret = kIOReturnInternalError;
- goto exit;
- }
-
- /* get key value */
- memset(&inputStruct, 0, sizeof(SMCParamStruct));
- inputStruct.data8 = kSMCReadKey;
- inputStruct.key = key;
- inputStruct.keyInfo.dataSize = outputStruct.keyInfo.dataSize;
-
- memset(&outputStruct, 0, sizeof(SMCParamStruct));
- ret = smc_call_struct_method(kSMCHandleYPCEvent, &inputStruct, &outputStruct);
- if (ret != kIOReturnSuccess) {
- goto exit;
- }
- if (outputStruct.result == kSMCKeyNotFound) {
- ret = kIOReturnNotFound;
- goto exit;
- }
- if (outputStruct.result != kSMCSuccess) {
- ret = kIOReturnInternalError;
- goto exit;
- }
-
- memset(bytes, 0, *dataSize);
- if (*dataSize > inputStruct.keyInfo.dataSize) {
- *dataSize = inputStruct.keyInfo.dataSize;
- }
- memcpy(bytes, outputStruct.bytes, *dataSize);
-
-exit:
- return ret;
-}
-#endif
-
/* #define DEBUG_SMC */
#define APPLESMC_DEFAULT_IOBASE 0x300
@@ -480,7 +315,6 @@ static const MemoryRegionOps applesmc_err_io_ops = {
static void applesmc_isa_realize(DeviceState *dev, Error **errp)
{
AppleSMCState *s = APPLE_SMC(dev);
- bool valid_key = false;
memory_region_init_io(&s->io_data, OBJECT(s), &applesmc_data_io_ops, s,
"applesmc-data", 1);
@@ -497,31 +331,7 @@ static void applesmc_isa_realize(DeviceState *dev, Error **errp)
isa_register_ioport(&s->parent_obj, &s->io_err,
s->iobase + APPLESMC_ERR_PORT);
- if (s->osk) {
- valid_key = strlen(s->osk) == 64;
- } else {
-#if defined(__APPLE__) && defined(__MACH__)
- IOReturn ret;
- IOByteCount size = 32;
-
- ret = smc_read_key('OSK0', (uint8_t *) default_osk, &size);
- if (ret != kIOReturnSuccess) {
- goto failure;
- }
-
- ret = smc_read_key('OSK1', (uint8_t *) default_osk + size, &size);
- if (ret != kIOReturnSuccess) {
- goto failure;
- }
-
- warn_report("Using AppleSMC with host key");
- valid_key = true;
- s->osk = default_osk;
-failure:;
-#endif
- }
-
- if (!valid_key) {
+ if (!s->osk || (strlen(s->osk) != 64)) {
warn_report("Using AppleSMC with invalid key");
s->osk = default_osk;
}
--
2.31.1
next prev parent reply other threads:[~2021-10-13 9:42 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 9:06 [PULL 00/40] Misc patches for 2021-10-13 Paolo Bonzini
2021-10-13 9:06 ` [PULL 01/40] MAINTAINERS: Add myself as reviewer of the 'Memory API' Paolo Bonzini
2021-10-13 9:06 ` [PULL 02/40] tests: add missing dependency for check-block Paolo Bonzini
2021-10-13 9:06 ` [PULL 03/40] build: fix "make check" without earlier "make" Paolo Bonzini
2021-10-13 9:06 ` [PULL 04/40] qemu-iotests: flush after every test Paolo Bonzini
2021-10-13 9:06 ` [PULL 05/40] util/compatfd.c: use libc signalfd wrapper instead of raw syscall Paolo Bonzini
2021-10-13 9:06 ` [PULL 06/40] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines Paolo Bonzini
2021-10-13 9:06 ` [PULL 07/40] qapi/misc-target: Group SEV QAPI definitions Paolo Bonzini
2021-10-13 9:06 ` [PULL 08/40] target/i386/kvm: Introduce i386_softmmu_kvm Meson source set Paolo Bonzini
2021-10-13 9:06 ` [PULL 09/40] target/i386/kvm: Restrict SEV stubs to x86 architecture Paolo Bonzini
2021-10-13 9:06 ` [PULL 10/40] target/i386/sev: Prefix QMP errors with 'SEV' Paolo Bonzini
2021-10-13 9:06 ` [PULL 11/40] target/i386/monitor: Return QMP error when SEV is not enabled for guest Paolo Bonzini
2021-10-13 9:07 ` [PULL 12/40] target/i386/cpu: Add missing 'qapi/error.h' header Paolo Bonzini
2021-10-13 9:07 ` [PULL 13/40] target/i386/sev_i386.h: Remove unused headers Paolo Bonzini
2021-10-13 9:07 ` [PULL 14/40] target/i386/sev: Remove sev_get_me_mask() Paolo Bonzini
2021-10-13 9:07 ` [PULL 15/40] target/i386/sev: Mark unreachable code with g_assert_not_reached() Paolo Bonzini
2021-10-13 9:07 ` [PULL 16/40] target/i386/sev: sev_get_attestation_report use g_autofree Paolo Bonzini
2021-10-13 9:07 ` [PULL 17/40] target/i386/sev: Use g_autofree in sev_launch_get_measure() Paolo Bonzini
2021-10-13 9:07 ` [PULL 18/40] target/i386/sev: Restrict SEV to system emulation Paolo Bonzini
2021-10-13 9:07 ` [PULL 19/40] target/i386/sev: Rename sev_i386.h -> sev.h Paolo Bonzini
2021-10-13 9:07 ` [PULL 20/40] target/i386/sev: Declare system-specific functions in 'sev.h' Paolo Bonzini
2021-10-13 9:07 ` [PULL 21/40] target/i386/sev: Remove stubs by using code elision Paolo Bonzini
2021-10-13 9:07 ` [PULL 22/40] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c Paolo Bonzini
2021-10-13 9:07 ` [PULL 23/40] target/i386/sev: Move qmp_sev_inject_launch_secret() " Paolo Bonzini
2021-10-13 9:07 ` [PULL 24/40] target/i386/sev: Move qmp_query_sev_capabilities() " Paolo Bonzini
2021-10-13 9:07 ` [PULL 25/40] target/i386/sev: Move qmp_query_sev_launch_measure() " Paolo Bonzini
2021-10-13 9:07 ` [PULL 26/40] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() " Paolo Bonzini
2021-10-13 9:07 ` [PULL 27/40] monitor: Reduce hmp_info_sev() declaration Paolo Bonzini
2021-10-13 9:07 ` [PULL 28/40] MAINTAINERS: Cover SEV-related files with X86/KVM section Paolo Bonzini
2021-10-13 9:07 ` [PULL 29/40] qapi: Make some ObjectTypes depend on the build settings Paolo Bonzini
2021-10-13 9:07 ` [PULL 30/40] tests: tcg: Fix PVH test with binutils 2.36+ Paolo Bonzini
2021-10-13 9:07 ` [PULL 31/40] hvf: Determine slot count from struct layout Paolo Bonzini
2021-10-13 9:07 ` [PULL 32/40] MAINTAINERS: Cover SGX documentation file with X86/KVM section Paolo Bonzini
2021-10-13 9:07 ` [PULL 33/40] hw/i386/sgx: Have sgx_epc_get_section() return a boolean Paolo Bonzini
2021-10-13 9:07 ` [PULL 34/40] hw/i386/sgx: Move qmp_query_sgx_capabilities() to hw/i386/sgx.c Paolo Bonzini
2021-10-13 9:07 ` [PULL 35/40] hw/i386/sgx: Move qmp_query_sgx() and hmp_info_sgx() " Paolo Bonzini
2021-10-13 9:07 ` Paolo Bonzini [this message]
2021-10-13 9:07 ` [PULL 37/40] monitor: Tidy up find_device_state() Paolo Bonzini
2021-10-15 11:08 ` Christian Borntraeger
2021-10-15 19:15 ` Richard Henderson
2021-10-18 10:08 ` regression on s390: was " Christian Borntraeger
2021-10-18 12:42 ` Markus Armbruster
2021-10-18 12:03 ` Markus Armbruster
2021-10-19 9:05 ` Markus Armbruster
2021-10-13 9:07 ` [PULL 38/40] target/i386/sev: Use local variable for kvm_sev_launch_start Paolo Bonzini
2021-10-13 9:07 ` [PULL 39/40] target/i386/sev: Use local variable for kvm_sev_launch_measure Paolo Bonzini
2021-10-13 9:07 ` [PULL 40/40] ebpf: really include it only in system emulators Paolo Bonzini
2021-10-13 17:28 ` [PULL 00/40] Misc patches for 2021-10-13 Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211013090728.309365-37-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).