From: "Fenghua Yu" <fenghua.yu@intel.com>
To: "Ingo Molnar" <mingo@elte.hu>,
"Thomas Gleixner" <tglx@linutronix.de>,
"H Peter Anvin" <hpa@zytor.com>,
"Tony Luck" <tony.luck@intel.com>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
"Fenghua Yu" <fenghua.yu@intel.com>
Subject: [PATCH 2/2] x86/kernel/cpu/mcheck/mce.c: Interfaces for mce inject driver exit
Date: Tue, 3 May 2011 15:34:40 -0700 [thread overview]
Message-ID: <1304462080-3358-3-git-send-email-fenghua.yu@intel.com> (raw)
In-Reply-To: <1304462080-3358-1-git-send-email-fenghua.yu@intel.com>
From: Fenghua Yu <fenghua.yu@intel.com>
Provide mce_write register and unregister interfaces for mce inject driver to
call. The interfaces take care of race condition for mce write.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/include/asm/mce.h | 3 ++-
arch/x86/kernel/cpu/mcheck/mce.c | 35 +++++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index eb16e94..0b777c4 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -198,7 +198,6 @@ int mce_notify_irq(void);
void mce_notify_process(void);
DECLARE_PER_CPU(struct mce, injectm);
-extern struct file_operations mce_chrdev_ops;
/*
* Exception handler
@@ -240,5 +239,7 @@ struct cper_sec_mem_err;
extern void apei_mce_report_mem_error(int corrected,
struct cper_sec_mem_err *mem_err);
+extern void mce_write_register(void *mce_write_inject);
+extern void mce_write_unregister(void);
#endif /* __KERNEL__ */
#endif /* _ASM_X86_MCE_H */
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 3385ea2..9f0bbcc 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -50,6 +50,7 @@
#include "mce-internal.h"
static DEFINE_MUTEX(mce_read_mutex);
+static DEFINE_MUTEX(mce_write_mutex);
#define rcu_dereference_check_mce(p) \
rcu_dereference_index_check((p), \
@@ -1539,6 +1540,36 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
return 0;
}
+static ssize_t (*_mce_write)(struct file *filp, const char __user *ubuf,
+ size_t usize, loff_t *off);
+void mce_write_register(void *mce_write_inject)
+{
+ mutex_lock(&mce_write_mutex);
+ _mce_write = mce_write_inject;
+ mutex_unlock(&mce_write_mutex);
+}
+EXPORT_SYMBOL(mce_write_register);
+
+void mce_write_unregister(void)
+{
+ mutex_lock(&mce_write_mutex);
+ _mce_write = 0;
+ mutex_unlock(&mce_write_mutex);
+}
+EXPORT_SYMBOL(mce_write_unregister);
+
+static ssize_t mce_write(struct file *filp, const char __user *ubuf,
+ size_t usize, loff_t *off)
+{
+ ssize_t ret = 0;
+
+ mutex_lock(&mce_write_mutex);
+ if (_mce_write)
+ ret = _mce_write(filp, ubuf, usize, off);
+ mutex_unlock(&mce_write_mutex);
+ return ret;
+}
+
static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
loff_t *off)
{
@@ -1659,11 +1690,11 @@ static long mce_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
}
}
-/* Modified in mce-inject.c, so not static or const */
-struct file_operations mce_chrdev_ops = {
+static const struct file_operations mce_chrdev_ops = {
.open = mce_open,
.release = mce_release,
.read = mce_read,
+ .write = mce_write,
.poll = mce_poll,
.unlocked_ioctl = mce_ioctl,
.llseek = no_llseek,
--
1.7.2
prev parent reply other threads:[~2011-05-03 22:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 22:34 [PATCH 0/2] Enable " Fenghua Yu
2011-05-03 22:34 ` [PATCH 1/2] x86/kernel/cpu/mcheck/mce-inject.c: Add " Fenghua Yu
2011-05-03 22:34 ` Fenghua Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304462080-3358-3-git-send-email-fenghua.yu@intel.com \
--to=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome