From: Alex Bligh <alex@alex.org.uk>
To: xen-devel <xen-devel@lists.xen.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>, Alex Bligh <alex@alex.org.uk>
Subject: [PATCH 3/5] exec: Introduce helper to set dirty flags.
Date: Fri, 21 Dec 2012 19:37:29 +0000 [thread overview]
Message-ID: <1356118651-4882-4-git-send-email-alex@alex.org.uk> (raw)
In-Reply-To: <1356118651-4882-1-git-send-email-alex@alex.org.uk>
This new helper/hook is used in the next patch to add an extra call in a single
place.
Backport of 51d7a9eb2b64e787c90bea1027308087eac22065
Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
exec.c | 45 +++++++++++++++++----------------------------
1 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/exec.c b/exec.c
index 6c206ff..511777b 100644
--- a/exec.c
+++ b/exec.c
@@ -3951,6 +3951,18 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
}
#else
+
+static void invalidate_and_set_dirty(target_phys_addr_t addr,
+ target_phys_addr_t length)
+{
+ if (!cpu_physical_memory_is_dirty(addr)) {
+ /* invalidate code */
+ tb_invalidate_phys_page_range(addr, addr + length, 0);
+ /* set dirty bit */
+ cpu_physical_memory_set_dirty_flags(addr, (0xff & ~CODE_DIRTY_FLAG));
+ }
+}
+
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
int len, int is_write)
{
@@ -4003,13 +4015,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
- if (!cpu_physical_memory_is_dirty(addr1)) {
- /* invalidate code */
- tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
- /* set dirty bit */
- cpu_physical_memory_set_dirty_flags(
- addr1, (0xff & ~CODE_DIRTY_FLAG));
- }
+ invalidate_and_set_dirty(addr1, l);
qemu_put_ram_ptr(ptr);
}
} else {
@@ -4081,6 +4087,7 @@ void cpu_physical_memory_write_rom(target_phys_addr_t addr,
/* ROM/RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
+ invalidate_and_set_dirty(addr1, l);
qemu_put_ram_ptr(ptr);
}
len -= l;
@@ -4211,13 +4218,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
l = TARGET_PAGE_SIZE;
if (l > access_len)
l = access_len;
- if (!cpu_physical_memory_is_dirty(addr1)) {
- /* invalidate code */
- tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
- /* set dirty bit */
- cpu_physical_memory_set_dirty_flags(
- addr1, (0xff & ~CODE_DIRTY_FLAG));
- }
+ invalidate_and_set_dirty(addr1, l);
addr1 += l;
access_len -= l;
}
@@ -4561,13 +4562,7 @@ static inline void stl_phys_internal(target_phys_addr_t addr, uint32_t val,
stl_p(ptr, val);
break;
}
- if (!cpu_physical_memory_is_dirty(addr1)) {
- /* invalidate code */
- tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
- /* set dirty bit */
- cpu_physical_memory_set_dirty_flags(addr1,
- (0xff & ~CODE_DIRTY_FLAG));
- }
+ invalidate_and_set_dirty(addr1, 4);
}
}
@@ -4639,13 +4634,7 @@ static inline void stw_phys_internal(target_phys_addr_t addr, uint32_t val,
stw_p(ptr, val);
break;
}
- if (!cpu_physical_memory_is_dirty(addr1)) {
- /* invalidate code */
- tb_invalidate_phys_page_range(addr1, addr1 + 2, 0);
- /* set dirty bit */
- cpu_physical_memory_set_dirty_flags(addr1,
- (0xff & ~CODE_DIRTY_FLAG));
- }
+ invalidate_and_set_dirty(addr1, 2);
}
}
--
1.7.4.1
next prev parent reply other threads:[~2012-12-21 19:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 19:37 [RFC] QEMU: Enabling live-migrate on HVM on qemu-xen device model in 4.2 Alex Bligh
2012-12-21 19:37 ` [PATCH 1/5] QMP, Introduce xen-set-global-dirty-log command Alex Bligh
2012-12-21 19:37 ` [PATCH 2/5] xen: Introduce xen_modified_memory Alex Bligh
2012-12-21 19:37 ` Alex Bligh [this message]
2012-12-21 19:37 ` [PATCH 4/5] exec, memory: Call to xen_modified_memory Alex Bligh
2012-12-21 19:37 ` [PATCH 5/5] xen: Set the vram dirty when an error occur Alex Bligh
2013-01-07 12:28 ` [RFC] QEMU: Enabling live-migrate on HVM on qemu-xen device model in 4.2 Alex Bligh
-- strict thread matches above, loose matches on Subject: below --
2013-01-19 17:56 Alex Bligh
2013-01-19 17:56 ` [PATCH 3/5] exec: Introduce helper to set dirty flags Alex Bligh
2013-02-13 18:33 QEMU: Enabling live-migrate on HVM on qemu-xen device model in 4.2 Alex Bligh
2013-02-13 18:33 ` [PATCH 3/5] exec: Introduce helper to set dirty flags Alex Bligh
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=1356118651-4882-4-git-send-email-alex@alex.org.uk \
--to=alex@alex.org.uk \
--cc=Ian.Campbell@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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).