1. 29 Apr, 2013 13 commits
    • Arnd Bergmann's avatar
      ARM: KVM: define KVM_ARM_MAX_VCPUS unconditionally · d21a1c83
      Arnd Bergmann authored
      The CONFIG_KVM_ARM_MAX_VCPUS symbol is needed in order to build the
      kernel/context_tracking.c code, which includes the vgic data structures
      implictly through the kvm headers. Definining the symbol to zero
      on builds without KVM resolves this build error:
      
      In file included from include/linux/kvm_host.h:33:0,
                       from kernel/context_tracking.c:18:
      arch/arm/include/asm/kvm_host.h:28:23: warning: "CONFIG_KVM_ARM_MAX_VCPUS" is not defined [-Wundef]
       #define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS
                             ^
      arch/arm/include/asm/kvm_vgic.h:34:24: note: in expansion of macro 'KVM_MAX_VCPUS'
       #define VGIC_MAX_CPUS  KVM_MAX_VCPUS
                              ^
      arch/arm/include/asm/kvm_vgic.h:38:6: note: in expansion of macro 'VGIC_MAX_CPUS'
       #if (VGIC_MAX_CPUS > 8)
            ^
      In file included from arch/arm/include/asm/kvm_host.h:41:0,
                       from include/linux/kvm_host.h:33,
                       from kernel/context_tracking.c:18:
      arch/arm/include/asm/kvm_vgic.h:59:11: error: 'CONFIG_KVM_ARM_MAX_VCPUS' undeclared here (not in a function)
        } percpu[VGIC_MAX_CPUS];
                 ^
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Christoffer Dall <cdall@cs.columbia.edu>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      d21a1c83
    • Christoffer Dall's avatar
      KVM: ARM: Fix API documentation for ONE_REG encoding · aa404ddf
      Christoffer Dall authored
      Unless I'm mistaken, the size field was encoded 4 bits off and a wrong
      value was used for 64-bit FP registers.
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      aa404ddf
    • Marc Zyngier's avatar
      ARM: KVM: promote vfp_host pointer to generic host cpu context · 3de50da6
      Marc Zyngier authored
      We use the vfp_host pointer to store the host VFP context, should
      the guest start using VFP itself.
      
      Actually, we can use this pointer in a more generic way to store
      CPU speficic data, and arm64 is using it to dump the whole host
      state before switching to the guest.
      
      Simply rename the vfp_host field to host_cpu_context, and the
      corresponding type to kvm_cpu_context_t. No change in functionnality.
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      3de50da6
    • Marc Zyngier's avatar
      ARM: KVM: add architecture specific hook for capabilities · 17b1e31f
      Marc Zyngier authored
      Most of the capabilities are common to both arm and arm64, but
      we still need to handle the exceptions.
      
      Introduce kvm_arch_dev_ioctl_check_extension, which both architectures
      implement (in the 32bit case, it just returns 0).
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      17b1e31f
    • Marc Zyngier's avatar
      ARM: KVM: perform HYP initilization for hotplugged CPUs · d157f4a5
      Marc Zyngier authored
      Now that we have the necessary infrastructure to boot a hotplugged CPU
      at any point in time, wire a CPU notifier that will perform the HYP
      init for the incoming CPU.
      
      Note that this depends on the platform code and/or firmware to boot the
      incoming CPU with HYP mode enabled and return to the kernel by following
      the normal boot path (HYP stub installed).
      Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: default avatarChristoffer Dall <cdall@cs.columbia.edu>
      d157f4a5
    • 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 20 commits