From: Laurent Dufour <ldufour@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: aik@ozlabs.ru, Ram Pai <linuxram@us.ibm.com>,
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
Subject: Re: [RFC PATCH] powerpc/pseries/svm: capture instruction faulting on MMIO access, in sprg0 register
Date: Tue, 21 Jul 2020 09:22:55 +0200 [thread overview]
Message-ID: <5d912506-5834-db1a-60a1-1ccb213ff37a@linux.ibm.com> (raw)
In-Reply-To: <20200720202452.GN30544@gate.crashing.org>
Le 20/07/2020 à 22:24, Segher Boessenkool a écrit :
> On Mon, Jul 20, 2020 at 03:10:41PM -0500, Segher Boessenkool wrote:
>> On Mon, Jul 20, 2020 at 11:39:56AM +0200, Laurent Dufour wrote:
>>> Le 16/07/2020 à 10:32, Ram Pai a écrit :
>>>> + 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" \
>>>> + : "=r" (ret) \
>>>> + : "Z" (*addr), "r" (0), "r" (0) \
>>>
>>> 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
>>> 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.
Oh nice, I was not aware that compiler may choose registers this way.
Good to know, thanks for the explanation.
>>> It may be clearer to use explicit registers for %2 and %3 and to mark them
>>> as modified for the compiler.
>>
>> That is not a good idea, imnsho.
>
> (The explicit register number part, I mean; operand 2 should be an
> output as well, yes.)
Sure if the compiler can choose the registers that's far better.
Cheers,
Laurent.
next prev parent reply other threads:[~2020-07-21 7:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 8:32 [RFC PATCH] powerpc/pseries/svm: capture instruction faulting on MMIO access, in sprg0 register Ram Pai
2020-07-20 9:39 ` Laurent Dufour
2020-07-20 20:10 ` Segher Boessenkool
2020-07-20 20:24 ` Segher Boessenkool
2020-07-21 7:22 ` Laurent Dufour [this message]
2020-07-21 15:00 ` Nicholas Piggin
2020-07-22 2:06 ` Michael Ellerman
2020-07-22 2:23 ` Benjamin Herrenschmidt
2020-07-22 7:49 ` Ram Pai
2020-07-22 12:45 ` Michael Ellerman
2020-07-24 11:49 ` Michael Ellerman
2020-07-22 5:02 ` Paul Mackerras
2020-07-22 7:42 ` Ram Pai
2020-07-22 7:45 ` Ram Pai
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=5d912506-5834-db1a-60a1-1ccb213ff37a@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=aik@ozlabs.ru \
--cc=bauerman@linux.ibm.com \
--cc=bharata@linux.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=linuxram@us.ibm.com \
--cc=sathnaga@linux.vnet.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=sukadev@linux.vnet.ibm.com \
/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).