mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-28 16:27:01 +00:00
hv: hypercall: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in hypercall.c and vmcall.c TO-DO: Enhance Makefile to compile debug/release into 2 libraries Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
fc9ec5d88f
commit
119eccfea1
@ -111,6 +111,8 @@ LD ?= ld
|
|||||||
OBJCOPY ?= objcopy
|
OBJCOPY ?= objcopy
|
||||||
|
|
||||||
D_SRCS += $(wildcard debug/*.c)
|
D_SRCS += $(wildcard debug/*.c)
|
||||||
|
R_SRCS += $(wildcard release/*.c)
|
||||||
|
|
||||||
C_SRCS += boot/acpi.c
|
C_SRCS += boot/acpi.c
|
||||||
C_SRCS += boot/dmar_parse.c
|
C_SRCS += boot/dmar_parse.c
|
||||||
C_SRCS += boot/reloc.c
|
C_SRCS += boot/reloc.c
|
||||||
@ -225,6 +227,8 @@ C_OBJS := $(patsubst %.c,$(HV_OBJDIR)/%.o,$(C_SRCS))
|
|||||||
ifneq ($(CONFIG_RELEASE),y)
|
ifneq ($(CONFIG_RELEASE),y)
|
||||||
C_OBJS += $(patsubst %.c,$(HV_OBJDIR)/%.o,$(D_SRCS))
|
C_OBJS += $(patsubst %.c,$(HV_OBJDIR)/%.o,$(D_SRCS))
|
||||||
CFLAGS += -DHV_DEBUG -DPROFILING_ON
|
CFLAGS += -DHV_DEBUG -DPROFILING_ON
|
||||||
|
else
|
||||||
|
C_OBJS += $(patsubst %.c,$(HV_OBJDIR)/%.o,$(R_SRCS))
|
||||||
endif
|
endif
|
||||||
S_OBJS := $(patsubst %.S,$(HV_OBJDIR)/%.o,$(S_SRCS))
|
S_OBJS := $(patsubst %.S,$(HV_OBJDIR)/%.o,$(S_SRCS))
|
||||||
|
|
||||||
|
@ -169,20 +169,6 @@ int vmcall_vmexit_handler(struct acrn_vcpu *vcpu)
|
|||||||
ret = hcall_reset_ptdev_intr_info(vm, (uint16_t)param1, param2);
|
ret = hcall_reset_ptdev_intr_info(vm, (uint16_t)param1, param2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef HV_DEBUG
|
|
||||||
case HC_SETUP_SBUF:
|
|
||||||
ret = hcall_setup_sbuf(vm, param1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HC_SETUP_HV_NPK_LOG:
|
|
||||||
ret = hcall_setup_hv_npk_log(vm, param1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HC_PROFILING_OPS:
|
|
||||||
ret = hcall_profiling_ops(vm, param1, param2);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case HC_WORLD_SWITCH:
|
case HC_WORLD_SWITCH:
|
||||||
ret = hcall_world_switch(vcpu);
|
ret = hcall_world_switch(vcpu);
|
||||||
break;
|
break;
|
||||||
@ -204,8 +190,7 @@ int vmcall_vmexit_handler(struct acrn_vcpu *vcpu)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
pr_err("op %d: Invalid hypercall\n", hypcall_id);
|
ret = hcall_debug(vm, param1, param2, hypcall_id);
|
||||||
ret = -EPERM;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,72 +924,6 @@ hcall_reset_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HV_DEBUG
|
|
||||||
/**
|
|
||||||
* @brief Setup a share buffer for a VM.
|
|
||||||
*
|
|
||||||
* @param vm Pointer to VM data structure
|
|
||||||
* @param param guest physical address. This gpa points to
|
|
||||||
* struct sbuf_setup_param
|
|
||||||
*
|
|
||||||
* @pre Pointer vm shall point to VM0
|
|
||||||
* @return 0 on success, non-zero on error.
|
|
||||||
*/
|
|
||||||
int32_t hcall_setup_sbuf(struct acrn_vm *vm, uint64_t param)
|
|
||||||
{
|
|
||||||
struct sbuf_setup_param ssp;
|
|
||||||
uint64_t *hva;
|
|
||||||
|
|
||||||
(void)memset((void *)&ssp, 0U, sizeof(ssp));
|
|
||||||
|
|
||||||
if (copy_from_gpa(vm, &ssp, param, sizeof(ssp)) != 0) {
|
|
||||||
pr_err("%s: Unable copy param to vm\n", __func__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ssp.gpa != 0U) {
|
|
||||||
hva = (uint64_t *)gpa2hva(vm, ssp.gpa);
|
|
||||||
} else {
|
|
||||||
hva = (uint64_t *)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sbuf_share_setup(ssp.pcpu_id, ssp.sbuf_id, hva);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HV_DEBUG
|
|
||||||
/**
|
|
||||||
* @brief Setup the hypervisor NPK log.
|
|
||||||
*
|
|
||||||
* @param vm Pointer to VM data structure
|
|
||||||
* @param param guest physical address. This gpa points to
|
|
||||||
* struct hv_npk_log_param
|
|
||||||
*
|
|
||||||
* @pre Pointer vm shall point to VM0
|
|
||||||
* @return 0 on success, non-zero on error.
|
|
||||||
*/
|
|
||||||
int32_t hcall_setup_hv_npk_log(struct acrn_vm *vm, uint64_t param)
|
|
||||||
{
|
|
||||||
struct hv_npk_log_param npk_param;
|
|
||||||
|
|
||||||
(void)memset((void *)&npk_param, 0U, sizeof(npk_param));
|
|
||||||
|
|
||||||
if (copy_from_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) {
|
|
||||||
pr_err("%s: Unable copy param from vm\n", __func__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
npk_log_setup(&npk_param);
|
|
||||||
|
|
||||||
if (copy_to_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) {
|
|
||||||
pr_err("%s: Unable copy param to vm\n", __func__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get VCPU Power state.
|
* @brief Get VCPU Power state.
|
||||||
*
|
*
|
||||||
|
@ -12,9 +12,18 @@
|
|||||||
|
|
||||||
#ifdef PROFILING_ON
|
#ifdef PROFILING_ON
|
||||||
/**
|
/**
|
||||||
*@pre Pointer vm shall point to VM0
|
* @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
|
||||||
|
*
|
||||||
|
* @pre Pointer vm shall point to VM0
|
||||||
|
* @return 0 on success, non-zero on error.
|
||||||
*/
|
*/
|
||||||
int32_t hcall_profiling_ops(struct acrn_vm *vm, uint64_t cmd, uint64_t param)
|
static int32_t hcall_profiling_ops(struct acrn_vm *vm, uint64_t cmd, uint64_t param)
|
||||||
{
|
{
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@ -49,4 +58,104 @@ int32_t hcall_profiling_ops(struct acrn_vm *vm, uint64_t cmd, uint64_t param)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* PROFILING_ON */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup a share buffer for a VM.
|
||||||
|
*
|
||||||
|
* @param vm Pointer to VM data structure
|
||||||
|
* @param param guest physical address. This gpa points to
|
||||||
|
* struct sbuf_setup_param
|
||||||
|
*
|
||||||
|
* @pre Pointer vm shall point to VM0
|
||||||
|
* @return 0 on success, non-zero on error.
|
||||||
|
*/
|
||||||
|
static int32_t hcall_setup_sbuf(struct acrn_vm *vm, uint64_t param)
|
||||||
|
{
|
||||||
|
struct sbuf_setup_param ssp;
|
||||||
|
uint64_t *hva;
|
||||||
|
|
||||||
|
(void)memset((void *)&ssp, 0U, sizeof(ssp));
|
||||||
|
|
||||||
|
if (copy_from_gpa(vm, &ssp, param, sizeof(ssp)) != 0) {
|
||||||
|
pr_err("%s: Unable copy param to vm\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssp.gpa != 0U) {
|
||||||
|
hva = (uint64_t *)gpa2hva(vm, ssp.gpa);
|
||||||
|
} else {
|
||||||
|
hva = (uint64_t *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sbuf_share_setup(ssp.pcpu_id, ssp.sbuf_id, hva);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup the hypervisor NPK log.
|
||||||
|
*
|
||||||
|
* @param vm Pointer to VM data structure
|
||||||
|
* @param param guest physical address. This gpa points to
|
||||||
|
* struct hv_npk_log_param
|
||||||
|
*
|
||||||
|
* @pre Pointer vm shall point to VM0
|
||||||
|
* @return 0 on success, non-zero on error.
|
||||||
|
*/
|
||||||
|
static int32_t hcall_setup_hv_npk_log(struct acrn_vm *vm, uint64_t param)
|
||||||
|
{
|
||||||
|
struct hv_npk_log_param npk_param;
|
||||||
|
|
||||||
|
(void)memset((void *)&npk_param, 0U, sizeof(npk_param));
|
||||||
|
|
||||||
|
if (copy_from_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) {
|
||||||
|
pr_err("%s: Unable copy param from vm\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
npk_log_setup(&npk_param);
|
||||||
|
|
||||||
|
if (copy_to_gpa(vm, &npk_param, param, sizeof(npk_param)) != 0) {
|
||||||
|
pr_err("%s: Unable copy param to vm\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup hypervisor debug infrastructure, such as share buffer, NPK log and profiling.
|
||||||
|
*
|
||||||
|
* @param vm Pointer to VM data structure
|
||||||
|
* @param param1 hypercall param1 from guest
|
||||||
|
* @param param2 hypercall param2 from guest
|
||||||
|
* @param hypcall_id hypercall ID from guest
|
||||||
|
*
|
||||||
|
* @pre Pointer vm shall point to VM0
|
||||||
|
* @return 0 on success, non-zero on error.
|
||||||
|
*/
|
||||||
|
int32_t hcall_debug(struct acrn_vm *vm, uint64_t param1, uint64_t param2, uint64_t hypcall_id)
|
||||||
|
{
|
||||||
|
int32_t ret;
|
||||||
|
|
||||||
|
/* Dispatch the debug hypercall handler */
|
||||||
|
switch (hypcall_id) {
|
||||||
|
case HC_SETUP_SBUF:
|
||||||
|
ret = hcall_setup_sbuf(vm, param1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HC_SETUP_HV_NPK_LOG:
|
||||||
|
ret = hcall_setup_hv_npk_log(vm, param1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HC_PROFILING_OPS:
|
||||||
|
ret = hcall_profiling_ops(vm, param1, param2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
pr_err("op %d: Invalid hypercall\n", hypcall_id);
|
||||||
|
ret = -EPERM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -307,44 +307,18 @@ int32_t hcall_set_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t pa
|
|||||||
int32_t hcall_reset_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid,
|
int32_t hcall_reset_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid,
|
||||||
uint64_t param);
|
uint64_t param);
|
||||||
|
|
||||||
#ifdef HV_DEBUG
|
|
||||||
/**
|
/**
|
||||||
* @brief Setup a share buffer for a VM.
|
* @brief Setup hypervisor debug infrastructure, such as share buffer, NPK log and profiling.
|
||||||
*
|
|
||||||
* @param vm Pointer to VM data structure
|
|
||||||
* @param param guest physical address. This gpa points to
|
|
||||||
* struct sbuf_setup_param
|
|
||||||
*
|
|
||||||
* @pre Pointer vm shall point to VM0
|
|
||||||
* @return 0 on success, non-zero on error.
|
|
||||||
*/
|
|
||||||
int32_t hcall_setup_sbuf(struct acrn_vm *vm, uint64_t param);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup the hypervisor NPK log.
|
|
||||||
*
|
*
|
||||||
* @param vm Pointer to VM data structure
|
* @param vm Pointer to VM data structure
|
||||||
* @param param guest physical address. This gpa points to
|
* @param param1 hypercall param1 from guest
|
||||||
* struct hv_npk_log_param
|
* @param param2 hypercall param2 from guest
|
||||||
|
* @param hypcall_id hypercall ID from guest
|
||||||
*
|
*
|
||||||
* @pre Pointer vm shall point to VM0
|
* @pre Pointer vm shall point to VM0
|
||||||
* @return 0 on success, non-zero on error.
|
* @return 0 on success, non-zero on error.
|
||||||
*/
|
*/
|
||||||
int32_t hcall_setup_hv_npk_log(struct acrn_vm *vm, uint64_t param);
|
int32_t hcall_debug(struct acrn_vm *vm, uint64_t param1, uint64_t param2, uint64_t hypcall_id);
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 acrn_vm *vm, uint64_t cmd, uint64_t param);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get VCPU Power state.
|
* @brief Get VCPU Power state.
|
||||||
|
@ -22,12 +22,6 @@ static inline void profiling_vmexit_handler(__unused struct acrn_vcpu *vcpu,
|
|||||||
__unused uint64_t exit_reason) {}
|
__unused uint64_t exit_reason) {}
|
||||||
static inline void profiling_setup(void) {}
|
static inline void profiling_setup(void) {}
|
||||||
|
|
||||||
static inline int32_t hcall_profiling_ops(__unused struct acrn_vm *vm,
|
|
||||||
__unused uint64_t cmd, __unused uint64_t param)
|
|
||||||
{
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PROFILING_H */
|
#endif /* PROFILING_H */
|
||||||
|
13
hypervisor/release/hypercall.c
Normal file
13
hypervisor/release/hypercall.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <hypervisor.h>
|
||||||
|
|
||||||
|
int32_t hcall_debug(__unused struct acrn_vm *vm, __unused uint64_t param1, __unused uint64_t param2,
|
||||||
|
__unused uint64_t hypcall_id)
|
||||||
|
{
|
||||||
|
return -EPERM;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user