From: Avi Kivity <avi@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] SPARC64: immediate segfault on startup with git mastervery
Date: Sun, 18 Mar 2012 17:36:13 +0200 [thread overview]
Message-ID: <4F6600ED.5090800@redhat.com> (raw)
In-Reply-To: <4F65D020.5000400@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 523 bytes --]
On 03/18/2012 02:08 PM, Avi Kivity wrote:
> >
> > Screen is not updated correctly, there are lines from previous
> > screenful. Pressing ctrl-alt-1 refreshes the display. Perhaps dirty
> > tracking is broken? VGA in x86 works.
>
> Ok, I see it. Will investigate.
>
Turns out it's a latent bug in qemu exposed by the memory patches. I
already had a fix in my tree (though of course I had no memory of this
when debugging).
Please try the attached patch.
--
error compiling committee.c: too many arguments to function
[-- Attachment #2: 0001-exec-fix-write-tlb-entry-misused-as-iotlb.patch --]
[-- Type: text/x-patch, Size: 2073 bytes --]
>From bb363db2608dfc9b49b53994dc20d68169e66774 Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@redhat.com>
Date: Wed, 14 Mar 2012 16:19:39 +0200
Subject: [PATCH] exec: fix write tlb entry misused as iotlb
A couple of code paths check the lower bits of CPUTLBEntry::addr_write
against io_mem_ram as a way of looking for a dirty RAM page. This works
by accident since the value is zero, which matches all clear bits for
TLB_INVALID, TLB_MMIO, and TLB_NOTDIRTY (indicating dirty RAM).
Make it work by design by checking for the proper bits.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
exec.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/exec.c b/exec.c
index 8fd50a1..d8b089e 100644
--- a/exec.c
+++ b/exec.c
@@ -2031,14 +2031,19 @@ static void tlb_unprotect_code_phys(CPUArchState *env, ram_addr_t ram_addr,
cpu_physical_memory_set_dirty_flags(ram_addr, CODE_DIRTY_FLAG);
}
+static bool tlb_is_dirty_ram(CPUTLBEntry *tlbe)
+{
+ return (tlbe->addr_write & (TLB_INVALID_MASK|TLB_MMIO|TLB_NOTDIRTY)) == 0;
+}
+
static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry,
unsigned long start, unsigned long length)
{
unsigned long addr;
- if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == io_mem_ram.ram_addr) {
+ if (tlb_is_dirty_ram(tlb_entry)) {
addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + tlb_entry->addend;
if ((addr - start) < length) {
- tlb_entry->addr_write = (tlb_entry->addr_write & TARGET_PAGE_MASK) | TLB_NOTDIRTY;
+ tlb_entry->addr_write |= TLB_NOTDIRTY;
}
}
}
@@ -2091,7 +2096,7 @@ static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
ram_addr_t ram_addr;
void *p;
- if ((tlb_entry->addr_write & ~TARGET_PAGE_MASK) == io_mem_ram.ram_addr) {
+ if (tlb_is_dirty_ram(tlb_entry)) {
p = (void *)(unsigned long)((tlb_entry->addr_write & TARGET_PAGE_MASK)
+ tlb_entry->addend);
ram_addr = qemu_ram_addr_from_host_nofail(p);
--
1.7.9
next prev parent reply other threads:[~2012-03-18 15:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-18 2:01 [Qemu-devel] SPARC64: immediate segfault on startup with git mastervery Mark Cave-Ayland
2012-03-18 9:44 ` Avi Kivity
2012-03-18 9:51 ` Blue Swirl
2012-03-18 10:31 ` Avi Kivity
2012-03-18 10:51 ` Blue Swirl
2012-03-18 11:03 ` Mark Cave-Ayland
2012-03-18 11:28 ` Blue Swirl
2012-03-18 12:08 ` Avi Kivity
2012-03-18 12:10 ` Blue Swirl
2012-03-18 12:13 ` Avi Kivity
2012-03-18 12:15 ` Blue Swirl
2012-03-18 15:36 ` Avi Kivity [this message]
2012-03-18 9:57 ` Blue Swirl
2012-03-18 10:29 ` Mark Cave-Ayland
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=4F6600ED.5090800@redhat.com \
--to=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
/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).