Commit bfe91da2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull kvm fixes from Paolo Bonzini:
 "Bugfixes and a one-liner patch to silence a sparse warning"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: arm64: Stop clobbering x0 for HVC_SOFT_RESTART
  KVM: arm64: PMU: Fix per-CPU access in preemptible context
  KVM: VMX: Use KVM_POSSIBLE_CR*_GUEST_BITS to initialize guest/host masks
  KVM: x86: Mark CR4.TSD as being possibly owned by the guest
  KVM: x86: Inject #GP if guest attempts to toggle CR4.LA57 in 64-bit mode
  kvm: use more precise cast and do not drop __user
  KVM: x86: bit 8 of non-leaf PDPEs is not reserved
  KVM: X86: Fix async pf caused null-ptr-deref
  KVM: arm64: vgic-v4: Plug race between non-residency and v4.1 doorbell
  KVM: arm64: pvtime: Ensure task delay accounting is enabled
  KVM: arm64: Fix kvm_reset_vcpu() return code being incorrect with SVE
  KVM: arm64: Annotate hyp NMI-related functions as __always_inline
  KVM: s390: reduce number of IO pins to 1
parents 5c82ec00 8038a922
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ static inline u32 gic_read_pmr(void)
	return read_sysreg_s(SYS_ICC_PMR_EL1);
	return read_sysreg_s(SYS_ICC_PMR_EL1);
}
}


static inline void gic_write_pmr(u32 val)
static __always_inline void gic_write_pmr(u32 val)
{
{
	write_sysreg_s(val, SYS_ICC_PMR_EL1);
	write_sysreg_s(val, SYS_ICC_PMR_EL1);
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -675,7 +675,7 @@ static inline bool system_supports_generic_auth(void)
		cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH);
		cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH);
}
}


static inline bool system_uses_irq_prio_masking(void)
static __always_inline bool system_uses_irq_prio_masking(void)
{
{
	return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) &&
	return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) &&
	       cpus_have_const_cap(ARM64_HAS_IRQ_PRIO_MASKING);
	       cpus_have_const_cap(ARM64_HAS_IRQ_PRIO_MASKING);
+7 −4
Original line number Original line Diff line number Diff line
@@ -136,11 +136,15 @@ SYM_CODE_START(__kvm_handle_stub_hvc)


1:	cmp	x0, #HVC_RESET_VECTORS
1:	cmp	x0, #HVC_RESET_VECTORS
	b.ne	1f
	b.ne	1f
reset:

	/*
	/*
	 * Reset kvm back to the hyp stub. Do not clobber x0-x4 in
	 * Set the HVC_RESET_VECTORS return code before entering the common
	 * case we coming via HVC_SOFT_RESTART.
	 * path so that we do not clobber x0-x2 in case we are coming via
	 * HVC_SOFT_RESTART.
	 */
	 */
	mov	x0, xzr
reset:
	/* Reset kvm back to the hyp stub. */
	mrs	x5, sctlr_el2
	mrs	x5, sctlr_el2
	mov_q	x6, SCTLR_ELx_FLAGS
	mov_q	x6, SCTLR_ELx_FLAGS
	bic	x5, x5, x6		// Clear SCTL_M and etc
	bic	x5, x5, x6		// Clear SCTL_M and etc
@@ -151,7 +155,6 @@ reset:
	/* Install stub vectors */
	/* Install stub vectors */
	adr_l	x5, __hyp_stub_vectors
	adr_l	x5, __hyp_stub_vectors
	msr	vbar_el2, x5
	msr	vbar_el2, x5
	mov	x0, xzr
	eret
	eret


1:	/* Bad stub call */
1:	/* Bad stub call */
+6 −1
Original line number Original line Diff line number Diff line
@@ -159,7 +159,10 @@ static void kvm_vcpu_pmu_disable_el0(unsigned long events)
}
}


/*
/*
 * On VHE ensure that only guest events have EL0 counting enabled
 * On VHE ensure that only guest events have EL0 counting enabled.
 * This is called from both vcpu_{load,put} and the sysreg handling.
 * Since the latter is preemptible, special care must be taken to
 * disable preemption.
 */
 */
void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu)
void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu)
{
{
@@ -169,12 +172,14 @@ void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu)
	if (!has_vhe())
	if (!has_vhe())
		return;
		return;


	preempt_disable();
	host = this_cpu_ptr(&kvm_host_data);
	host = this_cpu_ptr(&kvm_host_data);
	events_guest = host->pmu_events.events_guest;
	events_guest = host->pmu_events.events_guest;
	events_host = host->pmu_events.events_host;
	events_host = host->pmu_events.events_host;


	kvm_vcpu_pmu_enable_el0(events_guest);
	kvm_vcpu_pmu_enable_el0(events_guest);
	kvm_vcpu_pmu_disable_el0(events_host);
	kvm_vcpu_pmu_disable_el0(events_host);
	preempt_enable();
}
}


/*
/*
+12 −3
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@


#include <linux/arm-smccc.h>
#include <linux/arm-smccc.h>
#include <linux/kvm_host.h>
#include <linux/kvm_host.h>
#include <linux/sched/stat.h>


#include <asm/kvm_mmu.h>
#include <asm/kvm_mmu.h>
#include <asm/pvclock-abi.h>
#include <asm/pvclock-abi.h>
@@ -73,6 +74,11 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
	return base;
	return base;
}
}


static bool kvm_arm_pvtime_supported(void)
{
	return !!sched_info_on();
}

int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
			    struct kvm_device_attr *attr)
			    struct kvm_device_attr *attr)
{
{
@@ -82,7 +88,8 @@ int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
	int ret = 0;
	int ret = 0;
	int idx;
	int idx;


	if (attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
	if (!kvm_arm_pvtime_supported() ||
	    attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
		return -ENXIO;
		return -ENXIO;


	if (get_user(ipa, user))
	if (get_user(ipa, user))
@@ -110,7 +117,8 @@ int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu,
	u64 __user *user = (u64 __user *)attr->addr;
	u64 __user *user = (u64 __user *)attr->addr;
	u64 ipa;
	u64 ipa;


	if (attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
	if (!kvm_arm_pvtime_supported() ||
	    attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
		return -ENXIO;
		return -ENXIO;


	ipa = vcpu->arch.steal.base;
	ipa = vcpu->arch.steal.base;
@@ -125,6 +133,7 @@ int kvm_arm_pvtime_has_attr(struct kvm_vcpu *vcpu,
{
{
	switch (attr->attr) {
	switch (attr->attr) {
	case KVM_ARM_VCPU_PVTIME_IPA:
	case KVM_ARM_VCPU_PVTIME_IPA:
		if (kvm_arm_pvtime_supported())
			return 0;
			return 0;
	}
	}
	return -ENXIO;
	return -ENXIO;
Loading