From dcae4383061ceacb6a3565346a7ddc7a96778149 Mon Sep 17 00:00:00 2001 From: Zhi Jin Date: Wed, 1 Aug 2018 10:54:23 +0800 Subject: [PATCH] hv: add a hypercall for the hypervisor NPK log The hypercall HC_SETUP_HV_NPK_LOG is added to enable/disable/configure the hypervisor NPK log. Signed-off-by: Zhi Jin Signed-off-by: Zhonghua Sun Reviewed-by: CHEN Gang Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vmcall.c | 4 ++++ hypervisor/common/hypercall.c | 28 ++++++++++++++++++++++++ hypervisor/include/common/hypercall.h | 11 ++++++++++ hypervisor/include/debug/npk_log.h | 12 ++++++++++ hypervisor/include/hv_debug.h | 1 + hypervisor/include/public/acrn_hv_defs.h | 23 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 hypervisor/include/debug/npk_log.h diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index e0e4fa56f..e06f27c59 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -159,6 +159,10 @@ int vmcall_vmexit_handler(struct vcpu *vcpu) 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; #endif case HC_WORLD_SWITCH: diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index d585e80dc..fcb006198 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -821,6 +821,34 @@ int32_t hcall_setup_sbuf(__unused struct vm *vm, __unused uint64_t param) } #endif +#ifdef HV_DEBUG +int32_t hcall_setup_hv_npk_log(struct vm *vm, uint64_t param) +{ + struct hv_npk_log_param npk_param; + + memset((void *)&npk_param, 0, 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; +} +#else +int32_t hcall_setup_hv_npk_log(__unused struct vm *vm, __unused uint64_t param) +{ + return -ENODEV; +} +#endif + int32_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param) { uint16_t target_vm_id; diff --git a/hypervisor/include/common/hypercall.h b/hypervisor/include/common/hypercall.h index 914703137..69b3c0de2 100644 --- a/hypervisor/include/common/hypercall.h +++ b/hypervisor/include/common/hypercall.h @@ -343,6 +343,17 @@ int32_t hcall_reset_ptdev_intr_info(struct vm *vm, uint16_t vmid, */ int32_t hcall_setup_sbuf(struct vm *vm, uint64_t param); +/** + * @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 + * + * @return 0 on success, non-zero on error. + */ +int32_t hcall_setup_hv_npk_log(struct vm *vm, uint64_t param); + /** * @brief Get VCPU Power state. * diff --git a/hypervisor/include/debug/npk_log.h b/hypervisor/include/debug/npk_log.h new file mode 100644 index 000000000..4e169d0b4 --- /dev/null +++ b/hypervisor/include/debug/npk_log.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2018 Intel Corporation. + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef NPK_LOG_H +#define NPK_LOG_H + +static inline void npk_log_setup(__unused struct hv_npk_log_param *param) +{} + +#endif /* NPK_LOG_H */ diff --git a/hypervisor/include/hv_debug.h b/hypervisor/include/hv_debug.h index 7198132f0..e35057999 100644 --- a/hypervisor/include/hv_debug.h +++ b/hypervisor/include/hv_debug.h @@ -13,5 +13,6 @@ #include #include #include +#include #endif /* HV_DEBUG_H */ diff --git a/hypervisor/include/public/acrn_hv_defs.h b/hypervisor/include/public/acrn_hv_defs.h index 700ce9257..d3f2a720f 100644 --- a/hypervisor/include/public/acrn_hv_defs.h +++ b/hypervisor/include/public/acrn_hv_defs.h @@ -67,6 +67,7 @@ /* DEBUG */ #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) /* Trusty */ #define HC_ID_TRUSTY_BASE 0x70UL @@ -186,6 +187,28 @@ struct sbuf_setup_param { uint64_t gpa; } __aligned(8); +/** + * @brief Info to setup the hypervisor NPK log + * + * the parameter for HC_SETUP_HV_NPK_LOG hypercall + */ +struct hv_npk_log_param { + /** the setup command for the hypervisor NPK log */ + uint16_t cmd; + + /** the setup result for the hypervisor NPK log */ + uint16_t res; + + /** the loglevel for the hypervisor NPK log */ + uint16_t loglevel; + + /** Reserved */ + uint16_t reserved; + + /** the MMIO address for the hypervisor NPK log */ + uint64_t mmio_addr; +} __aligned(8); + /** * Gpa to hpa translation parameter, used for HC_VM_GPA2HPA hypercall */