summaryrefslogtreecommitdiffstats
path: root/arch
Commit message (Collapse)AuthorAgeFilesLines
* KVM: PPC: PV assembler helpersAlexander Graf2010-10-241-0/+30
| | | | | | | | | | | | | | When we hook an instruction we need to make sure we don't clobber any of the registers at that point. So we write them out to scratch space in the magic page. To make sure we don't fall into a race with another piece of hooked code, we need to disable interrupts. To make the later patches and code in general easier readable, let's introduce a set of defines that save and restore r30, r31 and cr. Let's also define some helpers to read the lower 32 bits of a 64 bit field on 32 bit systems. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Introduce branch patching helperAlexander Graf2010-10-241-0/+14
| | | | | | | | | | | We will need to patch several instruction streams over to a different code path, so we need a way to patch a single instruction with a branch somewhere else. This patch adds a helper to facilitate this patching. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Introduce kvm_tmp frameworkAlexander Graf2010-10-241-2/+40
| | | | | | | | | | | | | | | | We will soon require more sophisticated methods to replace single instructions with multiple instructions. We do that by branching to a memory region where we write replacement code for the instruction to. This region needs to be within 32 MB of the patched instruction though, because that's the furthest we can jump with immediate branches. So we keep 1MB of free space around in bss. After we're done initing we can just tell the mm system that the unused pages are free, but until then we have enough space to fit all our code in. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: PV tlbsync to nopAlexander Graf2010-10-241-0/+12
| | | | | | | | With our current MMU scheme we don't need to know about the tlbsync instruction. So we can just nop it out. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: PV instructions to loads and storesAlexander Graf2010-10-241-0/+109
| | | | | | | | | | Some instructions can simply be replaced by load and store instructions to or from the magic page. This patch replaces often called instructions that fall into the above category. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: KVM PV guest stubsAlexander Graf2010-10-241-0/+95
| | | | | | | | | | | | We will soon start and replace instructions from the text section with other, paravirtualized versions. To ease the readability of those patches I split out the generic looping and magic page mapping code out. This patch still only contains stubs. But at least it loops through the text section :). Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Generic KVM PV guest supportAlexander Graf2010-10-245-1/+65
| | | | | | | | | | | We have all the hypervisor pieces in place now, but the guest parts are still missing. This patch implements basic awareness of KVM when running Linux as guest. It doesn't do anything with it yet though. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: Move kvm_guest_init out of generic codeAlexander Graf2010-10-241-0/+6
| | | | | | | | | | | | Currently x86 is the only architecture that uses kvm_guest_init(). With PowerPC we're getting a second user, but the signature is different there and we don't need to export it, as it uses the normal kernel init framework. So let's move the x86 specific definition of that function over to the x86 specfic header file. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Expose magic page support to guestAlexander Graf2010-10-242-0/+13
| | | | | | | | Now that we have the shared page in place and the MMU code knows about the magic page, we can expose that capability to the guest! Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Magic Page Book3s supportAlexander Graf2010-10-246-12/+81
| | | | | | | | | | | We need to override EA as well as PA lookups for the magic page. When the guest tells us to project it, the magic page overrides any guest mappings. In order to reflect that, we need to hook into all the MMU layers of KVM to force map the magic page if necessary. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: First magic page stepsAlexander Graf2010-10-241-0/+2
| | | | | | | | | | | | We will be introducing a method to project the shared page in guest context. As soon as we're talking about this coupling, the shared page is colled magic page. This patch introduces simple defines, so the follow-up patches are easier to read. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Make PAM a defineAlexander Graf2010-10-242-2/+5
| | | | | | | | | | | | | | | | On PowerPC it's very normal to not support all of the physical RAM in real mode. To check if we're matching on the shared page or not, we need to know the limits so we can restrain ourselves to that range. So let's make it a define instead of open-coding it. And while at it, let's also increase it. Signed-off-by: Alexander Graf <agraf@suse.de> v2 -> v3: - RMO -> PAM (non-magic page) Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Tell guest about pending interruptsAlexander Graf2010-10-243-0/+15
| | | | | | | | | | | | When the guest turns on interrupts again, it needs to know if we have an interrupt pending for it. Because if so, it should rather get out of guest context and get the interrupt. So we introduce a new field in the shared page that we use to tell the guest that there's a pending interrupt lying around. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Add PV guest scratch registersAlexander Graf2010-10-241-0/+3
| | | | | | | | | | While running in hooked code we need to store register contents out because we must not clobber any registers. So let's add some fields to the shared page we can just happily write to. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Add PV guest critical sectionsAlexander Graf2010-10-243-2/+32
| | | | | | | | | | | | When running in hooked code we need a way to disable interrupts without clobbering any interrupts or exiting out to the hypervisor. To achieve this, we have an additional critical field in the shared page. If that field is equal to the r1 register of the guest, it tells the hypervisor that we're in such a critical section and thus may not receive any interrupts. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Implement hypervisor interfaceAlexander Graf2010-10-247-4/+232
| | | | | | | | | | | | | | To communicate with KVM directly we need to plumb some sort of interface between the guest and KVM. Usually those interfaces use hypercalls. This hypercall implementation is described in the last patch of the series in a special documentation file. Please read that for further information. This patch implements stubs to handle KVM PPC hypercalls on the host and guest side alike. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Convert SPRG[0-4] to shared pageAlexander Graf2010-10-245-28/+36
| | | | | | | | | | | When in kernel mode there are 4 additional registers available that are simple data storage. Instead of exiting to the hypervisor to read and write those, we can just share them with the guest using the page. This patch converts all users of the current field to the shared page. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Convert SRR0 and SRR1 to shared pageAlexander Graf2010-10-247-23/+28
| | | | | | | | | | | | | | | The SRR0 and SRR1 registers contain cached values of the PC and MSR respectively. They get written to by the hypervisor when an interrupt occurs or directly by the kernel. They are also used to tell the rfi(d) instruction where to jump to. Because it only gets touched on defined events that, it's very simple to share with the guest. Hypervisor and guest both have full r/w access. This patch converts all users of the current field to the shared page. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Convert DAR to shared page.Alexander Graf2010-10-247-15/+15
| | | | | | | | | | | | The DAR register contains the address a data page fault occured at. This register behaves pretty much like a simple data storage register that gets written to on data faults. There is no hypervisor interaction required on read or write. This patch converts all users of the current field to the shared page. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Convert DSISR to shared pageAlexander Graf2010-10-245-10/+11
| | | | | | | | | | | The DSISR register contains information about a data page fault. It is fully read/write from inside the guest context and we don't need to worry about interacting based on writes of this register. This patch converts all users of the current field to the shared page. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Convert MSR to shared pageAlexander Graf2010-10-2418-84/+93
| | | | | | | | | | | | | | | One of the most obvious registers to share with the guest directly is the MSR. The MSR contains the "interrupts enabled" flag which the guest has to toggle in critical sections. So in order to bring the overhead of interrupt en- and disabling down, let's put msr into the shared page. Keep in mind that even though you can fully read its contents, writing to it doesn't always update all state. There are a few safe fields that don't require hypervisor interaction. See the documentation for a list of MSR bits that are safe to be set from inside the guest. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: PPC: Introduce shared pageAlexander Graf2010-10-246-1/+30
| | | | | | | | | | | | For transparent variable sharing between the hypervisor and guest, I introduce a shared page. This shared page will contain all the registers the guest can read and write safely without exiting guest context. This patch only implements the stubs required for the basic structure of the shared page. The actual register moving follows. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Fix nop emulationMohammed Gamal2010-10-241-1/+1
| | | | | | | | If a nop instruction is encountered, we jump directly to the done label. This skip updating rip. Break from the switch case instead Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: Decode memory operands directly into a 'struct operand'Avi Kivity2010-10-242-71/+57
| | | | | | | Since modrm operand can be either register or memory, decoding it into a 'struct operand', which can represent both, is simpler. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: change invlpg emulation to use src.mem.addrAvi Kivity2010-10-241-1/+1
| | | | | | Instead of using modrm_ea, which will soon be gone. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: switch LEA to use SrcMem decodingAvi Kivity2010-10-241-2/+2
| | | | | | The NoAccess flag will prevent memory from being accessed. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: add NoAccess flag for memory instructions that skip accessAvi Kivity2010-10-241-2/+4
| | | | | | Use for INVLPG, which accesses the tlb, not memory. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use struct operand for mov reg,dr and mov dr,reg for reg opAvi Kivity2010-10-241-5/+4
| | | | | | | This is an ordinary modrm source or destination; use the standard structure representing it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use struct operand for mov reg,cr and mov cr,reg for reg opAvi Kivity2010-10-241-5/+4
| | | | | | | This is an ordinary modrm source or destination; use the standard structure representing it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: mark mov cr and mov dr as 64-bit instructions in long modeAvi Kivity2010-10-241-2/+2
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: introduce Op3264 for mov cr and mov dr instructionsAvi Kivity2010-10-241-0/+8
| | | | | | | The operands for these instructions are 32 bits or 64 bits, depending on long mode, and ignoring REX prefixes, or the operand size prefix. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify REX.W checkAvi Kivity2010-10-241-3/+2
| | | | | | (x && (x & y)) == (x & y) Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: drop use_modrm_eaAvi Kivity2010-10-242-2/+0
| | | | | | Unused (and has never been). Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: put register operand fetch into a functionAvi Kivity2010-10-241-40/+21
| | | | | | The code is repeated three times, put it into fetch_register_operand() Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use SrcAcc to simplify xchg decodingAvi Kivity2010-10-241-11/+4
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: simplify xchg decode tablesAvi Kivity2010-10-241-1/+1
| | | | | | Use X8() to avoid repetition. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: use correct type for memory address in operandsAvi Kivity2010-10-242-61/+61
| | | | | | | | | | Currently we use a void pointer for memory addresses. That's wrong since these are guest virtual addresses which are not directly dereferencable by the host. Use the correct type, unsigned long. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: push segment override out of decode_modrm()Avi Kivity2010-10-242-4/+7
| | | | | | Let it compute modrm_seg instead, and have the caller apply it. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Check for asid != 0 on nested vmrunJoerg Roedel2010-10-241-0/+3
| | | | | | | | This patch lets a nested vmrun fail if the L1 hypervisor left the asid zero. This fixes the asid_zero unit test. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: SVM: Check for nested vmrun intercept before emulating vmrunJoerg Roedel2010-10-241-0/+19
| | | | | | | | | This patch lets the nested vmrun fail if the L1 hypervisor has not intercepted vmrun. This fixes the "vmrun intercept check" unit test. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: mark page dirty only when page is really writtenXiao Guangrong2010-10-241-19/+28
| | | | | | | | Mark page dirty only when this page is really written, it's more exacter, and also can fix dirty page marking in speculation path Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: move bits lost judgement into a separate functionXiao Guangrong2010-10-241-3/+17
| | | | | | | | | Introduce spte_has_volatile_bits() function to judge whether spte bits will miss, it's more readable and can help us to cleanup code later Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: MMU: using kvm_set_pfn_accessed() instead of mark_page_accessed()Xiao Guangrong2010-10-241-1/+1
| | | | | | | | It's a small cleanup that using using kvm_set_pfn_accessed() instead of mark_page_accessed() Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: check io permissions only once for string pioGleb Natapov2010-10-243-0/+8
| | | | | | | Do not recheck io permission on every iteration. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: fix LMSW able to clear cr0.peAvi Kivity2010-10-241-1/+1
| | | | | | LMSW is documented not to be able to clear cr0.pe; make it so. Signed-off-by: Avi Kivity <avi@redhat.com>
* KVM: x86 emulator: don't update vcpu state if instruction is restartedGleb Natapov2010-10-241-18/+13
| | | | | | | | No need to update vcpu state since instruction is in the middle of the emulation. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: convert some push instructions to direct decodeAvi Kivity2010-10-241-9/+9
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: allow repeat macro arguments to contain commasAvi Kivity2010-10-241-8/+8
| | | | | | | Needed for repeating instructions with execution functions. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move decode tables downwardsAvi Kivity2010-10-241-236/+236
| | | | | | | So they can reference execution functions. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* KVM: x86 emulator: move x86_decode_insn() downwardsAvi Kivity2010-10-241-372/+372
| | | | | | | No code changes. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
OpenPOWER on IntegriCloud