mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 01:37:44 +00:00
HV: modularization cleanup instr_emul header file
separate the private macro/structure/functions, which are just used in instr_emul.c; and move instr_emul.h to public include path. Tracked-On: #1842 Signed-off-by: Minggui Cao <minggui.cao@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
100
hypervisor/include/arch/x86/guest/instr_emul.h
Normal file
100
hypervisor/include/arch/x86/guest/instr_emul.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 NetApp, Inc.
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef INSTR_EMUL_H
|
||||
#define INSTR_EMUL_H
|
||||
|
||||
struct instr_emul_vie_op {
|
||||
uint8_t op_type; /* type of operation (e.g. MOV) */
|
||||
uint16_t op_flags;
|
||||
};
|
||||
|
||||
#define VIE_PREFIX_SIZE 4U
|
||||
#define VIE_INST_SIZE 15U
|
||||
struct instr_emul_vie {
|
||||
uint8_t inst[VIE_INST_SIZE]; /* instruction bytes */
|
||||
uint8_t num_valid; /* size of the instruction */
|
||||
uint8_t num_processed;
|
||||
|
||||
uint8_t addrsize:4, opsize:4; /* address and operand sizes */
|
||||
uint8_t rex_w:1, /* REX prefix */
|
||||
rex_r:1,
|
||||
rex_x:1,
|
||||
rex_b:1,
|
||||
rex_present:1,
|
||||
repz_present:1, /* REP/REPE/REPZ prefix */
|
||||
repnz_present:1, /* REPNE/REPNZ prefix */
|
||||
opsize_override:1, /* Operand size override */
|
||||
addrsize_override:1, /* Address size override */
|
||||
seg_override:1; /* Segment override */
|
||||
|
||||
uint8_t mod:2, /* ModRM byte */
|
||||
reg:4,
|
||||
rm:4;
|
||||
|
||||
uint8_t ss:2, /* SIB byte */
|
||||
index:4,
|
||||
base:4;
|
||||
|
||||
uint8_t disp_bytes;
|
||||
uint8_t imm_bytes;
|
||||
|
||||
uint8_t scale;
|
||||
enum cpu_reg_name base_register; /* CPU_REG_xyz */
|
||||
enum cpu_reg_name index_register; /* CPU_REG_xyz */
|
||||
enum cpu_reg_name segment_register; /* CPU_REG_xyz */
|
||||
|
||||
int64_t displacement; /* optional addr displacement */
|
||||
int64_t immediate; /* optional immediate operand */
|
||||
|
||||
uint8_t decoded; /* set to 1 if successfully decoded */
|
||||
|
||||
uint8_t opcode;
|
||||
struct instr_emul_vie_op op; /* opcode description */
|
||||
|
||||
uint64_t dst_gpa; /* saved dst operand gpa. Only for movs */
|
||||
};
|
||||
|
||||
struct vm_guest_paging {
|
||||
uint64_t cr3;
|
||||
uint8_t cpl;
|
||||
enum vm_cpu_mode cpu_mode;
|
||||
enum vm_paging_mode paging_mode;
|
||||
};
|
||||
|
||||
struct instr_emul_ctxt {
|
||||
struct instr_emul_vie vie;
|
||||
struct vm_guest_paging paging;
|
||||
struct acrn_vcpu *vcpu;
|
||||
};
|
||||
|
||||
int32_t emulate_instruction(const struct acrn_vcpu *vcpu);
|
||||
int32_t decode_instruction(struct acrn_vcpu *vcpu);
|
||||
|
||||
#endif
|
@@ -16,7 +16,7 @@
|
||||
#include <gdt.h>
|
||||
#include <timer.h>
|
||||
#include <logmsg.h>
|
||||
#include "arch/x86/guest/instr_emul.h"
|
||||
#include <instr_emul.h>
|
||||
#include <profiling.h>
|
||||
#include <security.h>
|
||||
|
||||
|
Reference in New Issue
Block a user