Skip to content
Snippets Groups Projects
  1. Jun 15, 2023
  2. Jun 13, 2023
  3. Jun 12, 2023
  4. Apr 05, 2023
  5. Mar 30, 2023
  6. Mar 27, 2023
  7. Mar 11, 2023
  8. Jan 29, 2023
    • Gavin Shan's avatar
      KVM: arm64: Add helper vgic_write_guest_lock() · a23eaf93
      Gavin Shan authored
      
      Currently, the unknown no-running-vcpu sites are reported when a
      dirty page is tracked by mark_page_dirty_in_slot(). Until now, the
      only known no-running-vcpu site is saving vgic/its tables through
      KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} command on KVM device
      "kvm-arm-vgic-its". Unfortunately, there are more unknown sites to
      be handled and no-running-vcpu context will be allowed in these
      sites: (1) KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} command
      on KVM device "kvm-arm-vgic-its" to restore vgic/its tables. The
      vgic3 LPI pending status could be restored. (2) Save vgic3 pending
      table through KVM_DEV_ARM_{VGIC_GRP_CTRL, VGIC_SAVE_PENDING_TABLES}
      command on KVM device "kvm-arm-vgic-v3".
      
      In order to handle those unknown cases, we need a unified helper
      vgic_write_guest_lock(). struct vgic_dist::save_its_tables_in_progress
      is also renamed to struct vgic_dist::save_tables_in_progress.
      
      No functional change intended.
      
      Suggested-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGavin Shan <gshan@redhat.com>
      Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20230126235451.469087-3-gshan@redhat.com
      a23eaf93
  9. Dec 29, 2022
    • Sean Christopherson's avatar
      KVM: x86: Unify pr_fmt to use module name for all KVM modules · 8d20bd63
      Sean Christopherson authored
      
      Define pr_fmt using KBUILD_MODNAME for all KVM x86 code so that printks
      use consistent formatting across common x86, Intel, and AMD code.  In
      addition to providing consistent print formatting, using KBUILD_MODNAME,
      e.g. kvm_amd and kvm_intel, allows referencing SVM and VMX (and SEV and
      SGX and ...) as technologies without generating weird messages, and
      without causing naming conflicts with other kernel code, e.g. "SEV: ",
      "tdx: ", "sgx: " etc.. are all used by the kernel for non-KVM subsystems.
      
      Opportunistically move away from printk() for prints that need to be
      modified anyways, e.g. to drop a manual "kvm: " prefix.
      
      Opportunistically convert a few SGX WARNs that are similarly modified to
      WARN_ONCE; in the very unlikely event that the WARNs fire, odds are good
      that they would fire repeatedly and spam the kernel log without providing
      unique information in each print.
      
      Note, defining pr_fmt yields undesirable results for code that uses KVM's
      printk wrappers, e.g. vcpu_unimpl().  But, that's a pre-existing problem
      as SVM/kvm_amd already defines a pr_fmt, and thankfully use of KVM's
      wrappers is relatively limited in KVM x86 code.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Message-Id: <20221130230934.1014142-35-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8d20bd63
    • Marc Zyngier's avatar
      KVM: arm64: Simplify the CPUHP logic · 466d27e4
      Marc Zyngier authored
      
      For a number of historical reasons, the KVM/arm64 hotplug setup is pretty
      complicated, and we have two extra CPUHP notifiers for vGIC and timers.
      
      It looks pretty pointless, and gets in the way of further changes.
      So let's just expose some helpers that can be called from the core
      CPUHP callback, and get rid of everything else.
      
      This gives us the opportunity to drop a useless notifier entry,
      as well as tidy-up the timer enable/disable, which was a bit odd.
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Signed-off-by: default avatarIsaku Yamahata <isaku.yamahata@intel.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221130230934.1014142-17-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      466d27e4
  10. Nov 19, 2022
  11. Nov 17, 2022
    • Marc Zyngier's avatar
      KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode · bead0220
      Marc Zyngier authored
      
      Ricardo recently pointed out that the PMU chained counter emulation
      in KVM wasn't quite behaving like the one on actual hardware, in
      the sense that a chained counter would expose an overflow on
      both halves of a chained counter, while KVM would only expose the
      overflow on the top half.
      
      The difference is subtle, but significant. What does the architecture
      say (DDI0087 H.a):
      
      - Up to PMUv3p4, all counters but the cycle counter are 32bit
      
      - A 32bit counter that overflows generates a CHAIN event on the
        adjacent counter after exposing its own overflow status
      
      - The CHAIN event is accounted if the counter is correctly
        configured (CHAIN event selected and counter enabled)
      
      This all means that our current implementation (which uses 64bit
      perf events) prevents us from emulating this overflow on the lower half.
      
      How to fix this? By implementing the above, to the letter.
      
      This largely results in code deletion, removing the notions of
      "counter pair", "chained counters", and "canonical counter".
      The code is further restructured to make the CHAIN handling similar
      to SWINC, as the two are now extremely similar in behaviour.
      
      Reported-by: default avatarRicardo Koller <ricarkol@google.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarReiji Watanabe <reijiw@google.com>
      Link: https://lore.kernel.org/r/20221113163832.3154370-3-maz@kernel.org
      bead0220
  12. Nov 10, 2022
  13. Jul 17, 2022
  14. May 16, 2022
  15. May 15, 2022
  16. May 04, 2022
  17. May 03, 2022
    • Raghavendra Rao Ananta's avatar
      KVM: arm64: Setup a framework for hypercall bitmap firmware registers · 05714cab
      Raghavendra Rao Ananta authored
      
      KVM regularly introduces new hypercall services to the guests without
      any consent from the userspace. This means, the guests can observe
      hypercall services in and out as they migrate across various host
      kernel versions. This could be a major problem if the guest
      discovered a hypercall, started using it, and after getting migrated
      to an older kernel realizes that it's no longer available. Depending
      on how the guest handles the change, there's a potential chance that
      the guest would just panic.
      
      As a result, there's a need for the userspace to elect the services
      that it wishes the guest to discover. It can elect these services
      based on the kernels spread across its (migration) fleet. To remedy
      this, extend the existing firmware pseudo-registers, such as
      KVM_REG_ARM_PSCI_VERSION, but by creating a new COPROC register space
      for all the hypercall services available.
      
      These firmware registers are categorized based on the service call
      owners, but unlike the existing firmware pseudo-registers, they hold
      the features supported in the form of a bitmap.
      
      During the VM initialization, the registers are set to upper-limit of
      the features supported by the corresponding registers. It's expected
      that the VMMs discover the features provided by each register via
      GET_ONE_REG, and write back the desired values using SET_ONE_REG.
      KVM allows this modification only until the VM has started.
      
      Some of the standard features are not mapped to any bits of the
      registers. But since they can recreate the original problem of
      making it available without userspace's consent, they need to
      be explicitly added to the case-list in
      kvm_hvc_call_default_allowed(). Any function-id that's not enabled
      via the bitmap, or not listed in kvm_hvc_call_default_allowed, will
      be returned as SMCCC_RET_NOT_SUPPORTED to the guest.
      
      Older userspace code can simply ignore the feature and the
      hypercall services will be exposed unconditionally to the guests,
      thus ensuring backward compatibility.
      
      In this patch, the framework adds the register only for ARM's standard
      secure services (owner value 4). Currently, this includes support only
      for ARM True Random Number Generator (TRNG) service, with bit-0 of the
      register representing mandatory features of v1.0. Other services are
      momentarily added in the upcoming patches.
      
      Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@google.com>
      Reviewed-by: default avatarGavin Shan <gshan@redhat.com>
      [maz: reduced the scope of some helpers, tidy-up bitmap max values,
       dropped error-only fast path]
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220502233853.1233742-3-rananta@google.com
      05714cab
    • Raghavendra Rao Ananta's avatar
      KVM: arm64: Factor out firmware register handling from psci.c · 85fbe08e
      Raghavendra Rao Ananta authored
      
      Common hypercall firmware register handing is currently employed
      by psci.c. Since the upcoming patches add more of these registers,
      it's better to move the generic handling to hypercall.c for a
      cleaner presentation.
      
      While we are at it, collect all the firmware registers under
      fw_reg_ids[] to help implement kvm_arm_get_fw_num_regs() and
      kvm_arm_copy_fw_reg_indices() in a generic way. Also, define
      KVM_REG_FEATURE_LEVEL_MASK using a GENMASK instead.
      
      No functional change intended.
      
      Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@google.com>
      Reviewed-by: default avatarOliver Upton <oupton@google.com>
      Reviewed-by: default avatarGavin Shan <gshan@redhat.com>
      [maz: fixed KVM_REG_FEATURE_LEVEL_MASK]
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220502233853.1233742-2-rananta@google.com
      85fbe08e
  18. Apr 20, 2022
  19. Feb 21, 2022
  20. Feb 08, 2022
  21. Jan 04, 2022
  22. Nov 17, 2021
  23. Sep 20, 2021
  24. Jun 01, 2021
    • Marc Zyngier's avatar
      KVM: arm64: vgic: Implement SW-driven deactivation · 354920e7
      Marc Zyngier authored
      
      In order to deal with these systems that do not offer HW-based
      deactivation of interrupts, let implement a SW-based approach:
      
      - When the irq is queued into a LR, treat it as a pure virtual
        interrupt and set the EOI flag in the LR.
      
      - When the interrupt state is read back from the LR, force a
        deactivation when the state is invalid (neither active nor
        pending)
      
      Interrupts requiring such treatment get the VGIC_SW_RESAMPLE flag.
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      354920e7
Loading