HV: Added Initial support for SEP/SOCWATCH profiling

This patch adds support to sep/socwatch profiling
     Adds 2 new files include/arch/x86/profiling.h and arch/x86/profiling.c
     which contains most of the implementation for profiling,most of the functions
     in profiling.c have dummy implementation and will be implemented in next patches

     a. cpu.c, Initial profiling setup is done as part of bsp_boot_post
  and cpu_secondary_post flow
     b. vmcall.c, New ioctl is added for performing profiling related
  operations in vmcall_vmexit_handler
	ioctl - HC_PROFILING_OPS
        function - hcall_profiling_ops()
     c. common/hypercall.c, hcall_profiling_ops() implementation.
     d. hv_main.c, In vcpu_thread calling profiling related functions
  to save vm context
     e. acrn_hv_defs.h, list all the profiling command types

Tracked-On: projectacrn#1409
Acked-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Chinthapally, Manisha <manisha.chinthapally@intel.com>
This commit is contained in:
Chinthapally, Manisha
2018-10-22 12:29:21 -07:00
committed by wenlingz
parent 3010718d4a
commit 8ba333d275
14 changed files with 388 additions and 6 deletions

View File

@@ -23,6 +23,7 @@
#define VECTOR_VIRT_IRQ_VHM 0xF7U
#define VECTOR_SPURIOUS 0xFFU
#define VECTOR_HYPERVISOR_CALLBACK_VHM 0xF3U
#define VECTOR_PMI 0xF4U
/* the maximum number of msi entry is 2048 according to PCI
* local bus specification
@@ -34,10 +35,11 @@
#define NR_IRQS 256U
#define IRQ_INVALID 0xffffffffU
#define NR_STATIC_MAPPINGS (3U)
#define NR_STATIC_MAPPINGS (4U)
#define TIMER_IRQ (NR_IRQS - 1U)
#define NOTIFY_IRQ (NR_IRQS - 2U)
#define POSTED_INTR_NOTIFY_IRQ (NR_IRQS - 3U)
#define PMI_IRQ (NR_IRQS - 4U)
#define DEFAULT_DEST_MODE IOAPIC_RTE_DESTLOG
#define DEFAULT_DELIVERY_MODE IOAPIC_RTE_DELLOPRI

View File

@@ -17,6 +17,7 @@
#include <timer.h>
#include <logmsg.h>
#include "arch/x86/guest/instr_emul.h"
#include <profiling.h>
struct per_cpu_region {
/* vmxon_region MUST be 4KB-aligned */
@@ -50,6 +51,9 @@ struct per_cpu_region {
uint32_t lapic_id;
uint32_t lapic_ldr;
struct smp_call_info_data smp_call_info;
#ifdef PROFILING_ON
struct profiling_info_wrapper profiling_info;
#endif
} __aligned(CPU_PAGE_SIZE); /* per_cpu_region size aligned with CPU_PAGE_SIZE */
extern struct per_cpu_region *per_cpu_data_base_ptr;

View File

@@ -46,7 +46,7 @@ int32_t hcall_sos_offline_cpu(struct vm *vm, uint64_t lapicid);
* @param param guest physical memory address. The api version returned
* will be copied to this gpa
*
* @pre Pointer vm shall point to VM0
* @pre Pointer vm shall point to VM0
* @return 0 on success, non-zero on error.
*/
int32_t hcall_get_api_version(struct vm *vm, uint64_t param);
@@ -407,6 +407,19 @@ int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param);
*/
int32_t hcall_setup_hv_npk_log(struct vm *vm, uint64_t param);
/**
* @brief Execute profiling operation
*
* @param vm Pointer to VM data structure
* @param cmd profiling command to be executed
* @param cmd profiling command to be executed
* @param param guest physical address. This gpa points to
* data structure required by each command
*
* @return 0 on success, non-zero on error.
*/
int32_t hcall_profiling_ops(struct vm *vm, uint64_t cmd, uint64_t param);
/**
* @brief Get VCPU Power state.
*

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2018 int32_tel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PROFILING_H
#define PROFILING_H
#ifdef PROFILING_ON
#include <profiling_internal.h>
void profiling_vmenter_handler(struct vcpu *vcpu);
void profiling_vmexit_handler(struct vcpu *vcpu, uint64_t exit_reason);
void profiling_setup(void);
#else
static inline void profiling_vmenter_handler(__unused struct vcpu *vcpu) {}
static inline void profiling_vmexit_handler(__unused struct vcpu *vcpu,
__unused uint64_t exit_reason) {}
static inline void profiling_setup(void) {}
static inline int32_t hcall_profiling_ops(__unused struct vm *vm,
__unused uint64_t cmd, __unused uint64_t param)
{
return -ENODEV;
}
#endif
#endif /* PROFILING_H */

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2018 int32_tel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PROFILING_INTERNAL_H
#define PROFILING_INTERNAL_H
#ifdef PROFILING_ON
typedef enum IPI_COMMANDS {
IPI_MSR_OP = 0,
IPI_PMU_CONFIG,
IPI_PMU_START,
IPI_PMU_STOP,
IPI_VMSW_CONFIG,
IPI_UNKNOWN,
} ipi_commands;
/*
* Wrapper containing SEP sampling/profiling related data structures
*/
struct profiling_info_wrapper {
ipi_commands ipi_cmd;
};
int32_t profiling_get_version_info(struct vm *vm, uint64_t addr);
int32_t profiling_get_pcpu_id(struct vm *vm, uint64_t addr);
int32_t profiling_msr_ops_all_cpus(struct vm *vm, uint64_t addr);
int32_t profiling_vm_list_info(struct vm *vm, uint64_t addr);
int32_t profiling_get_control(struct vm *vm, uint64_t addr);
int32_t profiling_set_control(struct vm *vm, uint64_t addr);
int32_t profiling_configure_pmi(struct vm *vm, uint64_t addr);
int32_t profiling_configure_vmsw(struct vm *vm, uint64_t addr);
void profiling_ipi_handler(void *data);
#endif
#endif /* PROFILING_INTERNAL_H */

View File

@@ -13,5 +13,6 @@
#include <trace.h>
#include <sbuf.h>
#include <npk_log.h>
#include <profiling.h>
#endif /* HV_DEBUG_H */

View File

@@ -72,6 +72,7 @@
#define HC_ID_DBG_BASE 0x60UL
#define HC_SETUP_SBUF BASE_HC_ID(HC_ID, HC_ID_DBG_BASE + 0x00UL)
#define HC_SETUP_HV_NPK_LOG BASE_HC_ID(HC_ID, HC_ID_DBG_BASE + 0x01UL)
#define HC_PROFILING_OPS BASE_HC_ID(HC_ID, HC_ID_DBG_BASE + 0x02UL)
/* Trusty */
#define HC_ID_TRUSTY_BASE 0x70UL
@@ -317,4 +318,15 @@ struct trusty_boot_param {
* @}
*/
enum profiling_cmd_type {
PROFILING_MSR_OPS = 0U,
PROFILING_GET_VMINFO,
PROFILING_GET_VERSION,
PROFILING_GET_CONTROL_SWITCH,
PROFILING_SET_CONTROL_SWITCH,
PROFILING_CONFIG_PMI,
PROFILING_CONFIG_VMSWITCH,
PROFILING_GET_PCPUID
};
#endif /* ACRN_HV_DEFS_H */