1. 29 Apr, 2013 8 commits
    • Marc Zyngier's avatar
      ARM: KVM: switch to a dual-step HYP init code · 5a677ce0
      Marc Zyngier authored
      Our HYP init code suffers from two major design issues:
      - it cannot support CPU hotplug, as we tear down the idmap very early
      - it cannot perform a TLB invalidation when switching from init to
        runtime mappings, as pages are manipulated from PL1 exclusively
      
      The hotplug problem mandates that we keep two sets of page tables
      (boot and runtime). The TLB problem mandates that we're able to
      transition from one PGD to another while in HYP, invalidating the TLBs
      in the process.
      
      To be able to do this, we need to share a page between the two page
      tables. A page that will have the same VA in both configurations. All we
      need is a VA that has the following properties:
      - This VA can't be used to represent a kernel mapping.
      - This VA will not conflict with the physical address of the kernel text
      
      The vectors page seems to satisfy this requirement:
      - The kernel never maps anything else there
      - The kernel text being copied at the beginning of the physical memory,
        it is unlikely to use the last 64kB (I doubt we'll ever support KVM
        on a system with something like 4MB of RAM, but patches are very
        welcome).
      
      Let's call this VA the trampoline VA.
      
      Now, we map our init page at 3 locations:
      - idmap in the boot pgd
      - trampoline VA in the boot pgd
      - trampoline VA in the runtime pgd
      
      The init scenario is now the following:
      - We jump in HYP with four parameters: boot HYP pgd, runtime HYP pgd,
        runtime stack, runtime vectors
      - Enable the MMU with the boot pgd
      - Jump to a target into the trampoline page (remember, this is the same
        physical page!)
      - Now switch to the runtime pgd (same VA, and still the same physical
        page!)
      - Invalidate TLBs
      - Set stack and vectors
      - Profit! (or eret, if you only care about the code).
      
      Note that we keep the boot mapping permanently (it is not strictly an
      idmap anymore) to allow for CPU hotplug in later patches.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      5a677ce0
    • Marc Zyngier's avatar
      ARM: KVM: rework HYP page table freeing · 4f728276
      Marc Zyngier authored
      There is no point in freeing HYP page tables differently from Stage-2.
      They now have the same requirements, and should be dealt with the same way.
      
      Promote unmap_stage2_range to be The One True Way, and get rid of a number
      of nasty bugs in the process (good thing we never actually called free_hyp_pmds
      before...).
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      4f728276
    • Marc Zyngier's avatar
      ARM: KVM: enforce maximum size for identity mapped code · 0394e1f6
      Marc Zyngier authored
      We're about to move to an init procedure where we rely on the
      fact that the init code fits in a single page. Make sure we
      align the idmap text on a vector alignment, and that the code is
      not bigger than a single page.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      0394e1f6
    • Marc Zyngier's avatar
      ARM: KVM: move to a KVM provided HYP idmap · 2fb41059
      Marc Zyngier authored
      After the HYP page table rework, it is pretty easy to let the KVM
      code provide its own idmap, rather than expecting the kernel to
      provide it. It takes actually less code to do so.
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      2fb41059
    • Marc Zyngier's avatar
      ARM: KVM: fix HYP mapping limitations around zero · 3562c76d
      Marc Zyngier authored
      The current code for creating HYP mapping doesn't like to wrap
      around zero, which prevents from mapping anything into the last
      page of the virtual address space.
      
      It doesn't take much effort to remove this limitation, making
      the code more consistent with the rest of the kernel in the process.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      3562c76d
    • Marc Zyngier's avatar
      ARM: KVM: simplify HYP mapping population · 6060df84
      Marc Zyngier authored
      The way we populate HYP mappings is a bit convoluted, to say the least.
      Passing a pointer around to keep track of the current PFN is quite
      odd, and we end-up having two different PTE accessors for no good
      reason.
      
      Simplify the whole thing by unifying the two PTE accessors, passing
      a pgprot_t around, and moving the various validity checks to the
      upper layers.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      6060df84
    • Mark Rutland's avatar
      ARM: KVM: arch_timer: use symbolic constants · 372b7c1b
      Mark Rutland authored
      In clocksource/arm_arch_timer.h we define useful symbolic constants.
      Let's use them to make the KVM arch_timer code clearer.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Cc: Christoffer Dall <cdall@cs.columbia.edu>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      372b7c1b
    • Marc Zyngier's avatar
      ARM: KVM: add support for minimal host vs guest profiling · 210552c1
      Marc Zyngier authored
      In order to be able to correctly profile what is happening on the
      host, we need to be able to identify when we're running on the guest,
      and log these events differently.
      
      Perf offers a simple way to register callbacks into KVM. Mimic what
      x86 does and enjoy being able to profile your KVM host.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      210552c1
  2. 28 Apr, 2013 7 commits
  3. 26 Apr, 2013 25 commits