~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/kernel/cpacf.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  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 file *fp,                           \
 16                                      struct kobject *kobj,                      \
 17                                      struct bin_attribute *attr,                \
 18                                      char *buf, loff_t offs,                    \
 19                                      size_t count)                              \
 20 {                                                                               \
 21         cpacf_mask_t mask;                                                      \
 22                                                                                 \
 23         if (!cpacf_query(CPACF_##instruction, &mask))                           \
 24                 return -EOPNOTSUPP;                                             \
 25         return memory_read_from_buffer(buf, count, &offs, &mask, sizeof(mask)); \
 26 }                                                                               \
 27 static BIN_ATTR_RO(name##_query_raw, sizeof(cpacf_mask_t))
 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, loff_t offs,     \
 47         size_t count)                                           \
 48 {                                                               \
 49         cpacf_qai_t qai;                                        \
 50                                                                 \
 51         if (!cpacf_qai(CPACF_##instruction, &qai))              \
 52                 return -EOPNOTSUPP;                             \
 53         return memory_read_from_buffer(buf, count, &offs, &qai, \
 54                                         sizeof(qai));           \
 55 }                                                               \
 56 static BIN_ATTR_RO(name##_query_auth_info_raw, sizeof(cpacf_qai_t))
 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_grp = {
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_subsys);
113         if (cpu_root) {
114                 rc = sysfs_create_group(&cpu_root->kobj, &cpacf_attr_grp);
115                 put_device(cpu_root);
116         }
117         return rc;
118 }
119 device_initcall(cpacf_init);
120 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php