All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: peter.maydell@linaro.org
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	borntraeger@de.ibm.com, rth@twiddle.net, agraf@suse.de,
	david@redhat.com, thuth@redhat.com,
	Cornelia Huck <cohuck@redhat.com>
Subject: [Qemu-devel] [PULL v2 17/27] s390x/tcg: fix disabling/enabling DAT
Date: Thu,  1 Mar 2018 13:58:20 +0100	[thread overview]
Message-ID: <20180301125830.24377-18-cohuck@redhat.com> (raw)
In-Reply-To: <20180301125830.24377-1-cohuck@redhat.com>

From: David Hildenbrand <david@redhat.com>

Currently, all memory accesses go via the MMU of the address space
(primary, secondary, ...). This is bad, because we don't flush the TLB
when disabling/enabling DAT. So we could add a tlb flush. However it
is easier to simply select the MMU we already have in place for real
memory access.

All we have to do is point at the right MMU and allow to execute these
pages.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180213161240.19891-1-david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[CH: get rid of tabs]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 target/s390x/cpu.h        |  7 ++++++-
 target/s390x/mmu_helper.c |  2 +-
 target/s390x/translate.c  | 10 +++++++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 09ec8a9b76..d4641663ef 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -312,11 +312,12 @@ extern const struct VMStateDescription vmstate_s390_cpu;
 
 #define FLAG_MASK_PSW_SHIFT     31
 #define FLAG_MASK_PER           (PSW_MASK_PER    >> FLAG_MASK_PSW_SHIFT)
+#define FLAG_MASK_DAT           (PSW_MASK_DAT    >> FLAG_MASK_PSW_SHIFT)
 #define FLAG_MASK_PSTATE        (PSW_MASK_PSTATE >> FLAG_MASK_PSW_SHIFT)
 #define FLAG_MASK_ASC           (PSW_MASK_ASC    >> FLAG_MASK_PSW_SHIFT)
 #define FLAG_MASK_64            (PSW_MASK_64     >> FLAG_MASK_PSW_SHIFT)
 #define FLAG_MASK_32            (PSW_MASK_32     >> FLAG_MASK_PSW_SHIFT)
-#define FLAG_MASK_PSW		(FLAG_MASK_PER | FLAG_MASK_PSTATE \
+#define FLAG_MASK_PSW           (FLAG_MASK_PER | FLAG_MASK_DAT | FLAG_MASK_PSTATE \
                                 | FLAG_MASK_ASC | FLAG_MASK_64 | FLAG_MASK_32)
 
 /* Control register 0 bits */
@@ -340,6 +341,10 @@ extern const struct VMStateDescription vmstate_s390_cpu;
 
 static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch)
 {
+    if (!(env->psw.mask & PSW_MASK_DAT)) {
+        return MMU_REAL_IDX;
+    }
+
     switch (env->psw.mask & PSW_MASK_ASC) {
     case PSW_ASC_PRIMARY:
         return MMU_PRIMARY_IDX;
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index f477cc006a..23fb2e7501 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -544,7 +544,7 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,
 {
     const bool lowprot_enabled = env->cregs[0] & CR0_LOWPROT;
 
-    *flags = PAGE_READ | PAGE_WRITE;
+    *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
     if (is_low_address(raddr & TARGET_PAGE_MASK) && lowprot_enabled) {
         /* see comment in mmu_translate() how this works */
         *flags |= PAGE_WRITE_INV;
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index b470d691d3..5aea3bbca6 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -252,13 +252,17 @@ static inline uint64_t ld_code4(CPUS390XState *env, uint64_t pc)
 
 static int get_mem_index(DisasContext *s)
 {
+    if (!(s->tb->flags & FLAG_MASK_DAT)) {
+        return MMU_REAL_IDX;
+    }
+
     switch (s->tb->flags & FLAG_MASK_ASC) {
     case PSW_ASC_PRIMARY >> FLAG_MASK_PSW_SHIFT:
-        return 0;
+        return MMU_PRIMARY_IDX;
     case PSW_ASC_SECONDARY >> FLAG_MASK_PSW_SHIFT:
-        return 1;
+        return MMU_SECONDARY_IDX;
     case PSW_ASC_HOME >> FLAG_MASK_PSW_SHIFT:
-        return 2;
+        return MMU_HOME_IDX;
     default:
         tcg_abort();
         break;
-- 
2.13.6

  parent reply	other threads:[~2018-03-01 12:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 12:58 [Qemu-devel] [PULL v2 00/27] s390x updates (and friends) Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 01/27] s390-ccw: refactor boot map table code Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 02/27] s390-ccw: refactor eckd_block_num to use CHS Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 03/27] s390-ccw: refactor IPL structs Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 04/27] s390-ccw: update libc Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 05/27] s390-ccw: move auxiliary IPL data to separate location Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 06/27] s390-ccw: parse and set boot menu options Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 07/27] s390-ccw: set up interactive boot menu parameters Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 08/27] s390-ccw: read stage2 boot loader data to find menu Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 09/27] s390-ccw: print zipl boot menu Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 10/27] s390-ccw: read user input for boot index via the SCLP console Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 11/27] s390-ccw: set cp_receive mask only when needed and consume pending service irqs Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 12/27] s390-ccw: use zipl values when no boot menu options are present Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 13/27] s390-ccw: interactive boot menu for scsi Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 14/27] pc-bios/s390: Rebuild the s390x firmware images with the boot menu changes Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 15/27] s390x/cpu: expose the guest crash information Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 16/27] s390/stattrib: Make SaveVMHandlers data static Cornelia Huck
2018-03-01 12:58 ` Cornelia Huck [this message]
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 18/27] s390x/tcg: add various alignment checks Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 19/27] qmp: expose s390-specific CPU info Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 20/27] qmp: add query-cpus-fast Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 21/27] qmp: add architecture specific cpu data for query-cpus-fast Cornelia Huck
2018-03-01 12:58 ` [Qemu-devel] [PULL v2 22/27] qemu-doc: deprecate query-cpus Cornelia Huck
2018-03-01 13:01 [Qemu-devel] [PULL v2 00/27] s390x updates (and friends) Cornelia Huck
2018-03-01 13:01 ` [Qemu-devel] [PULL v2 17/27] s390x/tcg: fix disabling/enabling DAT Cornelia Huck

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=20180301125830.24377-18-cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.