^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * are not related to any other subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/kobject.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kexec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/profile.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/capability.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/rcupdate.h> /* rcu_expedited and rcu_normal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define KERNEL_ATTR_RO(_name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define KERNEL_ATTR_RW(_name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static struct kobj_attribute _name##_attr = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __ATTR(_name, 0644, _name##_show, _name##_store)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* current uevent sequence number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static ssize_t uevent_seqnum_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) KERNEL_ATTR_RO(uevent_seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #ifdef CONFIG_UEVENT_HELPER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* uevent helper program, used during early boot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static ssize_t uevent_helper_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return sprintf(buf, "%s\n", uevent_helper);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static ssize_t uevent_helper_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (count+1 > UEVENT_HELPER_PATH_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) memcpy(uevent_helper, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) uevent_helper[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (count && uevent_helper[count-1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) uevent_helper[count-1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) KERNEL_ATTR_RW(uevent_helper);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #ifdef CONFIG_PROFILING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static ssize_t profiling_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return sprintf(buf, "%d\n", prof_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static ssize_t profiling_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (prof_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return -EEXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * This eventually calls into get_option() which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * has a ton of callers and is not const. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * easiest to cast it away here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) profile_setup((char *)buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ret = profile_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) ret = create_proc_profile();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) KERNEL_ATTR_RW(profiling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #ifdef CONFIG_KEXEC_CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static ssize_t kexec_loaded_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return sprintf(buf, "%d\n", !!kexec_image);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) KERNEL_ATTR_RO(kexec_loaded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return sprintf(buf, "%d\n", kexec_crash_loaded());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) KERNEL_ATTR_RO(kexec_crash_loaded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static ssize_t kexec_crash_size_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return sprintf(buf, "%zu\n", crash_get_memory_size());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static ssize_t kexec_crash_size_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned long cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (kstrtoul(buf, 0, &cnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ret = crash_shrink_memory(cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return ret < 0 ? ret : count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) KERNEL_ATTR_RW(kexec_crash_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #endif /* CONFIG_KEXEC_CORE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #ifdef CONFIG_CRASH_CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static ssize_t vmcoreinfo_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) phys_addr_t vmcore_base = paddr_vmcoreinfo_note();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return sprintf(buf, "%pa %x\n", &vmcore_base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) (unsigned int)VMCOREINFO_NOTE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) KERNEL_ATTR_RO(vmcoreinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #endif /* CONFIG_CRASH_CORE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* whether file capabilities are enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static ssize_t fscaps_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return sprintf(buf, "%d\n", file_caps_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) KERNEL_ATTR_RO(fscaps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #ifndef CONFIG_TINY_RCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int rcu_expedited;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static ssize_t rcu_expedited_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return sprintf(buf, "%d\n", READ_ONCE(rcu_expedited));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static ssize_t rcu_expedited_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (kstrtoint(buf, 0, &rcu_expedited))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) KERNEL_ATTR_RW(rcu_expedited);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int rcu_normal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static ssize_t rcu_normal_show(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct kobj_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return sprintf(buf, "%d\n", READ_ONCE(rcu_normal));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static ssize_t rcu_normal_store(struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (kstrtoint(buf, 0, &rcu_normal))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) KERNEL_ATTR_RW(rcu_normal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #endif /* #ifndef CONFIG_TINY_RCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * Make /sys/kernel/notes give the raw contents of our kernel .notes section.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) extern const void __start_notes __weak;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) extern const void __stop_notes __weak;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define notes_size (&__stop_notes - &__start_notes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static ssize_t notes_read(struct file *filp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct bin_attribute *bin_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) char *buf, loff_t off, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) memcpy(buf, &__start_notes + off, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static struct bin_attribute notes_attr __ro_after_init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .name = "notes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) .mode = S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .read = ¬es_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct kobject *kernel_kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) EXPORT_SYMBOL_GPL(kernel_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static struct attribute * kernel_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) &fscaps_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) &uevent_seqnum_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #ifdef CONFIG_UEVENT_HELPER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) &uevent_helper_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #ifdef CONFIG_PROFILING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) &profiling_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #ifdef CONFIG_KEXEC_CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) &kexec_loaded_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) &kexec_crash_loaded_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) &kexec_crash_size_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) #ifdef CONFIG_CRASH_CORE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) &vmcoreinfo_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #ifndef CONFIG_TINY_RCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) &rcu_expedited_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) &rcu_normal_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static const struct attribute_group kernel_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) .attrs = kernel_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int __init ksysfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) kernel_kobj = kobject_create_and_add("kernel", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (!kernel_kobj) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) error = sysfs_create_group(kernel_kobj, &kernel_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) goto kset_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (notes_size > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) notes_attr.size = notes_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) error = sysfs_create_bin_file(kernel_kobj, ¬es_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) goto group_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) group_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) sysfs_remove_group(kernel_kobj, &kernel_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) kset_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) kobject_put(kernel_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) core_initcall(ksysfs_init);