From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC v1] arm64: Handle traps from accessing CNTVCT/CNTFRQ for CONFIG_COMPAT
Date: Wed, 17 Jan 2018 09:03:48 +0000 [thread overview]
Message-ID: <83b9c187-7fbf-3e05-6321-de7fa05fd868@arm.com> (raw)
In-Reply-To: <20180117021346.GA26166@Asurada-Nvidia>
On 17/01/18 02:13, Nicolin Chen wrote:
> On Tue, Jan 16, 2018 at 01:37:46PM -0800, Nicolin Chen wrote:
>> On Tue, Jan 16, 2018 at 09:19:13PM +0000, Marc Zyngier wrote:
>>
>>>> I understand that it should take care of the condition field as
>>>> a general instruction handler. Just for curiosity: If we confine
>>>> the topic to read access of CNTVCT/CNTFRQ, what'd be the penalty
>>>> by ignoring the condition field and executing it anyway?
>>>
>>> Do you mean, apart from severely corrupting userspace execution?
>>> That's a rhetorical question, right?
>>
>> I don't quite understand the corrupting userspace execution part.
>> What I see for a conditional CNTVCT read is more likely:
>> if (condition) { // in this case, if (true)
>> r1 = lower32(cntvct);
>> r2 = higher32(cntvct);
>> }
>>
>> Could you please elaborate a bit? Thank you.
>
> I guess I got it now. The concern seems to be Thumb instructions.
Not only.
> So ignoring a condition for a Thumb instruction may cause its IT
> scope shifting. For ARM mode, the only penalty could be two Rts
> getting written -- which shouldn't corrupt userspace execution.
>
> Please correct me if I am wrong or not thorough.
Consider the following:
mov r0, #0
mov r1, #0
cmp r1, #3
mrrceq r0, r1, cntvct // simplified version
Oh look, you've corrupted r0 and r1, which should never have be changed.
Whatever uses the content r0 and r1 after the mrrc will misbehave. How
is that an acceptable behaviour? How do you expect userspace to cope
with such a brain damage?
If you intend to emulate the CPU, you must emulate it fully, to the
letter of the architecture. No ifs, no buts.
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2018-01-17 9:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-11 4:43 [PATCH RFC v1] arm64: Handle traps from accessing CNTVCT/CNTFRQ for CONFIG_COMPAT Nicolin Chen
2018-01-11 8:51 ` Marc Zyngier
[not found] ` <20180116203218.GA6318@Asurada-Nvidia>
[not found] ` <86r2qpec32.wl-marc.zyngier@arm.com>
[not found] ` <20180116213745.GA9545@Asurada-Nvidia>
2018-01-17 2:13 ` Nicolin Chen
2018-01-17 9:03 ` Marc Zyngier [this message]
2018-01-17 20:41 ` Nicolin Chen
2018-01-17 23:35 ` Robin Murphy
2018-01-17 23:39 ` Nicolin Chen
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=83b9c187-7fbf-3e05-6321-de7fa05fd868@arm.com \
--to=marc.zyngier@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).