From: Ben Hutchings Subject: Re: [BACKPORT 3.14.y] MIPS: KVM: Fix modular KVM under QEMU Date: Sun, 08 Oct 2017 22:14:30 +0100 Message-ID: <1507497270.2677.96.camel@decadent.org.uk> References: <146827994122156@kroah.com> <1468430059-7958-1-git-send-email-james.hogan@imgtec.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-FEUdib+0n55yFZjHWhea" Cc: gregkh@linuxfoundation.org, rkrcmar@redhat.com, Paolo Bonzini , Ralf Baechle , kvm@vger.kernel.org, linux-mips@linux-mips.org To: James Hogan , stable@vger.kernel.org Return-path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:60787 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753347AbdJHVOy (ORCPT ); Sun, 8 Oct 2017 17:14:54 -0400 In-Reply-To: <1468430059-7958-1-git-send-email-james.hogan@imgtec.com> Sender: kvm-owner@vger.kernel.org List-ID: --=-FEUdib+0n55yFZjHWhea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2016-07-13 at 18:14 +0100, James Hogan wrote: > commit 797179bc4fe06c89e47a9f36f886f68640b423f8 upstream. >=20 > Copy __kvm_mips_vcpu_run() into unmapped memory, so that we can never > get a TLB refill exception in it when KVM is built as a module. >=20 > This was observed to happen with the host MIPS kernel running under > QEMU, due to a not entirely transparent optimisation in the QEMU TLB > handling where TLB entries replaced with TLBWR are copied to a separate > part of the TLB array. Code in those pages continue to be executable, > but those mappings persist only until the next ASID switch, even if they > are marked global. >=20 > An ASID switch happens in __kvm_mips_vcpu_run() at exception level after > switching to the guest exception base. Subsequent TLB mapped kernel > instructions just prior to switching to the guest trigger a TLB refill > exception, which enters the guest exception handlers without updating > EPC. This appears as a guest triggered TLB refill on a host kernel > mapped (host KSeg2) address, which is not handled correctly as user > (guest) mode accesses to kernel (host) segments always generate address > error exceptions. >=20 > Signed-off-by: James Hogan > Cc: Paolo Bonzini > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > Cc: Ralf Baechle > Cc: kvm@vger.kernel.org > Cc: linux-mips@linux-mips.org > Signed-off-by: Paolo Bonzini > [james.hogan@imgtec.com: backported for stable 3.14] > Signed-off-by: James Hogan [...] Belatedly queued this up for 3.16. Ben. --=20 Ben Hutchings compatible: Gracefully accepts erroneous data from any source --=-FEUdib+0n55yFZjHWhea Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEErCspvTSmr92z9o8157/I7JWGEQkFAlnalTcACgkQ57/I7JWG EQlhhRAAvvil9mnPeUcjes3gr8Chd7HqM2xmsMAvv0dAkKWw6Cw16AZaZz1kvGr8 UcSr/pJpKhS3Tz613sMst0cCc/+t5OGMqBqxPMrR0HR7oY9JA9XhVMw0YSxnA0l3 lkDU6kzV9p7s5e+jeVdOPqGE41NRDYtn5Qy0p0M68LqCM+FMoj36F84OujnyCzjk YICc81uYpe0irCUa2lep/umLGug0o1IksBnTKGaSBEkWyjms5g2gHwcopaUTBPVM YUVc/zOkwNt3jW5zjF6w17/+qa3G95cF7hG1HLnUmrOABL4+u1RUMmb2jkne8mji 0/dc5Z3buXwNEsY7capt4BsZsr1AlAZjo8FR17jOv0IzuVI+HKxRVxLW68lbN7vl j1QYXHyKNdREy6CNhJCGtqfuexhON9xPNC9XUilnw3G4G0YsN5Tbl7VM78fLXHUO +dkKa+oQ4qtBc3O0pNlVQxdbUXfivafTzfa6KN5TL/Io/80Q/Zv/bwrMQUGTK54z ET9nzaMt3DRkUIKpytg6Q2GxekamM6mXb91ypJ3AzA63bcZSrL3DKDzx6BtbBXiO OTrVreYi30m74hX781kDIiMcqNc5HhEoO1wGr3sxe0LYoqdLJ1UQv57qHwVeWQ0X 1c2SRqZWEdL5ibidexbwzgCOSLTE36TZwZ3I3jgeqJgub+V4f0E= =s1V6 -----END PGP SIGNATURE----- --=-FEUdib+0n55yFZjHWhea--