1. 26 Sep, 2022 29 commits
  2. 30 Aug, 2022 2 commits
  3. 24 Aug, 2022 4 commits
  4. 19 Aug, 2022 5 commits
    • David Matlack's avatar
      KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE() · 372d0708
      David Matlack authored
      Change the mov in KVM_ASM_SAFE() that zeroes @vector to a movb to
      make it unambiguous.
      
      This fixes a build failure with Clang since, unlike the GNU assembler,
      the LLVM integrated assembler rejects ambiguous X86 instructions that
      don't have suffixes:
      
        In file included from x86_64/hyperv_features.c:13:
        include/x86_64/processor.h:825:9: error: ambiguous instructions require an explicit suffix (could be 'movb', 'movw', 'movl', or 'movq')
                return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
                       ^
        include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
                asm volatile(KVM_ASM_SAFE(insn)                 \
                             ^
        include/x86_64/processor.h:788:16: note: expanded from macro 'KVM_ASM_SAFE'
                "1: " insn "\n\t"                                       \
                              ^
        <inline asm>:5:2: note: instantiated into assembly here
                mov $0, 15(%rsp)
                ^
      
      It seems like this change could introduce undesirable behavior in the
      future, e.g. if someone used a type larger than a u8 for @vector, since
      KVM_ASM_SAFE() will only zero the bottom byte. I tried changing the type
      of @vector to an int to see what would happen. GCC failed to compile due
      to a size mismatch between `movb` and `%eax`. Clang succeeded in
      compiling, but the generated code looked correct, so perhaps it will not
      be an issue. That being said it seems like there could be a better
      solution to this issue that does not assume @vector is a u8.
      
      Fixes: 3b23054c ("KVM: selftests: Add x86-64 support for exception fixup")
      Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220722234838.2160385-3-dmatlack@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      372d0708
    • David Matlack's avatar
      KVM: selftests: Fix KVM_EXCEPTION_MAGIC build with Clang · 67ef8664
      David Matlack authored
      Change KVM_EXCEPTION_MAGIC to use the all-caps "ULL", rather than lower
      case. This fixes a build failure with Clang:
      
        In file included from x86_64/hyperv_features.c:13:
        include/x86_64/processor.h:825:9: error: unexpected token in argument list
                return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr));
                       ^
        include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe'
                asm volatile(KVM_ASM_SAFE(insn)                 \
                             ^
        include/x86_64/processor.h:785:2: note: expanded from macro 'KVM_ASM_SAFE'
                "mov $" __stringify(KVM_EXCEPTION_MAGIC) ", %%r9\n\t"   \
                ^
        <inline asm>:1:18: note: instantiated into assembly here
                mov $0xabacadabaull, %r9
                                ^
      
      Fixes: 3b23054c ("KVM: selftests: Add x86-64 support for exception fixup")
      Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220722234838.2160385-2-dmatlack@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      67ef8664
    • Jim Mattson's avatar
      KVM: VMX: Heed the 'msr' argument in msr_write_intercepted() · 020dac41
      Jim Mattson authored
      Regardless of the 'msr' argument passed to the VMX version of
      msr_write_intercepted(), the function always checks to see if a
      specific MSR (IA32_SPEC_CTRL) is intercepted for write.  This behavior
      seems unintentional and unexpected.
      
      Modify the function so that it checks to see if the provided 'msr'
      index is intercepted for write.
      
      Fixes: 67f4b996 ("KVM: nVMX: Handle dynamic MSR intercept toggling")
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220810213050.2655000-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      020dac41
    • Junaid Shahid's avatar
      kvm: x86: mmu: Always flush TLBs when enabling dirty logging · b64d740e
      Junaid Shahid authored
      When A/D bits are not available, KVM uses a software access tracking
      mechanism, which involves making the SPTEs inaccessible. However,
      the clear_young() MMU notifier does not flush TLBs. So it is possible
      that there may still be stale, potentially writable, TLB entries.
      This is usually fine, but can be problematic when enabling dirty
      logging, because it currently only does a TLB flush if any SPTEs were
      modified. But if all SPTEs are in access-tracked state, then there
      won't be a TLB flush, which means that the guest could still possibly
      write to memory and not have it reflected in the dirty bitmap.
      
      So just unconditionally flush the TLBs when enabling dirty logging.
      As an alternative, KVM could explicitly check the MMU-Writable bit when
      write-protecting SPTEs to decide if a flush is needed (instead of
      checking the Writable bit), but given that a flush almost always happens
      anyway, so just making it unconditional seems simpler.
      Signed-off-by: default avatarJunaid Shahid <junaids@google.com>
      Message-Id: <20220810224939.2611160-1-junaids@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b64d740e
    • Junaid Shahid's avatar
      kvm: x86: mmu: Drop the need_remote_flush() function · 1441ca14
      Junaid Shahid authored
      This is only used by kvm_mmu_pte_write(), which no longer actually
      creates the new SPTE and instead just clears the old SPTE. So we
      just need to check if the old SPTE was shadow-present instead of
      calling need_remote_flush(). Hence we can drop this function. It was
      incomplete anyway as it didn't take access-tracking into account.
      
      This patch should not result in any functional change.
      Signed-off-by: default avatarJunaid Shahid <junaids@google.com>
      Reviewed-by: default avatarDavid Matlack <dmatlack@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220723024316.2725328-1-junaids@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      1441ca14