s390x: add TR function for EXECUTE
Newer gcc versions (or glibc?) also generate code that tries to EXECUTEthe TR opcode. Implement it so that we don't break valid guests.
Reported-by: Andreas Faerber <afaerber@suse.de>Signed-off-by: Alexander Graf <agraf@suse.de>
s390: fix cpu hotplug / cpu activity on interrupts
The add_del/running_cpu code and env->halted are tracking stopped cpus.Sleeping cpus (idle and enabled for interrupts) are waiting inside thekernel.No interrupt besides the restart can move a cpu from stopped to...
Fix spelling in comments, documentation and messages
accidently->accidentallyannother->anotherchoosen->chosenconsideres->considersdecriptor->descriptordevelopement->developmentparamter->parameterpreceed->precedepreceeding->precedingpriviledge->privilege...
fix typo: delete redundant semicolon
Double semicolons should be single.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
s390x: add ldeb instruction
While running perl, we encountered the ldeb instruction to be used,so we implement it :).
Signed-off-by: Alexander Graf <agraf@suse.de>
s390x: make ipte 31-bit aware
When running 31-bit code we can potentially map the same virtualaddress twice - once as 0x0yyyyyyy and once as 0x8yyyyyyy, becausethe upper bit gets ignored.
This also should be reflected in the tlb invalidation path, so we...
s390x: update R and C bits in storage key
When the s390x maps a page or writes happen to a page, the R and Cbits get updated. The easiest way to implement this in qemu is tosimply update them whenever we map a TLB translation and act accordingto the permissions....
s390x: implement rrbe instruction properly
The rrbe instruction resets the reference bit in the given storage key.So far, we merely made it a nop and also returned an invalid CC value,so that the kernel never knew if a page actually got accessed.
This patch implements it properly, flushing the R bit and returning the...
s390x: implement SIGP restart and shutdown
An s390x OS does reboot and shutdown triggers through hypercalls thatwe didn't implement on the TCG backend yet. That means that so far wecouldn't shut down virtual machines for example, having them hang onshutdown when not using KVM....
s390: Fix cpu shutdown for KVM
On s390 a shutdown is the state of all CPUs being either stoppedor disabled (for interrupts) waiting. We have to track the overallnumber of running CPUs to call the shutdown sequence accordingly.This patch implements the counting and shutdown handling for the...
s390x: Add shutdown for TCG s390-virtio machine
Now that we have code in place to do refcounting of online CPUs, wecan drag the TCG code along and implement shutdown for that one too,so it doesn't feel left out by its KVM counterpart.
softmmu_header: pass CPUState to tlb_fill
Pass CPUState pointer to tlb_fill() instead of architecture localcpu_single_env hacks.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:
git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...
Fix conversions from pointer to tcg_target_long
tcg_gen_exit_tb takes a parameter of type tcg_target_long,so the type casts of pointer to long should be replaced bytype casts of pointer to tcg_target_long.
These changes are needed for build environments where...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Remove unused is_softmmu parameter from cpu_handle_mmu_fault
Parameter is_softmmu (and its evil mutant twin brother is_softmuu)is not used in cpu_*_handle_mmu_fault() functions, remove themand adjust callers.
Acked-by: Richard Henderson <rth@twiddle.net>...
Avoid allocating TCG resources in non-TCG mode
Do not allocate TCG-only resources like the translation buffer whenrunning over KVM or XEN. Saves a "few" bytes in the qemu address spaceand is also conceptually cleaner.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
exec.h cleanup
Move softmmu_exec.h include directives from target-*/exec.h totarget-*/op_helper.c. Move also various other stuff only used inop_helper.c there.
Define global env in dyngen-exec.h.
For i386, move wrappers for segment and FPU helpers from user-exec.c...
Remove exec-all.h include directives
Most exec-all.h include directives are now useless, remove them.
Move cpu_has_work and cpu_pc_from_tb to cpu.h
Move functions cpu_has_work() and cpu_pc_from_tb() from exec.h to cpu.h. This isneeded by later patches.
exec.h: fix coding style and change cpu_has_work to return bool
Before the next patch, fix coding style of the areas affected.
Change the type of the return value from cpu_has_work() andqemu_cpu_has_work() to bool.
cpu_loop_exit: avoid using AREG0
Make cpu_loop_exit() take a parameter for CPUState instead of relyingon global env.
Fix fallouts from Linux header inclusion
This is an all-in-one fix for the smaller and bigger mistakes of thebuild system changes for accompanied Linux headers: - only enable KVM and vhost on Linux hosts - fix powerpc asm header symlink - do not use Linux headers on non-Linux hosts...
Switch build system to accompanied kernel headers
This helps reducing our build-time checks for feature support in theavailable Linux kernel headers. And it helps users that do not havesufficiently recent headers installed on their build machine.
Consequently, the patch removes and build-time checks for kvm and vhost...
target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Alexander Graf <agraf@suse.de>
target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90
target-s390x: Add missing tcg_temp_free_i32()
s390x: free tmp explicitly in every opcode for disas_a5()
The disas_a5() function provided a TCG tmp variable which was populatedby the respective opcode implementations, but freed at the end of thefunction in generic code.
That makes it really hard for code review, so let's move the freeing...
s390x: fix cksm instruction
The cksm instruction was implemented incorrectly, rendering UDP and TCPchecksum calculation wrong, making an emulated s390x Linux guest breakin most networking operations.
This patch fixes odd end checksum calculation, takes the input register...
s390x: implement lrvgr
The LRVGR instruction was missing. Implement it, so everyone's happy.
Reported-by: Balazs Kutil <bkutil@novell.com>Signed-off-by: Alexander Graf <agraf@suse.de>
target-s390x: Fix build for non-linux hosts
linux/kvm.h is not always available for compilation.
Neither linux/kvm.h nor kvm.h are needed, so remove bothwhich also fixes the build problem for non-linux hosts.
Cc: Alexander Graf <agraf@suse.de>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
target-s390x: Fix wrong argument in call of tcg_gen_shl_i64()
tcg_gen_shl_i64 needs a 3rd argument of type TCGv_i64.Set tmp4 so it can be used here.
v2:Don't call tcg_const_i64() inside of the loopbecause it creates additional code.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
target-s390x: Fix duplicate call of tcg_temp_new_i64
tmp2 = tcg_temp_new_i64() is already executed unconditionally,so there is no need to call it a second time for 64 bit hosts.
target-s390x: Add missing tcg_temp_free_i64() in gen_jcc()
target-s390x: Add missing tcg_temp_free_i64() in do_mh()
target-s390x: Add missing tcg_temp_free_i64() in disas_b2()
s390x: Fix debugging for unknown sigp order codes
On unknown sigp order codes we print a debug message. This patchfixes the output, since we want to see the order_code and notthe register numbers.Patch applies on agraf tree.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>...
s390x: fix memory detection for guests > 64GB
the s390 memory detection has a 16bit field that specifies the amount ofincrements. This patch adopts the memory size to always fit into thatscheme. This also fixes virtio detection for these guests, since the...
s390x: fix smp support for kvm
Currently smp support for kvm does not work. Qemu does a kvm run even onsecondary CPUs which dont have a sane state (initial psw == 0)triggering some program faults. Architecturally these cpus are in the stoppedstate, so we should not do the kvm run ioctl. (these CPUs will be started...
s390x: make kvm exported functions conditional on kvm
We have some helper functions we use to directly invoke KVMfunctionality from device emulation code.
This patch replaces those exported functions with static inlinestubs when not building with KVM enabled....
s390x: keep hint on virtio managing size
The s390x virtio bus keeps management information on virtio after the topof the guest's RAM. We need to be able to tell the guest the size of itsRAM (without virtio stuff), but also be able to trap when the guest accesses...
s390x: Shift variables in CPUState for memset(0)
The default reset handler does a memset(0) until right in between CPU_COMMON.I incorrectly changed that behavior on the s390x port, so let's move the fieldsin CPUState around to reflect the correct split up to which point memset(0)...
s390x: helper functions for system emulation
When running system emulation, we need to transverse through the MMU anddeliver interrupts according to the specification.
This patch implements those two pieces and in addition adjusts the CPUinitialization code to account for the new fields in CPUState....
s390x: Implement opcode helpers
There are some instructions that can't (or shouldn't) be expressed by puretcg code. For those, we call into externally compiled C functions.
This patch implements those C functions.
s390x: Adjust internal kvm code
We're now finally emulating an s390x CPU, so we can move quite some logicfrom the kvm code out into generic CPU code.
This patch does this and adjusts the interfaces according to what the codearound now expects to be able to call....
s390x: translate engine for s390x CPU
This is the main meat part of the patch set. It implements emulation for ans390x CPU.
The code does all the optimizations that are common for TCG code:
- direct branches - cc optimization - unrolling of simple microcode loops...
s390x: remove compatibility cc field
Remove the now unused cc field that was only required to not breakbisectability.
Remove unused function parameter from cpu_restore_state
The previous patch removed the need for parameter puc.Is is now unused, so remove it.
Cc: Aurelien Jarno <aurelien@aurel32.net>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Remove unused function parameters from gen_pc_load and rename the function
Function gen_pc_load was introduced in commitd2856f1ad4c259e5766847c49acbb4e390731bd4.The only reason for parameter searched_pc wasa debug statement in target-i386/translate.c....
s390x: Enable s390x-softmmu target
This patch adds some code paths for running s390x guest OSs without theneed for KVM.
Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
s390x: Prepare cpu.h for emulation
We need to add some more logic to the CPU description to leverage emulationof an s390x CPU. This patch adds all the required helpers, fields in CPUStateand constant definitions required for user and system emulation....
s390x: fix KVM target
During Jan's rework of the generic KVM layer, he added some more error checksand actually aborted if something went wrong. Unfortunately, one of the s390internal error codes slipped through, aborting the VM without needing to.
This patch fixes booting of S390x virtual machines in KVM....
kvm: Align kvm_arch_handle_exit to kvm_cpu_exec changes
Make the return code of kvm_arch_handle_exit directly usable forkvm_cpu_exec. This is straightforward for x86 and ppc, just s390would require more work. Avoid this for now by pushing the return code...
kvm: Rename kvm_arch_process_irqchip_events to async_events
We will broaden the scope of this function on x86 beyond irqchip events.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
inline cpu_halted into sole caller
All implementations are now the same, and there is only one caller,so inline the function there.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
always qemu_cpu_kick after unhalting a cpu
This ensures env->halt_cond is broadcast, and the loop inqemu_tcg_wait_io_event and qemu_kvm_wait_io_event is exitednaturally rather than through a timeout.
kvm: Drop return values from kvm_arch_pre/post_run
We do not check them, and the only arch with non-empty implementationsalways returns 0 (this is also true for qemu-kvm).
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>CC: Alexander Graf <agraf@suse.de>...
kvm: Provide sigbus services arch-independently
Provide arch-independent kvm_on_sigbus* stubs to remove the #ifdef'eryfrom cpus.c. This patch also fixes --disable-kvm build by providing themissing kvm_on_sigbus_vcpu kvm-stub.
Merge remote branch 'qemu-kvm/uq/master' into staging
aliguori: fix build with !defined(KVM_CAP_ASYNC_PF)
Delete useless 'extern' qualifiers for functions
'extern' qualifier is useless for function declarations. Deletethem.
kvm: Consolidate must-have capability checks
Instead of splattering the code with #ifdefs and runtime checks forcapabilities we cannot work without anyway, provide central testinfrastructure for verifying their availability both at build andruntime.
kvm: Drop smp_cpus argument from init functions
No longer used.
s390: compile fixes
The s390 target doesn't compile out of the box anymore. This patch fixes allthe obvious glitches that got introduced in the last few weeks.
target-xxx: Use fprintf_function (format checking)
fprintf_function uses format checking with GCC_FMT_ATTR.
Cc: Blue Swirl <blauwirbel@gmail.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
remove exec-all.h inclusion from cpu.h
move cpu_pc_from_tb to target-*/exec.h
target-s390: enable SIGP Initial Reset
For SMP to work with KVM, we need to properly emulate the SIGP Initial ResetCommand. Recent (2.6.32) kernels issue that before the SIGP Reset command thatactually wakes up the vcpu.
This patch makes -smp work on S390x....
Do not stop VM if emulation failed in userspace.
Continue vcpu execution in case emulation failure happened while vcpuwas in userspace. In this case #UD will be injected into the guestallowing guest OS to kill offending process and continue.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
kvm: enable smp > 1
Process INIT/SIPI requests and enable -smp > 1.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
S390: Add stub for cpu_get_phys_page_debug
We don't implement any virtual memory in the S390 target so far, so let'sadd a stub for this now mandatory function.
Fixes building of S390 target.
Large page TLB flush
QEMU uses a fixed page size for the CPU TLB. If the guest uses largepages then we effectively split these into multiple smaller pages, andpopulate the corresponding TLB entries on demand.
When the guest invalidates the TLB by virtual address we must invalidate...
Remove cpu_get_phys_page_debug from userspace emulation
cpu_get_phys_page_debug makes no sense for userspace emulation, so remove it.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Move TARGET_PHYS_ADDR_SPACE_BITS to target-*/cpu.h.
Removes a set of ifdefs from exec.c.
Introduce TARGET_VIRT_ADDR_SPACE_BITS for all targets otherthan Alpha. This will be used for page_find_alloc, which issupposed to be using virtual addresses in the first place....
Update to a hopefully more future proof FSF address
See also 8167ee883931cb20c6264fc19d040ce2dc6ceaaa,530e7615ce3c01882e582c84dc6304ab98a3d5c5 andfad6cb1a565bb73f83fc0e2654489457b489e436.
KVM: Rework VCPU state writeback API
This grand cleanup drops all reset and vmsave/load relatedsynchronization points in favor of four(!) generic hooks:
- cpu_synchronize_all_states in qemu_savevm_state_complete (initial sync from kernel before vmsave)...
Fix incorrect exception_index use
env->exception_index should be cleared with -1, not 0.
See also 821b19fe923ac49a24cdb4af902584fdd019cee6.
Spotted by Igor Kovalenko.
kill regs_to_env and env_to_regs
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
target-s390: Fail on unknown instructions
We were being a bit too nice and didn't give the guest an invalid instructioninterrupt.
While that works, it's not exactly the fastest thing to do, since now theguest doesn't know that we're not really implementing that instruction, so it...
Add support for S390x system emulation
Let's enable the basics for system emulation so we can run virtual machineswith KVM!
Add KVM support for S390x
S390x was one of the first platforms that received support for KVM back in theday. Unfortunately until now there hasn't been a qemu implementation that wouldenable users to actually run guests.
So let's include support for KVM S390x in qemu!...
S/390 CPU fake emulation
Because Qemu currently requires a TCG target to exist and there are quite someuseful helpers here to lay the groundwork for out KVM target, let's create astub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work...