OSDN Git Service

crypto: ccp - Add support for setting user ID for dynamic boost control
[tomoyo/tomoyo-test1.git] / include / uapi / linux / psp-dbc.h
1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2 /*
3  * Userspace interface for AMD Dynamic Boost Control (DBC)
4  *
5  * Copyright (C) 2023 Advanced Micro Devices, Inc.
6  *
7  * Author: Mario Limonciello <mario.limonciello@amd.com>
8  */
9
10 #ifndef __PSP_DBC_USER_H__
11 #define __PSP_DBC_USER_H__
12
13 #include <linux/types.h>
14
15 /**
16  * DOC: AMD Dynamic Boost Control (DBC) interface
17  */
18
19 #define DBC_NONCE_SIZE          16
20 #define DBC_SIG_SIZE            32
21 #define DBC_UID_SIZE            16
22
23 /**
24  * struct dbc_user_nonce - Nonce exchange structure (input/output).
25  * @auth_needed: Whether the PSP should authenticate this request (input).
26  *               0: no authentication, PSP will return single use nonce.
27  *               1: authentication: PSP will return multi-use nonce.
28  * @nonce:       8 byte value used for future authentication (output).
29  * @signature:   Optional 32 byte signature created by software using a
30  *               previous nonce (input).
31  */
32 struct dbc_user_nonce {
33         __u32   auth_needed;
34         __u8    nonce[DBC_NONCE_SIZE];
35         __u8    signature[DBC_SIG_SIZE];
36 } __packed;
37
38 /**
39  * struct dbc_user_setuid - UID exchange structure (input).
40  * @uid:       16 byte value representing software identity
41  * @signature: 32 byte signature created by software using a previous nonce
42  */
43 struct dbc_user_setuid {
44         __u8    uid[DBC_UID_SIZE];
45         __u8    signature[DBC_SIG_SIZE];
46 } __packed;
47
48 /**
49  * Dynamic Boost Control (DBC) IOC
50  *
51  * possible return codes for all DBC IOCTLs:
52  *  0:          success
53  *  -EINVAL:    invalid input
54  *  -E2BIG:     excess data passed
55  *  -EFAULT:    failed to copy to/from userspace
56  *  -EBUSY:     mailbox in recovery or in use
57  *  -ENODEV:    driver not bound with PSP device
58  *  -EACCES:    request isn't authorized
59  *  -EINVAL:    invalid parameter
60  *  -ETIMEDOUT: request timed out
61  *  -EAGAIN:    invalid request for state machine
62  *  -ENOENT:    not implemented
63  *  -ENFILE:    overflow
64  *  -EPERM:     invalid signature
65  *  -EIO:       unknown error
66  */
67 #define DBC_IOC_TYPE    'D'
68
69 /**
70  * DBCIOCNONCE - Fetch a nonce from the PSP for authenticating commands.
71  *               If a nonce is fetched without authentication it can only
72  *               be utilized for one command.
73  *               If a nonce is fetched with authentication it can be used
74  *               for multiple requests.
75  */
76 #define DBCIOCNONCE     _IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce)
77
78 /**
79  * DBCIOCUID - Set the user ID (UID) of a calling process.
80  *             The user ID is 8 bytes long. It must be programmed using a
81  *             32 byte signature built using the nonce fetched from
82  *             DBCIOCNONCE.
83  *             The UID can only be set once until the system is rebooted.
84  */
85 #define DBCIOCUID       _IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid)
86
87 #endif /* __PSP_DBC_USER_H__ */