From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TB42J-0004L4-Pf for qemu-devel@nongnu.org; Mon, 10 Sep 2012 09:29:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TB41n-0005gA-N5 for qemu-devel@nongnu.org; Mon, 10 Sep 2012 09:28:23 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38124 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TB41n-0005fT-EE for qemu-devel@nongnu.org; Mon, 10 Sep 2012 09:27:51 -0400 Message-ID: <504DEAD1.3060908@suse.de> Date: Mon, 10 Sep 2012 15:27:45 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1347244257-15586-1-git-send-email-david@gibson.dropbear.id.au> <1347244257-15586-3-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1347244257-15586-3-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] cpu_physical_memory_write_rom() needs to do TB invalidates List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Am 10.09.2012 04:30, schrieb David Gibson: > cpu_physical_memory_write_rom(), despite the name, can also be used to > write images into RAM - and will often be used that way if the machine > uses load_image_targphys() into RAM addresses. >=20 > However, cpu_physical_memory_write_rom(), unlike cpu_physical_memory_rw= () > does invalidate any cached TBs which might be affected by the region "doesn't"? Otherwise doesn't look wrong. Andreas > written. >=20 > This was breaking reset (under full emu) on the pseries machine - we lo= aded > our firmware image into RAM, and while executing it rewrite the code at > the entry point (correctly causing a TB invalidate/refresh). When we > reset the firmware image was reloaded, but the TB from the rewrite was > still active and caused us to get an illegal instruction trap. >=20 > This patch fixes the bug by duplicating the tb invalidate code from > cpu_physical_memory_rw() in cpu_physical_memory_write_rom(). >=20 > Signed-off-by: David Gibson > --- > exec.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/exec.c b/exec.c > index 5834766..eff40d7 100644 > --- a/exec.c > +++ b/exec.c > @@ -3523,6 +3523,13 @@ void cpu_physical_memory_write_rom(target_phys_a= ddr_t addr, > /* ROM/RAM case */ > ptr =3D 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)); > + } > qemu_put_ram_ptr(ptr); > } > len -=3D l; >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg