[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/11] s390: Lowcore mapping helper.
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PATCH 01/11] s390: Lowcore mapping helper. |
Date: |
Thu, 24 Jan 2013 13:28:01 +0100 |
Create a lowcore mapping helper that includes a check for sufficient
length.
Signed-off-by: Cornelia Huck <address@hidden>
---
v5 -> v6:
- Check returned len of cpu_physical_memory_map
- Don't pass lowcore len
---
target-s390x/helper.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 9a132e6..023c074 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -471,13 +471,31 @@ static uint64_t get_psw_mask(CPUS390XState *env)
return r;
}
+static LowCore *cpu_map_lowcore(CPUS390XState *env)
+{
+ LowCore *lowcore;
+ hwaddr len = sizeof(LowCore);
+
+ lowcore = cpu_physical_memory_map(env->psa, &len, 1);
+
+ if (len < sizeof(LowCore)) {
+ cpu_abort(env, "Could not map lowcore\n");
+ }
+
+ return lowcore;
+}
+
+static void cpu_unmap_lowcore(LowCore *lowcore)
+{
+ cpu_physical_memory_unmap(lowcore, sizeof(LowCore), 1, sizeof(LowCore));
+}
+
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);
lowcore->svc_code = cpu_to_be16(env->int_svc_code);
lowcore->svc_ilen = cpu_to_be16(env->int_svc_ilen);
@@ -486,7 +504,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);
load_psw(env, mask, addr);
}
@@ -495,7 +513,6 @@ static void do_program_interrupt(CPUS390XState *env)
{
uint64_t mask, addr;
LowCore *lowcore;
- hwaddr len = TARGET_PAGE_SIZE;
int ilen = env->int_pgm_ilen;
switch (ilen) {
@@ -513,7 +530,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);
lowcore->pgm_ilen = cpu_to_be16(ilen);
lowcore->pgm_code = cpu_to_be16(env->int_pgm_code);
@@ -522,7 +539,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);
DPRINTF("%s: %x %x %" PRIx64 " %" PRIx64 "\n", __func__,
env->int_pgm_code, ilen, env->psw.mask,
@@ -537,7 +554,6 @@ static void do_ext_interrupt(CPUS390XState *env)
{
uint64_t mask, addr;
LowCore *lowcore;
- hwaddr len = TARGET_PAGE_SIZE;
ExtQueue *q;
if (!(env->psw.mask & PSW_MASK_EXT)) {
@@ -549,7 +565,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);
lowcore->ext_int_code = cpu_to_be16(q->code);
lowcore->ext_params = cpu_to_be32(q->param);
@@ -560,7 +576,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);
env->ext_index--;
if (env->ext_index == -1) {
--
1.7.12.4
- [Qemu-devel] [PATCH v6 00/11] s390: channel I/O support in qemu., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 02/11] s390: Add mapping helper functions., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 03/11] s390: Channel I/O basic definitions., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 04/11] s390: I/O interrupt and machine check injection., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 01/11] s390: Lowcore mapping helper.,
Cornelia Huck <=
- [Qemu-devel] [PATCH 09/11] s390-virtio: Factor out some initialization code., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 07/11] s390: Wire up channel I/O in kvm., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 11/11] s390: Add s390-ccw-virtio machine., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 10/11] s390: Add default support for SCLP console, Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 05/11] s390: Add channel I/O instructions., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 06/11] s390: Virtual channel subsystem support., Cornelia Huck, 2013/01/24
- [Qemu-devel] [PATCH 08/11] s390: Add new channel I/O based virtio transport., Cornelia Huck, 2013/01/24