aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h.in6
-rwxr-xr-xconfigure37
-rw-r--r--pk/entry.S10
-rw-r--r--pk/pcr.h8
-rw-r--r--pk/pk.ac13
-rw-r--r--pk/pk.c7
-rw-r--r--pk/riscv-opc.h8
-rw-r--r--pk/riscv-pk.c7
8 files changed, 22 insertions, 74 deletions
diff --git a/config.h.in b/config.h.in
index 409162a..c05c064 100644
--- a/config.h.in
+++ b/config.h.in
@@ -24,12 +24,6 @@
/* Define if floating-point emulation is enabled */
#undef PK_ENABLE_FP_EMULATION
-/* Define if the kernel runs in 64-bit mode */
-#undef PK_ENABLE_KERNEL_64BIT
-
-/* Define if the user runs in 64-bit mode */
-#undef PK_ENABLE_USER_64BIT
-
/* Define if virtual memory support is enabled */
#undef PK_ENABLE_VM
diff --git a/configure b/configure
index e3446f2..520e099 100755
--- a/configure
+++ b/configure
@@ -636,8 +636,6 @@ enable_option_checking
enable_stow
enable_optional_subprojects
enable_vm
-enable_kernel_64bit
-enable_user_64bit
enable_fp_emulation
'
ac_precious_vars='build_alias
@@ -1272,8 +1270,6 @@ Optional Features:
--enable-optional-subprojects
Enable all optional subprojects
--disable-vm Disable virtual memory
- --disable-kernel-64bit Disable 64-bit kernel operation
- --disable-user-64bit Disable 64-bit user operation
--disable-fp-emulation Disable floating-point emulation
Some influential environment variables:
@@ -3990,39 +3986,6 @@ $as_echo "#define PK_ENABLE_VM /**/" >>confdefs.h
fi
-# Check whether --enable-kernel-64bit was given.
-if test "${enable_kernel_64bit+set}" = set; then :
- enableval=$enable_kernel_64bit;
-fi
-
-if test "x$enable_kernel_64bit" != "xno"; then :
-
-
-$as_echo "#define PK_ENABLE_KERNEL_64BIT /**/" >>confdefs.h
-
-
-else
-
- CFLAGS="$CFLAGS -mabi=32"
-
- LDFLAGS="$LDFLAGS -mabi=32"
-
-
-fi
-
-# Check whether --enable-user-64bit was given.
-if test "${enable_user_64bit+set}" = set; then :
- enableval=$enable_user_64bit;
-fi
-
-if test "x$enable_user_64bit" != "xno"; then :
-
-
-$as_echo "#define PK_ENABLE_USER_64BIT /**/" >>confdefs.h
-
-
-fi
-
# Check whether --enable-fp-emulation was given.
if test "${enable_fp_emulation+set}" = set; then :
enableval=$enable_fp_emulation;
diff --git a/pk/entry.S b/pk/entry.S
index d2fb72c..a5638dd 100644
--- a/pk/entry.S
+++ b/pk/entry.S
@@ -1,6 +1,6 @@
#include "pcr.h"
-#ifdef PK_ENABLE_KERNEL_64BIT
+#ifdef __riscv64
# define STORE sd
# define LOAD ld
# define REGBYTES 8
@@ -61,9 +61,11 @@ save_tf: # write the trap frame onto the stack
STORE $x3,35*REGBYTES($x2)
# get insn
- and $x4,$x4,~3
- lw $x3,0($x4)
- STORE $x3, 36*REGBYTES($x2)
+ and $x4,$x4,~1
+ lh $x3,0($x4)
+ lh $x4,2($x4)
+ sh $x3, 36*REGBYTES($x2)
+ sh $x4,2+36*REGBYTES($x2)
ret
.end save_tf
diff --git a/pk/pcr.h b/pk/pcr.h
index dd135ab..b95ff46 100644
--- a/pk/pcr.h
+++ b/pk/pcr.h
@@ -4,11 +4,13 @@
#include "config.h"
#define SR_ET 0x0000000000000001
+#define SR_EF 0x0000000000000002
#define SR_PS 0x0000000000000004
#define SR_S 0x0000000000000008
-#define SR_EF 0x0000000000000010
-#define SR_UX 0x0000000000000020
-#define SR_SX 0x0000000000000040
+#define SR_UX 0x0000000000000010
+#define SR_SX 0x0000000000000020
+#define SR_UC 0x0000000000000040
+#define SR_SC 0x0000000000000080
#define SR_IM 0x000000000000FF00
#define PCR_SR 0
diff --git a/pk/pk.ac b/pk/pk.ac
index c53c2c2..47c9207 100644
--- a/pk/pk.ac
+++ b/pk/pk.ac
@@ -3,19 +3,6 @@ AS_IF([test "x$enable_vm" != "xno"], [
AC_DEFINE([PK_ENABLE_VM],,[Define if virtual memory support is enabled])
])
-AC_ARG_ENABLE([kernel-64bit], AS_HELP_STRING([--disable-kernel-64bit], [Disable 64-bit kernel operation]))
-AS_IF([test "x$enable_kernel_64bit" != "xno"], [
- AC_DEFINE([PK_ENABLE_KERNEL_64BIT],,[Define if the kernel runs in 64-bit mode])
-],[
- AC_SUBST([CFLAGS],["$CFLAGS -mabi=32"])
- AC_SUBST([LDFLAGS],["$LDFLAGS -mabi=32"])
-])
-
-AC_ARG_ENABLE([user-64bit], AS_HELP_STRING([--disable-user-64bit], [Disable 64-bit user operation]))
-AS_IF([test "x$enable_user_64bit" != "xno"], [
- AC_DEFINE([PK_ENABLE_USER_64BIT],,[Define if the user runs in 64-bit mode])
-])
-
AC_ARG_ENABLE([fp-emulation], AS_HELP_STRING([--disable-fp-emulation], [Disable floating-point emulation]))
AS_IF([test "x$enable_fp_emulation" != "xno"], [
AC_DEFINE([PK_ENABLE_FP_EMULATION],,[Define if floating-point emulation is enabled])
diff --git a/pk/pk.c b/pk/pk.c
index 6b49b20..7ee573e 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -125,10 +125,11 @@ void dump_tf(trapframe_t* tf)
void init_tf(trapframe_t* tf, long pc, long sp, int user64)
{
memset(tf,0,sizeof(*tf));
- #ifndef PK_ENABLE_KERNEL_64BIT
+ if(sizeof(void*) != 8)
kassert(!user64);
- #endif
- tf->sr = mfpcr(PCR_SR) & ~(SR_PS | SR_ET) | (user64 ? SR_UX : 0);
+ tf->sr = (mfpcr(PCR_SR) & (SR_IM | SR_SX)) | SR_S | SR_UC | SR_UC;
+ if(user64)
+ tf->sr |= SR_UX;
tf->gpr[30] = sp;
tf->epc = pc;
}
diff --git a/pk/riscv-opc.h b/pk/riscv-opc.h
index 68fcd63..d5040b0 100644
--- a/pk/riscv-opc.h
+++ b/pk/riscv-opc.h
@@ -43,8 +43,6 @@
#define MASK_FENCE_G_V 0x3ff
#define MATCH_MFPCR 0x17b
#define MASK_MFPCR 0x7c1ffff
-#define MATCH_LHUSEG_V 0x228b
-#define MASK_LHUSEG_V 0x1ffff
#define MATCH_FMAX_D 0x190d3
#define MASK_FMAX_D 0x1ffff
#define MATCH_SBSEG_V 0x280b
@@ -357,6 +355,8 @@
#define MASK_SYSCALL 0xffffffff
#define MATCH_FSGNJ_S 0x5053
#define MASK_FSGNJ_S 0x1ffff
+#define MATCH_C_ADDI 0x0
+#define MASK_C_ADDI 0x1f
#define MATCH_SHSEGST_V 0x88f
#define MASK_SHSEGST_V 0xfff
#define MATCH_FLWSEGST_V 0x50f
@@ -387,8 +387,8 @@
#define MASK_FMOV_US 0x1ffff
#define MATCH_FCVT_LU_D 0x90d3
#define MASK_FCVT_LU_D 0x3ff1ff
-#define MATCH_UNIMP 0x0
-#define MASK_UNIMP 0xffffffff
+#define MATCH_LHUSEG_V 0x228b
+#define MASK_LHUSEG_V 0x1ffff
#define MATCH_FSUB_D 0x10d3
#define MASK_FSUB_D 0x1f1ff
#define MATCH_FMADD_S 0x43
diff --git a/pk/riscv-pk.c b/pk/riscv-pk.c
index df6e94b..5392100 100644
--- a/pk/riscv-pk.c
+++ b/pk/riscv-pk.c
@@ -4,7 +4,7 @@
void __attribute__((section(".boottext"))) __start()
{
extern char stack_top;
- asm("move $sp,%0" : : "r"(&stack_top-64));
+ asm volatile("move $sp,%0" : : "r"(&stack_top-64) : "memory");
extern char trap_entry;
register void* te = &trap_entry;
@@ -13,10 +13,9 @@ void __attribute__((section(".boottext"))) __start()
mtpcr(0,PCR_COUNT);
mtpcr(0,PCR_COMPARE);
- register long sr0 = SR_S | SR_PS | SR_ET | SR_IM;
- #ifdef PK_ENABLE_KERNEL_64BIT
+ register long sr0 = SR_S | SR_PS | SR_ET | SR_IM | SR_SC;
+ if(sizeof(void*) == 8)
sr0 |= SR_SX;
- #endif
mtpcr(sr0 | SR_EF, PCR_SR);
have_fp = mfpcr(PCR_SR) & SR_EF;