target-ppc: Some support for dumping TLB_EMB TLBs
Add mmubooke_dump_mmu().
TODO: Add printing of individual flags.
Signed-off-by: François Revol <revol@free.fr>[agraf: fix coding style]Signed-off-by: Alexander Graf <agraf@suse.de>
PPC: Fix up e500 cache size setting
When initializing the e500 code, we need to expose itscache line size for user and system mode, while the mmudetails are only interesting for system emulation.
Split the 2 switch statements apart, allowing us to #ifdef...
target-ppc/machine.c: Drop unnecessary ifdefs
machine.c is only compiled for softmmu targets, so checks for!defined(CONFIG_USER_ONLY) are unnecessary and can be dropped.
Signed-off-by: Juan Quintela <quintela@redhat.com>[AF: Use more verbose commit message suggested by PMM]...
target-ppc: Init dcache and icache size for e500 user mode
commit f7aa558396dd0f6b7a2b22c05cb503c655854102 pulled the dcache and icacheline size initialization inside of a '#if !defined(CONFIG_USER_ONLY)' block.This is not correct because instructions like 'dcbz' need the dcache size...
target-ppc: Fix type casts for w64 (uintptr_t)
This changes nothing for other hosts.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Andreas Färber <afaerber@suse.de>
target-ppc: QOM'ify CPU reset
Move code from cpu_state_reset() into ppc_cpu_reset().Reorder #include of helper_regs.h to use it in translate_init.c.
Adjust whitespace and add braces.
Signed-off-by: Andreas Färber <afaerber@suse.de>Acked-by: David Gibson <david@gibson.dropbear.id.au>
target-ppc: Start QOM'ifying CPU init
Move code not dependent on ppc_def_t from cpu_ppc_init() into an initfn.
target-ppc: QOM'ify CPU
Embed CPUPPCState as first member of PowerPCCPU.Distinguish between "powerpc-cpu", "powerpc64-cpu" and"embedded-powerpc-cpu".
Let CPUClass::reset() call cpu_state_reset() for now.
Signed-off-by: Andreas Färber <afaerber@suse.de>...
target-ppc: Add hooks for handling tcg and kvm limitations
On target-ppc, our table of CPU types and features encodes the features asfound on the hardware, regardless of whether these features are actuallyusable under TCG or KVM. We already have cases where the information from...
PPC: Fix TLB invalidation bug within the PPC interrupt handler.
Commit 41557447d30eeb944e42069513df13585f5e6c7f also introduced a subtle TLBflush bug. By applying a mask to the interrupt MSR which cleared the IR/DRbits at the start of the interrupt handler, the logic towards the end of the...
target-ppc: Drop cpu_ppc_close()
It is unused, so avoid QOM'ifying it unneededly.
Use uintptr_t for various op related functions
Use uintptr_t instead of void * or unsigned long inseveral op related functions, env->mem_io_pc andGETPC macro.
Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Replace Qemu by QEMU in comments
The official spelling is QEMU.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Andreas Färber <afaerber@suse.de>[blauwirbel@gmail.com: fixed comment style in hw/sun4m.c]Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
PPC: Fix large page support in TCG
Fix large page support in TCG. The old code would overwrite the large pagetable entry with the fake 4 KB one generated here whenever the ref/change bitswere updated, causing it to point to the wrong area of memory.
Signed-off-by: Nathan Whitehorn <nwhitehorn@freebsd.org>...
ppc: Correctly define POWERPC_INSNS2_DEFAULT
'POWERPC_INSNS2_DEFAULT' was defined incorrectly which was causing theopcode table creation code to erroneously register 'eieio' and 'mbar'for the "default" processor:
PPC: KVM: Synchronize regs on CPU dump
When we dump the CPU registers, there's a certain chance they haven't beensynchronized with KVM yet, so we have to manually trigger that.
This aligns the code with x86 and fixes a bug where the register state wasbogus on invalid/unknown kvm exit reasons....
pseries: Don't try to munmap() a malloc()ed TCE table
For the pseries machine, TCE (IOMMU) tables can either be directlymalloc()ed in qemu or, when running on a KVM which supports it, mmap()edfrom a KVM ioctl. The latter option is used when available, because it...
PPC64: Add support for ldbrx and stdbrx instructions
These instructions for loading and storing byte-swapped 64-bit values havebeen introduced in PowerISA 2.06.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>Signed-off-by: David Gibson <david@gibson.dropbear.id.au>...
PPC: Add PIR register to POWER7 CPU
The POWER7 emulation is missing the Processor Identification Register,mandatory in recent POWER CPUs, that is required for SMP on at leastsome operating systems (e.g. FreeBSD) to function properly. This patchcopies the existing PIR code from the other CPUs that implement it....
Rename CPUState -> CPUArchState
Scripted conversion: for file in .[hc] hw/.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do sed -i "s/CPUState/CPUArchState/g" $file done...
target-ppc: Don't overuse CPUState
Scripted conversion: sed -i "s/CPUState/CPUPPCState/g" target-ppc/*.[hc] sed -i "s/#define CPUPPCState/#define CPUState/" target-ppc/cpu.h
Signed-off-by: Andreas Färber <afaerber@suse.de>Acked-by: Anthony Liguori <aliguori@us.ibm.com>
PPC: 405: Use proper CPU reset
On ppc405ep there is a register that allows for software to reset thecore, but not the whole system. Implement this reset using a resetinterrupt.
This gets rid of a bunch of #if 0'ed code.
Reported-by: Andreas Färber <afaerber@suse.de>...
Rename cpu_reset() to cpu_state_reset()
Frees the identifier cpu_reset for QOM CPUs (manual rename).
Don't hide the parameter type behind explicit casts, use staticfunctions with strongly typed argument to indirect.
target-ppc: Clean includes
Remove some include statements which are not needed.
Acked-by: Alexander Graf <agraf@suse.de>Signed-off-by: Stefan Weil <sw@weilnetz.de>
ppc: remove unused variables
Fix this error:/src/qemu/target-ppc/helper.c: In function 'booke206_tlb_to_page_size':/src/qemu/target-ppc/helper.c:1296:14: error: variable 'tlbncfg' set but not used [-Werror=unused-but-set-variable]
Tested-by: Andreas Färber <afaerber@suse.de>...
PPC: E500: Populate L1CFG0 SPR
When running Linux on e500 with powersave-nap enabled, Linux tries toread out the L1CFG0 register and calculates some things from it. Passing0 there ends up in a division by 0, resulting in -1, resulting in badness.
So let's populate the L1CFG0 register with reasonable defaults. That way...
PPC: E500: Add doorbell defines
We're going to introduce doorbell instructions (called processorcontrol in the spec) soon. Add some defines for easier patchreadability later.
Signed-off-by: Alexander Graf <agraf@suse.de>
PPC: Add CPU feature for processor control
We're soon going to implement processor control features. Add thefeature flag, so we're well prepared.
PPC: Enable doorbell excp handlers
We already had all the code available to have doorbell exceptionsbe handled properly. It was just disabled.
Enable it, so we can rely on it.
PPC: E500: Implement msgclr
This patch implements the msgclr instruction. It is part of theEmbedded.Processor Control specification and clears pending doorbellinterrupts on the current CPU.
PPC: E500: Implement msgsnd
This patch implements the msgsnd instruction. It is part of theEmbedded.Processor Control specification and allows one CPU toIPI another CPU without going through an interrupt controller.
PPC: e500mc: Enable processor control
The e500mc implements Embedded.Processor Control, so enable it andthus enable guests to IPI each other. This makes -smp work with -cpue500mc.
PPC: booke: add tlbnps handling
When using MAV 2.0 TLB registers, we have another range of TLB registersavailable to read the supported page sizes from.
Add SPR definitions for those and add a helper function that we can useto receive such a bitmap even when using MAV 1.0....
PPC: booke206: Check for min/max TLB entry size
When setting a TLB entry, we need to check if the TLB we're putting it inactually supports the given size. According to the 2.06 PowerPC ISA, avalue that's out of range can either be redefined to something implementation...
PPC: booke206: Implement tlbilx
The PowerPC 2.06 BookE ISA defines an opcode called "tlbilx" which is usedto flush TLB entries. It's the recommended way of flushing in virtualizedenvironments.
So far we got away without implementing it, but Linux for e500mc uses this...
PPC: booke206: Check for TLB overrun
Our internal helpers to fetch TLB entries were not able to tell usthat an entry doesn't even exist. Pass an error out if we hit sucha case to not accidently pass beyond the TLB array.
PPC: booke206: move avail check to tlbwe
We can have TLBs that only support a single page size. This is definedby the absence of the AVAIL flag in TLBnCFG. If this is the case, wecurrently write invalid size info into the TLB, but override it oninternal fault....
PPC: E500: Add some more excp vectors
Our EXCP list is getting outdated. By now, 3 new exception vectors havebeen introduced. Update the list so we have everything at one place.
PPC: KVM: Update HIOR code to new interface
Unfortunately the HIOR setting code slipped into upstream QEMUbefore it was pulled into upstream KVM. And since Murphy is alwaysright, comments on the patches only emerged on the pull requestleading to changes in the interface....
PPC: Add IVOR 38-42
Our code only knows IVORs up to 37. Add the new ones defined in ISA 2.06from 38 - 42.
Signed-off-by: Alexander Graf <agraf@suse.de>Reviewed-by: Andreas Färber <afaerber@suse.de>
PPC: e500mc: add missing IVORs to bitmap
E500mc supports IVORs 36-41. Add them to the support mask. Drop SPEsupport too.
PPC: e500: msync is 440 only, e500 has real sync
The e500 CPUs don't use 440's msync which falls on the same opcode IDs,but instead use the real powerpc sync instruction. This is important,since the invalid mask differs between the two.
PPC: rename msync to msync_4xx
The msync instruction as defined today is only valid on 4xx cores, noton e500 which also supports msync, but treats it the same way as sync.
Rename it to reflect that it's 4xx only.
PPC: booke206: allow NULL raddr in ppcmas_tlb_check
We might want to call the tlb check function without actually caring aboutthe real address resolution. Check if we really should write the valueback.
PPC: Enable 440EP CPU target
Now that we have 440 TLB emulation, we can also support running the 440EPCPU target in system emulation mode.
kvm: fix build error in ppc kvm due to memory_region_init_ram_ptr() change
Commit c5705a772 ("vmstate, memory: decouple vmstate from memory API") changedthe signature of memory_region_init_ram_ptr() but did not update a caller inthe ppc kvm module. Fix....
PPC: Add description for the Freescale e500mc core.
This core is found on chips such as p4080, p3041, p2040, and p5020.
More needs to be done to make this viable for TCG (such as missing SPRsand instructions), but this suffices to get KVM running with appropriate...
kvm-ppc: halt secondary cpus when guest reset
When guest reset, we need to halt secondary cpus until guest kick them.This already works for tcg. The patch add the support for kvm.
Signed-off-by: Liu Yu <yu.liu@freescale.com>Signed-off-by: Alexander Graf <agraf@suse.de>...
PPC: monitor: add ability to dump SLB entries
When run with a PPC Book3S (server) CPU Currently 'info tlb' in theqemu monitor reports "dump_mmu: unimplemented". However, duringbringup work, it can be quite handy to have the SLB entries, which areavailable in the CPUPPCState. This patch adds an implementation of...
fix spelling in target sub directory
Cc: Richard Henderson <rth@twiddle.net>Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>Cc: Aurelien Jarno <aurelien@aurel32.net>Cc: Alexander Graf <agraf@suse.de>Cc: Aurelien Jarno <aurelien@aurel32.net>Cc: Blue Swirl <blauwirbel@gmail.com>...
PPC: Fix for the gdb single step problem on an rfi instruction
When using gdb to single step a ppc interrupt routine, the executionflow passes the rfi instruction without actually returning from theinterrupt.
The patch fixes this by avoiding to update the nip when the debug...
ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
The CPU state contains two bitmaps, initialized from the CPU specwhich describes which instructions are implemented on the CPU. Acouple of bits are defined which cover instructions (VSX and DFP)...
ppc: Fix up usermode only builds
The recent usage of MemoryRegion in kvm_ppc.h breaks builds withCONFIG_USER_ONLY=y. This patch fixes it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>Signed-off-by: Alexander Graf <agraf@suse.de>
KVM: PPC: Override host vmx/vsx/dfp only when information known
The -cpu host feature tries to find out the host capabilities basedon device tree information. However, we don't always have that availablebecause it's an optional property in dt.
So instead of force unsetting values depending on an unreliable source...
pseries: Allow writes to KVM accelerated TCE table
Sufficiently recent kernels include a KVM call to accelerate use ofPAPR TCE tables (IOMMU), which are used by PAPR virtual IO devices.This involves qemu mapping the TCE table in from a kernel obtained fd,...
PPC: Disable non-440 CPUs for ppcemb target
The sole reason we have the ppcemb target is to support MMUs that haveless than the usual 4k possible page size. There are very few of thesechips and I don't want to add additional QA and testing burden to everyone...
pseries: Correct vmx/dfp handling in both KVM and TCG cases
Currently, when KVM is enabled, the pseries machine checks if the hostCPU supports VMX, VSX and/or DFP instructions and advertisesaccordingly in the guest device tree. It does this regardless of what...
PPC: Bump qemu-system-ppc to 64-bit physical address space
Some 32-bit PPC CPUs can use up to 36 bit of physical address space.Treat them accordingly in the qemu-system-ppc binary type.
ppc: Remove broken partial PVR matching
The ppc target contains a ppc_find_by_pvr() function, which looks up aCPU spec based on a PVR (that is, based on the value in the target cpu'sProcessor Version Register). PVR values contain information on both the...
ppc: First cut implementation of -cpu host
For convenience with kvm, x86 allows the user to specify -cpu host on theqemu command line, which means make the guest cpu the same as the hostcpu. This patch implements the same option for ppc targets.
For now, this just read the host PVR (Processor Version Register) and...
ppc: Add cpu defs for POWER7 revisions 2.1 and 2.3
This patch adds cpu specs to the table for POWER7 revisions 2.1 and 2.3.This allows -cpu host to be used on these host cpus.
pseries: Support SMT systems for KVM Book3S-HV
Alex Graf has already made qemu support KVM for the pseries machinewhen using the Book3S-PR KVM variant (which runs the guest inusermode, emulating supervisor operations). This code allows gets usvery close to also working with KVM Book3S-HV (using the hypervisor...
pseries: Allow KVM Book3S-HV on PPC970 CPUS
At present, using the hypervisor aware Book3S-HV KVM will only workwith qemu on POWER7 CPUs. PPC970 CPUs also have hypervisorcapability, but they lack the VRMA feature which makes assigning guestmemory easier....
pseries: Use Book3S-HV TCE acceleration capabilities
The pseries machine of qemu implements the TCE mechanism used as avirtual IOMMU for the PAPR defined virtual IO devices. Because thePAPR spec only defines a small DMA address space, the guest VIOdrivers need to update TCE mappings very frequently - the virtual...
Set an invalid-bits mask for each SPE instructions
SPE instructions are defined by pairs. Currently, the invalid-bits mask is setfor the first instruction, but the second one can have a different mask.
example:GEN_SPE(efdcmpeq, efdcfs, 0x17, 0x0B, 0x00600000, 0x00180000, PPC_SPE_DOUBLE),...
ppc: Generalize the kvmppc_get_clockfreq() function
Currently the kvmppc_get_clockfreq() function reads the host's clockfrequency from /proc/device-tree, which is useful to past to the guestin KVM setups. However, there are some other host propertiesadvertised in the device tree which can also be relevant to the...
pseries: Add device tree properties for VMX/VSX and DFP under kvm
Sufficiently recent PAPR specifications define properties "ibm,vmx" and "ibm,dfp" on the CPU node which advertise whether the VMX vectorextensions (or the later VSX version) and/or the Decimal Floating...
PPC: booke timers
While working on the emulation of the freescale p2010 (e500v2) I realized thatthere's no implementation of booke's timers features. Currently mpc8544 usesppc_emb (ppc_emb_timers_init) which is close but not exactly like booke (forexample booke uses different SPR)....
KVM: PPC: Use HIOR setting for -M pseries with PR KVM
When running with PR KVM, we need to set HIOR directly. Thankfully thereis now a new interface to set registers individually so we can just use thatand poke HIOR into the guest vcpu's HIOR register....
Gdbstub: handle read of fpscr
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>Signed-off-by: Alexander Graf <agraf@suse.de>
kvm: ppc: booke206: use MMU API
Share the TLB array with KVM. This allows us to set the initial TLBboth on initial boot and reset, is useful for debugging, and couldeventually be used to support migration.
Signed-off-by: Scott Wood <scottwood@freescale.com>...
ppc: booke206: add "info tlb" support
Signed-off-by: Scott Wood <scottwood@freescale.com>Signed-off-by: Alexander Graf <agraf@suse.de>
ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages
This definition is backward compatible with MAV=1.0 as long asthe guest does not set reserved bits in MAS1/MAS4.
Also, fix the shift in booke206_tlb_to_page_size -- it's the basethat should be able to hold a 4G page size, not the shift count....
Implement POWER7's CFAR in TCG
This patch implements support for the CFAR SPR on POWER7 (Come FromAddress Register), which snapshots the PC value at the time of a branch oran rfid. The latest powerpc-next kernel also catches it and can show it inxmon or in the signal frames....
PPC: Enable to use PAPR with PR style KVM
When running PR style KVM, we need to tell the kernel that we wantto run in PAPR mode now. This means that we need to pass some moreregister information down and enable papr mode. We also need to alignthe HTAB to htab_size boundary....
PPC: KVM: Remove kvmppc_read_host_property
We just got rid of the last user of kvmppc_read_host_property, so wecan now safely remove it.
PPC: KVM: Add stubs for kvm helper functions
We have a bunch of helper functions that don't have any stubs for them in casewe don't have CONFIG_KVM enabled. That didn't bite us so far, because gcc canoptimize them out pretty well, but we should really provide them....
PPC: bamboo: Move host fdt copy to target
We have some code in generic kvm_ppc.c that is only used by 440. Move tothe 440 specific device code.
PPC: KVM: Add generic function to read host clockfreq
We need to find out the host's clock-frequency when running on KVM, solet's export a respective function.
v1 -> v2:
- enable 64bit values
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>
core: remove qemu_service_io
qemu_service_io was mainly an alias to qemu_notify_event,currently used only by PPC for timer hack, so callqemu_notify_event directly.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
PPC: E500: Add ESR bit definitions
The BookE spec specifies a number of ESR bits. Add defines for themso we can use them later on.
Reported-by: Jason Wessel <jason.wessel@windriver.com>Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
PPC: E500: Inject SPE exception on invalid SPE access
When accessing an SPE instruction despite it being not available,throw an SPE exception instead of an APU exception. That way theguest knows what's going on and actually uses SPE.
Reported-by: Jason Wessel <jason.wessel@windriver.com>...
PPC: E500: Set ESR values
When an exception occurs on BookE, we need to set ESR bits to exposeto the guest information on what exactly happened. Add the obvious ones.
Reported-by: Jason Wessel <jason.wessel@windriver.com>Signed-off-by: Alexander Graf <agraf@suse.de>...
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...
target-alpha, target-ppc: Remove unnecessary setjmp.h include
Remove the include of setjmp.h from the cpu.h of target-alphaand target-ppc. This is unnecessary because cpu-defs.h alreadyincludes this header; this change brings these two targetsinto line with all the rest....
Merge branch 'ppc-next' of git://repo.or.cz/qemu/agraf
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.
kvm: ppc: Drop KVM_CAP build dependencies
No longer needed with accompanied kernel headers.
CC: Alexander Graf <agraf@suse.de>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Reviewed-by: Alexander Graf <agraf@suse.de>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: ppc: Drop CONFIG_KVM_PPC_PVR
Required header support is now unconditionally available.
PPC: move TLBs to their own arrays
Until now, we've created a union over multiple different TLB types andallocated that union. While it's a waste of memory (and cache) to allocateTLB information for a TLB type with much information when you only needlittle, it also inflicts another issue....
PPC: E500: Use MAS registers instead of internal TLB representation
The natural format for e500 cores to do TLB manipulation with are the MASregisters. Instead of converting them into some internal representationand back again when the guest reads them, we can just keep the data...
PPC: Only set lower 32bits with mtmsr
As Nathan pointed out correctly, the mtmsr instruction does not modifythe high 32 bits of MSR. It also doesn't matter if SF is set or not,the instruction always behaves the same.
This patch moves it a bit closer to the spec....