From 8ad2d952b645c43391da1e3521672a6a0ffe8c99 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 30 Dec 2017 10:20:34 +0000 Subject: [PATCH] Add copyin32 implementation. ok guenther@ --- sys/arch/arm64/arm64/copy.S | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/arch/arm64/arm64/copy.S b/sys/arch/arm64/arm64/copy.S index 0a493cc16e1..af9f015ec08 100644 --- a/sys/arch/arm64/arm64/copy.S +++ b/sys/arch/arm64/arm64/copy.S @@ -1,4 +1,4 @@ -/* $OpenBSD: copy.S,v 1.3 2017/02/15 21:39:50 patrick Exp $ */ +/* $OpenBSD: copy.S,v 1.4 2017/12/30 10:20:34 kettenis Exp $ */ /* * Copyright (c) 2015 Dale Rahn * Copyright (c) 2014 Patrick Wildt @@ -60,6 +60,28 @@ ENTRY(copyin) ldr x4, [x3, #(PCB_ONFAULT)] ret +/* + * x0 = user space address + * x1 = kernel space address + * + * Atomically copies a 32-bit word from user space to kernel space + * + * XXX should this assert that address spaces are correct for each address? + */ +ENTRY(copyin32) + mrs x3, tpidr_el1 // load cpuinfo + ldr x3, [x3, #(CI_CURPCB)] + ldr x4, [x3, #(PCB_ONFAULT)] + adr x5, .Lcopyfault + str x5, [x3, #(PCB_ONFAULT)] // set handler + + ldtr w6, [x0] + str w6, [x1] + + str x4, [x3, #(PCB_ONFAULT)] // clear handler + mov x0, xzr + ret + /* * x0 = kernel space address * x1 = user space address -- 2.20.1