1. 20 5月, 2018 1 次提交
    • M
      arm64: KVM: Use lm_alias() for kvm_ksym_ref() · 46c4a30b
      Mark Rutland 提交于
      For historical reasons, we open-code lm_alias() in kvm_ksym_ref().
      
      Let's use lm_alias() to avoid duplication and make things clearer.
      
      As we have to pull this from <linux/mm.h> (which is not safe for
      inclusion in assembly), we may as well move the kvm_ksym_ref()
      definition into the existing !__ASSEMBLY__ block.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Christoffer Dall <christoffer.dall@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: kvmarm@lists.cs.columbia.edu
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      46c4a30b
  2. 12 4月, 2018 1 次提交
  3. 28 3月, 2018 1 次提交
  4. 20 3月, 2018 1 次提交
  5. 19 3月, 2018 2 次提交
    • C
      KVM: arm64: Introduce VHE-specific kvm_vcpu_run · 3f5c90b8
      Christoffer Dall 提交于
      So far this is mostly (see below) a copy of the legacy non-VHE switch
      function, but we will start reworking these functions in separate
      directions to work on VHE and non-VHE in the most optimal way in later
      patches.
      
      The only difference after this patch between the VHE and non-VHE run
      functions is that we omit the branch-predictor variant-2 hardening for
      QC Falkor CPUs, because this workaround is specific to a series of
      non-VHE ARMv8.0 CPUs.
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      3f5c90b8
    • C
      KVM: arm64: Avoid storing the vcpu pointer on the stack · 4464e210
      Christoffer Dall 提交于
      We already have the percpu area for the host cpu state, which points to
      the VCPU, so there's no need to store the VCPU pointer on the stack on
      every context switch.  We can be a little more clever and just use
      tpidr_el2 for the percpu offset and load the VCPU pointer from the host
      context.
      
      This has the benefit of being able to retrieve the host context even
      when our stack is corrupted, and it has a potential performance benefit
      because we trade a store plus a load for an mrs and a load on a round
      trip to the guest.
      
      This does require us to calculate the percpu offset without including
      the offset from the kernel mapping of the percpu array to the linear
      mapping of the array (which is what we store in tpidr_el1), because a
      PC-relative generated address in EL2 is already giving us the hyp alias
      of the linear mapping of a kernel address.  We do this in
      __cpu_init_hyp_mode() by using kvm_ksym_ref().
      
      The code that accesses ESR_EL2 was previously using an alternative to
      use the _EL1 accessor on VHE systems, but this was actually unnecessary
      as the _EL1 accessor aliases the ESR_EL2 register on VHE, and the _EL2
      accessor does the same thing on both systems.
      
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      4464e210
  6. 09 1月, 2018 1 次提交
  7. 06 11月, 2017 1 次提交
    • C
      KVM: arm/arm64: Move timer save/restore out of the hyp code · 688c50aa
      Christoffer Dall 提交于
      As we are about to be lazy with saving and restoring the timer
      registers, we prepare by moving all possible timer configuration logic
      out of the hyp code.  All virtual timer registers can be programmed from
      EL1 and since the arch timer is always a level triggered interrupt we
      can safely do this with interrupts disabled in the host kernel on the
      way to the guest without taking vtimer interrupts in the host kernel
      (yet).
      
      The downside is that the cntvoff register can only be programmed from
      hyp mode, so we jump into hyp mode and back to program it.  This is also
      safe, because the host kernel doesn't use the virtual timer in the KVM
      code.  It may add a little performance performance penalty, but only
      until following commits where we move this operation to vcpu load/put.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      688c50aa
  8. 09 4月, 2017 3 次提交
  9. 05 11月, 2016 1 次提交
    • M
      arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU · 94d0e598
      Marc Zyngier 提交于
      Architecturally, TLBs are private to the (physical) CPU they're
      associated with. But when multiple vcpus from the same VM are
      being multiplexed on the same CPU, the TLBs are not private
      to the vcpus (and are actually shared across the VMID).
      
      Let's consider the following scenario:
      
      - vcpu-0 maps PA to VA
      - vcpu-1 maps PA' to VA
      
      If run on the same physical CPU, vcpu-1 can hit TLB entries generated
      by vcpu-0 accesses, and access the wrong physical page.
      
      The solution to this is to keep a per-VM map of which vcpu ran last
      on each given physical CPU, and invalidate local TLBs when switching
      to a different vcpu from the same VM.
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      94d0e598
  10. 08 9月, 2016 2 次提交
  11. 28 4月, 2016 2 次提交
    • A
      arm64: kvm: allows kvm cpu hotplug · 67f69197
      AKASHI Takahiro 提交于
      The current kvm implementation on arm64 does cpu-specific initialization
      at system boot, and has no way to gracefully shutdown a core in terms of
      kvm. This prevents kexec from rebooting the system at EL2.
      
      This patch adds a cpu tear-down function and also puts an existing cpu-init
      code into a separate function, kvm_arch_hardware_disable() and
      kvm_arch_hardware_enable() respectively.
      We don't need the arm64 specific cpu hotplug hook any more.
      
      Since this patch modifies common code between arm and arm64, one stub
      definition, __cpu_reset_hyp_mode(), is added on arm side to avoid
      compilation errors.
      Signed-off-by: NAKASHI Takahiro <takahiro.akashi@linaro.org>
      [Rebase, added separate VHE init/exit path, changed resets use of
       kvm_call_hyp() to the __version, en/disabled hardware in init_subsystems(),
       added icache maintenance to __kvm_hyp_reset() and removed lr restore, removed
       guest-enter after teardown handling]
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      67f69197
    • J
      arm64: hyp/kvm: Make hyp-stub reject kvm_call_hyp() · c94b0cf2
      James Morse 提交于
      A later patch implements kvm_arch_hardware_disable(), to remove kvm
      from el2, and re-instate the hyp-stub.
      
      This can happen while guests are running, particularly when kvm_reboot()
      calls kvm_arch_hardware_disable() on each cpu. This can interrupt a guest,
      remove kvm, then allow the guest to be scheduled again. This causes
      kvm_call_hyp() to be run against the hyp-stub.
      
      Change the hyp-stub to return a new exception type when this happens,
      and add code to kvm's handle_exit() to tell userspace we failed to
      enter the guest.
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c94b0cf2
  12. 06 4月, 2016 1 次提交
    • M
      arm64: KVM: Warn when PARange is less than 40 bits · 6141570c
      Marc Zyngier 提交于
      We always thought that 40bits of PA range would be the minimum people
      would actually build. Anything less is terrifyingly small.
      
      Turns out that we were both right and wrong. Nobody has ever built
      such a system, but the ARM Foundation Model has a PARange set to 36bits.
      Just because we can. Oh well. Now, the KVM API explicitely says that
      we offer a 40bit PA space to the VM, so we shouldn't run KVM on
      the Foundation Model at all.
      
      That being said, this patch offers a less agressive alternative, and
      loudly warns about the configuration being unsupported. You'll still
      be able to run VMs (at your own risks, though).
      
      This is just a workaround until we have a proper userspace API where
      we report the PARange to userspace.
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      6141570c
  13. 21 3月, 2016 1 次提交
    • M
      arm64: KVM: Turn kvm_ksym_ref into a NOP on VHE · 2510ffe1
      Marc Zyngier 提交于
      When running with VHE, there is no need to translate kernel pointers
      to the EL2 memory space, since we're already there (and we have a much
      saner memory map to start with).
      
      Unfortunately, kvm_ksym_ref is getting in the way, and the first
      call into the "hypervisor" section is going to end up in fireworks,
      since we're now branching into nowhereland. Meh.
      
      A potential solution is to test if VHE is engaged or not, and only
      perform the translation in the negative case. With this in place,
      VHE is able to run again.
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      2510ffe1
  14. 09 3月, 2016 1 次提交
  15. 01 3月, 2016 2 次提交
  16. 19 2月, 2016 2 次提交
  17. 14 12月, 2015 1 次提交
  18. 17 9月, 2015 1 次提交
  19. 21 7月, 2015 2 次提交
    • A
      KVM: arm64: introduce vcpu->arch.debug_ptr · 84e690bf
      Alex Bennée 提交于
      This introduces a level of indirection for the debug registers. Instead
      of using the sys_regs[] directly we store registers in a structure in
      the vcpu. The new kvm_arm_reset_debug_ptr() sets the debug ptr to the
      guest context.
      
      Because we no longer give the sys_regs offset for the sys_reg_desc->reg
      field, but instead the index into a debug-specific struct we need to
      add a number of additional trap functions for each register. Also as the
      generic generic user-space access code no longer works we have
      introduced a new pair of function pointers to the sys_reg_desc structure
      to override the generic code when needed.
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      84e690bf
    • A
      KVM: arm: introduce kvm_arm_init/setup/clear_debug · 56c7f5e7
      Alex Bennée 提交于
      This is a precursor for later patches which will need to do more to
      setup debug state before entering the hyp.S switch code. The existing
      functionality for setting mdcr_el2 has been moved out of hyp.S and now
      uses the value kept in vcpu->arch.mdcr_el2.
      
      As the assembler used to previously mask and preserve MDCR_EL2.HPMN I've
      had to add a mechanism to save the value of mdcr_el2 as a per-cpu
      variable during the initialisation code. The kernel never sets this
      number so we are assuming the bootcode has set up the correct value
      here.
      
      This also moves the conditional setting of the TDA bit from the hyp code
      into the C code which is currently used for the lazy debug register
      context switch code.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      56c7f5e7
  20. 12 6月, 2015 1 次提交
  21. 26 5月, 2015 1 次提交
  22. 16 1月, 2015 1 次提交
  23. 11 7月, 2014 7 次提交
  24. 03 3月, 2014 1 次提交
  25. 09 8月, 2013 1 次提交
    • M
      arm64: KVM: perform save/restore of PAR_EL1 · 1bbd8054
      Marc Zyngier 提交于
      Not saving PAR_EL1 is an unfortunate oversight. If the guest
      performs an AT* operation and gets scheduled out before reading
      the result of the translation from PAREL1, it could become
      corrupted by another guest or the host.
      
      Saving this register is made slightly more complicated as KVM also
      uses it on the permission fault handling path, leading to an ugly
      "stash and restore" sequence. Fortunately, this is already a slow
      path so we don't really care. Also, Linux doesn't do any AT*
      operation, so Linux guests are not impacted by this bug.
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      1bbd8054
  26. 12 6月, 2013 1 次提交