1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * Copyright IBM Corp. 2024 4 */ 5 6 #define KMSG_COMPONENT "cpacf" 7 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 8 9 #include <linux/cpu.h> 10 #include <linux/device.h> 11 #include <linux/sysfs.h> 12 #include <asm/cpacf.h> 13 14 #define CPACF_QUERY(name, instruction) 15 static ssize_t name##_query_raw_read(struct fi 16 struct ko 17 struct bi 18 char *buf 19 size_t co 20 { 21 cpacf_mask_t mask; 22 23 if (!cpacf_query(CPACF_##instruction, 24 return -EOPNOTSUPP; 25 return memory_read_from_buffer(buf, co 26 } 27 static BIN_ATTR_RO(name##_query_raw, sizeof(cp 28 29 CPACF_QUERY(km, KM); 30 CPACF_QUERY(kmc, KMC); 31 CPACF_QUERY(kimd, KIMD); 32 CPACF_QUERY(klmd, KLMD); 33 CPACF_QUERY(kmac, KMAC); 34 CPACF_QUERY(pckmo, PCKMO); 35 CPACF_QUERY(kmf, KMF); 36 CPACF_QUERY(kmctr, KMCTR); 37 CPACF_QUERY(kmo, KMO); 38 CPACF_QUERY(pcc, PCC); 39 CPACF_QUERY(prno, PRNO); 40 CPACF_QUERY(kma, KMA); 41 CPACF_QUERY(kdsa, KDSA); 42 43 #define CPACF_QAI(name, instruction) 44 static ssize_t name##_query_auth_info_raw_read 45 struct file *fp, struct kobject *kobj, 46 struct bin_attribute *attr, char *buf, 47 size_t count) 48 { 49 cpacf_qai_t qai; 50 51 if (!cpacf_qai(CPACF_##instruction, &q 52 return -EOPNOTSUPP; 53 return memory_read_from_buffer(buf, co 54 sizeof 55 } 56 static BIN_ATTR_RO(name##_query_auth_info_raw, 57 58 CPACF_QAI(km, KM); 59 CPACF_QAI(kmc, KMC); 60 CPACF_QAI(kimd, KIMD); 61 CPACF_QAI(klmd, KLMD); 62 CPACF_QAI(kmac, KMAC); 63 CPACF_QAI(pckmo, PCKMO); 64 CPACF_QAI(kmf, KMF); 65 CPACF_QAI(kmctr, KMCTR); 66 CPACF_QAI(kmo, KMO); 67 CPACF_QAI(pcc, PCC); 68 CPACF_QAI(prno, PRNO); 69 CPACF_QAI(kma, KMA); 70 CPACF_QAI(kdsa, KDSA); 71 72 static struct bin_attribute *cpacf_attrs[] = { 73 &bin_attr_km_query_raw, 74 &bin_attr_kmc_query_raw, 75 &bin_attr_kimd_query_raw, 76 &bin_attr_klmd_query_raw, 77 &bin_attr_kmac_query_raw, 78 &bin_attr_pckmo_query_raw, 79 &bin_attr_kmf_query_raw, 80 &bin_attr_kmctr_query_raw, 81 &bin_attr_kmo_query_raw, 82 &bin_attr_pcc_query_raw, 83 &bin_attr_prno_query_raw, 84 &bin_attr_kma_query_raw, 85 &bin_attr_kdsa_query_raw, 86 &bin_attr_km_query_auth_info_raw, 87 &bin_attr_kmc_query_auth_info_raw, 88 &bin_attr_kimd_query_auth_info_raw, 89 &bin_attr_klmd_query_auth_info_raw, 90 &bin_attr_kmac_query_auth_info_raw, 91 &bin_attr_pckmo_query_auth_info_raw, 92 &bin_attr_kmf_query_auth_info_raw, 93 &bin_attr_kmctr_query_auth_info_raw, 94 &bin_attr_kmo_query_auth_info_raw, 95 &bin_attr_pcc_query_auth_info_raw, 96 &bin_attr_prno_query_auth_info_raw, 97 &bin_attr_kma_query_auth_info_raw, 98 &bin_attr_kdsa_query_auth_info_raw, 99 NULL, 100 }; 101 102 static const struct attribute_group cpacf_attr 103 .name = "cpacf", 104 .bin_attrs = cpacf_attrs, 105 }; 106 107 static int __init cpacf_init(void) 108 { 109 struct device *cpu_root; 110 int rc = 0; 111 112 cpu_root = bus_get_dev_root(&cpu_subsy 113 if (cpu_root) { 114 rc = sysfs_create_group(&cpu_r 115 put_device(cpu_root); 116 } 117 return rc; 118 } 119 device_initcall(cpacf_init); 120
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.