Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390707; b=r1HPIq8FPJVA2WVFq7cbYWq5O2dJ6h5c+vKwlKW8LcSg94LF0f5AKy/13O7GPJUSis7c E3CaVWav7LO9q+jKjhJmfR5l3LWug99xvMLQ2CWvMijqt6t1QlcFjjew6X7QTyNKkSVuB /VuGr3VtPW19uCYPhH4qXV6euTbiqXmGIDOuHYmKhYCFetvQHFFk4U+tdy/2L8ZLky8N+ sVArub4SaP6CBphEoj01pQ3rWGPjsvy5CUqlQg+orFlrL6hkSX/ZfIoF2t5XvSZuJ3QZg r7KfnY3MRrVt2QJ4Ar0kT8QHpYNmXQHxzAsp7jAd5YdGoa2+UJwOTvwkbjQ4ksftHSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390707; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=O2cEnQEeUxfdaHNoHTL+V8CQ+1m8Ci56bGz6i+IWhVw=; b=eX2WAl5i9SYjeVGhLqNvxMPG3I4hlHs9DJvNKctiaHLSxV1oASnjPckK70XUdklV1KHx snwwU9+YUqCHbDPfmShlLdUGmI3pi2hlCiW+trBMI0RkpGtOWfN/5Mlmc4GNWqjplysuC Bivnc29JJ9B9YAoXgD7Fttem8BK8CASy4s5+PP8IHJ9TDI04/NJVO3rcIzxyVPDu6WcOQ wJmcVVGqUcUfJWu41x4G4zoOAb+hxS/N+hMQO+AjcbiLIZuUIDM1VSqT+/OV8PbpcuCaU keawle6xVe6tIXBG2sbySbH62AdPJqIsizrAJAEF9iH1bsD4ClwrvIywMjEfKSfVGCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pwe15Vcl; arc=none smtp.remote-ip=74.125.82.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98489606A335 for ; Fri, 4 Dec 2026 13:25:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98489606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pwe15Vcl Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-38692f62b22so1870391eec.0 for ; Fri, 04 Dec 2026 05:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796390706; x=1796995506; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=O2cEnQEeUxfdaHNoHTL+V8CQ+1m8Ci56bGz6i+IWhVw=; b=pwe15Vclk05zg2cEOfB8PsYPiqE2opJLpkkm00nzBXbr11lvy83rLYz+6JeqGUJUDB HuXf1vMAP/YIMMqbA7v5u1dkqFSSAgfMCUM3Bi7VWaJjicqRzIXVXcAtGAxAd3MVCAwh nJnyyzyBvfJSXm4N+G4nIbSPZ0hxJ0R9WlJZXN1mLOSzL83qOlo5Ye89M3oO0E/H/E5o q2jC0fnBnkBQpzbw8AZDewre3JxgzaYNHMTcp2mXb4ximDPqqw4+itOzrzb7tVrEiu6n kg0iBz8xDhcEe0n//7ggNAbDfu1GCBDmgxHbbXjr1RYc7yLdsOw3/PUVQ0GwnHhLIi4z lesQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796390706; x=1796995506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=O2cEnQEeUxfdaHNoHTL+V8CQ+1m8Ci56bGz6i+IWhVw=; b=yN2fGZE2k3wM6s8MOP/44H9VQTihk3jfgiB8H9P7dL/UoQH+bpLsnR8wsC7Ho1xo9S Hz8vHfIHtiqah3ORaAJyTVewpN8ssjQCGIbig1/gToCoYb92dsvQ56v+RXBViplRKobl eQsWEPfj6dJZHvQFK7b0pmnVpdZOIIwNB7AnPkbbAuB1FXgXww1PW3r/w9Q36pzd30vL p1uVsRb+kwfQpLCjnr4okCT6lZrGJGl44rnjFXSCLaWciDXSarQPx44wWAjHyQplAqSh EtWmcQj/WmJQqFmlTBpx0D0GM7cvTXN/NQbLUdUoArfuAoDao8xWnRIM2iV4yddWS7vL 0Keg== X-Forwarded-Encrypted: i=1; AL+hErHgReAnkq5ZeySQ8AG9O98G4fSfRUOWbz8ftjkSHIpl9utIz31oJL1HG3my3CMVJsALqh2mKg==@lists.linux.dev X-Gm-Message-State: AB4q+uH5Bse9GICX7ONII5hkHlq5Qmuw7Xtu8sKbwOvnPWeg4/pS+eHu bXclyVE80pN8PP6MbfB72wejfubso3FfbpWTJfbcJw92IgK7BJdQ5no= X-Gm-Gg: AZFdTZe5hzpzoKcYNqCnyljBAJelG90xtnJCPvCrAhxorKyL/IAaSoI6z8XCxBLpPwK BcOn182OMJ2xnSTGMIUGBy6PYe6AgDmo42m3HwXxw4Nbr9ZyOzrBrS7IgcyMVVOU/IooeAOTkFV cWjnvqPVamFfkvkh5q1hH3DNHi5D46MzkFfy11hfSJ9D8twT8yvu6VrwVVFV2TJEbARqRZJMKrq rLzV0K0JANgqIKwiv/TzlX6jRok48mlcyEAywkb+5M1n6PZp8rCYqJa9NHjT8G1XuVea5nMFafM jhoEZF0zUslQy5JKG5el1a3fOgJwaOwuFzRaMa37YgR86r3nkVslwr3zYDdFlIBLPHSS/YcP22I CJvGWz4xRhL7jRG/jzPc+HsVUNRiB6fPxt5M1MdDpE21FLWnXCPDmoI70ZOuHdFoY2OupH5/8U1 P+TNnWKTAdUQpYYLlL0frQXdYD16j8rG1ePrLmeFzPM1HepN7unoDro4ZBYtJLLNBmJT/7L6ZZ5 LJYfrz+xTnNErN7JqCYi8M5rsoB95aqAzF864uewP55waNW3aDQBvinfzbF01hJ7Gc0N04KHID2 CJIHmRqRJARz/0QzIS79cdls38+mDjSpkQj2c5/L+Bz+RjWYzBbSXcBF7xLJEg== X-Received: by 2002:a05:693c:880f:10b0:384:bc32:fe6b with SMTP id 5a478bee46e88-387521699aemr1999446eec.13.1796390705312; Fri, 04 Dec 2026 05:25:05 -0800 (PST) Received: from at-Standard-PC-Q35-ICH9-2009 ([27.60.19.167]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521e1c55sm7152700eec.16.2026.12.04.05.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 05:25:04 -0800 (PST) From: Atharva Tiwari To: Cc: Atharva Tiwari , Ihor Odainyi , Antoine Sidem , Aditya Garg , Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Len Brown , Linus Walleij , Bartosz Golaszewski , Sven Peter , Janne Grunau , Neal Gompa , Guenter Roeck , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Lee Jones , Pavel Machek , Griffin Kroah-Hartman , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sebastian Reichel , Alexandre Belloni , Wim Van Sebroeck , Jarkko Sakkinen , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds@vger.kernel.org, mfd@lists.linux.dev, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 14/14] mfd/macsmc: add ioctl to access smc keys Date: Fri, 4 Dec 2026 08:12:54 -0500 Message-ID: <20261204131619.5059-15-atharvatiwarilinuxdev@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261204131619.5059-1-atharvatiwarilinuxdev@gmail.com> References: <20261204131619.5059-1-atharvatiwarilinuxdev@gmail.com> X-Mailing-List: asahi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a /dev/smc device so userspace can talk to the SMC directly. Some keys that need to be written aren't handled by any driver, or affect several drivers at once, so they can't be exposed cleanly through the kernel interfaces. Keys already managed by kernel drivers can't be written this way, to avoid conflicts. Tested-by: Ihor Odainyi Tested-by: Antoine Sidem Tested-by: Aditya Garg Signed-off-by: Atharva Tiwari --- drivers/mfd/macsmc-core.c | 140 ++++++++++++++++++++++++++++++++++++ include/linux/mfd/macsmc.h | 61 ++-------------- include/uapi/linux/macsmc.h | 119 ++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+), 56 deletions(-) create mode 100644 include/uapi/linux/macsmc.h diff --git a/drivers/mfd/macsmc-core.c b/drivers/mfd/macsmc-core.c index bc4200f57..a53df6f6c 100644 --- a/drivers/mfd/macsmc-core.c +++ b/drivers/mfd/macsmc-core.c @@ -6,10 +6,13 @@ #include #include +#include #include #include +#include #include #include +#include static const struct mfd_cell apple_smc_rtkit_devs[] = { MFD_CELL_NAME("macsmc-input"), @@ -112,6 +115,129 @@ static void apple_smc_disable_notifications(void *data) smc->be->disable_notifications(smc->be_cookie); } +static long apple_smc_fops_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct apple_smc *smc = file->private_data; + void __user *argp = (void __user *)arg; + int ret; + + switch (cmd) { + case IOCTL_SMC_READ: { + struct ioctl_smc_rw_payload payload; + struct apple_smc_key_info info; + + if (copy_from_user(&payload, argp, sizeof(payload))) + return -EFAULT; + + ret = apple_smc_get_key_info(smc, payload.key, &info); + if (ret < 0) + return ret; + + if (payload.size != info.size) + return -EINVAL; + + if (payload.size > 32 || !(info.flags & APPLE_SMC_READABLE)) + return -EINVAL; + + ret = apple_smc_read(smc, payload.key, payload.buf, payload.size); + if (ret < 0) + return ret; + + if (copy_to_user(argp, &payload, sizeof(payload))) + return -EFAULT; + return 0; + } + case IOCTL_SMC_WRITE: { + struct ioctl_smc_rw_payload payload; + struct apple_smc_key_info info; + + if (copy_from_user(&payload, argp, sizeof(payload))) + return -EFAULT; + + ret = apple_smc_get_key_info(smc, payload.key, &info); + if (ret < 0) + return ret; + + if (payload.size != info.size) + return -EINVAL; + + if (payload.size > 32) + return -EINVAL; + + switch (payload.key) { + case __SMC_KEY('H', 'E', '0', 'N'): + case __SMC_KEY('H', 'E', '2', 'N'): + case __SMC_KEY('H', 'I', '0', 'N'): + case __SMC_KEY('M', 'S', 'T', 'S'): + case __SMC_KEY('M', 'S', 'P', 'C'): + case __SMC_KEY('Q', 'E', 'N', 'A'): + break; + default: + return -EPERM; + } + + ret = apple_smc_write(smc, payload.key, payload.buf, payload.size); + if (ret < 0) + return ret; + + return 0; + } + case IOCTL_SMC_GET_KEY_INDEX: { + struct ioctl_smc_index_payload payload; + + if (copy_from_user(&payload, argp, sizeof(payload))) + return -EFAULT; + + ret = apple_smc_get_key_by_index(smc, payload.index, &payload.key); + if (ret < 0) + return ret; + + if (copy_to_user(argp, &payload, sizeof(payload))) + return -EFAULT; + + return 0; + } + case IOCTL_SMC_GET_KEY_INFO: { + struct ioctl_smc_info_payload payload; + + if (copy_from_user(&payload, argp, sizeof(payload))) + return -EFAULT; + + ret = apple_smc_get_key_info(smc, payload.key, &payload.info); + if (ret < 0) + return ret; + + if (copy_to_user(argp, &payload, sizeof(payload))) + return -EFAULT; + + return 0; + } + default: + return -EINVAL; + } +} + +static int apple_smc_fops_open(struct inode *inode, struct file *file) +{ + struct miscdevice *misc = file->private_data; + + file->private_data = container_of(misc, struct apple_smc, miscdev); + return 0; +} + +static const struct file_operations apple_smc_fops = { + .owner = THIS_MODULE, + .open = apple_smc_fops_open, + .unlocked_ioctl = apple_smc_fops_ioctl, + .compat_ioctl = compat_ptr_ioctl, + .llseek = noop_llseek, +}; + +static void apple_smc_misc_unregister(void *data) +{ + misc_deregister(data); +} + int apple_smc_probe(struct device *dev, const struct apple_smc_backend_ops *ops, void *cookie, struct blocking_notifier_head *event_handlers, bool is_acpi) { @@ -150,6 +276,20 @@ int apple_smc_probe(struct device *dev, const struct apple_smc_backend_ops *ops, if (ret) return ret; + smc->miscdev.minor = MISC_DYNAMIC_MINOR; + smc->miscdev.name = "smc"; + smc->miscdev.fops = &apple_smc_fops; + smc->miscdev.parent = dev; + smc->miscdev.mode = 0600; + + ret = misc_register(&smc->miscdev); + if (ret) + return ret; + + ret = devm_add_action_or_reset(dev, apple_smc_misc_unregister, &smc->miscdev); + if (ret) + return ret; + if (smc->is_acpi) { ret = devm_mfd_add_devices(dev, -1, apple_smc_acpi_common, ARRAY_SIZE(apple_smc_acpi_common), NULL, 0, NULL); diff --git a/include/linux/mfd/macsmc.h b/include/linux/mfd/macsmc.h index cdd040f0c..a09dc6396 100644 --- a/include/linux/mfd/macsmc.h +++ b/include/linux/mfd/macsmc.h @@ -8,44 +8,9 @@ #ifndef _LINUX_MFD_MACSMC_H #define _LINUX_MFD_MACSMC_H +#include #include - -/** - * typedef smc_key - Alias for u32 to be used for SMC keys - * - * SMC keys are 32bit integers containing packed ASCII characters in natural - * integer order, i.e. 0xAABBCCDD, which represent the FourCC ABCD. - * The SMC driver is designed with this assumption and ensures the right - * endianness is used when these are stored to memory and sent to or received - * from the actual SMC firmware (which can be done in either shared memory or - * as 64bit mailbox message on Apple Silicon). - * Internally, SMC stores these keys in a table sorted lexicographically and - * allows resolving an index into this table to the corresponding SMC key. - * Thus, storing keys as u32 is very convenient as it allows to e.g. use - * normal comparison operators which directly map to the natural order used - * by SMC firmware. - * - * This simple type alias is introduced to allow easy recognition of SMC key - * variables and arguments. - */ -typedef u32 smc_key; - -/** - * SMC_KEY - Convert FourCC SMC keys in source code to smc_key - * - * This macro can be used to easily define FourCC SMC keys in source code - * and convert these to u32 / smc_key, e.g. SMC_KEY(NTAP) will expand to - * 0x4e544150. - * - * @s: FourCC SMC key to be converted - */ -#define SMC_KEY(s) (smc_key)(_SMC_KEY(#s)) -#define _SMC_KEY(s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]) -#define __SMC_KEY(a, b, c, d) (((u32)(a) << 24) | ((u32)(b) << 16) | ((u32)(c) << 8) | ((u32)(d))) - -#define APPLE_SMC_READABLE BIT(7) -#define APPLE_SMC_WRITABLE BIT(6) -#define APPLE_SMC_FUNCTION BIT(4) +#include #define SMC_MSG_READ_KEY 0x10 #define SMC_MSG_WRITE_KEY 0x11 @@ -66,25 +31,6 @@ typedef u32 smc_key; #define SMC_INT_SMS_SHOCK 0x6F #define SMC_INT_PLIMIT_CHANGED 0x80 -/** - * struct apple_smc_key_info - Information for a SMC key as returned by SMC - * @type_code: FourCC code indicating the type for this key. - * Known types: - * ch8*: ASCII string - * flag: Boolean, 1 or 0 - * flt: 32-bit single-precision IEEE 754 float - * hex: Binary data - * ioft: 64bit Unsigned fixed-point intger (48.16) - * {si,ui}{8,16,32,64}: Signed/Unsigned 8-/16-/32-/64-bit integer - * @size: Size of the buffer associated with this key - * @flags: Bitfield encoding flags (APPLE_SMC_{READABLE,WRITABLE,FUNCTION}) - */ -struct apple_smc_key_info { - u32 type_code; - u8 size; - u8 flags; -}; - /** * enum apple_smc_boot_stage - SMC boot stage * @APPLE_SMC_BOOTING: SMC is booting @@ -136,6 +82,7 @@ struct apple_smc_backend_ops { * @is_acpi: Is the backend ACPI based * @mutex: Mutex for non-atomic mode * @lock: Spinlock for atomic mode + * @miscdev: Misc Device struct for ioctl ops */ struct apple_smc { struct device *dev; @@ -152,6 +99,8 @@ struct apple_smc { struct mutex mutex; spinlock_t lock; + + struct miscdevice miscdev; }; /** diff --git a/include/uapi/linux/macsmc.h b/include/uapi/linux/macsmc.h new file mode 100644 index 000000000..ef784539d --- /dev/null +++ b/include/uapi/linux/macsmc.h @@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT WITH Linux-syscall-note */ +/* + * Apple SMC Public Interface + * + * Copyright (C) 2026 Atharva Tiwari + */ + +#ifndef _UAPI_MACSMC_H +#define _UAPI_MACSMC_H + +#include +#include + +/** + * typedef smc_key - Alias for u32 to be used for SMC keys + * + * SMC keys are 32bit integers containing packed ASCII characters in natural + * integer order, i.e. 0xAABBCCDD, which represent the FourCC ABCD. + * The SMC driver is designed with this assumption and ensures the right + * endianness is used when these are stored to memory and sent to or received + * from the actual SMC firmware (which can be done in either shared memory or + * as 64bit mailbox message on Apple Silicon). + * Internally, SMC stores these keys in a table sorted lexicographically and + * allows resolving an index into this table to the corresponding SMC key. + * Thus, storing keys as u32 is very convenient as it allows to e.g. use + * normal comparison operators which directly map to the natural order used + * by SMC firmware. + * + * This simple type alias is introduced to allow easy recognition of SMC key + * variables and arguments. + */ +typedef __u32 smc_key; + +/** + * SMC_KEY - Convert FourCC SMC keys in source code to smc_key + * + * This macro can be used to easily define FourCC SMC keys in source code + * and convert these to u32 / smc_key, e.g. SMC_KEY(NTAP) will expand to + * 0x4e544150. + * + * @s: FourCC SMC key to be converted + */ +#define SMC_KEY(s) ((smc_key)(_SMC_KEY(#s))) +#define _SMC_KEY(s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]) +#define __SMC_KEY(a, b, c, d) (((__u32)(a) << 24) | ((__u32)(b) << 16) | ((__u32)(c) << 8) | ((__u32)(d))) + +#define APPLE_SMC_READABLE BIT(7) +#define APPLE_SMC_WRITABLE BIT(6) +#define APPLE_SMC_FUNCTION BIT(4) +#define APPLE_SMC_CONST BIT(3) +#define APPLE_SMC_ATOMIC BIT(2) +#define APPLE_SMC_PRIVATE_READ BIT(1) +#define APPLE_SMC_PRIVATE_WRITE BIT(0) + +/** + * struct apple_smc_key_info - Information for a SMC key as returned by SMC + * @type_code: FourCC code indicating the type for this key. + * Known types: + * ch8*: ASCII string + * flag: Boolean, 1 or 0 + * flt: 32-bit single-precision IEEE 754 float + * hex: Binary data + * ioft: 64bit Unsigned fixed-point intger (48.16) + * {si,ui}{8,16,32,64}: Signed/Unsigned 8-/16-/32-/64-bit integer + * @size: Size of the buffer associated with this key + * @flags: Bitfield encoding flags (APPLE_SMC_{READABLE,WRITABLE,FUNCTION, + * CONST,ATOMIC,PRIVATE_READ,PRIVATE_WRITE}) + */ +struct apple_smc_key_info { + __u32 type_code; + __u8 size; + __u8 flags; +}; + +/** + * struct ioctl_smc_rw_payload - argument for IOCTL_SMC_READ and IOCTL_SMC_WRITE + * @key: SMC key to access. Input. + * @size: Size of the key's data in bytes. Input. It must match the size the + * SMC reports for @key (see IOCTL_SMC_GET_KEY_INFO) and cannot exceed + * the size of @buf. + * @buf: Key data. For IOCTL_SMC_READ this is filled in by the kernel with the + * value read from @key. For IOCTL_SMC_WRITE it holds the value to write to + * @key. + */ +struct ioctl_smc_rw_payload { + smc_key key; + __u32 size; + __u8 buf[32]; +}; + +/** + * struct ioctl_smc_index_payload - argument for IOCTL_SMC_GET_KEY_INDEX + * @index: Position in the SMC's key table. Input. + * @key: Key stored at @index. Filled in by the kernel. + * + * Calling this with increasing @index values lists every key the SMC exposes. + */ +struct ioctl_smc_index_payload { + __u16 index; + smc_key key; +}; + +/** + * struct ioctl_smc_info_payload - argument for IOCTL_SMC_GET_KEY_INFO + * @key: SMC key to look up. Input. + * @info: Size, type code and flags of @key. Filled in by the kernel. + */ +struct ioctl_smc_info_payload { + smc_key key; + struct apple_smc_key_info info; +}; + +#define APPLE_SMC_MAGIC 'S' +#define IOCTL_SMC_READ _IOWR(APPLE_SMC_MAGIC, 1, struct ioctl_smc_rw_payload) +#define IOCTL_SMC_WRITE _IOW(APPLE_SMC_MAGIC, 2, struct ioctl_smc_rw_payload) +#define IOCTL_SMC_GET_KEY_INDEX _IOWR(APPLE_SMC_MAGIC, 3, struct ioctl_smc_index_payload) +#define IOCTL_SMC_GET_KEY_INFO _IOWR(APPLE_SMC_MAGIC, 4, struct ioctl_smc_info_payload) + +#endif /* _UAPI_MACSMC_H */ -- 2.55.0