1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 3 * Copyright (C) 2022 IBM Corporation 4 * Author: Nayna Jain <nayna@linux.ibm.com> 5 * 6 * Platform keystore for pseries LPAR(PLPKS). 7 */ 8 9 #ifndef _ASM_POWERPC_PLPKS_H 10 #define _ASM_POWERPC_PLPKS_H 11 12 #ifdef CONFIG_PSERIES_PLPKS 13 14 #include <linux/types.h> 15 #include <linux/list.h> 16 17 // Object policy flags from supported_policies 18 #define PLPKS_OSSECBOOTAUDIT PPC_BIT32(1) / 19 #define PLPKS_OSSECBOOTENFORCE PPC_BIT32(2) / 20 #define PLPKS_PWSET PPC_BIT32(3) / 21 #define PLPKS_WORLDREADABLE PPC_BIT32(4) / 22 #define PLPKS_IMMUTABLE PPC_BIT32(5) / 23 #define PLPKS_TRANSIENT PPC_BIT32(6) / 24 #define PLPKS_SIGNEDUPDATE PPC_BIT32(7) / 25 #define PLPKS_HVPROVISIONED PPC_BIT32(28) 26 27 // Signature algorithm flags from signed_updat 28 #define PLPKS_ALG_RSA2048 PPC_BIT(0) 29 #define PLPKS_ALG_RSA4096 PPC_BIT(1) 30 31 // Object label OS metadata flags 32 #define PLPKS_VAR_LINUX 0x02 33 #define PLPKS_VAR_COMMON 0x04 34 35 // Flags for which consumer owns an object is 36 #define PLPKS_FW_OWNER 0x1 37 #define PLPKS_BOOTLOADER_OWNER 0x2 38 #define PLPKS_OS_OWNER 0x3 39 40 // Flags for label metadata fields 41 #define PLPKS_LABEL_VERSION 0 42 #define PLPKS_MAX_LABEL_ATTR_SIZE 16 43 #define PLPKS_MAX_NAME_SIZE 239 44 #define PLPKS_MAX_DATA_SIZE 4000 45 46 // Timeouts for PLPKS operations 47 #define PLPKS_MAX_TIMEOUT (5 * U 48 #define PLPKS_FLUSH_SLEEP 10000 49 50 struct plpks_var { 51 char *component; 52 u8 *name; 53 u8 *data; 54 u32 policy; 55 u16 namelen; 56 u16 datalen; 57 u8 os; 58 }; 59 60 struct plpks_var_name { 61 u8 *name; 62 u16 namelen; 63 }; 64 65 struct plpks_var_name_list { 66 u32 varcount; 67 struct plpks_var_name varlist[]; 68 }; 69 70 /** 71 * Updates the authenticated variable. It expe 72 */ 73 int plpks_signed_update_var(struct plpks_var * 74 75 /** 76 * Writes the specified var and its data to PK 77 * Any caller of PKS driver should present a v 78 * their variable. 79 */ 80 int plpks_write_var(struct plpks_var var); 81 82 /** 83 * Removes the specified var and its data from 84 */ 85 int plpks_remove_var(char *component, u8 varos 86 struct plpks_var_name vna 87 88 /** 89 * Returns the data for the specified os varia 90 * 91 * Caller must allocate a buffer in var->data 92 * If no buffer is provided, var->datalen will 93 * size. 94 */ 95 int plpks_read_os_var(struct plpks_var *var); 96 97 /** 98 * Returns the data for the specified firmware 99 * 100 * Caller must allocate a buffer in var->data 101 * If no buffer is provided, var->datalen will 102 * size. 103 */ 104 int plpks_read_fw_var(struct plpks_var *var); 105 106 /** 107 * Returns the data for the specified bootload 108 * 109 * Caller must allocate a buffer in var->data 110 * If no buffer is provided, var->datalen will 111 * size. 112 */ 113 int plpks_read_bootloader_var(struct plpks_var 114 115 /** 116 * Returns if PKS is available on this LPAR. 117 */ 118 bool plpks_is_available(void); 119 120 /** 121 * Returns version of the Platform KeyStore. 122 */ 123 u8 plpks_get_version(void); 124 125 /** 126 * Returns hypervisor storage overhead per obj 127 * the object or label. Only valid for config 128 */ 129 u16 plpks_get_objoverhead(void); 130 131 /** 132 * Returns maximum password size. Must be >= 3 133 */ 134 u16 plpks_get_maxpwsize(void); 135 136 /** 137 * Returns maximum object size supported by Pl 138 */ 139 u16 plpks_get_maxobjectsize(void); 140 141 /** 142 * Returns maximum object label size supported 143 */ 144 u16 plpks_get_maxobjectlabelsize(void); 145 146 /** 147 * Returns total size of the configured Platfo 148 */ 149 u32 plpks_get_totalsize(void); 150 151 /** 152 * Returns used space from the total size of t 153 */ 154 u32 plpks_get_usedspace(void); 155 156 /** 157 * Returns bitmask of policies supported by th 158 */ 159 u32 plpks_get_supportedpolicies(void); 160 161 /** 162 * Returns maximum byte size of a single objec 163 * Only valid for config version >= 3 164 */ 165 u32 plpks_get_maxlargeobjectsize(void); 166 167 /** 168 * Returns bitmask of signature algorithms sup 169 * Only valid for config version >= 3 170 */ 171 u64 plpks_get_signedupdatealgorithms(void); 172 173 /** 174 * Returns the length of the PLPKS password in 175 */ 176 u16 plpks_get_passwordlen(void); 177 178 /** 179 * Called in early init to retrieve and clear 180 */ 181 void plpks_early_init_devtree(void); 182 183 /** 184 * Populates the FDT with the PLPKS password t 185 */ 186 int plpks_populate_fdt(void *fdt); 187 #else // CONFIG_PSERIES_PLPKS 188 static inline bool plpks_is_available(void) { 189 static inline u16 plpks_get_passwordlen(void) 190 static inline void plpks_early_init_devtree(vo 191 static inline int plpks_populate_fdt(void *fdt 192 #endif // CONFIG_PSERIES_PLPKS 193 194 #endif // _ASM_POWERPC_PLPKS_H 195
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.