Commit e23844b2 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

Merge tag 'kvmarm-fixes-7.1-3' of...

Merge tag 'kvmarm-fixes-7.1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD

KVM/arm64 fixes for 7.1, take #3

- Fix ITS EventID sanitisation when restoring an interrupt translation
  table.

- Fix PPI memory leak when failing to initialise a vcpu.

- Correctly return an error when the validation of a hypervisor trace
  descriptor fails, and limit this validation to protected mode only.
parents 5200f5f4 1702da76
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -555,8 +555,10 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
	kvm_destroy_mpidr_data(vcpu->kvm);

	err = kvm_vgic_vcpu_init(vcpu);
	if (err)
	if (err) {
		kvm_vgic_vcpu_destroy(vcpu);
		return err;
	}

	err = kvm_share_hyp(vcpu, vcpu + 1);
	if (err)
+7 −2
Original line number Diff line number Diff line
@@ -164,13 +164,16 @@ static int hyp_trace_buffer_load(struct hyp_trace_buffer *trace_buffer,
	return ret;
}

static bool hyp_trace_desc_validate(struct hyp_trace_desc *desc, size_t desc_size)
static bool hyp_trace_desc_is_valid(struct hyp_trace_desc *desc, size_t desc_size)
{
	struct ring_buffer_desc *rb_desc;
	unsigned int cpu;
	size_t nr_bpages;
	void *desc_end;

	if (!is_protected_kvm_enabled())
		return true;

	/*
	 * Both desc_size and bpages_backing_size are untrusted host-provided
	 * values. We rely on __pkvm_host_donate_hyp() to enforce their validity.
@@ -212,8 +215,10 @@ int __tracing_load(unsigned long desc_hva, size_t desc_size)
	if (ret)
		return ret;

	if (!hyp_trace_desc_validate(desc, desc_size))
	if (!hyp_trace_desc_is_valid(desc, desc_size)) {
		ret = -EINVAL;
		goto err_release_desc;
	}

	hyp_spin_lock(&trace_buffer.lock);

+4 −0
Original line number Diff line number Diff line
@@ -2307,6 +2307,10 @@ static int vgic_its_restore_dte(struct vgic_its *its, u32 id,
	/* dte entry is valid */
	offset = (entry & KVM_ITS_DTE_NEXT_MASK) >> KVM_ITS_DTE_NEXT_SHIFT;

	/* Mimic the MAPD behaviour and reject invalid EID bits. */
	if (num_eventid_bits > VITS_TYPER_IDBITS)
		return -EINVAL;

	if (!vgic_its_check_id(its, baser, id, NULL))
		return -EINVAL;