All of lore.kernel.org
 help / color / mirror / Atom feed
From: Changbin Du <changbin.du@gmail.com>
To: qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org, Changbin Du <changbin.du@gmail.com>
Subject: [PATCH] tcg: gdbstub: Fix missing breakpoint issue
Date: Fri, 24 Jan 2020 10:17:28 +0800	[thread overview]
Message-ID: <20200124021728.32518-1-changbin.du@gmail.com> (raw)

When inserting breakpoints, we need to invalidate related TBs to apply
helper call. This is done by breakpoint_invalidate(). But many users
found the BPs sometimes never hit.

In system mode emulation, the BPs are global in guest but not particular
address space. The issue is that the current implementation only trys to
invalidate TB of paddr corresponding to the target vaddr in current MMU
context. Then some cached TBs continue running without BPs applied.

To fix this issue, we can just invalidate all TBs as what step mode does.
(For old version users, issuing a step command can workaround this problem.)

Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
 exec.c | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/exec.c b/exec.c
index 67e520d18e..9d9fd48519 100644
--- a/exec.c
+++ b/exec.c
@@ -997,36 +997,9 @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
     tb_invalidate_phys_addr(pc);
 }
 #else
-void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
-{
-    ram_addr_t ram_addr;
-    MemoryRegion *mr;
-    hwaddr l = 1;
-
-    if (!tcg_enabled()) {
-        return;
-    }
-
-    RCU_READ_LOCK_GUARD();
-    mr = address_space_translate(as, addr, &addr, &l, false, attrs);
-    if (!(memory_region_is_ram(mr)
-          || memory_region_is_romd(mr))) {
-        return;
-    }
-    ram_addr = memory_region_get_ram_addr(mr) + addr;
-    tb_invalidate_phys_page_range(ram_addr, ram_addr + 1);
-}
-
 static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
 {
-    MemTxAttrs attrs;
-    hwaddr phys = cpu_get_phys_page_attrs_debug(cpu, pc, &attrs);
-    int asidx = cpu_asidx_from_attrs(cpu, attrs);
-    if (phys != -1) {
-        /* Locks grabbed by tb_invalidate_phys_addr */
-        tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as,
-                                phys | (pc & ~TARGET_PAGE_MASK), attrs);
-    }
+    tb_flush(cpu);
 }
 #endif
 
-- 
2.24.0



             reply	other threads:[~2020-01-24  2:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  2:17 Changbin Du [this message]
2020-02-03 12:58 ` [PATCH] tcg: gdbstub: Fix missing breakpoint issue Changbin Du
2020-02-05 11:03 ` Richard Henderson
2020-02-06  2:33   ` Changbin Du

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=20200124021728.32518-1-changbin.du@gmail.com \
    --to=changbin.du@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.