qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: rth7680@gmail.com, agraf@suse.de, pavel.dovgaluk@ispras.ru,
	pbonzini@redhat.com, leon.alrae@imgtec.com, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH v5 07/11] target-i386: exception handling for memory helpers
Date: Mon, 06 Jul 2015 11:26:17 +0300	[thread overview]
Message-ID: <20150706082617.11980.96446.stgit@PASHA-ISP> (raw)
In-Reply-To: <20150706082535.11980.88013.stgit@PASHA-ISP>

This patch fixes exception handling for memory helpers.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 target-i386/mem_helper.c |   39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/target-i386/mem_helper.c b/target-i386/mem_helper.c
index 1aec8a5..95b1f53 100644
--- a/target-i386/mem_helper.c
+++ b/target-i386/mem_helper.c
@@ -41,13 +41,14 @@ void helper_cmpxchg8b(CPUX86State *env, target_ulong a0)
     int eflags;
 
     eflags = cpu_cc_compute_all(env, CC_OP);
-    d = cpu_ldq_data(env, a0);
+    d = cpu_ldq_data_ra(env, a0, GETPC());
     if (d == (((uint64_t)env->regs[R_EDX] << 32) | (uint32_t)env->regs[R_EAX])) {
-        cpu_stq_data(env, a0, ((uint64_t)env->regs[R_ECX] << 32) | (uint32_t)env->regs[R_EBX]);
+        cpu_stq_data_ra(env, a0, ((uint64_t)env->regs[R_ECX] << 32)
+                                  | (uint32_t)env->regs[R_EBX], GETPC());
         eflags |= CC_Z;
     } else {
         /* always do the store */
-        cpu_stq_data(env, a0, d);
+        cpu_stq_data_ra(env, a0, d, GETPC());
         env->regs[R_EDX] = (uint32_t)(d >> 32);
         env->regs[R_EAX] = (uint32_t)d;
         eflags &= ~CC_Z;
@@ -62,19 +63,19 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0)
     int eflags;
 
     if ((a0 & 0xf) != 0) {
-        raise_exception(env, EXCP0D_GPF);
+        raise_exception_ra(env, EXCP0D_GPF, GETPC());
     }
     eflags = cpu_cc_compute_all(env, CC_OP);
-    d0 = cpu_ldq_data(env, a0);
-    d1 = cpu_ldq_data(env, a0 + 8);
+    d0 = cpu_ldq_data_ra(env, a0, GETPC());
+    d1 = cpu_ldq_data_ra(env, a0 + 8, GETPC());
     if (d0 == env->regs[R_EAX] && d1 == env->regs[R_EDX]) {
-        cpu_stq_data(env, a0, env->regs[R_EBX]);
-        cpu_stq_data(env, a0 + 8, env->regs[R_ECX]);
+        cpu_stq_data_ra(env, a0, env->regs[R_EBX], GETPC());
+        cpu_stq_data_ra(env, a0 + 8, env->regs[R_ECX], GETPC());
         eflags |= CC_Z;
     } else {
         /* always do the store */
-        cpu_stq_data(env, a0, d0);
-        cpu_stq_data(env, a0 + 8, d1);
+        cpu_stq_data_ra(env, a0, d0, GETPC());
+        cpu_stq_data_ra(env, a0 + 8, d1, GETPC());
         env->regs[R_EDX] = d1;
         env->regs[R_EAX] = d0;
         eflags &= ~CC_Z;
@@ -87,11 +88,11 @@ void helper_boundw(CPUX86State *env, target_ulong a0, int v)
 {
     int low, high;
 
-    low = cpu_ldsw_data(env, a0);
-    high = cpu_ldsw_data(env, a0 + 2);
+    low = cpu_ldsw_data_ra(env, a0, GETPC());
+    high = cpu_ldsw_data_ra(env, a0 + 2, GETPC());
     v = (int16_t)v;
     if (v < low || v > high) {
-        raise_exception(env, EXCP05_BOUND);
+        raise_exception_ra(env, EXCP05_BOUND, GETPC());
     }
 }
 
@@ -99,10 +100,10 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)
 {
     int low, high;
 
-    low = cpu_ldl_data(env, a0);
-    high = cpu_ldl_data(env, a0 + 4);
+    low = cpu_ldl_data_ra(env, a0, GETPC());
+    high = cpu_ldl_data_ra(env, a0 + 4, GETPC());
     if (v < low || v > high) {
-        raise_exception(env, EXCP05_BOUND);
+        raise_exception_ra(env, EXCP05_BOUND, GETPC());
     }
 }
 
@@ -122,11 +123,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
         X86CPU *cpu = X86_CPU(cs);
         CPUX86State *env = &cpu->env;
 
-        if (retaddr) {
-            /* now we have a real cpu fault */
-            cpu_restore_state(cs, retaddr);
-        }
-        raise_exception_err(env, cs->exception_index, env->error_code);
+        raise_exception_err_ra(env, cs->exception_index, env->error_code, retaddr);
     }
 }
 #endif

  parent reply	other threads:[~2015-07-06  8:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06  8:25 [Qemu-devel] [PATCH v5 00/11] Fix exceptions handling for MIPS, PowerPC, and i386 Pavel Dovgalyuk
2015-07-06  8:25 ` [Qemu-devel] [PATCH v5 01/11] softmmu: add helper function to pass through retaddr Pavel Dovgalyuk
2015-07-06 10:22   ` Aurelien Jarno
2015-07-06  8:25 ` [Qemu-devel] [PATCH v5 02/11] cpu-exec: introduce loop exit with restore function Pavel Dovgalyuk
2015-07-06 10:22   ` Aurelien Jarno
2015-07-06  8:25 ` [Qemu-devel] [PATCH v5 03/11] target-mips: improve exceptions handling Pavel Dovgalyuk
2015-07-06 10:23   ` Aurelien Jarno
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 04/11] target-i386: introduce new raise_exception functions Pavel Dovgalyuk
2015-07-06 11:57   ` Richard Henderson
2015-07-06 12:12   ` Aurelien Jarno
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 05/11] target-i386: exception handling for FPU instructions Pavel Dovgalyuk
2015-07-06 12:04   ` Richard Henderson
2015-07-06 12:42     ` Pavel Dovgaluk
     [not found]     ` <559a77d3.4e58980a.7a073.ffff997eSMTPIN_ADDED_BROKEN@mx.google.com>
2015-07-06 15:11       ` Richard Henderson
2015-07-06 12:12   ` Aurelien Jarno
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 06/11] target-i386: exception handling for div instructions Pavel Dovgalyuk
2015-07-06 12:04   ` Richard Henderson
2015-07-06 12:14   ` Aurelien Jarno
2015-07-06  8:26 ` Pavel Dovgalyuk [this message]
2015-07-06 12:07   ` [Qemu-devel] [PATCH v5 07/11] target-i386: exception handling for memory helpers Richard Henderson
2015-07-06 12:19   ` Aurelien Jarno
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 08/11] target-i386: exception handling for seg_helper functions Pavel Dovgalyuk
2015-07-06 12:13   ` Richard Henderson
2015-07-06 12:15     ` Pavel Dovgaluk
2015-07-07 10:13     ` Pavel Dovgaluk
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 09/11] target-i386: exception handling for other helper functions Pavel Dovgalyuk
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 10/11] target-i386: remove useless PC updates Pavel Dovgalyuk
2015-07-06 12:21   ` Aurelien Jarno
2015-07-06  8:26 ` [Qemu-devel] [PATCH v5 11/11] target-ppc: exceptions handling in icount mode Pavel Dovgalyuk
2015-07-06 12:21   ` Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150706082617.11980.96446.stgit@PASHA-ISP \
    --to=pavel.dovgaluk@ispras.ru \
    --cc=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=leon.alrae@imgtec.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth7680@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).