From: Thomas Huth <thuth@redhat.com>
To: David Hildenbrand <david@redhat.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: Cornelia Huck <cohuck@redhat.com>, Alexander Graf <agraf@suse.de>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [qemu-s390x] [PATCH v1 1/2] s390x/tcg: implement TEST PROTECTION
Date: Tue, 19 Dec 2017 09:20:26 +0100 [thread overview]
Message-ID: <4ea93c11-adf5-ca1c-b49b-e80d82bf3945@redhat.com> (raw)
In-Reply-To: <20171218224616.21030-2-david@redhat.com>
On 18.12.2017 23:46, David Hildenbrand wrote:
> Linux uses TEST PROTECTION to sense for available memory locations.
>
> Let's implement what we can for now (just as for the other instructions,
> excluding AR mode and special protection mechanisms).
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> target/s390x/helper.h | 2 +-
> target/s390x/mem_helper.c | 41 +++++++++++++++++++++++++++++++++++++++--
> target/s390x/translate.c | 2 +-
> 3 files changed, 41 insertions(+), 4 deletions(-)
>
> diff --git a/target/s390x/helper.h b/target/s390x/helper.h
> index 2f17b62d3d..26c1b07b44 100644
> --- a/target/s390x/helper.h
> +++ b/target/s390x/helper.h
> @@ -137,7 +137,7 @@ DEF_HELPER_FLAGS_4(lctlg, TCG_CALL_NO_WG, void, env, i32, i64, i32)
> DEF_HELPER_FLAGS_4(stctl, TCG_CALL_NO_WG, void, env, i32, i64, i32)
> DEF_HELPER_FLAGS_4(stctg, TCG_CALL_NO_WG, void, env, i32, i64, i32)
> DEF_HELPER_FLAGS_2(testblock, TCG_CALL_NO_WG, i32, env, i64)
> -DEF_HELPER_FLAGS_2(tprot, TCG_CALL_NO_RWG, i32, i64, i64)
> +DEF_HELPER_FLAGS_3(tprot, TCG_CALL_NO_RWG, i32, env, i64, i64)
> 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)
> diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
> index 2625d843b3..359e446c6f 100644
> --- a/target/s390x/mem_helper.c
> +++ b/target/s390x/mem_helper.c
> @@ -1717,9 +1717,46 @@ uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr)
> return 0;
> }
>
> -uint32_t HELPER(tprot)(uint64_t a1, uint64_t a2)
> +uint32_t HELPER(tprot)(CPUS390XState *env, uint64_t a1, uint64_t a2)
> {
> - /* XXX implement */
> + S390CPU *cpu = s390_env_get_cpu(env);
> + CPUState *cs = CPU(cpu);
> +
> + /*
> + * TODO: we currently don't handle all access protection types
> + * (including access-list and key-controlled) as well as AR mode.
> + */
Maybe add some "if (a2 & 0xf0) qemu_log_mask(LOG_UNIMPL, ...)" so that
we've got a chance to detect such conditions later?
> + if (!s390_cpu_virt_mem_check_write(cpu, a1, 0, 1)) {
> + /* Fetching permitted; storing permitted */
> + return 0;
> + }
> + switch (env->int_pgm_code) {
> + case PGM_PROTECTION:
> + /* Fetching permitted; storing not permitted */
> + cs->exception_index = 0;
> + return 1;
> + case PGM_ADDRESSING:
> + /* Fetching not permitted; storing not permitted */
> + cs->exception_index = 0;
> + return 2;
> + case PGM_ASCE_TYPE:
> + case PGM_REG_FIRST_TRANS:
> + case PGM_REG_SEC_TRANS:
> + case PGM_REG_THIRD_TRANS:
> + case PGM_SEGMENT_TRANS:
> + case PGM_PAGE_TRANS:
> + case PGM_ALET_SPEC:
> + case PGM_ALEN_SPEC:
> + case PGM_ALE_SEQ:
> + case PGM_ASTE_VALID:
> + case PGM_ASTE_SEQ:
> + case PGM_EXT_AUTH:
> + /* Translation not available */
> + cs->exception_index = 0;
> + return 3;
> + }
> + /* any other exception is forwarded to the guest */
> + s390_cpu_virt_mem_handle_exc(cpu, GETPC());
> return 0;
> }
>
> diff --git a/target/s390x/translate.c b/target/s390x/translate.c
> index eede2ed157..fdcc2ffb3d 100644
> --- a/target/s390x/translate.c
> +++ b/target/s390x/translate.c
> @@ -4534,7 +4534,7 @@ static ExitStatus op_testblock(DisasContext *s, DisasOps *o)
>
> static ExitStatus op_tprot(DisasContext *s, DisasOps *o)
> {
> - gen_helper_tprot(cc_op, o->addr1, o->in2);
> + gen_helper_tprot(cc_op, cpu_env, o->addr1, o->in2);
> set_cc_static(s);
> return NO_EXIT;
> }
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2017-12-19 8:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 22:46 [Qemu-devel] [PATCH v1 0/2] s390x/tcg: TEST PROTECTION and memory hotplug David Hildenbrand
2017-12-18 22:46 ` [Qemu-devel] [PATCH v1 1/2] s390x/tcg: implement TEST PROTECTION David Hildenbrand
2017-12-19 8:20 ` Thomas Huth [this message]
2017-12-19 10:32 ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2017-12-21 17:17 ` Cornelia Huck
2017-12-18 22:46 ` [Qemu-devel] [PATCH v1 2/2] s390x/sclp: fix missing be conversion David Hildenbrand
2017-12-19 8:25 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2017-12-22 10:57 ` [Qemu-devel] [PATCH v1 0/2] s390x/tcg: TEST PROTECTION and memory hotplug Cornelia Huck
2018-01-12 10:43 ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2018-01-12 10:51 ` Cornelia Huck
2018-01-12 10:52 ` 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=4ea93c11-adf5-ca1c-b49b-e80d82bf3945@redhat.com \
--to=thuth@redhat.com \
--cc=agraf@suse.de \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@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).