summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2011-07-15 12:03:19 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2011-07-18 12:04:40 -0500
commitbe301c4ea87c944bd1c51ca2c73ac719cec6b495 (patch)
tree529436aa13474e54badc7cd6690ae28f7eeda766 /src
parent62faccd737f97dd4c485770f59bacf1b44dcbc3b (diff)
downloadtalos-hostboot-be301c4ea87c944bd1c51ca2c73ac719cec6b495.tar.gz
talos-hostboot-be301c4ea87c944bd1c51ca2c73ac719cec6b495.zip
Add user-space stub for task entry.
This will prevent kernel space from needing to dereference user-space addresses for starting a task, which is safer and is easier for VMM. Change-Id: Icad3b832550cedbf291ed8b032840f4049fba18e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/202 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: MATTHEW S. BARTH <msbarth@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/kernel/start.S23
-rw-r--r--src/kernel/taskmgr.C13
2 files changed, 30 insertions, 6 deletions
diff --git a/src/kernel/start.S b/src/kernel/start.S
index ac57926b4..381e33bde 100644
--- a/src/kernel/start.S
+++ b/src/kernel/start.S
@@ -360,6 +360,29 @@ system_call_fast_path:
1:
rfid ;// Return from interrupt.
+
+ ;// @fn userspace_task_entry
+ ;// Stub to load the function address and TOC base from userspace and
+ ;// jump to task entry point. Used so the kernel doesn't need to
+ ;// dereference userspace addresses (which could be bad).
+ ;//
+ ;// Requires:
+ ;// * GPR4 -> Function pointer.
+ ;// * LR -> task_end stub.
+ ;// * GPR3 -> Task argument.
+ ;// * GPR1 -> Task stack pointer.
+ ;// Results:
+ ;// * TOC base -> GPR2
+ ;// * Function Address -> CTR
+ ;// * GPR1, GPR3 preserved.
+ ;// * Branch to CTR (no link).
+.global userspace_task_entry
+userspace_task_entry:
+ ld r5, 0(r4)
+ mtctr r5
+ ld r2, 8(r4)
+ bctr
+
.section .data
.balign 1024
kernel_stack:
diff --git a/src/kernel/taskmgr.C b/src/kernel/taskmgr.C
index 0573bab7d..8073c0b48 100644
--- a/src/kernel/taskmgr.C
+++ b/src/kernel/taskmgr.C
@@ -8,6 +8,8 @@
#include <string.h>
#include <limits.h>
+extern "C" void userspace_task_entry();
+
void TaskManager::idleTaskLoop(void* unused)
{
while(1)
@@ -55,12 +57,11 @@ task_t* TaskManager::_createTask(TaskManager::task_fn_t t,
memset(task, '\0', sizeof(task_t));
task->tid = this->getNextTid();
-
- // Function pointer 't' is actually a TOC entry.
- // TOC[0] = function address
- // TOC[1] = TOC base -> r2
- task->context.nip = (void*) ((uint64_t*) t)[0];
- task->context.gprs[2] = ((uint64_t*)t)[1];
+
+ // Set NIP to be userspace_task_entry stub and GPR3 to be the
+ // function pointer for the desired task entry point.
+ task->context.nip = reinterpret_cast<void*>(&userspace_task_entry);
+ task->context.gprs[4] = reinterpret_cast<uint64_t>(t);
// Set up LR to be the entry point for task_end in case a task
// 'returns' from its entry point. By the Power ABI, the entry
OpenPOWER on IntegriCloud