summaryrefslogtreecommitdiffstats
path: root/target-s390x/mmu_helper.c
Commit message (Collapse)AuthorAgeFilesLines
* s390x: Enable new s390-storage-keys deviceJason J. Herne2015-09-031-5/+23
| | | | | | | | | | | | | | | s390 guest initialization is modified to make use of new s390-storage-keys device. Old code that globally allocated storage key array is removed. The new device enables storage key access for kvm guests. Cache storage key QOM objects in frequently used helper functions to avoid a performance hit every time we use one of these functions. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* Stop including qemu-common.h in memory.hPeter Maydell2015-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | Including qemu-common.h from other header files is generally a bad idea, because it means it's very easy to end up with a circular dependency. For instance, if we wanted to include memory.h from qom/cpu.h we'd end up with this loop: memory.h -> qemu-common.h -> cpu.h -> cpu-qom.h -> qom/cpu.h -> memory.h Remove the include from memory.h. This requires us to fix up a few other files which were inadvertently getting declarations indirectly through memory.h. The biggest change is splitting the fprintf_function typedef out into its own header so other headers can get at it without having to include qemu-common.h. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <1435933104-15216-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* target-s390x: Only access allocated storage keysAlexander Graf2015-06-051-1/+1
| | | | | | | | | | | We allocate ram_size / PAGE_SIZE storage keys, so we need to make sure that we only access that many. Unfortunately the code can overrun this array by one, potentially overwriting unrelated memory. Fix it by limiting storage keys to their scope. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
* Merge remote-tracking branch ↵Peter Maydell2015-04-301-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'remotes/mjt/tags/pull-trivial-patches-2015-04-30' into staging trivial patches for 2015-04-30 # gpg: Signature made Thu Apr 30 14:07:50 2015 BST using RSA key ID A4C3D7DB # gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>" # gpg: aka "Michael Tokarev <mjt@corpit.ru>" # gpg: aka "Michael Tokarev <mjt@debian.org>" * remotes/mjt/tags/pull-trivial-patches-2015-04-30: (42 commits) openrisc: cpu: Remove unused cpu_get_pc microblaze: fix memory leak tcg: Delete unused cpu_pc_from_tb() kvm: Silence warning from valgrind vhost-user: remove superfluous '\n' around error_report() target-mips: fix memory leak qmp-commands: Fix typo linux-user/elfload: use QTAILQ_FOREACH instead of open-coding it coroutine: remove unnecessary parentheses in qemu_co_queue_empty qemu-char: remove unused list node from FDCharDriver input: remove unused mouse_handlers list cpus: use first_cpu macro instead of QTAILQ_FIRST(&cpus) microblaze: cpu: delete unused cpu_interrupts_enabled microblaze: cpu: Renumber EXCP_* constants to close gap microblaze: cpu: Delete EXCP_NMI microblaze: cpu: Remove unused CC_OP enum microblaze: cpu: Remote unused cpu_get_pc microblaze: mmu: Delete flip_um fn prototype defconfigs: Piggyback microblazeel on microblaze libcacard: do not use full paths for include files in the same dir ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * misc: Fix new collection of typosStefan Weil2015-04-301-4/+4
| | | | | | | | | | | | | | | | | | | | All of them were reported by codespell. Most typos are in comments, one is in an error message. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctlAlexander Yarygin2015-04-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Access register mode is one of the modes that control dynamic address translation. In this mode the address space is specified by values of the access registers. The effective address-space-control element is obtained from the result of the access register translation. See the "Access-Register Introduction" section of the chapter 5 "Program Execution" in "Principles of Operations" for more details. When the CPU is in AR mode, the s390_cpu_virt_mem_rw() function must know which access register number to use for address translation. This patch does several things: - add new parameter 'uint8_t ar' to that function - decode ar number from intercepted instructions - pass the ar number to s390_cpu_virt_mem_rw(), which in turn passes it to the KVM_S390_MEM_OP ioctl. Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | s390x/mmu: Use ioctl for reading and writing from/to guest memoryThomas Huth2015-04-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | Add code to make use of the new ioctl for reading from / writing to virtual guest memory. By using the ioctl, the memory accesses are now protected with the so-called ipte-lock in the kernel. [CH: moved error message into kvm_s390_mem_op()] Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* | s390x/mmu: Use access type definitions instead of magic valuesThomas Huth2015-04-301-5/+5
|/ | | | | | | | | | | Since there are now proper definitions for the MMU access type, let's use them in the s390x MMU code, too, instead of the hard-to-understand magic values. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390x/mmu: Add function for accessing guest memoryThomas Huth2015-02-181-0/+102
| | | | | | | | | | | | | | | | | 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 <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/kvm: Add function for injecting pgm access exceptionsThomas Huth2015-02-181-6/+16
| | | | | | | | | | | | | Program access exceptions are defined to deliver a translation exception code in the low-core. Add a function trigger_access_exception() that generates the proper program interrupt on both KVM and non-KVM systems and switch the existing code to use it. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Clean up mmu_translate_asc()Thomas Huth2015-02-181-24/+15
| | | | | | | | | | | | | We can get rid of the switch(asc) in mmu_translate_asc() by simply selecting the right control register ASCE in the mmu_translate() function already. This patch is based on an original patch/idea by Ralf Hoppe. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Check bit 52 in page table entryThomas Huth2015-02-181-1/+4
| | | | | | | | | | | Bit 52 in a page table entry has always to be zero, or a translation specification exception is to be recognized. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Renaming related to the ASCE confusionThomas Huth2015-02-181-6/+6
| | | | | | | | | | | | | | An Address Space Control Element (ASCE) is only the very first unit of an s390 address translation (normally residing in one of the control registers). The entries in the page tables are called differently. So let's call the relevant variable pt_entry instead of asce in mmu_translate_pte() to avoid future confusion (thus there is no functional change in this patch, just renaming). Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Add support for read-only regionsThomas Huth2015-02-181-3/+4
| | | | | | | | | | | If the "DAT-protection" bit is set in the region table entry and EDAT is enabled, only read accesses are allowed in the corresponding memory area. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Fix the exception codes for illegal table entriesThomas Huth2015-02-181-2/+1
| | | | | | | | | | | Each different level of region/segment table has a dedicated exception type for illegal entries. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Fix exception types when checking the ASCEsThomas Huth2015-02-181-3/+3
| | | | | | | | | | | If an ASCE has illegal bits set, an ASCE-type exception should be generated instead of a translation specification exception. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Fix translation exception code in lowcoreThomas Huth2015-02-181-33/+15
| | | | | | | | | | | | | | | The address space bits in the translation exception code were wrong. In fact, we can simply copy the bits from the PSW, so there's no need for the trans_bits() function anymore. Additionally, we now also set the fetch/store bits in the translation exception code, so a guest can determine whether the exception occured during a write or during a read. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Skip exceptions properly when translating addresses for debugThomas Huth2015-02-181-28/+49
| | | | | | | | | | | | | When a fault occurs during the MMU lookup in s390_cpu_get_phys_page_debug(), the trigger_page_fault() function writes the translation exception code into the lowcore - something you would not expect during a memory access by the debugger. Ease this problem by adding an additional parameter to mmu_translate() which can be used to specify whether a program check and the translation exception code should be injected or not. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Check table length and offset fieldsThomas Huth2015-02-181-0/+29
| | | | | | | | | | | The ACSEs have a table length field and the region entries have table length and offset fields which must be checked during translation to see whether the given virtual address is really covered by the translation table. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Fix the handling of the table levelsThomas Huth2015-02-181-68/+47
| | | | | | | | | | | | | | | | | | | | The current code used a wrong and very confusing way of dealing with the table levels by introducing a "fake level above current". However, the real problem was simply that the checks for the region/segment invalid bit and for the matching region/segment level was done at the wrong spot in the code - it has to be done after the first table entry has been looked up instead (e.g. there is also no "invalid" bit in the ASCE itself and the current "level" has to be the same as the level in the entry that we just looked up). Also the entries for the segment table are quite a bit different compared to the region table entries. So this patch moves the related code into the function mmu_translate_segment() to make it clear at which table level we currently are and to get rid of the ugly switch-statement in the function mmu_translate_region(). Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Fix the check for the real-space designation bitThomas Huth2015-02-181-7/+6
| | | | | | | | | | The real-space designation bits live in the ASCEs, not in the table entries, so the check must be done before we start walking the MMU table. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/mmu: Move mmu_translate() and friends to separate fileThomas Huth2015-02-181-0/+356
helper.c is quite overcrowded already, so let's move the MMU translation to a separate file instead (like it has been done with the other targets already). Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
OpenPOWER on IntegriCloud