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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1457697574-6710-3-git-send-email-jgross@suse.com>
Date:	Fri, 11 Mar 2016 12:59:30 +0100
From:	Juergen Gross <jgross@...e.com>
To:	linux-kernel@...r.kernel.org, xen-devel@...ts.xenproject.org
Cc:	konrad.wilk@...cle.com, boris.ostrovsky@...cle.com,
	david.vrabel@...rix.com, mingo@...hat.com, peterz@...radead.org,
	Douglas_Warzecha@...l.com, pali.rohar@...il.com, jdelvare@...e.com,
	linux@...ck-us.net, tglx@...utronix.de, hpa@...or.com,
	x86@...nel.org, Juergen Gross <jgross@...e.com>
Subject: [PATCH 2/6] sched: add function to execute a function synchronously on a physical cpu

On some hardware models (e.g. Dell Studio 1555 laptop) some hardware
related functions (e.g. SMIs) are to be executed on physical cpu 0
only. Instead of open coding such a functionality multiple times in
the kernel add a service function for this purpose. This will enable
the possibility to take special measures in virtualized environments
like Xen, too.

Signed-off-by: Juergen Gross <jgross@...e.com>
---
 include/linux/sched.h |  9 +++++++++
 kernel/sched/core.c   | 26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index a10494a..dfadf1a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2247,6 +2247,7 @@ extern void do_set_cpus_allowed(struct task_struct *p,
 
 extern int set_cpus_allowed_ptr(struct task_struct *p,
 				const struct cpumask *new_mask);
+int call_sync_on_phys_cpu(unsigned cpu, int (*func)(void *), void *par);
 #else
 static inline void do_set_cpus_allowed(struct task_struct *p,
 				      const struct cpumask *new_mask)
@@ -2259,6 +2260,14 @@ static inline int set_cpus_allowed_ptr(struct task_struct *p,
 		return -EINVAL;
 	return 0;
 }
+static inline int call_sync_on_phys_cpu(unsigned cpu, int (*func)(void *),
+					void *par)
+{
+	if (cpu != 0)
+		return -EINVAL;
+
+	return func(par);
+}
 #endif
 
 #ifdef CONFIG_NO_HZ_COMMON
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 41f6b22..cb9955f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1265,6 +1265,32 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
 }
 EXPORT_SYMBOL_GPL(set_cpus_allowed_ptr);
 
+int call_sync_on_phys_cpu(unsigned cpu, int (*func)(void *), void *par)
+{
+	cpumask_var_t old_mask;
+	int ret;
+
+	if (cpu >= nr_cpu_ids)
+		return -EINVAL;
+
+	if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
+		return -ENOMEM;
+
+	cpumask_copy(old_mask, &current->cpus_allowed);
+	ret = set_cpus_allowed_ptr(current, cpumask_of(cpu));
+	if (ret)
+		goto out;
+
+	ret = func(par);
+
+	set_cpus_allowed_ptr(current, old_mask);
+
+out:
+	free_cpumask_var(old_mask);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(call_sync_on_phys_cpu);
+
 void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 {
 #ifdef CONFIG_SCHED_DEBUG
-- 
2.6.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ