/* * Lockless MCE logging infrastructure. * This avoids deadlocks on printk locks without having to break locks. Also * separate MCEs from kernel messages to avoid bogus bug reports.
*/
if (mce->kflags & MCE_HANDLED_CEC) return NOTIFY_DONE;
mutex_lock(&mce_chrdev_read_mutex);
entry = mcelog->next;
/* * When the buffer fills up discard new entries. Assume that the * earlier errors are the more interesting ones:
*/ if (entry >= mcelog->len) {
set_bit(MCE_OVERFLOW, (unsignedlong *)&mcelog->flags); goto unlock;
}
/* Collect MCE record of previous boot in persistent storage via APEI ERST. */ staticint __mce_read_apei(char __user **ubuf, size_t usize)
{ int rc;
u64 record_id; struct mce m;
if (usize < sizeof(struct mce)) return -EINVAL;
rc = apei_read_mce(&m, &record_id); /* Error or no more MCE record */ if (rc <= 0) {
mce_apei_read_done = 1; /* * When ERST is disabled, mce_chrdev_read() should return * "no record" instead of "no device."
*/ if (rc == -ENODEV) return 0; return rc;
}
rc = -EFAULT; if (copy_to_user(*ubuf, &m, sizeof(struct mce))) return rc; /* * In fact, we should have cleared the record after that has * been flushed to the disk or sent to network in * /sbin/mcelog, but we have no interface to support that now, * so just clear it to avoid duplication.
*/
rc = apei_clear_mce(record_id); if (rc) {
mce_apei_read_done = 1; return rc;
}
*ubuf += sizeof(struct mce);
if (!capable(CAP_SYS_ADMIN)) return -EPERM; /* * There are some cases where real MSR reads could slip * through.
*/ if (!boot_cpu_has(X86_FEATURE_MCE) || !boot_cpu_has(X86_FEATURE_MCA)) return -EIO;
if ((unsignedlong)usize > sizeof(struct mce))
usize = sizeof(struct mce); if (copy_from_user(&m, ubuf, usize)) return -EFAULT;
if (m.extcpu >= num_possible_cpus() || !cpu_online(m.extcpu)) return -EINVAL;
/* * Need to give user space some time to set everything up, * so do it a jiffy or two later everywhere.
*/
schedule_timeout(2);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.