1. 17 4月, 2021 2 次提交
  2. 07 4月, 2021 2 次提交
  3. 06 4月, 2021 3 次提交
  4. 26 3月, 2021 1 次提交
  5. 15 3月, 2021 10 次提交
    • S
      KVM: x86: Get active PCID only when writing a CR3 value · e83bc09c
      Sean Christopherson 提交于
      Retrieve the active PCID only when writing a guest CR3 value, i.e. don't
      get the PCID when using EPT or NPT.  The PCID is especially problematic
      for EPT as the bits have different meaning, and so the PCID and must be
      manually stripped, which is annoying and unnecessary.  And on VMX,
      getting the active PCID also involves reading the guest's CR3 and
      CR4.PCIDE, i.e. may add pointless VMREADs.
      
      Opportunistically rename the pgd/pgd_level params to root_hpa and
      root_level to better reflect their new roles.  Keep the function names,
      as "load the guest PGD" is still accurate/correct.
      
      Last, and probably least, pass root_hpa as a hpa_t/u64 instead of an
      unsigned long.  The EPTP holds a 64-bit value, even in 32-bit mode, so
      in theory EPT could support HIGHMEM for 32-bit KVM.  Never mind that
      doing so would require changing the MMU page allocators and reworking
      the MMU to use kmap().
      Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210305183123.3978098-2-seanjc@google.com>
      Reviewed-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e83bc09c
    • S
      KVM: x86/mmu: Move logic for setting SPTE masks for EPT into the MMU proper · e7b7bdea
      Sean Christopherson 提交于
      Let the MMU deal with the SPTE masks to avoid splitting the logic and
      knowledge across the MMU and VMX.
      
      The SPTE masks that are used for EPT are very, very tightly coupled to
      the MMU implementation.  The use of available bits, the existence of A/D
      types, the fact that shadow_x_mask even exists, and so on and so forth
      are all baked into the MMU implementation.  Cross referencing the params
      to the masks is also a nightmare, as pretty much every param is a u64.
      
      A future patch will make the location of the MMU_WRITABLE and
      HOST_WRITABLE bits MMU specific, to free up bit 11 for a MMU_PRESENT bit.
      Doing that change with the current kvm_mmu_set_mask_ptes() would be an
      absolute mess.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210225204749.1512652-18-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e7b7bdea
    • B
      KVM: SVM: Add support for Virtual SPEC_CTRL · d00b99c5
      Babu Moger 提交于
      Newer AMD processors have a feature to virtualize the use of the
      SPEC_CTRL MSR. Presence of this feature is indicated via CPUID
      function 0x8000000A_EDX[20]: GuestSpecCtrl. Hypervisors are not
      required to enable this feature since it is automatically enabled on
      processors that support it.
      
      A hypervisor may wish to impose speculation controls on guest
      execution or a guest may want to impose its own speculation controls.
      Therefore, the processor implements both host and guest
      versions of SPEC_CTRL.
      
      When in host mode, the host SPEC_CTRL value is in effect and writes
      update only the host version of SPEC_CTRL. On a VMRUN, the processor
      loads the guest version of SPEC_CTRL from the VMCB. When the guest
      writes SPEC_CTRL, only the guest version is updated. On a VMEXIT,
      the guest version is saved into the VMCB and the processor returns
      to only using the host SPEC_CTRL for speculation control. The guest
      SPEC_CTRL is located at offset 0x2E0 in the VMCB.
      
      The effective SPEC_CTRL setting is the guest SPEC_CTRL setting or'ed
      with the hypervisor SPEC_CTRL setting. This allows the hypervisor to
      ensure a minimum SPEC_CTRL if desired.
      
      This support also fixes an issue where a guest may sometimes see an
      inconsistent value for the SPEC_CTRL MSR on processors that support
      this feature. With the current SPEC_CTRL support, the first write to
      SPEC_CTRL is intercepted and the virtualized version of the SPEC_CTRL
      MSR is not updated. When the guest reads back the SPEC_CTRL MSR, it
      will be 0x0, instead of the actual expected value. There isn’t a
      security concern here, because the host SPEC_CTRL value is or’ed with
      the Guest SPEC_CTRL value to generate the effective SPEC_CTRL value.
      KVM writes with the guest's virtualized SPEC_CTRL value to SPEC_CTRL
      MSR just before the VMRUN, so it will always have the actual value
      even though it doesn’t appear that way in the guest. The guest will
      only see the proper value for the SPEC_CTRL register if the guest was
      to write to the SPEC_CTRL register again. With Virtual SPEC_CTRL
      support, the save area spec_ctrl is properly saved and restored.
      So, the guest will always see the proper value when it is read back.
      Signed-off-by: NBabu Moger <babu.moger@amd.com>
      Message-Id: <161188100955.28787.11816849358413330720.stgit@bmoger-ubuntu>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d00b99c5
    • B
      x86/cpufeatures: Add the Virtual SPEC_CTRL feature · f333374e
      Babu Moger 提交于
      Newer AMD processors have a feature to virtualize the use of the
      SPEC_CTRL MSR. Presence of this feature is indicated via CPUID
      function 0x8000000A_EDX[20]: GuestSpecCtrl. When present, the
      SPEC_CTRL MSR is automatically virtualized.
      Signed-off-by: NBabu Moger <babu.moger@amd.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Message-Id: <161188100272.28787.4097272856384825024.stgit@bmoger-ubuntu>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f333374e
    • S
      KVM: x86: Move RDPMC emulation to common code · c483c454
      Sean Christopherson 提交于
      Move the entirety of the accelerated RDPMC emulation to x86.c, and assign
      the common handler directly to the exit handler array for VMX.  SVM has
      bizarre nrips behavior that prevents it from directly invoking the common
      handler.  The nrips goofiness will be addressed in a future patch.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210205005750.3841462-8-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c483c454
    • S
      KVM: x86: Move trivial instruction-based exit handlers to common code · 5ff3a351
      Sean Christopherson 提交于
      Move the trivial exit handlers, e.g. for instructions that KVM
      "emulates" as nops, to common x86 code.  Assign the common handlers
      directly to the exit handler arrays and drop the vendor trampolines.
      
      Opportunistically use pr_warn_once() where appropriate.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210205005750.3841462-7-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5ff3a351
    • S
      KVM: x86: Move XSETBV emulation to common code · 92f9895c
      Sean Christopherson 提交于
      Move the entirety of XSETBV emulation to x86.c, and assign the
      function directly to both VMX's and SVM's exit handlers, i.e. drop the
      unnecessary trampolines.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210205005750.3841462-6-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      92f9895c
    • S
      KVM: x86: Handle triple fault in L2 without killing L1 · cb6a32c2
      Sean Christopherson 提交于
      Synthesize a nested VM-Exit if L2 triggers an emulated triple fault
      instead of exiting to userspace, which likely will kill L1.  Any flow
      that does KVM_REQ_TRIPLE_FAULT is suspect, but the most common scenario
      for L2 killing L1 is if L0 (KVM) intercepts a contributory exception that
      is _not_intercepted by L1.  E.g. if KVM is intercepting #GPs for the
      VMware backdoor, a #GP that occurs in L2 while vectoring an injected #DF
      will cause KVM to emulate triple fault.
      
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Jim Mattson <jmattson@google.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210302174515.2812275-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cb6a32c2
    • S
      KVM: x86/mmu: Unexport MMU load/unload functions · 61a1773e
      Sean Christopherson 提交于
      Unexport the MMU load and unload helpers now that they are no longer
      used (incorrectly) in vendor code.
      
      Opportunistically move the kvm_mmu_sync_roots() declaration into mmu.h,
      it should not be exposed to vendor code.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210305011101.3597423-16-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      61a1773e
    • D
      KVM: x86: to track if L1 is running L2 VM · 43c11d91
      Dongli Zhang 提交于
      The new per-cpu stat 'nested_run' is introduced in order to track if L1 VM
      is running or used to run L2 VM.
      
      An example of the usage of 'nested_run' is to help the host administrator
      to easily track if any L1 VM is used to run L2 VM. Suppose there is issue
      that may happen with nested virtualization, the administrator will be able
      to easily narrow down and confirm if the issue is due to nested
      virtualization via 'nested_run'. For example, whether the fix like
      commit 88dddc11 ("KVM: nVMX: do not use dangling shadow VMCS after
      guest reset") is required.
      
      Cc: Joe Jin <joe.jin@oracle.com>
      Signed-off-by: NDongli Zhang <dongli.zhang@oracle.com>
      Message-Id: <20210305225747.7682-1-dongli.zhang@oracle.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      43c11d91
  6. 13 3月, 2021 1 次提交
    • M
      kvm: x86: annotate RCU pointers · 6fcd9cbc
      Muhammad Usama Anjum 提交于
      This patch adds the annotation to fix the following sparse errors:
      arch/x86/kvm//x86.c:8147:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//x86.c:8147:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//x86.c:8147:15:    struct kvm_apic_map *
      arch/x86/kvm//x86.c:10628:16: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//x86.c:10628:16:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//x86.c:10628:16:    struct kvm_apic_map *
      arch/x86/kvm//x86.c:10629:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//x86.c:10629:15:    struct kvm_pmu_event_filter [noderef] __rcu *
      arch/x86/kvm//x86.c:10629:15:    struct kvm_pmu_event_filter *
      arch/x86/kvm//lapic.c:267:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:267:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:267:15:    struct kvm_apic_map *
      arch/x86/kvm//lapic.c:269:9: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:269:9:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:269:9:    struct kvm_apic_map *
      arch/x86/kvm//lapic.c:637:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:637:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:637:15:    struct kvm_apic_map *
      arch/x86/kvm//lapic.c:994:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:994:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:994:15:    struct kvm_apic_map *
      arch/x86/kvm//lapic.c:1036:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:1036:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:1036:15:    struct kvm_apic_map *
      arch/x86/kvm//lapic.c:1173:15: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//lapic.c:1173:15:    struct kvm_apic_map [noderef] __rcu *
      arch/x86/kvm//lapic.c:1173:15:    struct kvm_apic_map *
      arch/x86/kvm//pmu.c:190:18: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//pmu.c:190:18:    struct kvm_pmu_event_filter [noderef] __rcu *
      arch/x86/kvm//pmu.c:190:18:    struct kvm_pmu_event_filter *
      arch/x86/kvm//pmu.c:251:18: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//pmu.c:251:18:    struct kvm_pmu_event_filter [noderef] __rcu *
      arch/x86/kvm//pmu.c:251:18:    struct kvm_pmu_event_filter *
      arch/x86/kvm//pmu.c:522:18: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//pmu.c:522:18:    struct kvm_pmu_event_filter [noderef] __rcu *
      arch/x86/kvm//pmu.c:522:18:    struct kvm_pmu_event_filter *
      arch/x86/kvm//pmu.c:522:18: error: incompatible types in comparison expression (different address spaces):
      arch/x86/kvm//pmu.c:522:18:    struct kvm_pmu_event_filter [noderef] __rcu *
      arch/x86/kvm//pmu.c:522:18:    struct kvm_pmu_event_filter *
      Signed-off-by: NMuhammad Usama Anjum <musamaanjum@gmail.com>
      Message-Id: <20210305191123.GA497469@LEGION>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6fcd9cbc
  7. 12 3月, 2021 1 次提交
  8. 09 3月, 2021 1 次提交
  9. 08 3月, 2021 1 次提交
  10. 03 3月, 2021 2 次提交
    • J
      xen: fix p2m size in dom0 for disabled memory hotplug case · 88221399
      Juergen Gross 提交于
      Since commit 9e2369c0 ("xen: add helpers to allocate unpopulated
      memory") foreign mappings are using guest physical addresses allocated
      via ZONE_DEVICE functionality.
      
      This will result in problems for the case of no balloon memory hotplug
      being configured, as the p2m list will only cover the initial memory
      size of the domain. Any ZONE_DEVICE allocated address will be outside
      the p2m range and thus a mapping can't be established with that memory
      address.
      
      Fix that by extending the p2m size for that case. At the same time add
      a check for a to be created mapping to be within the p2m limits in
      order to detect errors early.
      
      While changing a comment, remove some 32-bit leftovers.
      
      This is XSA-369.
      
      Fixes: 9e2369c0 ("xen: add helpers to allocate unpopulated memory")
      Cc: <stable@vger.kernel.org> # 5.9
      Reported-by: NMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      Reviewed-by: NJan Beulich <jbeulich@suse.com>
      Signed-off-by: NJuergen Gross <jgross@suse.com>
      88221399
    • D
      KVM: x86/xen: Add support for vCPU runstate information · 30b5c851
      David Woodhouse 提交于
      This is how Xen guests do steal time accounting. The hypervisor records
      the amount of time spent in each of running/runnable/blocked/offline
      states.
      
      In the Xen accounting, a vCPU is still in state RUNSTATE_running while
      in Xen for a hypercall or I/O trap, etc. Only if Xen explicitly schedules
      does the state become RUNSTATE_blocked. In KVM this means that even when
      the vCPU exits the kvm_run loop, the state remains RUNSTATE_running.
      
      The VMM can explicitly set the vCPU to RUNSTATE_blocked by using the
      KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT attribute, and can also use
      KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST to retrospectively add a given
      amount of time to the blocked state and subtract it from the running
      state.
      
      The state_entry_time corresponds to get_kvmclock_ns() at the time the
      vCPU entered the current state, and the total times of all four states
      should always add up to state_entry_time.
      Co-developed-by: NJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      Message-Id: <20210301125309.874953-2-dwmw2@infradead.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      30b5c851
  11. 27 2月, 2021 2 次提交
  12. 26 2月, 2021 1 次提交
  13. 19 2月, 2021 5 次提交
  14. 17 2月, 2021 4 次提交
  15. 16 2月, 2021 4 次提交