hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/arm/kernel/unwind.c
....@@ -300,6 +300,29 @@
300300 return URC_OK;
301301 }
302302
303
+static unsigned long unwind_decode_uleb128(struct unwind_ctrl_block *ctrl)
304
+{
305
+ unsigned long bytes = 0;
306
+ unsigned long insn;
307
+ unsigned long result = 0;
308
+
309
+ /*
310
+ * unwind_get_byte() will advance `ctrl` one instruction at a time, so
311
+ * loop until we get an instruction byte where bit 7 is not set.
312
+ *
313
+ * Note: This decodes a maximum of 4 bytes to output 28 bits data where
314
+ * max is 0xfffffff: that will cover a vsp increment of 1073742336, hence
315
+ * it is sufficient for unwinding the stack.
316
+ */
317
+ do {
318
+ insn = unwind_get_byte(ctrl);
319
+ result |= (insn & 0x7f) << (bytes * 7);
320
+ bytes++;
321
+ } while (!!(insn & 0x80) && (bytes != sizeof(result)));
322
+
323
+ return result;
324
+}
325
+
303326 /*
304327 * Execute the current unwind instruction.
305328 */
....@@ -353,7 +376,7 @@
353376 if (ret)
354377 goto error;
355378 } else if (insn == 0xb2) {
356
- unsigned long uleb128 = unwind_get_byte(ctrl);
379
+ unsigned long uleb128 = unwind_decode_uleb128(ctrl);
357380
358381 ctrl->vrs[SP] += 0x204 + (uleb128 << 2);
359382 } else {