linux-stable/arch/x86/kvm
Nikunj A Dadhania fffb532378 KVM: x86: Check for rmaps allocation
With TDP MMU being the default now, access to mmu_rmaps_stat debugfs
file causes following oops:

BUG: kernel NULL pointer dereference, address: 0000000000000000
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 7 PID: 3185 Comm: cat Not tainted 5.16.0-rc4+ #204
RIP: 0010:pte_list_count+0x6/0x40
 Call Trace:
  <TASK>
  ? kvm_mmu_rmaps_stat_show+0x15e/0x320
  seq_read_iter+0x126/0x4b0
  ? aa_file_perm+0x124/0x490
  seq_read+0xf5/0x140
  full_proxy_read+0x5c/0x80
  vfs_read+0x9f/0x1a0
  ksys_read+0x67/0xe0
  __x64_sys_read+0x19/0x20
  do_syscall_64+0x3b/0xc0
  entry_SYSCALL_64_after_hwframe+0x44/0xae
 RIP: 0033:0x7fca6fc13912

Return early when rmaps are not present.

Reported-by: Vasant Hegde <vasant.hegde@amd.com>
Tested-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220105040337.4234-1-nikunj@amd.com>
Cc: stable@vger.kernel.org
Fixes: 3bcd0662d6 ("KVM: X86: Introduce mmu_rmaps_stat per-vm debugfs file")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-01-07 12:04:01 -05:00
..
mmu KVM: x86/mmu: Don't advance iterator after restart due to yielding 2021-12-20 08:06:53 -05:00
svm KVM: SEV: Mark nested locking of kvm->lock 2022-01-07 12:01:55 -05:00
vmx KVM: VMX: Wake vCPU when delivering posted IRQ even if vCPU == this vCPU 2021-12-21 12:39:03 -05:00
Kconfig KVM: x86: add config for non-kvm users of page tracking 2021-10-01 03:44:57 -04:00
Makefile KVM: stats: Add fd-based API to read binary stats data 2021-06-24 11:47:57 -04:00
cpuid.c cpuid: kvm_find_kvm_cpuid_features() should be declared 'static' 2021-11-18 02:03:14 -05:00
cpuid.h KVM: x86: Move reverse CPUID helpers to separate header file 2021-04-26 05:27:13 -04:00
debugfs.c KVM: x86: Check for rmaps allocation 2022-01-07 12:04:01 -05:00
emulate.c KVM/arm64 updates for Linux 5.16 2021-10-31 02:28:48 -04:00
fpu.h KVM: x86: Move FPU register accessors into fpu.h 2021-06-17 13:09:24 -04:00
hyperv.c KVM: x86: Ignore sparse banks size for an "all CPUs", non-sparse IPI req 2021-12-10 07:12:42 -05:00
hyperv.h KVM: x86: Query vcpu->vcpu_idx directly and drop its accessor 2021-09-22 10:33:11 -04:00
i8254.c KVM: x86: Migrate the PIT only if vcpu0 is migrated, not any BSP 2021-08-02 11:01:51 -04:00
i8254.h
i8259.c x86: Fix typo s/ECLR/ELCR/ for the PIC register 2021-08-10 23:31:44 +02:00
ioapic.c kvm: rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS 2021-09-30 04:27:05 -04:00
ioapic.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq.c KVM: x86/xen: Add event channel interrupt vector upcall 2021-02-04 14:19:39 +00:00
irq.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq_comm.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
kvm_cache_regs.h KVM: x86: Introduce KVM_GET_SREGS2 / KVM_SET_SREGS2 2021-06-17 13:09:47 -04:00
kvm_emulate.h KVM: x86: Drop "pre_" from enter/leave_smm() helpers 2021-06-17 13:09:35 -04:00
kvm_onhyperv.c KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx 2021-06-17 13:09:36 -04:00
kvm_onhyperv.h KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx 2021-06-17 13:09:36 -04:00
lapic.c KVM: x86: check PIR even for vCPUs with disabled APICv 2021-11-30 03:52:39 -05:00
lapic.h KVM: x86: Rename kvm_lapic_enable_pv_eoi() 2021-11-11 10:56:22 -05:00
mmu.h KVM: X86: Don't unload MMU in kvm_vcpu_flush_tlb_guest() 2021-10-22 05:44:43 -04:00
mtrr.c KVM: x86: Add helper to consolidate "raw" reserved GPA mask calculations 2021-02-04 09:27:30 -05:00
pmu.c kvm: x86: Convert return type of *is_valid_rdpmc_ecx() to bool 2021-11-11 10:56:19 -05:00
pmu.h kvm: x86: Convert return type of *is_valid_rdpmc_ecx() to bool 2021-11-11 10:56:19 -05:00
reverse_cpuid.h KVM: SEV: Mask CPUID[0x8000001F].eax according to supported features 2021-04-26 05:27:15 -04:00
trace.h KVM: x86: Get exit_reason as part of kvm_x86_ops.get_exit_info 2021-10-25 06:48:24 -04:00
tss.h
x86.c KVM: x86: Always set kvm_run->if_flag 2021-12-20 08:06:53 -05:00
x86.h KVM: nVMX: Abide to KVM_REQ_TLB_FLUSH_GUEST request on nested vmentry/vmexit 2021-11-26 07:07:49 -05:00
xen.c KVM: x86: Assume a 64-bit hypercall for guests with protected state 2021-11-18 02:12:13 -05:00
xen.h KVM: xen: do not use struct gfn_to_hva_cache 2021-08-05 03:31:40 -04:00