* [PATCH 6/6] dcdbas: don't play with current's cpumask
@ 2009-06-11 13:29 Rusty Russell
0 siblings, 0 replies; only message in thread
From: Rusty Russell @ 2009-06-11 13:29 UTC (permalink / raw)
To: linux-kernel; +Cc: Matthew Garrett, Matt Domsch, Douglas_Warzecha
It's generally a very bad idea to mug some process's cpumask: it could
legitimately and reasonably be changed by root, which could break us
(if done before our code) or them (if we restore the wrong value).
So we use smp_call_function_single instead of cpumask games. I hope we
are allowed to trigger the smi from interrupt context.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Cc: Douglas_Warzecha@dell.com
---
drivers/firmware/dcdbas.c | 51 +++++++++++++++++-----------------------------
1 file changed, 19 insertions(+), 32 deletions(-)
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -237,34 +237,9 @@ static ssize_t host_control_on_shutdown_
return count;
}
-/**
- * dcdbas_smi_request: generate SMI request
- *
- * Called with smi_data_lock.
- */
-int dcdbas_smi_request(struct smi_cmd *smi_cmd)
+static void generate_smi(void *_smi_cmd)
{
- cpumask_var_t old_mask;
- int ret = 0;
-
- if (smi_cmd->magic != SMI_CMD_MAGIC) {
- dev_info(&dcdbas_pdev->dev, "%s: invalid magic value\n",
- __func__);
- return -EBADR;
- }
-
- /* SMI requires CPU 0 */
- if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
- return -ENOMEM;
-
- cpumask_copy(old_mask, ¤t->cpus_allowed);
- set_cpus_allowed_ptr(current, cpumask_of(0));
- if (smp_processor_id() != 0) {
- dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
- __func__);
- ret = -EBUSY;
- goto out;
- }
+ struct smi_cmd *smi_cmd = _smi_cmd;
/* generate SMI */
asm volatile (
@@ -276,14 +251,26 @@ int dcdbas_smi_request(struct smi_cmd *s
"c" (smi_cmd->ecx)
: "memory"
);
-
-out:
- set_cpus_allowed_ptr(current, old_mask);
- free_cpumask_var(old_mask);
- return ret;
}
/**
+ * dcdbas_smi_request: generate SMI request
+ *
+ * Called with smi_data_lock.
+ */
+int dcdbas_smi_request(struct smi_cmd *smi_cmd)
+{
+ if (smi_cmd->magic != SMI_CMD_MAGIC) {
+ dev_info(&dcdbas_pdev->dev, "%s: invalid magic value\n",
+ __func__);
+ return -EBADR;
+ }
+
+ /* SMI requires CPU 0 */
+ smp_call_function_single(0, generate_smi, smi_cmd, 1);
+ return 0;
+}
+/**
* smi_request_store:
*
* The valid values are:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-11 22:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-11 13:29 [PATCH 6/6] dcdbas: don't play with current's cpumask Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®