From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avhpU-00063B-T7 for qemu-devel@nongnu.org; Thu, 28 Apr 2016 05:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avhpQ-0001q0-4n for qemu-devel@nongnu.org; Thu, 28 Apr 2016 05:01:48 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:44093 helo=imgpgp01.kl.imgtec.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avhpP-0001pt-S8 for qemu-devel@nongnu.org; Thu, 28 Apr 2016 05:01:44 -0400 Date: Thu, 28 Apr 2016 10:01:42 +0100 From: James Hogan Message-ID: <20160428090142.GE19902@jhogan-linux.le.imgtec.org> References: <1461795666-4704-1-git-send-email-james.hogan@imgtec.com> <5721CF70.2010801@imgtec.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="h56sxpGKRmy85csR" Content-Disposition: inline In-Reply-To: <5721CF70.2010801@imgtec.com> Subject: Re: [Qemu-devel] [PATCH] target-mips: Fix RDHWR exception host PC List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leon Alrae Cc: qemu-devel@nongnu.org, Yongbok Kim , Aurelien Jarno , Peter Maydell --h56sxpGKRmy85csR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 28, 2016 at 09:53:04AM +0100, Leon Alrae wrote: > On 27/04/16 23:21, James Hogan wrote: > > Commit b00c72180c36 ("target-mips: add PC, XNP reg numbers to RDHWR") > > changed the rdhwr helpers to use check_hwrena() to check the register > > being accessed is enabled in CP0_HWREna when used from user mode. If > > that check fails an EXCP_RI exception is raised at the host PC > > calculated with GETPC(). > >=20 > > However check_hwrena() may not be fully inlined as the > > do_raise_exception() part of it is common regardless of the arguments. > > This causes GETPC() to calculate the address in the call in the helper > > instead of the generated code calling the helper. No TB will be found > > and the EPC reported with the resulting guest RI exception points to the > > beginning of the TB instead of the RDHWR instruction. > >=20 > > We can't reliably force check_hwrena() to be inlined, and converting it > > to a macro would be ugly, so instead pass the host PC in as an argument, > > with each rdhwr helper passing GETPC(). This should avoid any dependence > > on compiler behaviour, and in practice seems to prevent the partial > > inlining of check_hwrena() on x86_64. Note also this sentence isn't actually very clear. preventing partial inlining sounds like it stops inlining altogether, whereas actually I meant that it seems to ensure full inlining of check_hwrena(). Perhaps you could change it to ", and in practice seems to ensure the full inlining of check_hwrena() on x86_64." when you apply it. > >=20 > > This issue causes failures when running a MIPS KVM (trap & emulate) > > guest in a MIPS QEMU TCG guest, as the inner guest kernel will do a > > RDHWR of counter, which is disabled in the outer guest's CP0_HWREna by > > KVM so it can emulate the inner guest's counter. The emulation fails and > > the RI exception is passed to the inner guest. > >=20 > > Fixes: b00c72180c36 ("target-mips: add PC, XNP reg numbers to RDHWR") > > Signed-off-by: James Hogan > > Cc: Leon Alrae > > Cc: Yongbok Kim > > Cc: Aurelien Jarno > > --- > > target-mips/op_helper.c | 16 ++++++++-------- > > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > Whoops, thanks for the fix. I'll send the pullreq soon, hopefully it's > not too late for 2.6. Thanks James --h56sxpGKRmy85csR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXIdF2AAoJEGwLaZPeOHZ6Q1MQAIy+Xg0FEWhrBAivAOoLxDIw ht26qRiUJni4vCbRjxkR+QDDNrO0ddReY6BKxUoP6/wSD1u1M+eh2Ud3/ECMP3wi 8y4SwCP6MbGsG3Yx9THpVmR+ulP2TMFLx3UzIm1kYqzek6yvYdKPd/azWpwtZhsB V0VyCdf9lLRYg7txLdn4bpoTMavVWuo1KGZtGe0QsJUphtppJBdj/+aYab/pwRU8 IwdXMsWJFiGoWCZ7Nfl2zXg0Bm9iob9lTdLZM9KjP+Am7fGdyJka3l13O9q7NltA zZl52PWI64drj8PAUmPwJLOA3Ka6l17RFDk5nxNdsTwa+hEg1Q2f5VayIjorBtZq OYyHXt5f+RpUQWXD+uCxa4hs+pxWV3wr1zSziH9zrUNdg0O/Jg0zF6CvOFkegkNX 3/gztl1hxqRA/I2QlfN6FpmoaeZ1BBmOfu4jHojx+7CliSIwmsYXo/ggzcjey4Mj 8zFPfampXMy5ylhtXNP/3wfZZYv+oQ9V+UUkOjuWg+ByjGPATcR+ribm+aFs1/rb CE6WX+BIc+M8o6RDGOwMD//pD3RLPs7xoZZTBrGLDKYefP8KyAOP8Qsz8D5FoYxt qNWz0SCmn0OXhqbY5H7xOWWa+GhdSA64DwP2ZtrL11EmELD9CvPOeJzUi9P3/ss9 HeeJSL3oUkJ7QENiVuA2 =fKMh -----END PGP SIGNATURE----- --h56sxpGKRmy85csR--