summaryrefslogtreecommitdiffstats
path: root/target-s390x/misc_helper.c
Commit message (Collapse)AuthorAgeFilesLines
* s390x/cmma: clean up cmma resetDavid Hildenbrand2015-10-211-2/+2
| | | | | | | | | | | | The cmma reset is per VM, so we don't need a cpu object. We can directly make use of kvm_state, as it is already available when the reset is called. By moving the cmma reset in our machine reset function, we can avoid a manual reset handler. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390x: reset crypto only on clear reset and QEMU resetDavid Hildenbrand2015-10-211-0/+1
| | | | | | | | | | | | | | | | | | | Initializing VM crypto in initial cpu reset has multiple problems 1. We call the exact same function #VCPU times, although one time is enough 2. On SIGP initial cpu reset, we exchange the wrapping key while other VCPUs are running. Bad! 3. It is simply wrong. According to the Pop, a reset happens only during a clear reset. So, we have to reset the keys - on modified clear reset - on load clear (QEMU reset - via machine reset) - on qemu start (via machine reset) Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390x/ipl: we always have an ipl deviceDavid Hildenbrand2015-10-211-5/+2
| | | | | | | | | | | | Both s390 machines unconditionally create an ipl device, so no need to handle the missing case. Now we can also change s390_ipl_update_diag308() to return void. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390x: rename io_subsystem_reset -> subsystem_resetDavid Hildenbrand2015-10-021-2/+2
| | | | | | | | | | | | | | According to the Pop: "Subsystem reset operates only on those elements in the configuration which are not CPUs". As this is what we actually do, let's simply rename the function. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Message-Id: <1443689387-34473-6-git-send-email-jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* target-s390x: PER instruction-fetch nullification event supportAurelien Jarno2015-06-171-0/+12
| | | | | | | | | | | | | For the instruction-fetch nullification event, we just reuse the existing instruction-fetch code and trigger the exception immediately in that case. There is no need to save the CPU state in the TCG code as it has been saved by the previous instruction before calling the per_check_exception helper. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: PER instruction-fetch event supportAurelien Jarno2015-06-171-0/+8
| | | | | | | | | | | | | | | | | | | For the PER instruction-fetch, we can't use the QEMU breakpoint infrastructure as it triggers for a single address and not a full address range, and as it actually stop before the instruction and not before. We therefore call an helper with the just fetched instruction address, which check if the address is within the PER address range. If it is the case, an event is recorded and will be signaled through an exception. Note that we implement here the PER-3 behaviour, that is an invalid opcode is not considered as an instruction fetch. Without PER-3 this behavious is undefined. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: PER successful-branching event supportAurelien Jarno2015-06-171-0/+11
| | | | | | | | | | | | | For the PER successful-branching event support, we can't rely on any QEMU infrastucture. We therefore call an helper in all places where a branch can be taken. We have to pay attention to the branch to next case, as it's still a taken branch. We don't need to care about the cases using goto_tb, as we have disabled them in the previous patch. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: basic PER event handlingAurelien Jarno2015-06-171-0/+15
| | | | | | | | | | | | | | | | | | This patch add basic support to generate PER exceptions. It adds two fields to the cpu structure to record for the PER address and PER code & ATMID values. When an exception is triggered and a PER event is pending, the two PER values are copied to the lowcore area. At the end of an instruction, an helper is checking for a possible pending PER event and triggers an exception in that case. For that to work with branches, we need to disable TB chaining when PER is activated. Fortunately it's already in the TB flags. Finally in case of a SERVICE CALL exception, we need to trigger the PER exception immediately after. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: wire up I/O instructions in TCG modeAlexander Graf2015-06-171-0/+62
| | | | | | | | | The code handling the I/O instructions for KVM decodes the instruction itself. In TCG mode also pass the full instruction word to the helpers. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: wire up DIAG REIPL in TCG modeAurelien Jarno2015-06-171-0/+6
| | | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: wire up DIAG IPL in TCG modeAurelien Jarno2015-06-171-5/+8
| | | | | | | | | | | | | | DIAG IPL is already implemented for KVM, but not wired from TCG. For that change the format of the instruction so that we can get R1 and R3 numbers in addition to the function code. The diag function can change plenty of things, including CC, so we should enter with a static CC. Also it doesn't set the value of general register 2 to 0 as in the current code. We also need to exit the CPU loop after a reset, which means a new PSW. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390x/kvm: diag288 instruction interception and handlingXu Wang2015-06-111-0/+29
| | | | | | | | | | Intercept the diag288 requests from kvm guests, and hand the requested command to the diag288 watchdog device for further handling. Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* target-s390x: fix PSW value on dynamical exception from helpersAurelien Jarno2015-06-051-1/+1
| | | | | | | | | | | runtime_exception computes the psw.addr value using the actual exception address and the instruction length computed by calling the get_ilen function. However as explained above the get_ilen code, it returns the actual instruction length, and not the ILC. Therefore there is no need to multiply the value by 2. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: implement STPT helperAurelien Jarno2015-06-051-3/+4
| | | | | | | | | | Save the timer target value in the SPT helper, so that the STPT helper can compute the remaining time. This allow the Linux kernel to correctly do time accounting. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: implement STCKC helperAurelien Jarno2015-06-051-2/+3
| | | | | | | | The STCKC instruction just returns the last written clock comparator value and KVM already provides the corresponding variable. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: streamline STCK helperAurelien Jarno2015-06-051-7/+2
| | | | | | | | Now that clock_value is only used in one place, we can inline it in the STCK helper. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: simplify SCKC helperAurelien Jarno2015-06-051-3/+4
| | | | | | | | | | | The clock comparator and the QEMU timer work the same way, triggering at a given time, they just differ by the origin and the scale. It is therefore possible to go from one to another without using the current clock value. This spares two calls to qemu_clock_get_ns, which probably return slightly different values, possibly reducing the accuracy. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390x: add a tod2time functionAurelien Jarno2015-06-051-2/+2
| | | | | | | | Add a tod2time function similar to the time2tod one, instead of open coding the conversion. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390x: introduce defines for SIGP condition codesDavid Hildenbrand2015-03-101-2/+2
| | | | | | | | | | | This patch introduces defines for the SIGP condition codes and replaces all occurrences of numeral condition codes with the new defines. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Message-Id: <1424783731-43426-2-git-send-email-jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/ipl: support diagnose 308 subcodes 5 and 6Fan Zhang2015-02-131-2/+31
| | | | | | | | | | | | | | | | | | | | To support dynamically updating the IPL device from inside the KVM guest on the s390 platform, DIAG 308 instruction is intercepted in QEMU to handle the request. Subcode 5 allows to specify a new boot device, which is saved for later in the s390_ipl device. This also allows to switch from an external kernel to a boot device. Subcode 6 retrieves boot device configuration that has been previously set. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Fan Zhang <zhangfan@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x/kvm: run guest triggered resets on the target vcpu threadDavid Hildenbrand2014-09-011-22/+8
| | | | | | | | | | | | | | | Currently, load_normal_reset() and modified_clear_reset() as triggered by a guest vcpu will initiate cpu resets on the current vcpu thread for all cpus. The reset should happen on the individual vcpu thread instead, so let's use run_on_cpu() for this. This avoids calls to synchronize_rcu() in the kernel. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390x: cleanup interrupt injectionCornelia Huck2014-06-101-1/+6
| | | | | | | Remove the need for a cpu to inject a floating interrupt on kvm. Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390x/kvm: enable/reset cmma via vm attributesDominik Dingel2014-06-101-0/+2
| | | | | | | | | | | | | | | | | | | Exploit the new api for userspace-controlled cmma. If supported, enable cmma during kvm initialization and register a reset handler for cmma, which is also called directly from the load IPL code. The reset functionality is needed to reset the cmma state of the guest pages, e.g. if a system reset is triggered via qemu monitor; otherwise this could result in data corruption. A guest triggered reboot may now lead to multiple cmma resets; this is OK, however, as this is slowpath anyway and the simplest way to achieve the intended effects. Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* softmmu: introduce cpu_ldst.hPaolo Bonzini2014-06-051-1/+1
| | | | | | | | | | This will collect all load and store helpers soon. For now it is just a replacement for softmmu_exec.h, which this patch stops including directly, but we also include it where this will be necessary in order to simplify the next patch. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* tcg: Invert the inclusion of helper.hRichard Henderson2014-05-281-1/+1
| | | | | | | | | | Rather than include helper.h with N values of GEN_HELPER, include a secondary file that sets up the macros to include helper.h. This minimizes the files that must be rebuilt when changing the macros for file N. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
* misc: Use cpu_physical_memory_read and cpu_physical_memory_writeStefan Weil2014-04-271-6/+6
| | | | | | | | These functions don't need type casts (as does cpu_physical_memory_rw) and also make the code better readable. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* cputlb: Change tlb_flush_page() argument to CPUStateAndreas Färber2014-03-131-2/+4
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* translate-all: Change cpu_restore_state() argument to CPUStateAndreas Färber2014-03-131-1/+1
| | | | | | This lets us drop some local variables in tlb_fill() functions. Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu-exec: Change cpu_loop_exit() argument to CPUStateAndreas Färber2014-03-131-5/+5
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Move exception_index field from CPU_COMMON to CPUStateAndreas Färber2014-03-131-4/+11
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* s390x/sclp: Add missing checks to SCLP handlerThomas Huth2014-02-271-1/+1
| | | | | | | | | | | If the 51 most significant bits of the SCCB address are zero or equal to the prefix, we should throw an specification exception, too. Also moved the check for privileged mode to sclp_service_call() to have all program checks in one place now. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390/ebcdic: Move conversion tables to header fileHeinz Graalfs2013-09-201-80/+1
| | | | | | | | | | Move conversion tables to header file. - In SCLP line mode processing EBCDIC/ASCII conversion is needed. - An additional EBCDIC to ASCII conversion function is added. Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com> Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390/kexec: Implement diag308 subcode 0Christian Borntraeger2013-09-201-0/+26
| | | | | | | | | This patch implements subcode 0 of diag 308. This is necessary for kexec (without kdump). The main difference to subcode 1 is that all CPUs get a full reset, instead of the architectured CPU reset (which leaves all registers untouched). Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* cpu: Use QTAILQ for CPU listAndreas Färber2013-09-031-4/+4
| | | | | | | Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthand macros. Signed-off-by: Andreas Färber <afaerber@suse.de>
* s390: Implement load normal resetChristian Borntraeger2013-08-301-0/+30
| | | | | | | | | | | kdump on s390 uses a load normal reset to bring the system in a defined state by doing a subsystem reset. The issuing CPUs will have an initial CPU reset, all other CPUs will have a CPU reset as defined in POP (no register content will change). Implement this as architectured. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390/kvm: basic implementation of diagnose 308 subcode 6Eugene (jno) Dvurechenski2013-08-301-0/+40
| | | | | | | | | | | Linux uses a check for subcode 6 to decide if other subcodes are available. Provide a minimal implementation for subcode 6, as well as for subcode 5. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> [Move code from kvm.c into misc_helper.c]
* aio / timers: Switch entire codebase to the new timer APIAlex Bligh2013-08-221-3/+3
| | | | | | | | | | | This is an autogenerated patch using scripts/switch-timer-api. Switch the entire code base to using the new timer API. Note this patch may introduce some line length issues. Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* s390: Add a hypercall registration interface.Cornelia Huck2013-01-181-1/+1
| | | | | | | | Allow virtio machines to register for different diag500 function codes and convert s390-virtio to use it. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390x: Remove inline function ebcdic_put and related data from cpu.hStefan Weil2013-01-181-0/+81
| | | | | | | | | | | | | | | | | | | | The function is only used in misc_helper.c, so move it to that file. This reduces the size of debug executables (compiled without optimization) because they get unused code and data for each compilation which includes cpu.h. Executables with optimization don't change their size. ebcdic2ascii is currently unused and could be removed (not done here). The array ascii2ebcdic must be accessed with an unsigned index, therefore (int)ascii[i] was replaced by (uint8_t)ascii[i]. The old code would have failed for a signed char less than 0. The current code only converts "QEMU" and spaces to EBCDIC, so there is no problem today. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-s390: Convert SERVCRichard Henderson2013-01-051-4/+2
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert STSIRichard Henderson2013-01-051-2/+2
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert STCKERichard Henderson2013-01-051-14/+0
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert SPX, STPXRichard Henderson2013-01-051-4/+2
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert SPT, STPTRichard Henderson2013-01-051-5/+3
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert SCKC, STCKCRichard Henderson2013-01-051-5/+3
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert STCKRichard Henderson2013-01-051-4/+2
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert SCKRichard Henderson2013-01-051-8/+0
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Convert STIDPRichard Henderson2013-01-051-6/+0
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Send signals for divideRichard Henderson2013-01-051-0/+20
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-s390: Reorg exception handlingRichard Henderson2013-01-051-4/+4
| | | | | | | | | Make the user path more like the system path. Prepare for more kinds of runtime exceptions. Rename ILC to ILEN to make it clear that we want to pass around a full instruction length, rather than a "code" that happens to be stored one bit left in a larger field. Signed-off-by: Richard Henderson <rth@twiddle.net>
OpenPOWER on IntegriCloud