Commit a313c8e0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull KVM fixes from Paolo Bonzini:
 "PPC:
   - Fix a bug where we try to do an ultracall on a system without an
     ultravisor

  KVM:
   - Fix uninitialised sysreg accessor
   - Fix handling of demand-paged device mappings
   - Stop spamming the console on IMPDEF sysregs
   - Relax mappings of writable memslots
   - Assorted cleanups

  MIPS:
   - Now orphan, James Hogan is stepping down

  x86:
   - MAINTAINERS change, so long Radim and thanks for all the fish
   - supported CPUID fixes for AMD machines without SPEC_CTRL"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  MAINTAINERS: remove Radim from KVM maintainers
  MAINTAINERS: Orphan KVM for MIPS
  kvm: x86: Host feature SSBD doesn't imply guest feature AMD_SSBD
  kvm: x86: Host feature SSBD doesn't imply guest feature SPEC_CTRL_SSBD
  KVM: PPC: Book3S HV: Don't do ultravisor calls on systems without ultravisor
  KVM: arm/arm64: Properly handle faulting of device mappings
  KVM: arm64: Ensure 'params' is initialised when looking up sys register
  KVM: arm/arm64: Remove excessive permission check in kvm_arch_prepare_memory_region
  KVM: arm64: Don't log IMP DEF sysreg traps
  KVM: arm64: Sanely ratelimit sysreg messages
  KVM: arm/arm64: vgic: Use wrapper function to lock/unlock all vcpus in kvm_vgic_create()
  KVM: arm/arm64: vgic: Fix potential double free dist->spis in __kvm_vgic_destroy()
  KVM: arm/arm64: Get rid of unused arg in cpu_init_hyp_mode()
parents 7214618c d68321de
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -9041,7 +9041,6 @@ F: include/linux/umh.h
KERNEL VIRTUAL MACHINE (KVM)
M:	Paolo Bonzini <pbonzini@redhat.com>
M:	Radim Krčmář <rkrcmar@redhat.com>
L:	kvm@vger.kernel.org
W:	http://www.linux-kvm.org
T:	git git://git.kernel.org/pub/scm/virt/kvm/kvm.git
@@ -9076,9 +9075,9 @@ F: virt/kvm/arm/
F:	include/kvm/arm_*
KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
M:	James Hogan <jhogan@kernel.org>
L:	linux-mips@vger.kernel.org
S:	Supported
L:	kvm@vger.kernel.org
S:	Orphan
F:	arch/mips/include/uapi/asm/kvm*
F:	arch/mips/include/asm/kvm*
F:	arch/mips/kvm/
@@ -9113,7 +9112,6 @@ F: tools/testing/selftests/kvm/*/s390x/
KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
M:	Paolo Bonzini <pbonzini@redhat.com>
M:	Radim Krčmář <rkrcmar@redhat.com>
R:	Sean Christopherson <sean.j.christopherson@intel.com>
R:	Vitaly Kuznetsov <vkuznets@redhat.com>
R:	Wanpeng Li <wanpengli@tencent.com>
+18 −7
Original line number Diff line number Diff line
@@ -2098,9 +2098,9 @@ static void unhandled_cp_access(struct kvm_vcpu *vcpu,
		WARN_ON(1);
	}

	kvm_err("Unsupported guest CP%d access at: %08lx [%08lx]\n",
	print_sys_reg_msg(params,
			  "Unsupported guest CP%d access at: %08lx [%08lx]\n",
			  cp, *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
	print_sys_reg_instr(params);
	kvm_inject_undefined(vcpu);
}

@@ -2233,6 +2233,12 @@ int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
				NULL, 0);
}

static bool is_imp_def_sys_reg(struct sys_reg_params *params)
{
	// See ARM DDI 0487E.a, section D12.3.2
	return params->Op0 == 3 && (params->CRn & 0b1011) == 0b1011;
}

static int emulate_sys_reg(struct kvm_vcpu *vcpu,
			   struct sys_reg_params *params)
{
@@ -2248,10 +2254,12 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu,

	if (likely(r)) {
		perform_access(vcpu, params, r);
	} else if (is_imp_def_sys_reg(params)) {
		kvm_inject_undefined(vcpu);
	} else {
		kvm_err("Unsupported guest sys_reg access at: %lx [%08lx]\n",
		print_sys_reg_msg(params,
				  "Unsupported guest sys_reg access at: %lx [%08lx]\n",
				  *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
		print_sys_reg_instr(params);
		kvm_inject_undefined(vcpu);
	}
	return 1;
@@ -2360,8 +2368,11 @@ static const struct sys_reg_desc *index_to_sys_reg_desc(struct kvm_vcpu *vcpu,
	if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM64_SYSREG)
		return NULL;

	if (!index_to_params(id, &params))
		return NULL;

	table = get_target_table(vcpu->arch.target, true, &num);
	r = find_reg_by_id(id, &params, table, num);
	r = find_reg(&params, table, num);
	if (!r)
		r = find_reg(&params, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));

+15 −2
Original line number Diff line number Diff line
@@ -62,11 +62,24 @@ struct sys_reg_desc {
#define REG_HIDDEN_USER		(1 << 0) /* hidden from userspace ioctls */
#define REG_HIDDEN_GUEST	(1 << 1) /* hidden from guest */

static inline void print_sys_reg_instr(const struct sys_reg_params *p)
static __printf(2, 3)
inline void print_sys_reg_msg(const struct sys_reg_params *p,
				       char *fmt, ...)
{
	va_list va;

	va_start(va, fmt);
	/* Look, we even formatted it for you to paste into the table! */
	kvm_pr_unimpl(" { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
	kvm_pr_unimpl("%pV { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
		      &(struct va_format){ fmt, &va },
		      p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ? "write" : "read");
	va_end(va);
}

static inline void print_sys_reg_instr(const struct sys_reg_params *p)
{
	/* GCC warns on an empty format string */
	print_sys_reg_msg(p, "%s", "");
}

static inline bool ignore_write(struct kvm_vcpu *vcpu,
+2 −1
Original line number Diff line number Diff line
@@ -4983,6 +4983,7 @@ static void kvmppc_core_destroy_vm_hv(struct kvm *kvm)
		if (nesting_enabled(kvm))
			kvmhv_release_all_nested(kvm);
		kvm->arch.process_table = 0;
		if (kvm->arch.secure_guest)
			uv_svm_terminate(kvm->arch.lpid);
		kvmhv_set_ptbl_entry(kvm->arch.lpid, 0, 0);
	}
+4 −2
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
			entry->edx |= F(SPEC_CTRL);
		if (boot_cpu_has(X86_FEATURE_STIBP))
			entry->edx |= F(INTEL_STIBP);
		if (boot_cpu_has(X86_FEATURE_SSBD))
		if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
		    boot_cpu_has(X86_FEATURE_AMD_SSBD))
			entry->edx |= F(SPEC_CTRL_SSBD);
		/*
		 * We emulate ARCH_CAPABILITIES in software even
@@ -759,7 +760,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
			entry->ebx |= F(AMD_IBRS);
		if (boot_cpu_has(X86_FEATURE_STIBP))
			entry->ebx |= F(AMD_STIBP);
		if (boot_cpu_has(X86_FEATURE_SSBD))
		if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
		    boot_cpu_has(X86_FEATURE_AMD_SSBD))
			entry->ebx |= F(AMD_SSBD);
		if (!boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
			entry->ebx |= F(AMD_SSB_NO);
Loading