1. 04 2月, 2021 6 次提交
  2. 08 1月, 2021 2 次提交
  3. 12 12月, 2020 2 次提交
    • A
      selftests: kvm: Merge user_msr_test into userspace_msr_exit_test · fb636053
      Aaron Lewis 提交于
      Both user_msr_test and userspace_msr_exit_test tests the functionality
      of kvm_msr_filter.  Instead of testing this feature in two tests, merge
      them together, so there is only one test for this feature.
      Signed-off-by: NAaron Lewis <aaronlewis@google.com>
      Message-Id: <20201204172530.2958493-1-aaronlewis@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fb636053
    • A
      selftests: kvm: Test MSR exiting to userspace · 3cea1891
      Aaron Lewis 提交于
      Add a selftest to test that when the ioctl KVM_X86_SET_MSR_FILTER is
      called with an MSR list, those MSRs exit to userspace.
      
      This test uses 3 MSRs to test this:
        1. MSR_IA32_XSS, an MSR the kernel knows about.
        2. MSR_IA32_FLUSH_CMD, an MSR the kernel does not know about.
        3. MSR_NON_EXISTENT, an MSR invented in this test for the purposes of
           passing a fake MSR from the guest to userspace.  KVM just acts as a
           pass through.
      
      Userspace is also able to inject a #GP.  This is demonstrated when
      MSR_IA32_XSS and MSR_IA32_FLUSH_CMD are misused in the test.  When this
      happens a #GP is initiated in userspace to be thrown in the guest which is
      handled gracefully by the exception handling framework introduced earlier
      in this series.
      
      Tests for the generic instruction emulator were also added.  For this to
      work the module parameter kvm.force_emulation_prefix=1 has to be enabled.
      If it isn't enabled the tests will be skipped.
      
      A test was also added to ensure the MSR permission bitmap is being set
      correctly by executing reads and writes of MSR_FS_BASE and MSR_GS_BASE
      in the guest while alternating which MSR userspace should intercept.  If
      the permission bitmap is being set correctly only one of the MSRs should
      be coming through at a time, and the guest should be able to read and
      write the other one directly.
      Signed-off-by: NAaron Lewis <aaronlewis@google.com>
      Reviewed-by: NAlexander Graf <graf@amazon.com>
      Message-Id: <20201012194716.3950330-5-aaronlewis@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3cea1891
  4. 10 12月, 2020 1 次提交
  5. 15 11月, 2020 1 次提交
  6. 08 11月, 2020 6 次提交
  7. 31 10月, 2020 1 次提交
  8. 28 9月, 2020 2 次提交
    • P
      KVM: x86: do not attempt TSC synchronization on guest writes · 0c899c25
      Paolo Bonzini 提交于
      KVM special-cases writes to MSR_IA32_TSC so that all CPUs have
      the same base for the TSC.  This logic is complicated, and we
      do not want it to have any effect once the VM is started.
      
      In particular, if any guest started to synchronize its TSCs
      with writes to MSR_IA32_TSC rather than MSR_IA32_TSC_ADJUST,
      the additional effect of kvm_write_tsc code would be uncharted
      territory.
      
      Therefore, this patch makes writes to MSR_IA32_TSC behave
      essentially the same as writes to MSR_IA32_TSC_ADJUST when
      they come from the guest.  A new selftest (which passes
      both before and after the patch) checks the current semantics
      of writes to MSR_IA32_TSC and MSR_IA32_TSC_ADJUST originating
      from both the host and the guest.
      
      Upcoming work to remove the special side effects
      of host-initiated writes to MSR_IA32_TSC and MSR_IA32_TSC_ADJUST
      will be able to build onto this test, adjusting the host side
      to use the new APIs and achieve the same effect.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0c899c25
    • A
      KVM: selftests: Add test for user space MSR handling · d468706e
      Alexander Graf 提交于
      Now that we have the ability to handle MSRs from user space and also to
      select which ones we do want to prevent in-kernel KVM code from handling,
      let's add a selftest to show case and verify the API.
      Signed-off-by: NAlexander Graf <graf@amazon.com>
      
      Message-Id: <20200925143422.21718-9-graf@amazon.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d468706e
  9. 05 6月, 2020 1 次提交
    • V
      KVM: selftests: Fix build with "make ARCH=x86_64" · b80db73d
      Vitaly Kuznetsov 提交于
      Marcelo reports that kvm selftests fail to build with
      "make ARCH=x86_64":
      
      gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99
       -fno-stack-protector -fno-PIE -I../../../../tools/include
       -I../../../../tools/arch/x86_64/include  -I../../../../usr/include/
       -Iinclude -Ilib -Iinclude/x86_64 -I.. -c lib/kvm_util.c
       -o /var/tmp/20200604202744-bin/lib/kvm_util.o
      
      In file included from lib/kvm_util.c:11:
      include/x86_64/processor.h:14:10: fatal error: asm/msr-index.h: No such
       file or directory
      
       #include <asm/msr-index.h>
                ^~~~~~~~~~~~~~~~~
      compilation terminated.
      
      "make ARCH=x86", however, works. The problem is that arch specific headers
      for x86_64 live in 'tools/arch/x86/include', not in
      'tools/arch/x86_64/include'.
      
      Fixes: 66d69e08 ("selftests: fix kvm relocatable native/cross builds and installs")
      Reported-by: NMarcelo Bandeira Condotta <mcondotta@redhat.com>
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Message-Id: <20200605142028.550068-1-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b80db73d
  10. 01 6月, 2020 1 次提交
  11. 07 5月, 2020 1 次提交
  12. 01 5月, 2020 1 次提交
    • S
      selftests: fix kvm relocatable native/cross builds and installs · 66d69e08
      Shuah Khan 提交于
      kvm test Makefile doesn't fully support cross-builds and installs.
      UNAME_M = $(shell uname -m) variable is used to define the target
      programs and libraries to be built from arch specific sources in
      sub-directories.
      
      For cross-builds to work, UNAME_M has to map to ARCH and arch specific
      directories and targets in this Makefile.
      
      UNAME_M variable to used to run the compiles pointing to the right arch
      directories and build the right targets for these supported architectures.
      
      TEST_GEN_PROGS and LIBKVM are set using UNAME_M variable.
      LINUX_TOOL_ARCH_INCLUDE is set using ARCH variable.
      
      x86_64 targets are named to include x86_64 as a suffix and directories
      for includes are in x86_64 sub-directory. s390x and aarch64 follow the
      same convention. "uname -m" doesn't result in the correct mapping for
      s390x and aarch64. Fix it to set UNAME_M correctly for s390x and aarch64
      cross-builds.
      
      In addition, Makefile doesn't create arch sub-directories in the case of
      relocatable builds and test programs under s390x and x86_64 directories
      fail to build. This is a problem for native and cross-builds. Fix it to
      create all necessary directories keying off of TEST_GEN_PROGS.
      
      The following use-cases work with this change:
      
      Native x86_64:
      make O=/tmp/kselftest -C tools/testing/selftests TARGETS=kvm install \
       INSTALL_PATH=$HOME/x86_64
      
      arm64 cross-build:
      make O=$HOME/arm64_build/ ARCH=arm64 HOSTCC=gcc \
      	CROSS_COMPILE=aarch64-linux-gnu- defconfig
      
      make O=$HOME/arm64_build/ ARCH=arm64 HOSTCC=gcc \
      	CROSS_COMPILE=aarch64-linux-gnu- all
      
      make kselftest-install TARGETS=kvm O=$HOME/arm64_build ARCH=arm64 \
      	HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu-
      
      s390x cross-build:
      make O=$HOME/s390x_build/ ARCH=s390 HOSTCC=gcc \
      	CROSS_COMPILE=s390x-linux-gnu- defconfig
      
      make O=$HOME/s390x_build/ ARCH=s390 HOSTCC=gcc \
      	CROSS_COMPILE=s390x-linux-gnu- all
      
      make kselftest-install TARGETS=kvm O=$HOME/s390x_build/ ARCH=s390 \
      	HOSTCC=gcc CROSS_COMPILE=s390x-linux-gnu- all
      
      No regressions in the following use-cases:
      make -C tools/testing/selftests TARGETS=kvm
      make kselftest-all TARGETS=kvm
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      66d69e08
  13. 16 4月, 2020 1 次提交
  14. 17 3月, 2020 3 次提交
  15. 25 2月, 2020 1 次提交
  16. 13 2月, 2020 2 次提交
  17. 31 1月, 2020 1 次提交
  18. 14 1月, 2020 1 次提交
  19. 22 10月, 2019 1 次提交
  20. 03 10月, 2019 1 次提交
    • S
      selftests: kvm: Fix libkvm build error · 6e06983d
      Shuah Khan 提交于
      Fix the following build error from "make TARGETS=kvm kselftest":
      
      libkvm.a(assert.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
      
      This error is seen when build is done from the main Makefile using
      kselftest target. In this case KBUILD_CPPFLAGS and CC_OPTION_CFLAGS
      are defined.
      
      When build is invoked using:
      
      "make -C tools/testing/selftests/kvm" KBUILD_CPPFLAGS and CC_OPTION_CFLAGS
      aren't defined.
      
      There is no need to pass in KBUILD_CPPFLAGS and CC_OPTION_CFLAGS for the
      check to determine if --no-pie is necessary, which is the case when these
      two aren't defined when "make -C tools/testing/selftests/kvm" runs.
      
      Fix it by simplifying the no-pie-option logic. With this change, both
      build variations work.
      
      "make TARGETS=kvm kselftest"
      "make -C tools/testing/selftests/kvm"
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6e06983d
  21. 27 9月, 2019 1 次提交
  22. 29 8月, 2019 1 次提交
  23. 02 8月, 2019 2 次提交