1. 23 Jan, 2015 29 commits
  2. 21 Jan, 2015 1 commit
  3. 20 Jan, 2015 10 commits
    • Marcelo Tosatti's avatar
      KVM: x86: workaround SuSE's 2.6.16 pvclock vs masterclock issue · 54750f2c
      Marcelo Tosatti authored
      SuSE's 2.6.16 kernel fails to boot if the delta between tsc_timestamp
      and rdtsc is larger than a given threshold:
      
       * If we get more than the below threshold into the future, we rerequest
       * the real time from the host again which has only little offset then
       * that we need to adjust using the TSC.
       *
       * For now that threshold is 1/5th of a jiffie. That should be good
       * enough accuracy for completely broken systems, but also give us swing
       * to not call out to the host all the time.
       */
      #define PVCLOCK_DELTA_MAX ((1000000000ULL / HZ) / 5)
      
      Disable masterclock support (which increases said delta) in case the
      boot vcpu does not use MSR_KVM_SYSTEM_TIME_NEW.
      
      Upstreams kernels which support pvclock vsyscalls (and therefore make
      use of PVCLOCK_STABLE_BIT) use MSR_KVM_SYSTEM_TIME_NEW.
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      54750f2c
    • Fengguang Wu's avatar
      KVM: fix "Should it be static?" warnings from sparse · 69b0049a
      Fengguang Wu authored
      arch/x86/kvm/x86.c:495:5: sparse: symbol 'kvm_read_nested_guest_page' was not declared. Should it be static?
      arch/x86/kvm/x86.c:646:5: sparse: symbol '__kvm_set_xcr' was not declared. Should it be static?
      arch/x86/kvm/x86.c:1183:15: sparse: symbol 'max_tsc_khz' was not declared. Should it be static?
      arch/x86/kvm/x86.c:1237:6: sparse: symbol 'kvm_track_tsc_matching' was not declared. Should it be static?
      Signed-off-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      69b0049a
    • Andre Przywara's avatar
      arm/arm64: KVM: force alignment of VGIC dist/CPU/redist addresses · 4fa96afd
      Andre Przywara authored
      Although the GIC architecture requires us to map the MMIO regions
      only at page aligned addresses, we currently do not enforce this from
      the kernel side.
      Restrict any vGICv2 regions to be 4K aligned and any GICv3 regions
      to be 64K aligned. Document this requirement.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      4fa96afd
    • Andre Przywara's avatar
      arm/arm64: KVM: allow userland to request a virtual GICv3 · ac3d3735
      Andre Przywara authored
      With all of the GICv3 code in place now we allow userland to ask the
      kernel for using a virtual GICv3 in the guest.
      Also we provide the necessary support for guests setting the memory
      addresses for the virtual distributor and redistributors.
      This requires some userland code to make use of that feature and
      explicitly ask for a virtual GICv3.
      Document that KVM_CREATE_IRQCHIP only works for GICv2, but is
      considered legacy and using KVM_CREATE_DEVICE is preferred.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      ac3d3735
    • Andre Przywara's avatar
      arm/arm64: KVM: enable kernel side of GICv3 emulation · b5d84ff6
      Andre Przywara authored
      With all the necessary GICv3 emulation code in place, we can now
      connect the code to the GICv3 backend in the kernel.
      The LR register handling is different depending on the emulated GIC
      model, so provide different implementations for each.
      Also allow non-v2-compatible GICv3 implementations (which don't
      provide MMIO regions for the virtual CPU interface in the DT), but
      restrict those hosts to support GICv3 guests only.
      If the device tree provides a GICv2 compatible GICV resource entry,
      but that one is faulty, just disable the GICv2 emulation and let the
      user use at least the GICv3 emulation for guests.
      To provide proper support for the legacy KVM_CREATE_IRQCHIP ioctl,
      note virtual GICv2 compatibility in struct vgic_params and use it
      on creating a VGICv2.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      b5d84ff6
    • Andre Przywara's avatar
      arm64: KVM: add SGI generation register emulation · 6d52f35a
      Andre Przywara authored
      While the generation of a (virtual) inter-processor interrupt (SGI)
      on a GICv2 works by writing to a MMIO register, GICv3 uses the system
      register ICC_SGI1R_EL1 to trigger them.
      Add a trap handler function that calls the new SGI register handler
      in the GICv3 code. As ICC_SRE_EL1.SRE at this point is still always 0,
      this will not trap yet, but will only be used later when all the data
      structures have been initialized properly.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      6d52f35a
    • Andre Przywara's avatar
      arm64: GICv3: introduce symbolic names for GICv3 ICC_SGI1R_EL1 fields · 7e580278
      Andre Przywara authored
      The gic_send_sgi() function used hardcoded bit shift values to
      generate the ICC_SGI1R_EL1 register value.
      Replace this with symbolic names to allow reusing them later.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      7e580278
    • Andre Przywara's avatar
      arm/arm64: KVM: add virtual GICv3 distributor emulation · a0675c25
      Andre Przywara authored
      With everything separated and prepared, we implement a model of a
      GICv3 distributor and redistributors by using the existing framework
      to provide handler functions for each register group.
      
      Currently we limit the emulation to a model enforcing a single
      security state, with SRE==1 (forcing system register access) and
      ARE==1 (allowing more than 8 VCPUs).
      
      We share some of the functions provided for GICv2 emulation, but take
      the different ways of addressing (v)CPUs into account.
      Save and restore is currently not implemented.
      
      Similar to the split-off of the GICv2 specific code, the new emulation
      code goes into a new file (vgic-v3-emul.c).
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      a0675c25
    • Andre Przywara's avatar
      arm/arm64: KVM: add opaque private pointer to MMIO data · 9fedf146
      Andre Przywara authored
      For a GICv2 there is always only one (v)CPU involved: the one that
      does the access. On a GICv3 the access to a CPU redistributor is
      memory-mapped, but not banked, so the (v)CPU affected is determined by
      looking at the MMIO address region being accessed.
      To allow passing the affected CPU into the accessors later, extend
      struct kvm_exit_mmio to add an opaque private pointer parameter.
      The current GICv2 emulation just does not use it.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      9fedf146
    • Andre Przywara's avatar
      arm/arm64: KVM: split GICv2 specific emulation code from vgic.c · 1d916229
      Andre Przywara authored
      vgic.c is currently a mixture of generic vGIC emulation code and
      functions specific to emulating a GICv2. To ease the addition of
      GICv3, split off strictly v2 specific parts into a new file
      vgic-v2-emul.c.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      
      -------
      As the diff isn't always obvious here (and to aid eventual rebases),
      here is a list of high-level changes done to the code:
      * added new file to respective arm/arm64 Makefiles
      * moved GICv2 specific functions to vgic-v2-emul.c:
        - handle_mmio_misc()
        - handle_mmio_set_enable_reg()
        - handle_mmio_clear_enable_reg()
        - handle_mmio_set_pending_reg()
        - handle_mmio_clear_pending_reg()
        - handle_mmio_priority_reg()
        - vgic_get_target_reg()
        - vgic_set_target_reg()
        - handle_mmio_target_reg()
        - handle_mmio_cfg_reg()
        - handle_mmio_sgi_reg()
        - vgic_v2_unqueue_sgi()
        - read_set_clear_sgi_pend_reg()
        - write_set_clear_sgi_pend_reg()
        - handle_mmio_sgi_set()
        - handle_mmio_sgi_clear()
        - vgic_v2_handle_mmio()
        - vgic_get_sgi_sources()
        - vgic_dispatch_sgi()
        - vgic_v2_queue_sgi()
        - vgic_v2_map_resources()
        - vgic_v2_init()
        - vgic_v2_add_sgi_source()
        - vgic_v2_init_model()
        - vgic_v2_init_emulation()
        - handle_cpu_mmio_misc()
        - handle_mmio_abpr()
        - handle_cpu_mmio_ident()
        - vgic_attr_regs_access()
        - vgic_create() (renamed to vgic_v2_create())
        - vgic_destroy() (renamed to vgic_v2_destroy())
        - vgic_has_attr() (renamed to vgic_v2_has_attr())
        - vgic_set_attr() (renamed to vgic_v2_set_attr())
        - vgic_get_attr() (renamed to vgic_v2_get_attr())
        - struct kvm_mmio_range vgic_dist_ranges[]
        - struct kvm_mmio_range vgic_cpu_ranges[]
        - struct kvm_device_ops kvm_arm_vgic_v2_ops {}
      Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      1d916229