Commit a0b95bdf authored by Zengruan Ye's avatar Zengruan Ye Committed by Zheng Zengkai
Browse files

KVM: arm64: Implement PV_SCHED_FEATURES call



virt inclusion
category: feature
bugzilla: 47624
CVE: NA

--------------------------------

This provides a mechanism for querying which paravirtualized sched
features are available in this hypervisor.

Add some SMCCC compatible hypercalls for PV sched features:
  PV_SCHED_FEATURES:       0xC5000090
  PV_SCHED_IPA_INIT:       0xC5000091
  PV_SCHED_IPA_RELEASE:    0xC5000092

Also add the header file which defines the ABI for the paravirtualized
sched features we're about to add.

Signed-off-by: default avatarZengruan Ye <yezengruan@huawei.com>
Reviewed-by: default avatarZhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent b74edaf6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -589,6 +589,8 @@ static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch)
	return (vcpu_arch->steal.base != GPA_INVALID);
}

long kvm_hypercall_pvsched_features(struct kvm_vcpu *vcpu);

void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);

struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
+16 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright(c) 2019 Huawei Technologies Co., Ltd
 * Author: Zengruan Ye <yezengruan@huawei.com>
 */

#ifndef __ASM_PVSCHED_ABI_H
#define __ASM_PVSCHED_ABI_H

struct pvsched_vcpu_state {
	__le32 preempted;
	/* Structure must be 64 byte aligned, pad to that size */
	u8 padding[60];
} __packed;

#endif
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ obj-$(CONFIG_KVM) += hyp/

kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \
	 $(KVM)/vfio.o $(KVM)/irqchip.o \
	 arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \
	 arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o pvsched.o \
	 inject_fault.o regmap.o va_layout.o handle_exit.o \
	 guest.o debug.o reset.o sys_regs.o \
	 vgic-sys-reg-v3.o fpsimd.o pmu.o \
+6 −0
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
		case ARM_SMCCC_HV_PV_TIME_FEATURES:
			val = SMCCC_RET_SUCCESS;
			break;
		case ARM_SMCCC_HV_PV_SCHED_FEATURES:
			val = SMCCC_RET_SUCCESS;
			break;
		}
		break;
	case ARM_SMCCC_HV_PV_TIME_FEATURES:
@@ -71,6 +74,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
		if (gpa != GPA_INVALID)
			val = gpa;
		break;
	case ARM_SMCCC_HV_PV_SCHED_FEATURES:
		val = kvm_hypercall_pvsched_features(vcpu);
		break;
	default:
		return kvm_psci_call(vcpu);
	}
+23 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright(c) 2019 Huawei Technologies Co., Ltd
 * Author: Zengruan Ye <yezengruan@huawei.com>
 */

#include <linux/arm-smccc.h>

#include <kvm/arm_hypercalls.h>

long kvm_hypercall_pvsched_features(struct kvm_vcpu *vcpu)
{
	u32 feature = smccc_get_arg1(vcpu);
	long val = SMCCC_RET_NOT_SUPPORTED;

	switch (feature) {
	case ARM_SMCCC_HV_PV_SCHED_FEATURES:
		val = SMCCC_RET_SUCCESS;
		break;
	}

	return val;
}
Loading