From c3edd62851098e6417786193ed9e9341781fcf57 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 12 Feb 2015 18:09:31 +0100 Subject: s390x/mmu: Add function for accessing guest memory According to the POP specification, the parameter blocks of various functions like the IO instructions are accessed with logical addresses. Thus we need a function that can read or write a buffer from/to the guest's logical address space. This patch now provides a function that can be used to access virtual guest memory by using the mmu_translate function of QEMU to convert the virtual addresses to physical. Signed-off-by: Thomas Huth Signed-off-by: Jens Freimann Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Christian Borntraeger --- target-s390x/cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'target-s390x/cpu.h') diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index f8cea308b6..a9ab587627 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -287,6 +287,7 @@ typedef struct CPUS390XState { #define FLAG_MASK_32 0x00001000 /* Control register 0 bits */ +#define CR0_LOWPROT 0x0000000010000000ULL #define CR0_EDAT 0x0000000000800000ULL static inline int cpu_mmu_index (CPUS390XState *env) @@ -897,6 +898,16 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code); uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst, uint64_t vr); +int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf, int len, + bool is_write); + +#define s390_cpu_virt_mem_read(cpu, laddr, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, dest, len, false) +#define s390_cpu_virt_mem_write(cpu, laddr, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, dest, len, true) +#define s390_cpu_virt_mem_check_write(cpu, laddr, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, NULL, len, true) + /* The value of the TOD clock for 1.1.1970. */ #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL -- cgit v1.2.3