aboutsummaryrefslogtreecommitdiff
path: root/sys/riscv/include
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2016-02-04 12:49:28 +0000
committerRuslan Bukin <br@FreeBSD.org>2016-02-04 12:49:28 +0000
commit4d50647d52b1c860b11b68933e11ed35f15e83d6 (patch)
tree9073a5444f815c7ecf68e5e2f15d95513f9cfc4c /sys/riscv/include
parent0b5afe4aea1428b80d8bf6c4aa82be3f2cb6b69a (diff)
downloadsrc-4d50647d52b1c860b11b68933e11ed35f15e83d6.tar.gz
src-4d50647d52b1c860b11b68933e11ed35f15e83d6.zip
Reuse gp register for pcpu pointer.
gp (global pointer) is used by compiler in userland only, so re-use it for pcpup in kernel, save it on stack on switching out to userland and load back on return to kernel. Discussed with: jhb, andrew, kib Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D5178
Notes
Notes: svn path=/head/; revision=295253
Diffstat (limited to 'sys/riscv/include')
-rw-r--r--sys/riscv/include/pcpu.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/riscv/include/pcpu.h b/sys/riscv/include/pcpu.h
index c60a95428fe1..7dfe23d991bf 100644
--- a/sys/riscv/include/pcpu.h
+++ b/sys/riscv/include/pcpu.h
@@ -47,8 +47,11 @@ extern struct pcpu *pcpup;
static inline struct pcpu *
get_pcpu(void)
{
+ struct pcpu *pcpu;
- return (pcpup);
+ __asm __volatile("mv %0, gp" : "=&r"(pcpu));
+
+ return (pcpu);
}
static inline struct thread *
@@ -56,7 +59,7 @@ get_curthread(void)
{
struct thread *td;
- td = (struct thread *)*(uint64_t *)pcpup;
+ __asm __volatile("ld %0, 0(gp)" : "=&r"(td));
return (td);
}