From: Segher Boessenkool Date: Mon, 20 Jul 2020 20:10:41 +0000 Subject: Re: [RFC PATCH] powerpc/pseries/svm: capture instruction faulting on MMIO access, in sprg0 register Message-Id: <20200720201041.GM30544@gate.crashing.org> List-Id: References: <1594888333-9370-1-git-send-email-linuxram@us.ibm.com> <18e3bcee-8a3a-bd13-c995-8e4168471f74@linux.ibm.com> In-Reply-To: <18e3bcee-8a3a-bd13-c995-8e4168471f74@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Laurent Dufour Cc: aik@ozlabs.ru, Ram Pai , kvm-ppc@vger.kernel.org, bharata@linux.ibm.com, sathnaga@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com, david@gibson.dropbear.id.au On Mon, Jul 20, 2020 at 11:39:56AM +0200, Laurent Dufour wrote: > Le 16/07/2020 =E0 10:32, Ram Pai a =E9crit=A0: > >+ if (is_secure_guest()) { \ > >+ __asm__ __volatile__("mfsprg0 %3;" \ > >+ "lnia %2;" \ > >+ "ld %2,12(%2);" \ > >+ "mtsprg0 %2;" \ > >+ "sync;" \ > >+ #insn" %0,%y1;" \ > >+ "twi 0,%0,0;" \ > >+ "isync;" \ > >+ "mtsprg0 %3" \ > >+ : "=3Dr" (ret) \ > >+ : "Z" (*addr), "r" (0), "r" (0) \ >=20 > I'm wondering if SPRG0 is restored to its original value. > You're using the same register (r0) for parameters 2 and 3, so when doing= =20 > lnia %2, you're overwriting the SPRG0 value you saved in r0 just earlier. It is putting the value 0 in the registers the compiler chooses for operands 2 and 3. But operand 3 is written, while the asm says it is an input. It needs an earlyclobber as well. > It may be clearer to use explicit registers for %2 and %3 and to mark the= m=20 > as modified for the compiler. That is not a good idea, imnsho. Segher