lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1304462080-3358-3-git-send-email-fenghua.yu@intel.com>
Date:	Tue,  3 May 2011 15:34:40 -0700
From:	"Fenghua Yu" <fenghua.yu@...el.com>
To:	"Ingo Molnar" <mingo@...e.hu>,
	"Thomas Gleixner" <tglx@...utronix.de>,
	"H Peter Anvin" <hpa@...or.com>, "Tony Luck" <tony.luck@...el.com>
Cc:	"linux-kernel" <linux-kernel@...r.kernel.org>,
	"Fenghua Yu" <fenghua.yu@...el.com>
Subject: [PATCH 2/2] x86/kernel/cpu/mcheck/mce.c: Interfaces for mce inject driver exit

From: Fenghua Yu <fenghua.yu@...el.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@...el.com>
Acked-by: Tony Luck <tony.luck@...el.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ