2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VMEXIT_H_
|
|
|
|
#define VMEXIT_H_
|
|
|
|
|
|
|
|
struct vm_exit_dispatch {
|
|
|
|
int (*handler)(struct vcpu *);
|
|
|
|
uint32_t need_exit_qualification;
|
|
|
|
};
|
|
|
|
|
2018-05-22 14:33:13 +08:00
|
|
|
int vmexit_handler(struct vcpu *vcpu);
|
2018-04-16 19:57:05 +08:00
|
|
|
int vmcall_vmexit_handler(struct vcpu *vcpu);
|
|
|
|
int cpuid_vmexit_handler(struct vcpu *vcpu);
|
|
|
|
int cr_access_vmexit_handler(struct vcpu *vcpu);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
#define VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, MSB, LSB) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(exit_qual & (((1UL << (MSB+1U))-1UL) - ((1UL << (LSB))-1UL)))
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* MACROs to access Control-Register Info using exit qualification field */
|
|
|
|
#define VM_EXIT_CR_ACCESS_CR_NUM(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 3U, 0U) >> 0U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_CR_ACCESS_ACCESS_TYPE(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 5U, 4U) >> 4U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_CR_ACCESS_LMSW_OP(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 6U, 6U) >> 6U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_CR_ACCESS_REG_IDX(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 11U, 8U) >> 8U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_CR_ACCESS_LMSW_SRC_DATE(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 31U, 16U) >> 16U)
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* MACROs to access IO Access Info using exit qualification field */
|
|
|
|
#define VM_EXIT_IO_INSTRUCTION_SIZE(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 2U, 0U) >> 0U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_IO_INSTRUCTION_ACCESS_DIRECTION(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 3U, 3U) >> 3U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_IO_INSTRUCTION_IS_STRING(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 4U, 4U) >> 4U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_IO_INSTRUCTION_IS_REP_PREFIXED(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 5U, 5U) >> 5U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_IO_INSTRUCTION_IS_OPERAND_ENCODING(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 6U, 6U) >> 6U)
|
2018-03-07 20:57:14 +08:00
|
|
|
#define VM_EXIT_IO_INSTRUCTION_PORT_NUMBER(exit_qual) \
|
2018-07-24 11:28:46 +08:00
|
|
|
(VM_EXIT_QUALIFICATION_BIT_MASK(exit_qual, 31U, 16U) >> 16U)
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-07-02 19:01:08 +08:00
|
|
|
#ifdef HV_DEBUG
|
2018-07-26 12:03:12 +08:00
|
|
|
void get_vmexit_profile(char *str_arg, int str_max);
|
2018-07-02 19:01:08 +08:00
|
|
|
#endif /* HV_DEBUG */
|
|
|
|
|
2018-03-07 20:57:14 +08:00
|
|
|
#endif /* VMEXIT_H_ */
|