qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel <qemu-devel@nongnu.org>, KVM <kvm@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>
Cc: Carsten Otte <cotte@de.ibm.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Gleb Natapov <gleb@redhat.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [Qemu-devel] [PATCH 02/12] s390: Lowcore mapping helper.
Date: Thu, 17 Jan 2013 15:23:47 +0100	[thread overview]
Message-ID: <1358432637-42512-3-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1358432637-42512-1-git-send-email-cornelia.huck@de.ibm.com>

Create a lowcore mapping helper that includes a check for sufficient
length.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/helper.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 9a132e6..bf2b4d3 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -471,13 +471,32 @@ static uint64_t get_psw_mask(CPUS390XState *env)
     return r;
 }
 
+static LowCore *cpu_map_lowcore(CPUS390XState *env, hwaddr *len)
+{
+    LowCore *lowcore;
+
+    if (*len < sizeof(LowCore)) {
+        cpu_abort(env, "Insufficient length %d for mapping lowcore\n",
+                  (int) *len);
+    }
+
+    lowcore = cpu_physical_memory_map(env->psa, len, 1);
+
+    return lowcore;
+}
+
+static void cpu_unmap_lowcore(LowCore *lowcore, hwaddr len)
+{
+    cpu_physical_memory_unmap(lowcore, len, 1, len);
+}
+
 static void do_svc_interrupt(CPUS390XState *env)
 {
     uint64_t mask, addr;
     LowCore *lowcore;
     hwaddr len = TARGET_PAGE_SIZE;
 
-    lowcore = cpu_physical_memory_map(env->psa, &len, 1);
+    lowcore = cpu_map_lowcore(env, &len);
 
     lowcore->svc_code = cpu_to_be16(env->int_svc_code);
     lowcore->svc_ilen = cpu_to_be16(env->int_svc_ilen);
@@ -486,7 +505,7 @@ static void do_svc_interrupt(CPUS390XState *env)
     mask = be64_to_cpu(lowcore->svc_new_psw.mask);
     addr = be64_to_cpu(lowcore->svc_new_psw.addr);
 
-    cpu_physical_memory_unmap(lowcore, len, 1, len);
+    cpu_unmap_lowcore(lowcore, len);
 
     load_psw(env, mask, addr);
 }
@@ -513,7 +532,7 @@ static void do_program_interrupt(CPUS390XState *env)
     qemu_log_mask(CPU_LOG_INT, "%s: code=0x%x ilen=%d\n",
                   __func__, env->int_pgm_code, ilen);
 
-    lowcore = cpu_physical_memory_map(env->psa, &len, 1);
+    lowcore = cpu_map_lowcore(env, &len);
 
     lowcore->pgm_ilen = cpu_to_be16(ilen);
     lowcore->pgm_code = cpu_to_be16(env->int_pgm_code);
@@ -522,7 +541,7 @@ static void do_program_interrupt(CPUS390XState *env)
     mask = be64_to_cpu(lowcore->program_new_psw.mask);
     addr = be64_to_cpu(lowcore->program_new_psw.addr);
 
-    cpu_physical_memory_unmap(lowcore, len, 1, len);
+    cpu_unmap_lowcore(lowcore, len);
 
     DPRINTF("%s: %x %x %" PRIx64 " %" PRIx64 "\n", __func__,
             env->int_pgm_code, ilen, env->psw.mask,
@@ -549,7 +568,7 @@ static void do_ext_interrupt(CPUS390XState *env)
     }
 
     q = &env->ext_queue[env->ext_index];
-    lowcore = cpu_physical_memory_map(env->psa, &len, 1);
+    lowcore = cpu_map_lowcore(env, &len);
 
     lowcore->ext_int_code = cpu_to_be16(q->code);
     lowcore->ext_params = cpu_to_be32(q->param);
@@ -560,7 +579,7 @@ static void do_ext_interrupt(CPUS390XState *env)
     mask = be64_to_cpu(lowcore->external_new_psw.mask);
     addr = be64_to_cpu(lowcore->external_new_psw.addr);
 
-    cpu_physical_memory_unmap(lowcore, len, 1, len);
+    cpu_unmap_lowcore(lowcore, len);
 
     env->ext_index--;
     if (env->ext_index == -1) {
-- 
1.7.12.4

  parent reply	other threads:[~2013-01-17 14:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 14:23 [Qemu-devel] [PATCH v5 00/12] s390: channel I/O support in qemu Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 01/12] s390: Add a hypercall registration interface Cornelia Huck
2013-01-18 16:51   ` Alexander Graf
2013-01-17 14:23 ` Cornelia Huck [this message]
2013-01-18 16:54   ` [Qemu-devel] [PATCH 02/12] s390: Lowcore mapping helper Alexander Graf
2013-01-17 14:23 ` [Qemu-devel] [PATCH 03/12] s390: Add mapping helper functions Cornelia Huck
2013-01-18 17:07   ` Alexander Graf
2013-01-17 14:23 ` [Qemu-devel] [PATCH 04/12] Update linux headers Cornelia Huck
2013-01-17 15:05   ` Peter Maydell
2013-01-17 16:20     ` Cornelia Huck
2013-01-17 16:55       ` Alexander Graf
2013-01-17 14:23 ` [Qemu-devel] [PATCH 05/12] s390: Channel I/O basic defintions Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 06/12] s390: I/O interrupt and machine check injection Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 07/12] s390: Add channel I/O instructions Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 08/12] s390: Virtual channel subsystem support Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 09/12] s390: Wire up channel I/O in kvm Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 10/12] s390: Add new channel I/O based virtio transport Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 11/12] s390-virtio: Factor out some initialization code Cornelia Huck
2013-01-17 14:23 ` [Qemu-devel] [PATCH 12/12] s390: Add s390-ccw-virtio machine Cornelia Huck
2013-01-18 17:24   ` Alexander Graf
2013-01-18 16:49 ` [Qemu-devel] [PATCH v5 00/12] s390: channel I/O support in qemu Alexander Graf

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=1358432637-42512-3-git-send-email-cornelia.huck@de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=gleb@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=sebott@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).