From: Thomas Huth <thuth@redhat.com>
To: Miroslav Benes <mbenes@suse.cz>
Cc: qemu-devel@nongnu.org, ebischoff@suse.com, mmarek@suse.com,
agraf@suse.de, rth@twiddle.net,
Aurelien Jarno <aurelien@aurel32.net>,
David Hildenbrand <david@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH] target-s390x: Implement mvcos instruction
Date: Mon, 12 Jun 2017 18:44:31 +0200 [thread overview]
Message-ID: <faddb81d-8fe2-bb67-ce85-5b6ca321fc14@redhat.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1703011310200.5005@pobox.suse.cz>
On 01.03.2017 13:19, Miroslav Benes wrote:
> On Wed, 1 Mar 2017, Thomas Huth wrote:
>
>> On 28.02.2017 14:17, Miroslav Benes wrote:
>>> Implement MVCOS instruction, which the Linux kernel uses in user access
>>> functions.
>>>
>>> Signed-off-by: Miroslav Benes <mbenes@suse.cz>
>>> ---
>>> I tried to do my best to follow the specification but it is quite
>>> possible that I got something wrong because of my lack of
>>> understanding. Especially I am not sure about all those bit ops :/.
>>>
>>> Anyway, there is one piece missing. The actual use of keys and
>>> address-space-control during the move. I used fast_memmove, but
>>> it is not correct. Is there a helper which I could use? I looked at
>>> other instructions which should implement access control, but there were
>>> silently ignore it :).
>>
>> I'm not aware of a function that could deal with two address spaces
>> already (but that does not mean that there is no such function already)
>> ... still, I guess, you likely need to write your own memmove helper
>> function that can deal with two different address spaces.
>
> Ok, I thought that was the case. I'll try to come up with something.
>
>>> target/s390x/helper.h | 1 +
>>> target/s390x/insn-data.def | 2 ++
>>> target/s390x/mem_helper.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
>>> target/s390x/translate.c | 12 +++++++
>>> 4 files changed, 95 insertions(+)
>>>
>>> diff --git a/target/s390x/helper.h b/target/s390x/helper.h
>>> index 9102071d0aa4..bc5dfccc3d7e 100644
>>> --- a/target/s390x/helper.h
>>> +++ b/target/s390x/helper.h
>>> @@ -104,6 +104,7 @@ DEF_HELPER_FLAGS_2(iske, TCG_CALL_NO_RWG_SE, i64, env, i64)
>>> DEF_HELPER_FLAGS_3(sske, TCG_CALL_NO_RWG, void, env, i64, i64)
>>> DEF_HELPER_FLAGS_2(rrbe, TCG_CALL_NO_RWG, i32, env, i64)
>>> DEF_HELPER_3(csp, i32, env, i32, i64)
>>> +DEF_HELPER_5(mvcos, i32, env, i64, i64, i64, i64)
>>> DEF_HELPER_4(mvcs, i32, env, i64, i64, i64)
>>> DEF_HELPER_4(mvcp, i32, env, i64, i64, i64)
>>> DEF_HELPER_4(sigp, i32, env, i64, i32, i64)
>>> diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def
>>> index 075ff597c3de..a1e6d735d090 100644
>>> --- a/target/s390x/insn-data.def
>>> +++ b/target/s390x/insn-data.def
>>> @@ -854,6 +854,8 @@
>>> /* LOAD USING REAL ADDRESS */
>>> C(0xb24b, LURA, RRE, Z, 0, r2, new, r1_32, lura, 0)
>>> C(0xb905, LURAG, RRE, Z, 0, r2, r1, 0, lurag, 0)
>>> +/* MOVE WITH OPTIONAL SPECIFICATION */
>>> + C(0xc800, MVCOS, SSF, MVCOS, la1, a2, 0, 0, mvcos, 0)
>>> /* MOVE TO PRIMARY */
>>> C(0xda00, MVCP, SS_d, Z, la1, a2, 0, 0, mvcp, 0)
>>> /* MOVE TO SECONDARY */
>>> diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
>>> index 675aba2e44d4..ca8f7c49250c 100644
>>> --- a/target/s390x/mem_helper.c
>>> +++ b/target/s390x/mem_helper.c
>>> @@ -1089,6 +1089,86 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2)
>>> return cc;
>>> }
>>>
>>> +uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t r0, uint64_t dest,
>>> + uint64_t src, uint64_t len)
>>> +{
>>> + int cc;
>>> + int key1, as1, abit1, kbit1;
>>> + int key2, as2, abit2, kbit2;
>>> +
>>> + HELPER_LOG("%s dest %" PRIx64 ", src %" PRIx64 ", len %" PRIx64 "\n",
>>> + __func__, dest, src, len);
>>> +
>>> + /* check DAT */
>>> + if (!(env->psw.mask & PSW_MASK_DAT)) {
>>> + program_interrupt(env, PGM_SPECIAL_OP, 2);
>>
>> Length of the opcode is 6 bytes, not 2.
>
> True. Sorry, I don't know where 2 came from. It does not make sense.
As I recently had to learn it the hard way (while implementing the TEST
BLOCK instruction), you should use ILEN_LATER_INC here instead of 2 (or
6), since the Special operation exception is suppressing, too, i.e. the
program counter should be increased afterwards to the next instruction.
BTW, are you still working on a new version of this patch?
Thomas
next prev parent reply other threads:[~2017-06-12 16:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 13:17 [Qemu-devel] [RFC PATCH] target-s390x: Implement mvcos instruction Miroslav Benes
2017-03-01 11:11 ` Thomas Huth
2017-03-01 12:19 ` Miroslav Benes
2017-06-12 16:44 ` Thomas Huth [this message]
2017-06-12 20:03 ` David Hildenbrand
2017-06-13 8:18 ` Miroslav Benes
2017-06-13 16:21 ` David Hildenbrand
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=faddb81d-8fe2-bb67-ce85-5b6ca321fc14@redhat.com \
--to=thuth@redhat.com \
--cc=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=david@redhat.com \
--cc=ebischoff@suse.com \
--cc=mbenes@suse.cz \
--cc=mmarek@suse.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).