[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/4] target/i386: Make translator stop before the end of a

From: Richard Henderson
Subject: Re: [PATCH v2 3/4] target/i386: Make translator stop before the end of a page
Date: Fri, 5 Aug 2022 13:19:43 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/5/22 09:09, Ilya Leoshkevich wrote:
@@ -4568,9 +4598,19 @@ static target_ulong disas_insn(DisasContext *s, CPUState 
      s->rip_offset = 0; /* for relative ip address */
      s->vex_l = 0;
      s->vex_v = 0;
-    if (sigsetjmp(s->jmpbuf, 0) != 0) {
+    disas_save(&snapshot, s);
+    switch (sigsetjmp(s->jmpbuf, 0)) {
+    case 0:
+        break;
+    case 1:
          return s->pc;
+    case 2:
+        disas_restore(&snapshot, s);
+        s->base.is_jmp = DISAS_TOO_MANY;
+        return pc_start;
+    default:

Similarly, this is too late for DISAS_TOO_MANY.

It will be more difficult to fix this for x86, since unlike s390x (or arm for that matter), we cannot probe for the total insn length within the first few bits of the insn.

The simplest possibility would to force single-stepping when we're within 16 bytes of the end of the page, as that's a hard maximum on the number of bytes within an x86 insn.

We could probably still use this sort of longjmp thing, but we'd need to unwind more than you're doing here. We'd need to discard the insn_start opcode (which is before the last_op that you're currently saving), and decrement s->base.num_insns.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]