aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/amd64/vm_machdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/amd64/amd64/vm_machdep.c')
-rw-r--r--sys/amd64/amd64/vm_machdep.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index c9c498180c7e..c6b78824d730 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -37,14 +37,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "opt_isa.h"
#include "opt_cpu.h"
@@ -170,6 +166,8 @@ copy_thread(struct thread *td1, struct thread *td2)
cpu_max_ext_state_size);
}
+ td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1;
+
/*
* Set registers for trampoline to user mode. Leave space for the
* return address on stack. These are the kernel mode register values.
@@ -371,7 +369,7 @@ cpu_thread_clean(struct thread *td)
if (pcb->pcb_tssp != NULL) {
pmap_pti_remove_kva((vm_offset_t)pcb->pcb_tssp,
(vm_offset_t)pcb->pcb_tssp + ctob(IOPAGES + 1));
- kmem_free((vm_offset_t)pcb->pcb_tssp, ctob(IOPAGES + 1));
+ kmem_free(pcb->pcb_tssp, ctob(IOPAGES + 1));
pcb->pcb_tssp = NULL;
}
}
@@ -613,7 +611,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0)
* Set that machine state for performing an upcall that starts
* the entry function with the given argument.
*/
-void
+int
cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
@@ -639,13 +637,15 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
td->td_frame->tf_rip = (uintptr_t)entry;
/* Return address sentinel value to stop stack unwinding. */
- suword32((void *)td->td_frame->tf_rsp, 0);
+ if (suword32((void *)td->td_frame->tf_rsp, 0) != 0)
+ return (EFAULT);
/* Pass the argument to the entry point. */
- suword32((void *)(td->td_frame->tf_rsp + sizeof(int32_t)),
- (uint32_t)(uintptr_t)arg);
-
- return;
+ if (suword32(
+ (void *)(td->td_frame->tf_rsp + sizeof(int32_t)),
+ (uint32_t)(uintptr_t)arg) != 0)
+ return (EFAULT);
+ return (0);
}
#endif
@@ -665,10 +665,13 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
td->td_frame->tf_flags = TF_HASSEGS;
/* Return address sentinel value to stop stack unwinding. */
- suword((void *)td->td_frame->tf_rsp, 0);
+ if (suword((void *)td->td_frame->tf_rsp, 0) != 0)
+ return (EFAULT);
/* Pass the argument to the entry point. */
td->td_frame->tf_rdi = (register_t)arg;
+
+ return (0);
}
int