From 8195bec788e6a5e9bef972872b858093a97a69b3 Mon Sep 17 00:00:00 2001 From: Dolu1990 Date: Thu, 23 Mar 2023 11:24:38 +0100 Subject: [PATCH] privSpec now check FPU dirty flag --- src/test/cpp/raw/privSpec/makefile | 2 + src/test/cpp/raw/privSpec/src/crt.S | 72 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/test/cpp/raw/privSpec/makefile b/src/test/cpp/raw/privSpec/makefile index 7ef3700..b3270f1 100644 --- a/src/test/cpp/raw/privSpec/makefile +++ b/src/test/cpp/raw/privSpec/makefile @@ -1,3 +1,5 @@ PROJ_NAME=privSpec +FLOATING=yes + include ../common/asm.mk \ No newline at end of file diff --git a/src/test/cpp/raw/privSpec/src/crt.S b/src/test/cpp/raw/privSpec/src/crt.S index 62a8801..f013ab2 100644 --- a/src/test/cpp/raw/privSpec/src/crt.S +++ b/src/test/cpp/raw/privSpec/src/crt.S @@ -188,7 +188,76 @@ test1: j fail machine_handle_trap + //Test FPU dirty + la x1, fail + csrw mtvec, x1 +#define checkFpuDirty() \ + csrr x1, mstatus ;\ + li x2, 0x80006000 ;\ + and x1, x1, x2 ;\ + bne x1, x2, fail + +#define checkFpuClean() \ + csrr x1, mstatus ;\ + li x2, 0x80006000 ;\ + and x1, x1, x2 ;\ + li x2, 0x00004000 ;\ + bne x1, x2, fail + +#define fpuClean() \ + li x1, 0x00004000 ;\ + csrw mstatus, x1 + + fpuClean() + checkFpuClean() + + la x1, fpuTwo + flw ft0, 0(x1) + checkFpuDirty(); fpuClean() + + checkFpuClean(); + la x1, fpuTwo + fsw ft0, 0(x1) + checkFpuClean(); + + fmv.x.w x1, ft0 + li x2, 0x40000000 + bne x1, x2, fail + checkFpuClean(); + + li x1, 0x80000000 + fmv.w.x ft0, x1 + checkFpuDirty();fpuClean(); + + //Check inprecise convertion + li x1, 0x3f000000 + fmv.w.x ft0, x1 + checkFpuDirty();fpuClean(); + fcvt.w.s x1, ft0 + checkFpuDirty();fpuClean(); + + //check precise convertion + li x1, 0x40000000 + fmv.w.x ft0, x1 + checkFpuDirty();fpuClean(); + fcvt.w.s x1, ft0 + checkFpuClean(); + + //check overflow convertion + li x1, 0x4f800000 + fmv.w.x ft0, x1 + checkFpuDirty();fpuClean(); + fcvt.w.s x1, ft0 + checkFpuDirty();fpuClean(); + + //Check CSR write making things dirty + csrw fcsr, x0 + checkFpuDirty();fpuClean(); + csrw frm, x0 + checkFpuDirty();fpuClean(); + csrw fflags, x0 + checkFpuDirty();fpuClean(); j pass @@ -206,3 +275,6 @@ pass: nop nop nop + +fpuTwo: +.word 0x40000000 \ No newline at end of file