aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-01-07KVM: s390: implement the RI support of guestFan Zhang4-1/+28
This patch adds runtime instrumentation support for KVM guest. We need to setup a save area for the runtime instrumentation-controls control block(RICCB) and implement the necessary interfaces to live migrate the guest settings. We setup the sie control block in a way, that the runtime instrumentation instructions of a guest are handled by hardware. We also add a capability KVM_CAP_S390_RI to make this feature opt-in as it needs migration support. Signed-off-by: Fan Zhang <[email protected]> Acked-by: Cornelia Huck <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2016-01-07kvm/s390: drop unpaired smp_mbMichael S. Tsirkin1-1/+0
smp_mb on vcpu destroy isn't paired with anything, violating pairing rules, and seems to be useless. Drop it. Signed-off-by: Michael S. Tsirkin <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-12-16Merge tag 'kvm-s390-next-4.5-2' of ↵Paolo Bonzini7-18/+50
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD KVM: s390 features and fixes for 4.5 (kvm/next) Some small cleanups - use assignment instead of memcpy - use %pK for kernel pointers Changes regarding guest memory size - Fix an off-by-one error in our guest memory interface (we might use unnecessarily big page tables, e.g. 3 levels for a 2GB guest instead of 2 levels) - We now ask the machine about the max. supported guest address and limit accordingly.
2015-12-15KVM: s390: consider system MHA for guest storageGuenther Hutzl2-2/+12
Verify that the guest maximum storage address is below the MHA (maximum host address) value allowed on the host. Acked-by: Michael Holzheu <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Guenther Hutzl <[email protected]> Signed-off-by: Dominik Dingel <[email protected]> [adopt to match recent limit,size changes] Signed-off-by: Christian Borntraeger <[email protected]>
2015-12-15KVM: s390: fix mismatch between user and in-kernel guest limitDominik Dingel5-8/+27
While the userspace interface requests the maximum size the gmap code expects to get a maximum address. This error resulted in bigger page tables than necessary for some guest sizes, e.g. a 2GB guest used 3 levels instead of 2. At the same time we introduce KVM_S390_NO_MEM_LIMIT, which allows in a bright future that a guest spans the complete 64 bit address space. We also switch to TASK_MAX_SIZE for the initial memory size, this is a cosmetic change as the previous size also resulted in a 4 level pagetable creation. Reported-by: David Hildenbrand <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Dominik Dingel <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-12-15KVM: s390: obey kptr_restrict in tracesChristian Borntraeger2-7/+8
The s390dbf and trace events provide a debugfs interface. If kptr_restrict is active, we should not expose kernel pointers. We can fence the debugfs output by using %pK instead of %p. Cc: Kees Cook <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-12-15KVM: s390: use assignment instead of memcpyChristian Borntraeger1-2/+4
Replace two memcpy with proper assignment. Suggested-by: Paolo Bonzini <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Cornelia Huck <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-12-02Merge tag 'kvm-s390-next-4.5-1' of ↵Paolo Bonzini15-159/+407
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD KVM: s390 features, kvm_get_vcpu_by_id and stat Several features for s390 1. ESCA support (up to 248 vCPUs) 2. KVM detection: we can now detect if we support KVM (e.g. does KVM under KVM work?) kvm_stat: 1. cleanup the exit path kvm_get_vcpu_by_id: 1. Use kvm_get_vcpu_by_id where appropriate 2. Apply a heuristic to optimize for ID VCPU == No. VCPU
2015-11-30KVM: s390: remove redudant assigment of error codeChristian Borntraeger1-3/+1
rc already contains -ENOMEM, no need to assign it twice. Signed-off-by: Christian Borntraeger <[email protected]> Acked-by: Cornelia Huck <[email protected]> Reviewed-by: David Hildenbrand <[email protected]>
2015-11-30KVM: s390: remove pointless test_facility(2) checkHeiko Carstens1-1/+1
This evaluates always to 'true'. Signed-off-by: Heiko Carstens <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: don't load kvm without virtualization supportDavid Hildenbrand1-0/+5
If we don't have support for virtualization (SIE), e.g. when running under a hypervisor not supporting execution of the SIE instruction, we should immediately abort loading the kvm module, as the SIE instruction cannot be enabled dynamically. Currently, the SIE instructions fails with an exception on a non-SIE host, resulting in the guest making no progress, instead of failing hard. Reviewed-by: Cornelia Huck <[email protected]> Acked-by: Martin Schwidefsky <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30s390: show virtualization support in /proc/cpuinfoDavid Hildenbrand3-0/+22
This patch exposes the SIE capability (aka virtualization support) via /proc/cpuinfo -> "features" as "sie". As we don't want to expose this hwcap via elf, let's add a second, "internal"/non-elf capability list. The content is simply concatenated to the existing features when printing /proc/cpuinfo. We also add the defines to elf.h to keep the hwcap stuff at a common place. Acked-by: Martin Schwidefsky <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30s390/sclp: introduce check for SIEDavid Hildenbrand2-1/+6
This patch adds a way to check if the SIE with zArchitecture support is available. Acked-by: Martin Schwidefsky <[email protected]> Acked-by: Cornelia Huck <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: don't switch to ESCA for ucontrolDavid Hildenbrand1-1/+1
sca_add_vpcu is not called for ucontrol guests. We must also not apply the sca checking for sca_can_add_vcpu as ucontrol guests do not have to follow the sca limits. As common code already checks that id < KVM_MAX_VCPUS all other data structures are safe as well. Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: cleanup sca_add_vcpuDavid Hildenbrand1-12/+11
Now that we already have kvm and the VCPU id set for the VCPU, we can convert sda_add_vcpu to look much more like sda_del_vcpu. Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: always set/clear the SCA sda fieldDavid Hildenbrand1-8/+4
Let's always set and clear the sda when enabling/disabling a VCPU. Dealing with sda being set to something else makes no sense anymore as we enable a VCPU in the SCA now after it has been registered at the VM. Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: fix SCA related races and double useDavid Hildenbrand1-6/+5
If something goes wrong in kvm_arch_vcpu_create, the VCPU has already been added to the sca but will never be removed. Trying to create VCPUs with duplicate ids (e.g. after a failed attempt) is problematic. Also, when creating multiple VCPUs in parallel, we could theoretically forget to set the correct SCA when the switch to ESCA happens just before the VCPU is registered. Let's add the VCPU to the SCA in kvm_arch_vcpu_postcreate, where we can be sure that no duplicate VCPU with the same id is around and the VCPU has already been registered at the VM. We also have to make sure to update ECB at that point. Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: we always have a SCADavid Hildenbrand1-6/+1
Having no sca can never happen, even when something goes wrong when switching to ESCA. Otherwise we would have a serious bug. Let's remove this superfluous check. Acked-by: Dominik Dingel <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: fast path for sca_ext_call_pendingDavid Hildenbrand1-2/+4
If CPUSTAT_ECALL_PEND isn't set, we can't have an external call pending, so we can directly avoid taking the lock. Acked-by: Christian Borntraeger <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Enable up to 248 VCPUs per VMEugene (jno) Dvurechenski2-2/+3
This patch allows s390 to have more than 64 VCPUs for a guest (up to 248 for memory usage considerations), if supported by the underlaying hardware (sclp.has_esca). Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Introduce switching codeEugene (jno) Dvurechenski4-9/+103
This patch adds code that performs transparent switch to Extended SCA on addition of 65th VCPU in a VM. Disposal of ESCA is added too. The entier ESCA functionality, however, is still not enabled. The enablement will be provided in a separate patch. This patch also uses read/write lock protection of SCA and its subfields for possible disposal at the BSCA-to-ESCA transition. While only Basic SCA needs such a protection (for the swap), any SCA access is now guarded. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Make provisions for ESCA utilizationEugene (jno) Dvurechenski3-29/+106
This patch updates the routines (sca_*) to provide transparent access to and manipulation on the data for both Basic and Extended SCA in use. The kvm.arch.sca is generalized to (void *) to handle BSCA/ESCA cases. Also the kvm.arch.use_esca flag is provided. The actual functionality is kept the same. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Introduce new structuresEugene (jno) Dvurechenski4-26/+70
This patch adds new structures and updates some existing ones to provide the base for Extended SCA functionality. The old sca_* structures were renamed to bsca_* to keep things uniform. The access to fields of SIGP controls were turned into bitfields instead of hardcoded bitmasks. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Provide SCA-aware helpers for VCPU add/delEugene (jno) Dvurechenski1-13/+31
This patch provides SCA-aware helpers to create/delete a VCPU. This is to prepare for upcoming introduction of Extended SCA support. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Generalize access to SIGP controlsEugene (jno) Dvurechenski1-27/+45
This patch generalizes access to the SIGP controls, which is a part of SCA. This is to prepare for upcoming introduction of Extended SCA support. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: Generalize access to IPTE controlsEugene (jno) Dvurechenski2-5/+10
This patch generalizes access to the IPTE controls, which is a part of SCA. This is to prepare for upcoming introduction of Extended SCA support. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30s390/sclp: introduce checks for ESCA and HVSEugene (jno) Dvurechenski2-1/+8
Introduce sclp.has_hvs and sclp.has_esca to provide a way for kvm to check whether the extended-SCA and the home-virtual-SCA facilities are available. Signed-off-by: Eugene (jno) Dvurechenski <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: s390: rewrite vcpu_post_run and drop out earlyDavid Hildenbrand2-42/+24
Let's rewrite this function to better reflect how we actually handle exit_code. By dropping out early we can save a few cycles. This especially speeds up sie exits caused by host irqs. Also, let's move the special -EOPNOTSUPP for intercepts to the place where it belongs and convert it to -EREMOTE. Reviewed-by: Dominik Dingel <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: Remove unnecessary debugfs dentry referencesJanosch Frank2-15/+4
KVM creates debugfs files to export VM statistics to userland. To be able to remove them on kvm exit it tracks the files' dentries. Since their parent directory is also tracked and since each parent direntry knows its children we can easily remove them by using debugfs_remove_recursive(kvm_debugfs_dir). Therefore we don't need the extra tracking in the kvm_stats_debugfs_item anymore. Signed-off-by: Janosch Frank <[email protected]> Reviewed-By: Sascha Silbe <[email protected]> Acked-by: Christian Borntraeger <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: use heuristic for fast VCPU lookup by idDavid Hildenbrand1-0/+5
Usually, VCPU ids match the array index. So let's try a fast lookup first before falling back to the slow iteration. Suggested-by: Christian Borntraeger <[email protected]> Reviewed-by: Dominik Dingel <[email protected]> Reviewed-by: Christian Borntraeger <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
2015-11-30KVM: Use common function for VCPU lookup by idDavid Hildenbrand3-23/+10
Let's reuse the new common function for VPCU lookup by id. Reviewed-by: Christian Borntraeger <[email protected]> Reviewed-by: Dominik Dingel <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]> [split out the new function into a separate patch]
2015-11-26KVM: x86: MMU: Remove unused parameter parent_pte from kvm_mmu_get_page()Takuya Yoshikawa2-15/+9
Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-26KVM: x86: MMU: Use for_each_rmap_spte macro instead of pte_list_walk()Takuya Yoshikawa1-21/+6
As kvm_mmu_get_page() was changed so that every parent pointer would not get into the sp->parent_ptes chain before the entry pointed to by it was set properly, we can use the for_each_rmap_spte macro instead of pte_list_walk(). Signed-off-by: Takuya Yoshikawa <[email protected]> Cc: Xiao Guangrong <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-26KVM: x86: MMU: Move parent_pte handling from kvm_mmu_get_page() to ↵Takuya Yoshikawa2-18/+11
link_shadow_page() Every time kvm_mmu_get_page() is called with a non-NULL parent_pte argument, link_shadow_page() follows that to set the parent entry so that the new mapping will point to the returned page table. Moving parent_pte handling there allows to clean up the code because parent_pte is passed to kvm_mmu_get_page() just for mark_unsync() and mmu_page_add_parent_pte(). In addition, the patch avoids calling mark_unsync() for other parents in the sp->parent_ptes chain than the newly added parent_pte, because they have been there since before the current page fault handling started. Signed-off-by: Takuya Yoshikawa <[email protected]> Cc: Xiao Guangrong <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Move initialization of parent_ptes out from kvm_mmu_alloc_page()Takuya Yoshikawa1-7/+7
Make kvm_mmu_alloc_page() do just what its name tells to do, and remove the extra allocation error check and zero-initialization of parent_ptes: shadow page headers allocated by kmem_cache_zalloc() are always in the per-VCPU pools. Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Consolidate BUG_ON checks for reverse-mapped sptesTakuya Yoshikawa2-11/+19
At some call sites of rmap_get_first() and rmap_get_next(), BUG_ON is placed right after the call to detect unrelated sptes which must not be found in the reverse-mapping list. Move this check in rmap_get_first/next() so that all call sites, not just the users of the for_each_rmap_spte() macro, will be checked the same way. One thing to keep in mind is that kvm_mmu_unlink_parents() also uses rmap_get_first() to handle parent sptes. The change will not break it because parent sptes are present, at least until drop_parent_pte() actually unlinks them, and not mmio-sptes. Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Remove is_rmap_spte() and use is_shadow_present_pte()Takuya Yoshikawa2-10/+5
is_rmap_spte(), originally named is_rmap_pte(), was introduced when the simple reverse mapping was implemented by commit cd4a4e5374110444 ("[PATCH] KVM: MMU: Implement simple reverse mapping"). At that point, its role was clear and only rmap_add() and rmap_remove() were using it to select sptes that need to be reverse-mapped. Independently of that, is_shadow_present_pte() was first introduced by commit c7addb902054195b ("KVM: Allow not-present guest page faults to bypass kvm") to do bypass_guest_pf optimization, which does not exist any more. These two seem to have changed their roles somewhat, and is_rmap_spte() just calls is_shadow_present_pte() now. Since using both of them without clear distinction just makes the code confusing, remove is_rmap_spte(). Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Make mmu_set_spte() return emulate valueTakuya Yoshikawa2-18/+19
mmu_set_spte()'s code is based on the assumption that the emulate parameter has a valid pointer value if set_spte() returns true and write_fault is not zero. In other cases, emulate may be NULL, so a NULL-check is needed. Stop passing emulate pointer and make mmu_set_spte() return the emulate value instead to clean up this complex interface. Prefetch functions can just throw away the return value. Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Add helper function to clear a bit in unsync child bitmapTakuya Yoshikawa1-18/+18
Both __mmu_unsync_walk() and mmu_pages_clear_parents() have three line code which clears a bit in the unsync child bitmap; the former places it inside a loop block and uses a few goto statements to jump to it. A new helper function, clear_unsync_child_bit(), makes the code cleaner. Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Remove unused parameter of __direct_map()Takuya Yoshikawa1-8/+4
Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: Encapsulate the type of rmap-chain head in a new structTakuya Yoshikawa3-104/+113
New struct kvm_rmap_head makes the code type-safe to some extent. Signed-off-by: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: powerpc: kvmppc_visible_gpa can be booleanYaowei Bai1-2/+2
In another patch kvm_is_visible_gfn is maken return bool due to this function only returns zero or one as its return value, let's also make kvmppc_visible_gpa return bool to keep consistent. No functional change. Signed-off-by: Yaowei Bai <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: kvm_para_has_feature can be booleanYaowei Bai1-4/+2
This patch makes kvm_para_has_feature return bool due to this particular function only using either one or zero as its return value. No functional change. Signed-off-by: Yaowei Bai <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: kvm_is_visible_gfn can be booleanYaowei Bai2-4/+4
This patch makes kvm_is_visible_gfn return bool due to this particular function only using either one or zero as its return value. No functional change. Signed-off-by: Yaowei Bai <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM-async_pf: Delete an unnecessary check before the function call ↵Markus Elfring1-2/+1
"kmem_cache_destroy" The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: MMU: always set accessed bit in shadow PTEsPaolo Bonzini2-8/+5
Commit 7a1638ce4220 ("nEPT: Redefine EPT-specific link_shadow_page()", 2013-08-05) says: Since nEPT doesn't support A/D bit, we should not set those bit when building the shadow page table. but this is not necessary. Even though nEPT doesn't support A/D bits, and hence the vmcs12 EPT pointer will never enable them, we always use them for shadow page tables if available (see construct_eptp in vmx.c). So we can set the A/D bits freely in the shadow page table. This patch hence basically reverts commit 7a1638ce4220. Cc: Yang Zhang <[email protected]> Cc: Takuya Yoshikawa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: correctly print #AC in tracesPaolo Bonzini1-1/+1
Poor #AC was so unimportant until a few days ago that we were not even tracing its name correctly. But now it's all over the place. Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: svm: add support for RDTSCPPaolo Bonzini1-1/+23
RDTSCP was never supported for AMD CPUs, which nobody noticed because Linux does not use it. But exactly the fact that Linux does not use it makes the implementation very simple; we can freely trash MSR_TSC_AUX while running the guest. Cc: Joerg Roedel <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25KVM: x86: expose MSR_TSC_AUX to userspacePaolo Bonzini1-5/+6
If we do not do this, it is not properly saved and restored across migration. Windows notices due to its self-protection mechanisms, and is very upset about it (blue screen of death). Cc: Radim Krcmar <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
2015-11-25kvm/x86: Hyper-V kvm exitAndrey Smetanin6-0/+67
A new vcpu exit is introduced to notify the userspace of the changes in Hyper-V SynIC configuration triggered by guest writing to the corresponding MSRs. Changes v4: * exit into userspace only if guest writes into SynIC MSR's Changes v3: * added KVM_EXIT_HYPERV types and structs notes into docs Signed-off-by: Andrey Smetanin <[email protected]> Reviewed-by: Roman Kagan <[email protected]> Signed-off-by: Denis V. Lunev <[email protected]> CC: Gleb Natapov <[email protected]> CC: Paolo Bonzini <[email protected]> CC: Roman Kagan <[email protected]> CC: Denis V. Lunev <[email protected]> CC: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>