1. 21 6月, 2016 1 次提交
  2. 31 5月, 2016 4 次提交
  3. 20 5月, 2016 2 次提交
  4. 10 5月, 2016 1 次提交
    • C
      kvm: arm64: Enable hardware updates of the Access Flag for Stage 2 page tables · 06485053
      Catalin Marinas 提交于
      The ARMv8.1 architecture extensions introduce support for hardware
      updates of the access and dirty information in page table entries. With
      VTCR_EL2.HA enabled (bit 21), when the CPU accesses an IPA with the
      PTE_AF bit cleared in the stage 2 page table, instead of raising an
      Access Flag fault to EL2 the CPU sets the actual page table entry bit
      (10). To ensure that kernel modifications to the page table do not
      inadvertently revert a bit set by hardware updates, certain Stage 2
      software pte/pmd operations must be performed atomically.
      
      The main user of the AF bit is the kvm_age_hva() mechanism. The
      kvm_age_hva_handler() function performs a "test and clear young" action
      on the pte/pmd. This needs to be atomic in respect of automatic hardware
      updates of the AF bit. Since the AF bit is in the same position for both
      Stage 1 and Stage 2, the patch reuses the existing
      ptep_test_and_clear_young() functionality if
      __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG is defined. Otherwise, the
      existing pte_young/pte_mkold mechanism is preserved.
      
      The kvm_set_s2pte_readonly() (and the corresponding pmd equivalent) have
      to perform atomic modifications in order to avoid a race with updates of
      the AF bit. The arm64 implementation has been re-written using
      exclusives.
      
      Currently, kvm_set_s2pte_writable() (and pmd equivalent) take a pointer
      argument and modify the pte/pmd in place. However, these functions are
      only used on local variables rather than actual page table entries, so
      it makes more sense to follow the pte_mkwrite() approach for stage 1
      attributes. The change to kvm_s2pte_mkwrite() makes it clear that these
      functions do not modify the actual page table entries.
      
      The (pte|pmd)_mkyoung() uses on Stage 2 entries (setting the AF bit
      explicitly) do not need to be modified since hardware updates of the
      dirty status are not supported by KVM, so there is no possibility of
      losing such information.
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      06485053
  5. 03 5月, 2016 1 次提交
    • J
      arm64: kvm: Fix kvm teardown for systems using the extended idmap · c612505f
      James Morse 提交于
      If memory is located above 1<<VA_BITS, kvm adds an extra level to its page
      tables, merging the runtime tables and boot tables that contain the idmap.
      This lets us avoid the trampoline dance during initialisation.
      
      This also means there is no trampoline page mapped, so
      __cpu_reset_hyp_mode() can't call __kvm_hyp_reset() in this page. The good
      news is the idmap is still mapped, so we don't need the trampoline page.
      The bad news is we can't call it directly as the idmap is above
      HYP_PAGE_OFFSET, so its address is masked by kvm_call_hyp.
      
      Add a function __extended_idmap_trampoline which will branch into
      __kvm_hyp_reset in the idmap, change kvm_hyp_reset_entry() to return
      this address if __kvm_cpu_uses_extended_idmap(). In this case
      __kvm_hyp_reset() will still switch to the boot tables (which are the
      merged tables that were already in use), and branch into the idmap (where
      it already was).
      
      This fixes boot failures on these systems, where we fail to execute the
      missing trampoline page when tearing down kvm in init_subsystems():
      [    2.508922] kvm [1]: 8-bit VMID
      [    2.512057] kvm [1]: Hyp mode initialized successfully
      [    2.517242] kvm [1]: interrupt-controller@e1140000 IRQ13
      [    2.522622] kvm [1]: timer IRQ3
      [    2.525783] Kernel panic - not syncing: HYP panic:
      [    2.525783] PS:200003c9 PC:0000007ffffff820 ESR:86000005
      [    2.525783] FAR:0000007ffffff820 HPFAR:00000000003ffff0 PAR:0000000000000000
      [    2.525783] VCPU:          (null)
      [    2.525783]
      [    2.547667] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W       4.6.0-rc5+ #1
      [    2.555137] Hardware name: Default string Default string/Default string, BIOS ROD0084E 09/03/2015
      [    2.563994] Call trace:
      [    2.566432] [<ffffff80080888d0>] dump_backtrace+0x0/0x240
      [    2.571818] [<ffffff8008088b24>] show_stack+0x14/0x20
      [    2.576858] [<ffffff80083423ac>] dump_stack+0x94/0xb8
      [    2.581899] [<ffffff8008152130>] panic+0x10c/0x250
      [    2.586677] [<ffffff8008152024>] panic+0x0/0x250
      [    2.591281] SMP: stopping secondary CPUs
      [    3.649692] SMP: failed to stop secondary CPUs 0-2,4-7
      [    3.654818] Kernel Offset: disabled
      [    3.658293] Memory Limit: none
      [    3.661337] ---[ end Kernel panic - not syncing: HYP panic:
      [    3.661337] PS:200003c9 PC:0000007ffffff820 ESR:86000005
      [    3.661337] FAR:0000007ffffff820 HPFAR:00000000003ffff0 PAR:0000000000000000
      [    3.661337] VCPU:          (null)
      [    3.661337]
      Reported-by: NWill Deacon <will.deacon@arm.com>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c612505f
  6. 28 4月, 2016 5 次提交
    • 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
    • G
      arm64: hyp/kvm: Make hyp-stub extensible · ad72e59f
      Geoff Levand 提交于
      The existing arm64 hcall implementations are limited in that they only
      allow for two distinct hcalls; with the x0 register either zero or not
      zero.  Also, the API of the hyp-stub exception vector routines and the
      KVM exception vector routines differ; hyp-stub uses a non-zero value in
      x0 to implement __hyp_set_vectors, whereas KVM uses it to implement
      kvm_call_hyp.
      
      To allow for additional hcalls to be defined and to make the arm64 hcall
      API more consistent across exception vector routines, change the hcall
      implementations to reserve all x0 values below 0xfff for hcalls such
      as {s,g}et_vectors().
      
      Define two new preprocessor macros HVC_GET_VECTORS, and HVC_SET_VECTORS
      to be used as hcall type specifiers and convert the existing
      __hyp_get_vectors() and __hyp_set_vectors() routines to use these new
      macros when executing an HVC call.  Also, change the corresponding
      hyp-stub and KVM el1_sync exception vector routines to use these new
      macros.
      Signed-off-by: NGeoff Levand <geoff@infradead.org>
      [Merged two hcall patches, moved immediate value from esr to x0, use lr
       as a scratch register, changed limit to 0xfff]
      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>
      ad72e59f
    • J
      arm64: kvm: Move lr save/restore from do_el2_call into EL1 · 00a44cda
      James Morse 提交于
      Today the 'hvc' calling KVM or the hyp-stub is expected to preserve all
      registers. KVM saves/restores the registers it needs on the EL2 stack using
      do_el2_call(). The hyp-stub has no stack, later patches need to be able to
      be able to clobber the link register.
      
      Move the link register save/restore to the the call sites.
      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>
      00a44cda
    • G
      arm64: Cleanup SCTLR flags · e7227d0e
      Geoff Levand 提交于
      We currently have macros defining flags for the arm64 sctlr registers in
      both kvm_arm.h and sysreg.h.  To clean things up and simplify move the
      definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any
      SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be
      SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to
      include the proper header or to use the new macro names.
      Signed-off-by: NGeoff Levand <geoff@infradead.org>
      [Restored pgtable-hwdef.h include]
      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>
      e7227d0e
  7. 21 4月, 2016 1 次提交
  8. 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
  9. 31 3月, 2016 1 次提交
  10. 21 3月, 2016 1 次提交
    • C
      kvm: arm64: Disable compiler instrumentation for hypervisor code · a6cdf1c0
      Catalin Marinas 提交于
      With the recent rewrite of the arm64 KVM hypervisor code in C, enabling
      certain options like KASAN would allow the compiler to generate memory
      accesses or function calls to addresses not mapped at EL2. This patch
      disables the compiler instrumentation on the arm64 hypervisor code for
      gcov-based profiling (GCOV_KERNEL), undefined behaviour sanity checker
      (UBSAN) and kernel address sanitizer (KASAN).
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Christoffer Dall <christoffer.dall@linaro.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: <stable@vger.kernel.org> # 4.5+
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      a6cdf1c0
  11. 09 3月, 2016 5 次提交
  12. 01 3月, 2016 17 次提交