mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 10:00:03 -04:00
KVM: arm64: Add hyp_enter/hyp_exit events to nVHE/pKVM hyp
The hyp_enter and hyp_exit events are logged by the hypervisor any time it is entered and exited. Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Link: https://patch.msgid.link/20260309162516.2623589-29-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
committed by
Marc Zyngier
parent
0a90fbc8a1
commit
696dfec22b
@@ -920,6 +920,9 @@ struct kvm_vcpu_arch {
|
|||||||
|
|
||||||
/* Per-vcpu TLB for VNCR_EL2 -- NULL when !NV */
|
/* Per-vcpu TLB for VNCR_EL2 -- NULL when !NV */
|
||||||
struct vncr_tlb *vncr_tlb;
|
struct vncr_tlb *vncr_tlb;
|
||||||
|
|
||||||
|
/* Hyp-readable copy of kvm_vcpu::pid */
|
||||||
|
pid_t pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -7,4 +7,43 @@
|
|||||||
#include <nvhe/trace.h>
|
#include <nvhe/trace.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HYP_ENTER_EXIT_REASON
|
||||||
|
#define __HYP_ENTER_EXIT_REASON
|
||||||
|
enum hyp_enter_exit_reason {
|
||||||
|
HYP_REASON_SMC,
|
||||||
|
HYP_REASON_HVC,
|
||||||
|
HYP_REASON_PSCI,
|
||||||
|
HYP_REASON_HOST_ABORT,
|
||||||
|
HYP_REASON_GUEST_EXIT,
|
||||||
|
HYP_REASON_ERET_HOST,
|
||||||
|
HYP_REASON_ERET_GUEST,
|
||||||
|
HYP_REASON_UNKNOWN /* Must be last */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HYP_EVENT(hyp_enter,
|
||||||
|
HE_PROTO(struct kvm_cpu_context *host_ctxt, u8 reason),
|
||||||
|
HE_STRUCT(
|
||||||
|
he_field(u8, reason)
|
||||||
|
he_field(pid_t, vcpu)
|
||||||
|
),
|
||||||
|
HE_ASSIGN(
|
||||||
|
__entry->reason = reason;
|
||||||
|
__entry->vcpu = __tracing_get_vcpu_pid(host_ctxt);
|
||||||
|
),
|
||||||
|
HE_PRINTK("reason=%s vcpu=%d", __hyp_enter_exit_reason_str(__entry->reason), __entry->vcpu)
|
||||||
|
);
|
||||||
|
|
||||||
|
HYP_EVENT(hyp_exit,
|
||||||
|
HE_PROTO(struct kvm_cpu_context *host_ctxt, u8 reason),
|
||||||
|
HE_STRUCT(
|
||||||
|
he_field(u8, reason)
|
||||||
|
he_field(pid_t, vcpu)
|
||||||
|
),
|
||||||
|
HE_ASSIGN(
|
||||||
|
__entry->reason = reason;
|
||||||
|
__entry->vcpu = __tracing_get_vcpu_pid(host_ctxt);
|
||||||
|
),
|
||||||
|
HE_PRINTK("reason=%s vcpu=%d", __hyp_enter_exit_reason_str(__entry->reason), __entry->vcpu)
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -707,6 +707,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
|
|||||||
|
|
||||||
if (!cpumask_test_cpu(cpu, vcpu->kvm->arch.supported_cpus))
|
if (!cpumask_test_cpu(cpu, vcpu->kvm->arch.supported_cpus))
|
||||||
vcpu_set_on_unsupported_cpu(vcpu);
|
vcpu_set_on_unsupported_cpu(vcpu);
|
||||||
|
|
||||||
|
vcpu->arch.pid = pid_nr(vcpu->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
|
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
|
||||||
|
|||||||
23
arch/arm64/kvm/hyp/include/nvhe/arm-smccc.h
Normal file
23
arch/arm64/kvm/hyp/include/nvhe/arm-smccc.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef __ARM64_KVM_HYP_NVHE_ARM_SMCCC_H__
|
||||||
|
#define __ARM64_KVM_HYP_NVHE_ARM_SMCCC_H__
|
||||||
|
|
||||||
|
#include <asm/kvm_hypevents.h>
|
||||||
|
|
||||||
|
#include <linux/arm-smccc.h>
|
||||||
|
|
||||||
|
#define hyp_smccc_1_1_smc(...) \
|
||||||
|
do { \
|
||||||
|
trace_hyp_exit(NULL, HYP_REASON_SMC); \
|
||||||
|
arm_smccc_1_1_smc(__VA_ARGS__); \
|
||||||
|
trace_hyp_enter(NULL, HYP_REASON_SMC); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define hyp_smccc_1_2_smc(...) \
|
||||||
|
do { \
|
||||||
|
trace_hyp_exit(NULL, HYP_REASON_SMC); \
|
||||||
|
arm_smccc_1_2_smc(__VA_ARGS__); \
|
||||||
|
trace_hyp_enter(NULL, HYP_REASON_SMC); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* __ARM64_KVM_HYP_NVHE_ARM_SMCCC_H__ */
|
||||||
@@ -6,6 +6,18 @@
|
|||||||
|
|
||||||
#include <asm/kvm_hyptrace.h>
|
#include <asm/kvm_hyptrace.h>
|
||||||
|
|
||||||
|
static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu_context *host_ctxt)
|
||||||
|
{
|
||||||
|
struct kvm_vcpu *vcpu;
|
||||||
|
|
||||||
|
if (!host_ctxt)
|
||||||
|
host_ctxt = host_data_ptr(host_ctxt);
|
||||||
|
|
||||||
|
vcpu = host_ctxt->__hyp_running_vcpu;
|
||||||
|
|
||||||
|
return vcpu ? vcpu->arch.pid : 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define HE_PROTO(__args...) __args
|
#define HE_PROTO(__args...) __args
|
||||||
#define HE_ASSIGN(__args...) __args
|
#define HE_ASSIGN(__args...) __args
|
||||||
#define HE_STRUCT RE_STRUCT
|
#define HE_STRUCT RE_STRUCT
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
* the duration and are therefore serialised.
|
* the duration and are therefore serialised.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/arm-smccc.h>
|
|
||||||
#include <linux/arm_ffa.h>
|
#include <linux/arm_ffa.h>
|
||||||
#include <asm/kvm_pkvm.h>
|
#include <asm/kvm_pkvm.h>
|
||||||
|
|
||||||
|
#include <nvhe/arm-smccc.h>
|
||||||
#include <nvhe/ffa.h>
|
#include <nvhe/ffa.h>
|
||||||
#include <nvhe/mem_protect.h>
|
#include <nvhe/mem_protect.h>
|
||||||
#include <nvhe/memory.h>
|
#include <nvhe/memory.h>
|
||||||
@@ -147,7 +147,7 @@ static int ffa_map_hyp_buffers(u64 ffa_page_count)
|
|||||||
{
|
{
|
||||||
struct arm_smccc_1_2_regs res;
|
struct arm_smccc_1_2_regs res;
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_FN64_RXTX_MAP,
|
.a0 = FFA_FN64_RXTX_MAP,
|
||||||
.a1 = hyp_virt_to_phys(hyp_buffers.tx),
|
.a1 = hyp_virt_to_phys(hyp_buffers.tx),
|
||||||
.a2 = hyp_virt_to_phys(hyp_buffers.rx),
|
.a2 = hyp_virt_to_phys(hyp_buffers.rx),
|
||||||
@@ -161,7 +161,7 @@ static int ffa_unmap_hyp_buffers(void)
|
|||||||
{
|
{
|
||||||
struct arm_smccc_1_2_regs res;
|
struct arm_smccc_1_2_regs res;
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_RXTX_UNMAP,
|
.a0 = FFA_RXTX_UNMAP,
|
||||||
.a1 = HOST_FFA_ID,
|
.a1 = HOST_FFA_ID,
|
||||||
}, &res);
|
}, &res);
|
||||||
@@ -172,7 +172,7 @@ static int ffa_unmap_hyp_buffers(void)
|
|||||||
static void ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
static void ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
||||||
u32 handle_hi, u32 fraglen, u32 endpoint_id)
|
u32 handle_hi, u32 fraglen, u32 endpoint_id)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_MEM_FRAG_TX,
|
.a0 = FFA_MEM_FRAG_TX,
|
||||||
.a1 = handle_lo,
|
.a1 = handle_lo,
|
||||||
.a2 = handle_hi,
|
.a2 = handle_hi,
|
||||||
@@ -184,7 +184,7 @@ static void ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
|||||||
static void ffa_mem_frag_rx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
static void ffa_mem_frag_rx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
||||||
u32 handle_hi, u32 fragoff)
|
u32 handle_hi, u32 fragoff)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_MEM_FRAG_RX,
|
.a0 = FFA_MEM_FRAG_RX,
|
||||||
.a1 = handle_lo,
|
.a1 = handle_lo,
|
||||||
.a2 = handle_hi,
|
.a2 = handle_hi,
|
||||||
@@ -196,7 +196,7 @@ static void ffa_mem_frag_rx(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
|||||||
static void ffa_mem_xfer(struct arm_smccc_1_2_regs *res, u64 func_id, u32 len,
|
static void ffa_mem_xfer(struct arm_smccc_1_2_regs *res, u64 func_id, u32 len,
|
||||||
u32 fraglen)
|
u32 fraglen)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = func_id,
|
.a0 = func_id,
|
||||||
.a1 = len,
|
.a1 = len,
|
||||||
.a2 = fraglen,
|
.a2 = fraglen,
|
||||||
@@ -206,7 +206,7 @@ static void ffa_mem_xfer(struct arm_smccc_1_2_regs *res, u64 func_id, u32 len,
|
|||||||
static void ffa_mem_reclaim(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
static void ffa_mem_reclaim(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
||||||
u32 handle_hi, u32 flags)
|
u32 handle_hi, u32 flags)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_MEM_RECLAIM,
|
.a0 = FFA_MEM_RECLAIM,
|
||||||
.a1 = handle_lo,
|
.a1 = handle_lo,
|
||||||
.a2 = handle_hi,
|
.a2 = handle_hi,
|
||||||
@@ -216,7 +216,7 @@ static void ffa_mem_reclaim(struct arm_smccc_1_2_regs *res, u32 handle_lo,
|
|||||||
|
|
||||||
static void ffa_retrieve_req(struct arm_smccc_1_2_regs *res, u32 len)
|
static void ffa_retrieve_req(struct arm_smccc_1_2_regs *res, u32 len)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_FN64_MEM_RETRIEVE_REQ,
|
.a0 = FFA_FN64_MEM_RETRIEVE_REQ,
|
||||||
.a1 = len,
|
.a1 = len,
|
||||||
.a2 = len,
|
.a2 = len,
|
||||||
@@ -225,7 +225,7 @@ static void ffa_retrieve_req(struct arm_smccc_1_2_regs *res, u32 len)
|
|||||||
|
|
||||||
static void ffa_rx_release(struct arm_smccc_1_2_regs *res)
|
static void ffa_rx_release(struct arm_smccc_1_2_regs *res)
|
||||||
{
|
{
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_RX_RELEASE,
|
.a0 = FFA_RX_RELEASE,
|
||||||
}, res);
|
}, res);
|
||||||
}
|
}
|
||||||
@@ -728,7 +728,7 @@ static int hyp_ffa_post_init(void)
|
|||||||
size_t min_rxtx_sz;
|
size_t min_rxtx_sz;
|
||||||
struct arm_smccc_1_2_regs res;
|
struct arm_smccc_1_2_regs res;
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){
|
||||||
.a0 = FFA_ID_GET,
|
.a0 = FFA_ID_GET,
|
||||||
}, &res);
|
}, &res);
|
||||||
if (res.a0 != FFA_SUCCESS)
|
if (res.a0 != FFA_SUCCESS)
|
||||||
@@ -737,7 +737,7 @@ static int hyp_ffa_post_init(void)
|
|||||||
if (res.a2 != HOST_FFA_ID)
|
if (res.a2 != HOST_FFA_ID)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){
|
||||||
.a0 = FFA_FEATURES,
|
.a0 = FFA_FEATURES,
|
||||||
.a1 = FFA_FN64_RXTX_MAP,
|
.a1 = FFA_FN64_RXTX_MAP,
|
||||||
}, &res);
|
}, &res);
|
||||||
@@ -788,7 +788,7 @@ static void do_ffa_version(struct arm_smccc_1_2_regs *res,
|
|||||||
* first if TEE supports it.
|
* first if TEE supports it.
|
||||||
*/
|
*/
|
||||||
if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_version)) {
|
if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_version)) {
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_VERSION,
|
.a0 = FFA_VERSION,
|
||||||
.a1 = ffa_req_version,
|
.a1 = ffa_req_version,
|
||||||
}, res);
|
}, res);
|
||||||
@@ -824,7 +824,7 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res,
|
|||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_PARTITION_INFO_GET,
|
.a0 = FFA_PARTITION_INFO_GET,
|
||||||
.a1 = uuid0,
|
.a1 = uuid0,
|
||||||
.a2 = uuid1,
|
.a2 = uuid1,
|
||||||
@@ -939,7 +939,7 @@ int hyp_ffa_init(void *pages)
|
|||||||
if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2)
|
if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
hyp_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) {
|
||||||
.a0 = FFA_VERSION,
|
.a0 = FFA_VERSION,
|
||||||
.a1 = FFA_VERSION_1_2,
|
.a1 = FFA_VERSION_1_2,
|
||||||
}, &res);
|
}, &res);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <asm/kvm_emulate.h>
|
#include <asm/kvm_emulate.h>
|
||||||
#include <asm/kvm_host.h>
|
#include <asm/kvm_host.h>
|
||||||
#include <asm/kvm_hyp.h>
|
#include <asm/kvm_hyp.h>
|
||||||
|
#include <asm/kvm_hypevents.h>
|
||||||
#include <asm/kvm_mmu.h>
|
#include <asm/kvm_mmu.h>
|
||||||
|
|
||||||
#include <nvhe/ffa.h>
|
#include <nvhe/ffa.h>
|
||||||
@@ -137,6 +138,8 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
|
|||||||
hyp_vcpu->vcpu.arch.vsesr_el2 = host_vcpu->arch.vsesr_el2;
|
hyp_vcpu->vcpu.arch.vsesr_el2 = host_vcpu->arch.vsesr_el2;
|
||||||
|
|
||||||
hyp_vcpu->vcpu.arch.vgic_cpu.vgic_v3 = host_vcpu->arch.vgic_cpu.vgic_v3;
|
hyp_vcpu->vcpu.arch.vgic_cpu.vgic_v3 = host_vcpu->arch.vgic_cpu.vgic_v3;
|
||||||
|
|
||||||
|
hyp_vcpu->vcpu.arch.pid = host_vcpu->arch.pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sync_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
|
static void sync_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
|
||||||
@@ -728,7 +731,9 @@ static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
|
|||||||
|
|
||||||
static void default_host_smc_handler(struct kvm_cpu_context *host_ctxt)
|
static void default_host_smc_handler(struct kvm_cpu_context *host_ctxt)
|
||||||
{
|
{
|
||||||
|
trace_hyp_exit(host_ctxt, HYP_REASON_SMC);
|
||||||
__kvm_hyp_host_forward_smc(host_ctxt);
|
__kvm_hyp_host_forward_smc(host_ctxt);
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_SMC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_host_smc(struct kvm_cpu_context *host_ctxt)
|
static void handle_host_smc(struct kvm_cpu_context *host_ctxt)
|
||||||
@@ -815,15 +820,19 @@ void handle_trap(struct kvm_cpu_context *host_ctxt)
|
|||||||
{
|
{
|
||||||
u64 esr = read_sysreg_el2(SYS_ESR);
|
u64 esr = read_sysreg_el2(SYS_ESR);
|
||||||
|
|
||||||
|
|
||||||
switch (ESR_ELx_EC(esr)) {
|
switch (ESR_ELx_EC(esr)) {
|
||||||
case ESR_ELx_EC_HVC64:
|
case ESR_ELx_EC_HVC64:
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_HVC);
|
||||||
handle_host_hcall(host_ctxt);
|
handle_host_hcall(host_ctxt);
|
||||||
break;
|
break;
|
||||||
case ESR_ELx_EC_SMC64:
|
case ESR_ELx_EC_SMC64:
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_SMC);
|
||||||
handle_host_smc(host_ctxt);
|
handle_host_smc(host_ctxt);
|
||||||
break;
|
break;
|
||||||
case ESR_ELx_EC_IABT_LOW:
|
case ESR_ELx_EC_IABT_LOW:
|
||||||
case ESR_ELx_EC_DABT_LOW:
|
case ESR_ELx_EC_DABT_LOW:
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_HOST_ABORT);
|
||||||
handle_host_mem_abort(host_ctxt);
|
handle_host_mem_abort(host_ctxt);
|
||||||
break;
|
break;
|
||||||
case ESR_ELx_EC_SYS64:
|
case ESR_ELx_EC_SYS64:
|
||||||
@@ -833,4 +842,6 @@ void handle_trap(struct kvm_cpu_context *host_ctxt)
|
|||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace_hyp_exit(host_ctxt, HYP_REASON_ERET_HOST);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
|
|
||||||
#include <asm/kvm_asm.h>
|
#include <asm/kvm_asm.h>
|
||||||
#include <asm/kvm_hyp.h>
|
#include <asm/kvm_hyp.h>
|
||||||
|
#include <asm/kvm_hypevents.h>
|
||||||
#include <asm/kvm_mmu.h>
|
#include <asm/kvm_mmu.h>
|
||||||
#include <linux/arm-smccc.h>
|
|
||||||
#include <linux/kvm_host.h>
|
#include <linux/kvm_host.h>
|
||||||
#include <uapi/linux/psci.h>
|
#include <uapi/linux/psci.h>
|
||||||
|
|
||||||
|
#include <nvhe/arm-smccc.h>
|
||||||
#include <nvhe/memory.h>
|
#include <nvhe/memory.h>
|
||||||
#include <nvhe/trap_handler.h>
|
#include <nvhe/trap_handler.h>
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ static unsigned long psci_call(unsigned long fn, unsigned long arg0,
|
|||||||
{
|
{
|
||||||
struct arm_smccc_res res;
|
struct arm_smccc_res res;
|
||||||
|
|
||||||
arm_smccc_1_1_smc(fn, arg0, arg1, arg2, &res);
|
hyp_smccc_1_1_smc(fn, arg0, arg1, arg2, &res);
|
||||||
return res.a0;
|
return res.a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +207,7 @@ asmlinkage void __noreturn __kvm_host_psci_cpu_entry(bool is_cpu_on)
|
|||||||
struct kvm_cpu_context *host_ctxt;
|
struct kvm_cpu_context *host_ctxt;
|
||||||
|
|
||||||
host_ctxt = host_data_ptr(host_ctxt);
|
host_ctxt = host_data_ptr(host_ctxt);
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_PSCI);
|
||||||
|
|
||||||
if (is_cpu_on)
|
if (is_cpu_on)
|
||||||
boot_args = this_cpu_ptr(&cpu_on_args);
|
boot_args = this_cpu_ptr(&cpu_on_args);
|
||||||
@@ -221,6 +223,7 @@ asmlinkage void __noreturn __kvm_host_psci_cpu_entry(bool is_cpu_on)
|
|||||||
write_sysreg_el1(INIT_SCTLR_EL1_MMU_OFF, SYS_SCTLR);
|
write_sysreg_el1(INIT_SCTLR_EL1_MMU_OFF, SYS_SCTLR);
|
||||||
write_sysreg(INIT_PSTATE_EL1, SPSR_EL2);
|
write_sysreg(INIT_PSTATE_EL1, SPSR_EL2);
|
||||||
|
|
||||||
|
trace_hyp_exit(host_ctxt, HYP_REASON_PSCI);
|
||||||
__host_enter(host_ctxt);
|
__host_enter(host_ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <hyp/switch.h>
|
#include <hyp/switch.h>
|
||||||
#include <hyp/sysreg-sr.h>
|
#include <hyp/sysreg-sr.h>
|
||||||
|
|
||||||
#include <linux/arm-smccc.h>
|
|
||||||
#include <linux/kvm_host.h>
|
#include <linux/kvm_host.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/jump_label.h>
|
#include <linux/jump_label.h>
|
||||||
@@ -21,6 +20,7 @@
|
|||||||
#include <asm/kvm_asm.h>
|
#include <asm/kvm_asm.h>
|
||||||
#include <asm/kvm_emulate.h>
|
#include <asm/kvm_emulate.h>
|
||||||
#include <asm/kvm_hyp.h>
|
#include <asm/kvm_hyp.h>
|
||||||
|
#include <asm/kvm_hypevents.h>
|
||||||
#include <asm/kvm_mmu.h>
|
#include <asm/kvm_mmu.h>
|
||||||
#include <asm/fpsimd.h>
|
#include <asm/fpsimd.h>
|
||||||
#include <asm/debug-monitors.h>
|
#include <asm/debug-monitors.h>
|
||||||
@@ -308,10 +308,13 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
|
|||||||
__debug_switch_to_guest(vcpu);
|
__debug_switch_to_guest(vcpu);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
trace_hyp_exit(host_ctxt, HYP_REASON_ERET_GUEST);
|
||||||
|
|
||||||
/* Jump in the fire! */
|
/* Jump in the fire! */
|
||||||
exit_code = __guest_enter(vcpu);
|
exit_code = __guest_enter(vcpu);
|
||||||
|
|
||||||
/* And we're baaack! */
|
/* And we're baaack! */
|
||||||
|
trace_hyp_enter(host_ctxt, HYP_REASON_GUEST_EXIT);
|
||||||
} while (fixup_guest_exit(vcpu, &exit_code));
|
} while (fixup_guest_exit(vcpu, &exit_code));
|
||||||
|
|
||||||
__sysreg_save_state_nvhe(guest_ctxt);
|
__sysreg_save_state_nvhe(guest_ctxt);
|
||||||
|
|||||||
@@ -364,8 +364,26 @@ static struct trace_remote_callbacks trace_remote_callbacks = {
|
|||||||
.enable_event = hyp_trace_enable_event,
|
.enable_event = hyp_trace_enable_event,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *__hyp_enter_exit_reason_str(u8 reason);
|
||||||
|
|
||||||
#include <asm/kvm_define_hypevents.h>
|
#include <asm/kvm_define_hypevents.h>
|
||||||
|
|
||||||
|
static const char *__hyp_enter_exit_reason_str(u8 reason)
|
||||||
|
{
|
||||||
|
static const char strs[][12] = {
|
||||||
|
"smc",
|
||||||
|
"hvc",
|
||||||
|
"psci",
|
||||||
|
"host_abort",
|
||||||
|
"guest_exit",
|
||||||
|
"eret_host",
|
||||||
|
"eret_guest",
|
||||||
|
"unknown",
|
||||||
|
};
|
||||||
|
|
||||||
|
return strs[min(reason, HYP_REASON_UNKNOWN)];
|
||||||
|
}
|
||||||
|
|
||||||
static void __init hyp_trace_init_events(void)
|
static void __init hyp_trace_init_events(void)
|
||||||
{
|
{
|
||||||
struct hyp_event_id *hyp_event_id = __hyp_event_ids_start;
|
struct hyp_event_id *hyp_event_id = __hyp_event_ids_start;
|
||||||
|
|||||||
Reference in New Issue
Block a user