about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorxctan <xctan@cirno.icu>2025-01-24 15:10:45 +0800
committerGitHub <noreply@github.com>2025-01-24 08:10:45 +0100
commit8c1ffca530fb471984cd91347d93457575c7ee5d (patch)
tree66508b2cf993b209f5f54a2e146ba66257528e42 /src/libtools
parent7099774a3c82642ad64bc3a4f1b798e951904f7d (diff)
downloadbox64-8c1ffca530fb471984cd91347d93457575c7ee5d.tar.gz
box64-8c1ffca530fb471984cd91347d93457575c7ee5d.zip
[RV64_DYNAREC] Added codegen for unaligned stores (#2289)
* [RV64_DYNAREC] Added another special SIGBUS case

* [RV64_DYNAREC] Added codegen for unaligned stores
Diffstat (limited to 'src/libtools')
-rw-r--r--src/libtools/signals.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libtools/signals.c b/src/libtools/signals.c
index 85a66590..10dbdb74 100644
--- a/src/libtools/signals.c
+++ b/src/libtools/signals.c
@@ -1000,14 +1000,14 @@ int sigbus_specialcases(siginfo_t* info, void * ucntx, void* pc, void* _fpsimd,
 
     uint32_t funct3 = GET_FIELD(inst, 14, 12);
     uint32_t opcode = GET_FIELD(inst, 6, 0);
-    if ((opcode == 0b0100011 || opcode == 0b0100111 /* F */) && (funct3 == 0b010 /* (F)SW */ || funct3 == 0b011 /* (F)SD */)) {
+    if ((opcode == 0b0100011 || opcode == 0b0100111 /* F */) && (funct3 == 0b010 /* (F)SW */ || funct3 == 0b011 /* (F)SD */ || funct3 == 0b001 /* SH */)) {
         int val = (inst >> 20) & 0x1f;
         int dest = (inst >> 15) & 0x1f;
         int64_t imm = (GET_FIELD(inst, 31, 25) << 5) | (GET_FIELD(inst, 11, 7));
         imm = SIGN_EXT(imm, 12);
         volatile uint8_t *addr = (void *)(p->uc_mcontext.__gregs[dest] + imm);
         uint64_t value = opcode == 0b0100011 ? p->uc_mcontext.__gregs[val] : p->uc_mcontext.__fpregs.__d.__f[val<<1];
-        for(int i = 0; i < (funct3 == 0b010 ? 4 : 8); ++i) {
+        for(int i = 0; i < (funct3 == 0b010 ? 4 : funct3 == 0b011 ? 8 : 2); ++i) {
             addr[i] = (value >> (i * 8)) & 0xff;
         }
         p->uc_mcontext.__gregs[0] += 4; // pc += 4