mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
hv: improve vmexit array size to avoid overflow
change vmexit data array size according to vmexit dispatch_table size. also add a size check to avoid array overflow. Tracked-On: #7043 Signed-off-by: Minggui Cao <minggui.cao@intel.com>
This commit is contained in:
parent
f4e0bf34dd
commit
79359441ff
@ -27,7 +27,6 @@
|
|||||||
* According to "SDM APPENDIX C VMX BASIC EXIT REASONS",
|
* According to "SDM APPENDIX C VMX BASIC EXIT REASONS",
|
||||||
* there are 65 Basic Exit Reasons.
|
* there are 65 Basic Exit Reasons.
|
||||||
*/
|
*/
|
||||||
#define NR_VMX_EXIT_REASONS 70U
|
|
||||||
|
|
||||||
static int32_t triple_fault_vmexit_handler(struct acrn_vcpu *vcpu);
|
static int32_t triple_fault_vmexit_handler(struct acrn_vcpu *vcpu);
|
||||||
static int32_t unhandled_vmexit_handler(struct acrn_vcpu *vcpu);
|
static int32_t unhandled_vmexit_handler(struct acrn_vcpu *vcpu);
|
||||||
|
@ -2026,7 +2026,7 @@ static int shell_show_vmexit_profile(__unused int argc, __unused char **argv)
|
|||||||
/* to sample vmexit tsc data */
|
/* to sample vmexit tsc data */
|
||||||
void sample_vmexit_end(uint32_t basic_exit_reason, struct acrn_vcpu *vcpu)
|
void sample_vmexit_end(uint32_t basic_exit_reason, struct acrn_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
if (!sample_vmexit_enabled)
|
if (!sample_vmexit_enabled || (basic_exit_reason >= NR_VMX_EXIT_REASONS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vcpu->vmexit_begin != 0UL) {
|
if (vcpu->vmexit_begin != 0UL) {
|
||||||
@ -2060,7 +2060,7 @@ void sample_vmexit_end(uint32_t basic_exit_reason, struct acrn_vcpu *vcpu)
|
|||||||
|
|
||||||
void sample_vmexit_begin(uint32_t basic_exit_reason, struct acrn_vcpu *vcpu)
|
void sample_vmexit_begin(uint32_t basic_exit_reason, struct acrn_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
if (!sample_vmexit_enabled)
|
if (!sample_vmexit_enabled || (basic_exit_reason >= NR_VMX_EXIT_REASONS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vcpu->vmexit_begin = rdtsc();
|
vcpu->vmexit_begin = rdtsc();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <asm/guest/virtual_cr.h>
|
#include <asm/guest/virtual_cr.h>
|
||||||
#include <asm/guest/vlapic.h>
|
#include <asm/guest/vlapic.h>
|
||||||
#include <asm/guest/vmtrr.h>
|
#include <asm/guest/vmtrr.h>
|
||||||
|
#include <asm/guest/vmexit.h>
|
||||||
#include <schedule.h>
|
#include <schedule.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <io_req.h>
|
#include <io_req.h>
|
||||||
@ -311,8 +312,8 @@ struct acrn_vcpu {
|
|||||||
#ifdef HV_DEBUG
|
#ifdef HV_DEBUG
|
||||||
uint64_t vmexit_begin;
|
uint64_t vmexit_begin;
|
||||||
|
|
||||||
uint64_t vmexit_cnt[64][TOTAL_ARRAY_LEVEL];
|
uint64_t vmexit_cnt[NR_VMX_EXIT_REASONS][TOTAL_ARRAY_LEVEL];
|
||||||
uint64_t vmexit_time[64][2]; /*0 for total latency, 1 for max latency */
|
uint64_t vmexit_time[NR_VMX_EXIT_REASONS][2]; /*0 for total latency, 1 for max latency */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} __aligned(PAGE_SIZE);
|
} __aligned(PAGE_SIZE);
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#ifndef VMEXIT_H_
|
#ifndef VMEXIT_H_
|
||||||
#define VMEXIT_H_
|
#define VMEXIT_H_
|
||||||
|
|
||||||
|
#define NR_VMX_EXIT_REASONS 70U
|
||||||
|
|
||||||
struct vm_exit_dispatch {
|
struct vm_exit_dispatch {
|
||||||
int32_t (*handler)(struct acrn_vcpu *);
|
int32_t (*handler)(struct acrn_vcpu *);
|
||||||
uint32_t need_exit_qualification;
|
uint32_t need_exit_qualification;
|
||||||
|
@ -30,8 +30,8 @@ struct per_cpu_region {
|
|||||||
struct shared_buf *sbuf[ACRN_SBUF_ID_MAX];
|
struct shared_buf *sbuf[ACRN_SBUF_ID_MAX];
|
||||||
char logbuf[LOG_MESSAGE_MAX_SIZE];
|
char logbuf[LOG_MESSAGE_MAX_SIZE];
|
||||||
|
|
||||||
uint64_t vmexit_cnt[64][TOTAL_ARRAY_LEVEL];
|
uint64_t vmexit_cnt[NR_VMX_EXIT_REASONS][TOTAL_ARRAY_LEVEL];
|
||||||
uint64_t vmexit_time[64][2]; /*0 for total latency, 1 for max latency */
|
uint64_t vmexit_time[NR_VMX_EXIT_REASONS][2]; /*0 for total latency, 1 for max latency */
|
||||||
|
|
||||||
uint32_t npk_log_ref;
|
uint32_t npk_log_ref;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user