*/
struct page *apic_access_page;
struct page *virtual_apic_page;
-@@ -6682,94 +6674,6 @@ static int handle_monitor(struct kvm_vcp
+@@ -6678,94 +6670,6 @@ static int handle_monitor(struct kvm_vcp
}
/*
* The following 3 functions, nested_vmx_succeed()/failValid()/failInvalid(),
* set the success or error code of an emulated VMX instruction, as specified
* by Vol 2B, VMX Instruction Reference, "Conventions".
-@@ -7082,6 +6986,12 @@ static int handle_vmon(struct kvm_vcpu *
+@@ -7078,6 +6982,12 @@ static int handle_vmon(struct kvm_vcpu *
return 1;
}
if (cpu_has_vmx_msr_bitmap()) {
vmx->nested.msr_bitmap =
(unsigned long *)__get_free_page(GFP_KERNEL);
-@@ -7104,9 +7014,6 @@ static int handle_vmon(struct kvm_vcpu *
+@@ -7100,9 +7010,6 @@ static int handle_vmon(struct kvm_vcpu *
vmx->vmcs01.shadow_vmcs = shadow_vmcs;
}
hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC,
HRTIMER_MODE_REL_PINNED);
vmx->nested.preemption_timer.function = vmx_preemption_timer_fn;
-@@ -7124,6 +7031,9 @@ out_cached_vmcs12:
+@@ -7120,6 +7027,9 @@ out_cached_vmcs12:
free_page((unsigned long)vmx->nested.msr_bitmap);
out_msr_bitmap:
return -ENOMEM;
}
-@@ -7209,7 +7119,7 @@ static void free_nested(struct vcpu_vmx
+@@ -7205,7 +7115,7 @@ static void free_nested(struct vcpu_vmx
vmx->vmcs01.shadow_vmcs = NULL;
}
kfree(vmx->nested.cached_vmcs12);
if (vmx->nested.apic_access_page) {
nested_release_page(vmx->nested.apic_access_page);
vmx->nested.apic_access_page = NULL;
-@@ -7225,7 +7135,7 @@ static void free_nested(struct vcpu_vmx
+@@ -7221,7 +7131,7 @@ static void free_nested(struct vcpu_vmx
vmx->nested.pi_desc = NULL;
}
}
/* Emulate the VMXOFF instruction */
-@@ -7259,8 +7169,6 @@ static int handle_vmclear(struct kvm_vcp
+@@ -7255,8 +7165,6 @@ static int handle_vmclear(struct kvm_vcp
vmptr + offsetof(struct vmcs12, launch_state),
&zero, sizeof(zero));
skip_emulated_instruction(vcpu);
nested_vmx_succeed(vcpu);
return 1;
-@@ -8049,10 +7957,11 @@ static bool nested_vmx_exit_handled(stru
+@@ -8045,10 +7953,11 @@ static bool nested_vmx_exit_handled(stru
/*
* The host physical addresses of some pages of guest memory
*
* Mark them dirty on every exit from L2 to prevent them from
* getting out of sync with dirty tracking.
-@@ -10221,7 +10130,6 @@ static int nested_vmx_run(struct kvm_vcp
+@@ -10212,7 +10121,6 @@ static int nested_vmx_run(struct kvm_vcp
struct vmcs12 *vmcs12;
struct vcpu_vmx *vmx = to_vmx(vcpu);
int cpu;
bool ia32e;
u32 msr_entry_idx;
-@@ -10361,17 +10269,13 @@ static int nested_vmx_run(struct kvm_vcp
+@@ -10352,17 +10260,13 @@ static int nested_vmx_run(struct kvm_vcp
* the nested entry.
*/
vmx_vcpu_put(vcpu);
vmx_vcpu_load(vcpu, cpu);
vcpu->cpu = cpu;
-@@ -10886,10 +10790,6 @@ static void nested_vmx_vmexit(struct kvm
+@@ -10877,10 +10781,6 @@ static void nested_vmx_vmexit(struct kvm
vm_exit_controls_reset_shadow(vmx);
vmx_segment_cache_clear(vmx);
--- /dev/null
+From 42cf014d38d8822cce63703a467e00f65d000952 Mon Sep 17 00:00:00 2001
+From: David Hildenbrand <david@redhat.com>
+Date: Wed, 25 Jan 2017 11:58:57 +0100
+Subject: KVM: nVMX: kmap() can't fail
+
+From: David Hildenbrand <david@redhat.com>
+
+commit 42cf014d38d8822cce63703a467e00f65d000952 upstream.
+
+kmap() can't fail, therefore it will always return a valid pointer. Let's
+just get rid of the unnecessary checks.
+
+Signed-off-by: David Hildenbrand <david@redhat.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/vmx.c | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -4756,10 +4756,6 @@ static int vmx_complete_nested_posted_in
+ return 0;
+
+ vapic_page = kmap(vmx->nested.virtual_apic_page);
+- if (!vapic_page) {
+- WARN_ON(1);
+- return -ENOMEM;
+- }
+ __kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page);
+ kunmap(vmx->nested.virtual_apic_page);
+
+@@ -9584,11 +9580,6 @@ static inline bool nested_vmx_merge_msr_
+ if (!page)
+ return false;
+ msr_bitmap_l1 = (unsigned long *)kmap(page);
+- if (!msr_bitmap_l1) {
+- nested_release_page_clean(page);
+- WARN_ON(1);
+- return false;
+- }
+
+ memset(msr_bitmap_l0, 0xff, PAGE_SIZE);
+
+ max_irr = find_last_bit((unsigned long *)vmx->nested.pi_desc->pir, 256);
+ if (max_irr != 256) {
vapic_page = kmap(vmx->nested.virtual_apic_page);
- if (!vapic_page) {
- WARN_ON(1);
-@@ -4770,6 +4789,8 @@ static void vmx_complete_nested_posted_i
+ __kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page);
+ kunmap(vmx->nested.virtual_apic_page);
+@@ -4766,6 +4785,8 @@ static void vmx_complete_nested_posted_i
vmcs_write16(GUEST_INTR_STATUS, status);
}
}
}
static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu)
-@@ -8026,6 +8047,18 @@ static bool nested_vmx_exit_handled(stru
+@@ -8022,6 +8043,18 @@ static bool nested_vmx_exit_handled(stru
vmcs_read32(VM_EXIT_INTR_ERROR_CODE),
KVM_ISA_VMX);
+ return;
vapic_page = kmap(vmx->nested.virtual_apic_page);
- if (!vapic_page) {
-@@ -4770,7 +4770,6 @@ static int vmx_complete_nested_posted_in
+ __kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page);
+@@ -4766,7 +4766,6 @@ static int vmx_complete_nested_posted_in
vmcs_write16(GUEST_INTR_STATUS, status);
}
}
}
static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu)
-@@ -10491,7 +10490,8 @@ static int vmx_check_nested_events(struc
+@@ -10482,7 +10481,8 @@ static int vmx_check_nested_events(struc
return 0;
}
case MSR_IA32_PRED_CMD:
if (!msr_info->host_initiated &&
!guest_cpuid_has_ibpb(vcpu))
-@@ -5243,6 +5304,7 @@ static void vmx_vcpu_reset(struct kvm_vc
+@@ -5239,6 +5300,7 @@ static void vmx_vcpu_reset(struct kvm_vc
u64 cr0;
vmx->rmode.vm86_active = 0;
vmx->soft_vnmi_blocked = 0;
-@@ -8828,6 +8890,15 @@ static void __noclone vmx_vcpu_run(struc
+@@ -8824,6 +8886,15 @@ static void __noclone vmx_vcpu_run(struc
vmx_arm_hv_timer(vcpu);
vmx->__launched = vmx->loaded_vmcs->launched;
asm(
/* Store host registers */
-@@ -8946,6 +9017,27 @@ static void __noclone vmx_vcpu_run(struc
+@@ -8942,6 +9013,27 @@ static void __noclone vmx_vcpu_run(struc
#endif
);
/* Eliminate branch target predictions from guest mode */
vmexit_fill_RSB();
-@@ -9505,7 +9597,7 @@ static inline bool nested_vmx_merge_msr_
+@@ -9501,7 +9593,7 @@ static inline bool nested_vmx_merge_msr_
unsigned long *msr_bitmap_l1;
unsigned long *msr_bitmap_l0 = to_vmx(vcpu)->nested.vmcs02.msr_bitmap;
/*
*
* 1. L0 gave a permission to L1 to actually passthrough the MSR. This
* ensures that we do not accidentally generate an L02 MSR bitmap
-@@ -9518,9 +9610,10 @@ static inline bool nested_vmx_merge_msr_
+@@ -9514,9 +9606,10 @@ static inline bool nested_vmx_merge_msr_
* the MSR.
*/
bool pred_cmd = msr_write_intercepted_l01(vcpu, MSR_IA32_PRED_CMD);
return false;
page = nested_get_page(vcpu, vmcs12->msr_bitmap);
-@@ -9559,6 +9652,12 @@ static inline bool nested_vmx_merge_msr_
+@@ -9550,6 +9643,12 @@ static inline bool nested_vmx_merge_msr_
}
}
case MSR_IA32_CR_PAT:
if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
-@@ -5200,6 +5213,8 @@ static int vmx_vcpu_setup(struct vcpu_vm
+@@ -5196,6 +5209,8 @@ static int vmx_vcpu_setup(struct vcpu_vm
++vmx->nmsrs;
}
static void free_kvm_area(void)
{
int cpu;
-@@ -6947,6 +6958,7 @@ static int handle_vmon(struct kvm_vcpu *
+@@ -6943,6 +6954,7 @@ static int handle_vmon(struct kvm_vcpu *
struct vmcs *shadow_vmcs;
const u64 VMXON_NEEDED_FEATURES = FEATURE_CONTROL_LOCKED
| FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
/* The Intel VMX Instruction Reference lists a bunch of bits that
* are prerequisite to running VMXON, most notably cr4.VMXE must be
-@@ -6986,11 +6998,9 @@ static int handle_vmon(struct kvm_vcpu *
+@@ -6982,11 +6994,9 @@ static int handle_vmon(struct kvm_vcpu *
return 1;
}
if (cpu_has_vmx_msr_bitmap()) {
vmx->nested.msr_bitmap =
-@@ -9111,17 +9121,15 @@ static struct kvm_vcpu *vmx_create_vcpu(
+@@ -9107,17 +9117,15 @@ static struct kvm_vcpu *vmx_create_vcpu(
if (!vmx->guest_msrs)
goto free_pml;
}
static bool vmx_get_enable_apicv(void)
-@@ -4980,7 +4983,7 @@ static void vmx_refresh_apicv_exec_ctrl(
+@@ -4976,7 +4979,7 @@ static void vmx_refresh_apicv_exec_ctrl(
}
if (cpu_has_vmx_msr_bitmap())
}
static u32 vmx_exec_control(struct vcpu_vmx *vmx)
-@@ -5069,7 +5072,7 @@ static int vmx_vcpu_setup(struct vcpu_vm
+@@ -5065,7 +5068,7 @@ static int vmx_vcpu_setup(struct vcpu_vm
vmcs_write64(VMWRITE_BITMAP, __pa(vmx_vmwrite_bitmap));
}
if (cpu_has_vmx_msr_bitmap())
vmcs_write64(VMCS_LINK_POINTER, -1ull); /* 22.3.1.5 */
-@@ -6400,7 +6403,7 @@ static void wakeup_handler(void)
+@@ -6396,7 +6399,7 @@ static void wakeup_handler(void)
static __init int hardware_setup(void)
{
rdmsrl_safe(MSR_EFER, &host_efer);
-@@ -6415,41 +6418,13 @@ static __init int hardware_setup(void)
+@@ -6411,41 +6414,13 @@ static __init int hardware_setup(void)
if (!vmx_io_bitmap_b)
goto out;
memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE);
memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE);
-@@ -6458,12 +6433,9 @@ static __init int hardware_setup(void)
+@@ -6454,12 +6429,9 @@ static __init int hardware_setup(void)
memset(vmx_io_bitmap_b, 0xff, PAGE_SIZE);
}
if (boot_cpu_has(X86_FEATURE_NX))
-@@ -6520,47 +6492,8 @@ static __init int hardware_setup(void)
+@@ -6516,47 +6488,8 @@ static __init int hardware_setup(void)
kvm_tsc_scaling_ratio_frac_bits = 48;
}
if (enable_ept) {
kvm_mmu_set_mask_ptes(VMX_EPT_READABLE_MASK,
(enable_ept_ad_bits) ? VMX_EPT_ACCESS_BIT : 0ull,
-@@ -6606,22 +6539,10 @@ static __init int hardware_setup(void)
+@@ -6602,22 +6535,10 @@ static __init int hardware_setup(void)
return alloc_kvm_area();
out1:
free_page((unsigned long)vmx_io_bitmap_b);
out:
-@@ -6632,12 +6553,6 @@ out:
+@@ -6628,12 +6549,6 @@ out:
static __exit void hardware_unsetup(void)
{
free_page((unsigned long)vmx_io_bitmap_b);
free_page((unsigned long)vmx_io_bitmap_a);
free_page((unsigned long)vmx_vmwrite_bitmap);
-@@ -7002,13 +6917,6 @@ static int handle_vmon(struct kvm_vcpu *
+@@ -6998,13 +6913,6 @@ static int handle_vmon(struct kvm_vcpu *
if (r < 0)
goto out_vmcs02;
vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL);
if (!vmx->nested.cached_vmcs12)
goto out_cached_vmcs12;
-@@ -7038,9 +6946,6 @@ out_shadow_vmcs:
+@@ -7034,9 +6942,6 @@ out_shadow_vmcs:
kfree(vmx->nested.cached_vmcs12);
out_cached_vmcs12:
free_loaded_vmcs(&vmx->nested.vmcs02);
out_vmcs02:
-@@ -7119,10 +7024,6 @@ static void free_nested(struct vcpu_vmx
+@@ -7115,10 +7020,6 @@ static void free_nested(struct vcpu_vmx
vmx->nested.vmxon = false;
free_vpid(vmx->nested.vpid02);
nested_release_vmcs12(vmx);
if (enable_shadow_vmcs) {
vmcs_clear(vmx->vmcs01.shadow_vmcs);
free_vmcs(vmx->vmcs01.shadow_vmcs);
-@@ -8469,7 +8370,7 @@ static void vmx_set_virtual_x2apic_mode(
+@@ -8465,7 +8366,7 @@ static void vmx_set_virtual_x2apic_mode(
}
vmcs_write32(SECONDARY_VM_EXEC_CONTROL, sec_exec_control);
}
static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu, hpa_t hpa)
-@@ -9089,6 +8990,7 @@ static struct kvm_vcpu *vmx_create_vcpu(
+@@ -9085,6 +8986,7 @@ static struct kvm_vcpu *vmx_create_vcpu(
{
int err;
struct vcpu_vmx *vmx = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
int cpu;
if (!vmx)
-@@ -9129,6 +9031,15 @@ static struct kvm_vcpu *vmx_create_vcpu(
+@@ -9125,6 +9027,15 @@ static struct kvm_vcpu *vmx_create_vcpu(
if (err < 0)
goto free_msrs;
vmx->loaded_vmcs = &vmx->vmcs01;
cpu = get_cpu();
vmx_vcpu_load(&vmx->vcpu, cpu);
-@@ -9523,7 +9434,7 @@ static inline bool nested_vmx_merge_msr_
+@@ -9519,7 +9430,7 @@ static inline bool nested_vmx_merge_msr_
int msr;
struct page *page;
unsigned long *msr_bitmap_l1;
/* This shortcut is ok because we support only x2APIC MSRs so far. */
if (!nested_cpu_has_virt_x2apic_mode(vmcs12))
-@@ -10043,6 +9954,9 @@ static void prepare_vmcs02(struct kvm_vc
+@@ -10034,6 +9945,9 @@ static void prepare_vmcs02(struct kvm_vc
if (kvm_has_tsc_control)
decache_tsc_multiplier(vmx);
if (enable_vpid) {
/*
* There is no direct mapping between vpid02 and vpid12, the
-@@ -10747,7 +10661,7 @@ static void load_vmcs12_host_state(struc
+@@ -10738,7 +10652,7 @@ static void load_vmcs12_host_state(struc
vmcs_write64(GUEST_IA32_DEBUGCTL, 0);
if (cpu_has_vmx_msr_bitmap())
case MSR_IA32_CR_PAT:
if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
-@@ -9435,9 +9489,23 @@ static inline bool nested_vmx_merge_msr_
+@@ -9431,9 +9485,23 @@ static inline bool nested_vmx_merge_msr_
struct page *page;
unsigned long *msr_bitmap_l1;
unsigned long *msr_bitmap_l0 = to_vmx(vcpu)->nested.vmcs02.msr_bitmap;
return false;
page = nested_get_page(vcpu, vmcs12->msr_bitmap);
-@@ -9475,6 +9543,13 @@ static inline bool nested_vmx_merge_msr_
+@@ -9466,6 +9534,13 @@ static inline bool nested_vmx_merge_msr_
MSR_TYPE_W);
}
}
x86-spectre-simplify-spectre_v2-command-line-parsing.patch
x86-pti-mark-constant-arrays-as-__initconst.patch
x86-speculation-fix-typo-ibrs_att-which-should-be-ibrs_all.patch
+kvm-nvmx-kmap-can-t-fail.patch
kvm-nvmx-vmx_complete_nested_posted_interrupt-can-t-fail.patch
kvm-nvmx-mark-vmcs12-pages-dirty-on-l2-exit.patch
kvm-nvmx-eliminate-vmcs02-pool.patch