1. 01 Dec, 2022 7 commits
    • Sean Christopherson's avatar
      KVM: selftests: Define and use a custom static assert in lib headers · 0c326523
      Sean Christopherson authored
      Define and use kvm_static_assert() in the common KVM selftests headers to
      provide deterministic behavior, and to allow creating static asserts
      without dummy messages.
      
      The kernel's static_assert() makes the message param optional, and on the
      surface, tools/include/linux/build_bug.h appears to follow suit.  However,
      glibc may override static_assert() and redefine it as a direct alias of
      _Static_assert(), which makes the message parameter mandatory.  This leads
      to non-deterministic behavior as KVM selftests code that utilizes
      static_assert() without a custom message may or not compile depending on
      the order of includes.  E.g. recently added asserts in
      x86_64/processor.h fail on some systems with errors like
      
        In file included from lib/memstress.c:11:0:
        include/x86_64/processor.h: In function ‘this_cpu_has_p’:
        include/x86_64/processor.h:193:34: error: expected ‘,’ before ‘)’ token
          static_assert(low_bit < high_bit);     \
                                          ^
      due to _Static_assert() expecting a comma before a message.  The "message
      optional" version of static_assert() uses macro magic to strip away the
      comma when presented with empty an __VA_ARGS__
      
        #ifndef static_assert
        #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
        #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
        #endif // static_assert
      
      and effectively generates "_Static_assert(expr, #expr)".
      
      The incompatible version of static_assert() gets defined by this snippet
      in /usr/include/assert.h:
      
        #if defined __USE_ISOC11 && !defined __cplusplus
        # undef static_assert
        # define static_assert _Static_assert
        #endif
      
      which yields "_Static_assert(expr)" and thus fails as above.
      
      KVM selftests don't actually care about using C11, but __USE_ISOC11 gets
      defined because of _GNU_SOURCE, which many tests do #define.  _GNU_SOURCE
      triggers a massive pile of defines in /usr/include/features.h, including
      _ISOC11_SOURCE:
      
        /* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
        #ifdef _GNU_SOURCE
        # undef  _ISOC95_SOURCE
        # define _ISOC95_SOURCE 1
        # undef  _ISOC99_SOURCE
        # define _ISOC99_SOURCE 1
        # undef  _ISOC11_SOURCE
        # define _ISOC11_SOURCE 1
        # undef  _POSIX_SOURCE
        # define _POSIX_SOURCE  1
        # undef  _POSIX_C_SOURCE
        # define _POSIX_C_SOURCE        200809L
        # undef  _XOPEN_SOURCE
        # define _XOPEN_SOURCE  700
        # undef  _XOPEN_SOURCE_EXTENDED
        # define _XOPEN_SOURCE_EXTENDED 1
        # undef  _LARGEFILE64_SOURCE
        # define _LARGEFILE64_SOURCE    1
        # undef  _DEFAULT_SOURCE
        # define _DEFAULT_SOURCE        1
        # undef  _ATFILE_SOURCE
        # define _ATFILE_SOURCE 1
        #endif
      
      which further down in /usr/include/features.h leads to:
      
        /* This is to enable the ISO C11 extension.  */
        #if (defined _ISOC11_SOURCE \
             || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
        # define __USE_ISOC11   1
        #endif
      
      To make matters worse, /usr/include/assert.h doesn't guard against
      multiple inclusion by turning itself into a nop, but instead #undefs a
      few macros and continues on.  As a result, it's all but impossible to
      ensure the "message optional" version of static_assert() will actually be
      used, e.g. explicitly including assert.h and #undef'ing static_assert()
      doesn't work as a later inclusion of assert.h will again redefine its
      version.
      
        #ifdef  _ASSERT_H
      
        # undef _ASSERT_H
        # undef assert
        # undef __ASSERT_VOID_CAST
      
        # ifdef __USE_GNU
        #  undef assert_perror
        # endif
      
        #endif /* assert.h      */
      
        #define _ASSERT_H       1
        #include <features.h>
      
      Fixes: fcba483e ("KVM: selftests: Sanity check input to ioctls() at build time")
      Fixes: ee379553 ("KVM: selftests: Refactor X86_FEATURE_* framework to prep for X86_PROPERTY_*")
      Fixes: 53a7dc0f ("KVM: selftests: Add X86_PROPERTY_* framework to retrieve CPUID values")
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221122013309.1872347-1-seanjc@google.com
      0c326523
    • Sean Christopherson's avatar
      KVM: selftests: Do kvm_cpu_has() checks before creating VM+vCPU · 553d1652
      Sean Christopherson authored
      Move the AMX test's kvm_cpu_has() checks before creating the VM+vCPU,
      there are no dependencies between the two operations.  Opportunistically
      add a comment to call out that enabling off-by-default XSAVE-managed
      features must be done before KVM_GET_SUPPORTED_CPUID is cached.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221128225735.3291648-5-seanjc@google.com
      553d1652
    • Sean Christopherson's avatar
      KVM: selftests: Disallow "get supported CPUID" before REQ_XCOMP_GUEST_PERM · cd5f3d21
      Sean Christopherson authored
      Disallow using kvm_get_supported_cpuid() and thus caching KVM's supported
      CPUID info before enabling XSAVE-managed features that are off-by-default
      and must be enabled by ARCH_REQ_XCOMP_GUEST_PERM.  Caching the supported
      CPUID before all XSAVE features are enabled can result in false negatives
      due to testing features that were cached before they were enabled.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221128225735.3291648-4-seanjc@google.com
      cd5f3d21
    • Sean Christopherson's avatar
      KVM: selftests: Move __vm_xsave_require_permission() below CPUID helpers · 2ceade1d
      Sean Christopherson authored
      Move __vm_xsave_require_permission() below the CPUID helpers so that a
      future change can reference the cached result of KVM_GET_SUPPORTED_CPUID
      while keeping the definition of the variable close to its intended user,
      kvm_get_supported_cpuid().
      
      No functional change intended.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221128225735.3291648-3-seanjc@google.com
      2ceade1d
    • Lei Wang's avatar
      KVM: selftests: Move XFD CPUID checking out of __vm_xsave_require_permission() · 18eee7bf
      Lei Wang authored
      Move the kvm_cpu_has() check on X86_FEATURE_XFD out of the helper to
      enable off-by-default XSAVE-managed features and into the one test that
      currenty requires XFD (XFeature Disable) support.   kvm_cpu_has() uses
      kvm_get_supported_cpuid() and thus caches KVM_GET_SUPPORTED_CPUID, and so
      using kvm_cpu_has() before ARCH_REQ_XCOMP_GUEST_PERM effectively results
      in the test caching stale values, e.g. subsequent checks on AMX_TILE will
      get false negatives.
      
      Although off-by-default features are nonsensical without XFD, checking
      for XFD virtualization prior to enabling such features isn't strictly
      required.
      Signed-off-by: default avatarLei Wang <lei4.wang@intel.com>
      Fixes: 7fbb653e ("KVM: selftests: Check KVM's supported CPUID, not host CPUID, for XFD")
      Link: https://lore.kernel.org/r/20221125023839.315207-1-lei4.wang@intel.com
      [sean: add Fixes, reword changelog]
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221128225735.3291648-2-seanjc@google.com
      18eee7bf
    • Sean Christopherson's avatar
      KVM: selftests: Restore assert for non-nested VMs in access tracking test · 8fcee042
      Sean Christopherson authored
      Restore the assert (on x86-64) that <10% of pages are still idle when NOT
      running as a nested VM in the access tracking test.  The original assert
      was converted to a "warning" to avoid false failures when running the
      test in a VM, but the non-nested case does not suffer from the same
      "infinite TLB size" issue.
      
      Using the HYPERVISOR flag isn't infallible as VMMs aren't strictly
      required to enumerate the "feature" in CPUID, but practically speaking
      anyone that is running KVM selftests in VMs is going to be using a VMM
      and hypervisor that sets the HYPERVISOR flag.
      
      Cc: David Matlack <dmatlack@google.com>
      Reviewed-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221129175300.4052283-3-seanjc@google.com
      8fcee042
    • Sean Christopherson's avatar
      KVM: selftests: Fix inverted "warning" in access tracking perf test · a33004e8
      Sean Christopherson authored
      Warn if the number of idle pages is greater than or equal to 10% of the
      total number of pages, not if the percentage of idle pages is less than
      10%.  The original code asserted that less than 10% of pages were still
      idle, but the check got inverted when the assert was converted to a
      warning.
      
      Opportunistically clean up the warning; selftests are 64-bit only, there
      is no need to use "%PRIu64" instead of "%lu".
      
      Fixes: 6336a810 ("KVM: selftests: replace assertion with warning in access_tracking_perf_test")
      Reviewed-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221129175300.4052283-2-seanjc@google.com
      a33004e8
  2. 30 Nov, 2022 6 commits
    • Paolo Bonzini's avatar
      KVM: x86: fix uninitialized variable use on KVM_REQ_TRIPLE_FAULT · df0bb47b
      Paolo Bonzini authored
      If a triple fault was fixed by kvm_x86_ops.nested_ops->triple_fault (by
      turning it into a vmexit), there is no need to leave vcpu_enter_guest().
      Any vcpu->requests will be caught later before the actual vmentry,
      and in fact vcpu_enter_guest() was not initializing the "r" variable.
      Depending on the compiler's whims, this could cause the
      x86_64/triple_fault_event_test test to fail.
      
      Cc: Maxim Levitsky <mlevitsk@redhat.com>
      Fixes: 92e7d5c8 ("KVM: x86: allow L1 to not intercept triple fault")
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      df0bb47b
    • Michal Luczaj's avatar
      KVM: x86: Remove unused argument in gpc_unmap_khva() · c1a81f3b
      Michal Luczaj authored
      Remove the unused @kvm argument from gpc_unmap_khva().
      Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c1a81f3b
    • Michal Luczaj's avatar
      KVM: Shorten gfn_to_pfn_cache function names · aba3caef
      Michal Luczaj authored
      Formalize "gpc" as the acronym and use it in function names.
      
      No functional change intended.
      Suggested-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      aba3caef
    • David Woodhouse's avatar
      KVM: x86/xen: Add runstate tests for 32-bit mode and crossing page boundary · 8acc3518
      David Woodhouse authored
      Torture test the cases where the runstate crosses a page boundary, and
      and especially the case where it's configured in 32-bit mode and doesn't,
      but then switching to 64-bit mode makes it go onto the second page.
      
      To simplify this, make the KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST ioctl
      also update the guest runstate area. It already did so if the actual
      runstate changed, as a side-effect of kvm_xen_update_runstate(). So
      doing it in the plain adjustment case is making it more consistent, as
      well as giving us a nice way to trigger the update without actually
      running the vCPU again and changing the values.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8acc3518
    • David Woodhouse's avatar
      KVM: x86/xen: Allow XEN_RUNSTATE_UPDATE flag behaviour to be configured · d8ba8ba4
      David Woodhouse authored
      Closer inspection of the Xen code shows that we aren't supposed to be
      using the XEN_RUNSTATE_UPDATE flag unconditionally. It should be
      explicitly enabled by guests through the HYPERVISOR_vm_assist hypercall.
      If we randomly set the top bit of ->state_entry_time for a guest that
      hasn't asked for it and doesn't expect it, that could make the runtimes
      fail to add up and confuse the guest. Without the flag it's perfectly
      safe for a vCPU to read its own vcpu_runstate_info; just not for one
      vCPU to read *another's*.
      
      I briefly pondered adding a word for the whole set of VMASST_TYPE_*
      flags but the only one we care about for HVM guests is this, so it
      seemed a bit pointless.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Message-Id: <20221127122210.248427-3-dwmw2@infradead.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d8ba8ba4
    • David Woodhouse's avatar
      KVM: x86/xen: Compatibility fixes for shared runstate area · 5ec3289b
      David Woodhouse authored
      The guest runstate area can be arbitrarily byte-aligned. In fact, even
      when a sane 32-bit guest aligns the overall structure nicely, the 64-bit
      fields in the structure end up being unaligned due to the fact that the
      32-bit ABI only aligns them to 32 bits.
      
      So setting the ->state_entry_time field to something|XEN_RUNSTATE_UPDATE
      is buggy, because if it's unaligned then we can't update the whole field
      atomically; the low bytes might be observable before the _UPDATE bit is.
      Xen actually updates the *byte* containing that top bit, on its own. KVM
      should do the same.
      
      In addition, we cannot assume that the runstate area fits within a single
      page. One option might be to make the gfn_to_pfn cache cope with regions
      that cross a page — but getting a contiguous virtual kernel mapping of a
      discontiguous set of IOMEM pages is a distinctly non-trivial exercise,
      and it seems this is the *only* current use case for the GPC which would
      benefit from it.
      
      An earlier version of the runstate code did use a gfn_to_hva cache for
      this purpose, but it still had the single-page restriction because it
      used the uhva directly — because it needs to be able to do so atomically
      when the vCPU is being scheduled out, so it used pagefault_disable()
      around the accesses and didn't just use kvm_write_guest_cached() which
      has a fallback path.
      
      So... use a pair of GPCs for the first and potential second page covering
      the runstate area. We can get away with locking both at once because
      nothing else takes more than one GPC lock at a time so we can invent
      a trivial ordering rule.
      
      The common case where it's all in the same page is kept as a fast path,
      but in both cases, the actual guest structure (compat or not) is built
      up from the fields in @vx, following preset pointers to the state and
      times fields. The only difference is whether those pointers point to
      the kernel stack (in the split case) or to guest memory directly via
      the GPC.  The fast path is also fixed to use a byte access for the
      XEN_RUNSTATE_UPDATE bit, then the only real difference is the dual
      memcpy.
      
      Finally, Xen also does write the runstate area immediately when it's
      configured. Flip the kvm_xen_update_runstate() and …_guest() functions
      and call the latter directly when the runstate area is set. This means
      that other ioctls which modify the runstate also write it immediately
      to the guest when they do so, which is also intended.
      
      Update the xen_shinfo_test to exercise the pathological case where the
      XEN_RUNSTATE_UPDATE flag in the top byte of the state_entry_time is
      actually in a different page to the rest of the 64-bit word.
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5ec3289b
  3. 28 Nov, 2022 12 commits
    • Paolo Bonzini's avatar
      Merge tag 'kvm-s390-next-6.2-1' of... · 1e79a9e3
      Paolo Bonzini authored
      Merge tag 'kvm-s390-next-6.2-1' of https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
      
      - Second batch of the lazy destroy patches
      - First batch of KVM changes for kernel virtual != physical address support
      - Removal of a unused function
      1e79a9e3
    • Jiaxi Chen's avatar
      KVM: x86: Advertise PREFETCHIT0/1 CPUID to user space · 29c46979
      Jiaxi Chen authored
      Latest Intel platform Granite Rapids has introduced a new instruction -
      PREFETCHIT0/1, which moves code to memory (cache) closer to the
      processor depending on specific hints.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EDX[bit 14]
      
      PREFETCHIT0/1 is on a KVM-only subleaf. Plus an x86_FEATURE definition
      for this feature bit to direct it to the KVM entry.
      
      Advertise PREFETCHIT0/1 to KVM userspace. This is safe because there are
      no new VMX controls or additional host enabling required for guests to
      use this feature.
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Message-Id: <20221125125845.1182922-9-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      29c46979
    • Jiaxi Chen's avatar
      KVM: x86: Advertise AVX-NE-CONVERT CPUID to user space · 9977f087
      Jiaxi Chen authored
      AVX-NE-CONVERT is a new set of instructions which can convert low
      precision floating point like BF16/FP16 to high precision floating point
      FP32, and can also convert FP32 elements to BF16. This instruction
      allows the platform to have improved AI capabilities and better
      compatibility.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EDX[bit 5]
      
      AVX-NE-CONVERT is on a KVM-only subleaf. Plus an x86_FEATURE definition
      for this feature bit to direct it to the KVM entry.
      
      Advertise AVX-NE-CONVERT to KVM userspace. This is safe because there
      are no new VMX controls or additional host enabling required for guests
      to use this feature.
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Message-Id: <20221125125845.1182922-8-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9977f087
    • Jiaxi Chen's avatar
      KVM: x86: Advertise AVX-VNNI-INT8 CPUID to user space · 24d74b9f
      Jiaxi Chen authored
      AVX-VNNI-INT8 is a new set of instructions in the latest Intel platform
      Sierra Forest, aims for the platform to have superior AI capabilities.
      This instruction multiplies the individual bytes of two unsigned or
      unsigned source operands, then adds and accumulates the results into the
      destination dword element size operand.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EDX[bit 4]
      
      AVX-VNNI-INT8 is on a new and sparse CPUID leaf and all bits on this
      leaf have no truly kernel use case for now. Given that and to save space
      for kernel feature bits, move this new leaf to KVM-only subleaf and plus
      an x86_FEATURE definition for AVX-VNNI-INT8 to direct it to the KVM
      entry.
      
      Advertise AVX-VNNI-INT8 to KVM userspace. This is safe because there are
      no new VMX controls or additional host enabling required for guests to
      use this feature.
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Message-Id: <20221125125845.1182922-7-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      24d74b9f
    • Jiaxi Chen's avatar
      x86: KVM: Advertise AVX-IFMA CPUID to user space · 5e85c4eb
      Jiaxi Chen authored
      AVX-IFMA is a new instruction in the latest Intel platform Sierra
      Forest. This instruction packed multiplies unsigned 52-bit integers and
      adds the low/high 52-bit products to Qword Accumulators.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EAX[bit 23]
      
      AVX-IFMA is on an expected-dense CPUID leaf and some other bits on this
      leaf have kernel usages. Given that, define this feature bit like
      X86_FEATURE_<name> in kernel. Considering AVX-IFMA itself has no truly
      kernel usages and /proc/cpuinfo has too much unreadable flags, hide this
      one in /proc/cpuinfo.
      
      Advertise AVX-IFMA to KVM userspace. This is safe because there are no
      new VMX controls or additional host enabling required for guests to use
      this feature.
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Message-Id: <20221125125845.1182922-6-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5e85c4eb
    • Chang S. Bae's avatar
      x86: KVM: Advertise AMX-FP16 CPUID to user space · af2872f6
      Chang S. Bae authored
      Latest Intel platform Granite Rapids has introduced a new instruction -
      AMX-FP16, which performs dot-products of two FP16 tiles and accumulates
      the results into a packed single precision tile. AMX-FP16 adds FP16
      capability and also allows a FP16 GPU trained model to run faster
      without loss of accuracy or added SW overhead.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EAX[bit 21]
      
      AMX-FP16 is on an expected-dense CPUID leaf and some other bits on this
      leaf have kernel usages. Given that, define this feature bit like
      X86_FEATURE_<name> in kernel. Considering AMX-FP16 itself has no truly
      kernel usages and /proc/cpuinfo has too much unreadable flags, hide this
      one in /proc/cpuinfo.
      
      Advertise AMX-FP16 to KVM userspace. This is safe because there are no
      new VMX controls or additional host enabling required for guests to use
      this feature.
      Signed-off-by: default avatarChang S. Bae <chang.seok.bae@intel.com>
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Message-Id: <20221125125845.1182922-5-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      af2872f6
    • Jiaxi Chen's avatar
      x86: KVM: Advertise CMPccXADD CPUID to user space · 6a19d7aa
      Jiaxi Chen authored
      CMPccXADD is a new set of instructions in the latest Intel platform
      Sierra Forest. This new instruction set includes a semaphore operation
      that can compare and add the operands if condition is met, which can
      improve database performance.
      
      The bit definition:
      CPUID.(EAX=7,ECX=1):EAX[bit 7]
      
      CMPccXADD is on an expected-dense CPUID leaf and some other bits on this
      leaf have kernel usages. Given that, define this feature bit like
      X86_FEATURE_<name> in kernel. Considering CMPccXADD itself has no truly
      kernel usages and /proc/cpuinfo has too much unreadable flags, hide this
      one in /proc/cpuinfo.
      
      Advertise CMPCCXADD to KVM userspace. This is safe because there are no
      new VMX controls or additional host enabling required for guests to use
      this feature.
      Signed-off-by: default avatarJiaxi Chen <jiaxi.chen@linux.intel.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Message-Id: <20221125125845.1182922-4-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      6a19d7aa
    • Sean Christopherson's avatar
      KVM: x86: Update KVM-only leaf handling to allow for 100% KVM-only leafs · 047c7229
      Sean Christopherson authored
      Rename kvm_cpu_cap_init_scattered() to kvm_cpu_cap_init_kvm_defined() in
      anticipation of adding KVM-only CPUID leafs that aren't recognized by the
      kernel and thus not scattered, i.e. for leafs that are 100% KVM-defined.
      
      Adjust/add comments to kvm_only_cpuid_leafs and KVM_X86_FEATURE to
      document how to create new kvm_only_cpuid_leafs entries for scattered
      features as well as features that are entirely unknown to the kernel.
      
      No functional change intended.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221125125845.1182922-3-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      047c7229
    • Sean Christopherson's avatar
      KVM: x86: Add BUILD_BUG_ON() to detect bad usage of "scattered" flags · c4690d01
      Sean Christopherson authored
      Add a compile-time assert in the SF() macro to detect improper usage,
      i.e. to detect passing in an X86_FEATURE_* flag that isn't actually
      scattered by the kernel.  Upcoming feature flags will be 100% KVM-only
      and will have X86_FEATURE_* macros that point at a kvm_only_cpuid_leafs
      word, not a kernel-defined word.  Using SF() and thus boot_cpu_has() for
      such feature flags would access memory beyond x86_capability[NCAPINTS]
      and at best incorrectly hide a feature, and at worst leak kernel state to
      userspace.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221125125845.1182922-2-jiaxi.chen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c4690d01
    • David Woodhouse's avatar
      MAINTAINERS: Add KVM x86/xen maintainer list · 7927e275
      David Woodhouse authored
      Adding Paul as co-maintainer of Xen support to help ensure that things
      don't fall through the cracks when I spend three months at a time
      travelling...
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7927e275
    • David Woodhouse's avatar
    • Paolo Bonzini's avatar
      KVM: always declare prototype for kvm_arch_irqchip_in_kernel · 3ca9d84e
      Paolo Bonzini authored
      Architecture code might want to use it even if CONFIG_HAVE_KVM_IRQ_ROUTING
      is false; for example PPC XICS has KVM_IRQ_LINE and wants to use
      kvm_arch_irqchip_in_kernel from there, but it does not have
      KVM_SET_GSI_ROUTING so the prototype was not provided.
      
      Fixes: d663b8a2 ("KVM: replace direct irq.h inclusion")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      3ca9d84e
  4. 24 Nov, 2022 1 commit
  5. 23 Nov, 2022 11 commits
  6. 21 Nov, 2022 3 commits