2018-07-15 17:41:35 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
2018-06-05 15:25:07 +08:00
|
|
|
#ifndef PER_CPU_H
|
|
|
|
#define PER_CPU_H
|
2018-07-15 17:41:35 +08:00
|
|
|
|
2019-02-15 14:45:09 +08:00
|
|
|
#include <types.h>
|
2018-06-05 15:25:07 +08:00
|
|
|
#include <sbuf.h>
|
2019-02-15 14:45:09 +08:00
|
|
|
#include <irq.h>
|
2021-04-12 13:40:00 +08:00
|
|
|
#include <timer.h>
|
2018-10-23 03:29:21 +08:00
|
|
|
#include <profiling.h>
|
2019-02-15 14:45:09 +08:00
|
|
|
#include <logmsg.h>
|
2019-02-24 20:19:33 +08:00
|
|
|
#include <schedule.h>
|
2021-04-23 15:50:57 +08:00
|
|
|
#include <asm/notify.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/gdt.h>
|
|
|
|
#include <asm/security.h>
|
|
|
|
#include <asm/vm_config.h>
|
2018-06-05 15:25:07 +08:00
|
|
|
|
|
|
|
struct per_cpu_region {
|
2018-09-05 13:51:32 +08:00
|
|
|
/* vmxon_region MUST be 4KB-aligned */
|
2018-12-03 09:15:28 +08:00
|
|
|
uint8_t vmxon_region[PAGE_SIZE];
|
2018-12-12 20:48:57 +08:00
|
|
|
void *vmcs_run;
|
2018-08-13 13:20:24 +08:00
|
|
|
#ifdef HV_DEBUG
|
2019-07-09 11:20:04 +08:00
|
|
|
struct shared_buf *sbuf[ACRN_SBUF_ID_MAX];
|
2018-10-25 14:25:35 +08:00
|
|
|
char logbuf[LOG_MESSAGE_MAX_SIZE];
|
2018-08-01 13:23:35 +08:00
|
|
|
uint32_t npk_log_ref;
|
2018-08-13 13:20:24 +08:00
|
|
|
#endif
|
|
|
|
uint64_t irq_count[NR_IRQS];
|
2018-06-05 15:25:07 +08:00
|
|
|
uint64_t softirq_pending;
|
|
|
|
uint64_t spurious;
|
2019-08-14 16:34:29 +08:00
|
|
|
struct acrn_vcpu *ever_run_vcpu;
|
2018-06-05 15:25:07 +08:00
|
|
|
#ifdef STACK_PROTECTOR
|
2018-07-30 14:23:38 +08:00
|
|
|
struct stack_canary stk_canary;
|
2018-06-05 15:25:07 +08:00
|
|
|
#endif
|
|
|
|
struct per_cpu_timers cpu_timers;
|
2019-05-23 16:17:28 +08:00
|
|
|
struct sched_control sched_ctl;
|
2019-06-17 17:31:14 +08:00
|
|
|
struct sched_noop_control sched_noop_ctl;
|
2019-06-20 11:10:53 +08:00
|
|
|
struct sched_iorr_control sched_iorr_ctl;
|
2020-02-05 22:51:43 +08:00
|
|
|
struct sched_bvt_control sched_bvt_ctl;
|
2019-05-23 16:17:28 +08:00
|
|
|
struct thread_object idle;
|
2018-06-05 15:25:07 +08:00
|
|
|
struct host_gdt gdt;
|
|
|
|
struct tss_64 tss;
|
2018-10-11 17:13:47 +08:00
|
|
|
enum pcpu_boot_state boot_state;
|
2019-05-21 11:52:21 +08:00
|
|
|
uint64_t pcpu_flag;
|
2018-05-22 23:24:07 +08:00
|
|
|
uint8_t mc_stack[CONFIG_STACK_SIZE] __aligned(16);
|
|
|
|
uint8_t df_stack[CONFIG_STACK_SIZE] __aligned(16);
|
|
|
|
uint8_t sf_stack[CONFIG_STACK_SIZE] __aligned(16);
|
|
|
|
uint8_t stack[CONFIG_STACK_SIZE] __aligned(16);
|
2018-10-21 06:25:08 +08:00
|
|
|
uint32_t lapic_id;
|
|
|
|
uint32_t lapic_ldr;
|
2019-07-09 18:02:55 +08:00
|
|
|
uint32_t softirq_servicing;
|
2018-08-12 21:02:27 +08:00
|
|
|
struct smp_call_info_data smp_call_info;
|
2019-09-03 11:50:01 +08:00
|
|
|
struct list_head softirq_dev_entry_list;
|
2018-10-23 03:29:21 +08:00
|
|
|
#ifdef PROFILING_ON
|
|
|
|
struct profiling_info_wrapper profiling_info;
|
|
|
|
#endif
|
2020-10-22 17:25:27 +08:00
|
|
|
uint64_t shutdown_vm_bitmap;
|
2019-09-18 10:58:09 +08:00
|
|
|
uint64_t tsc_suspend;
|
2021-02-01 18:15:20 +08:00
|
|
|
struct acrn_vcpu *whose_iwkey;
|
2020-04-08 09:38:01 +08:00
|
|
|
/*
|
|
|
|
* We maintain a per-pCPU array of vCPUs. vCPUs of a VM won't
|
|
|
|
* share same pCPU. So the maximum possible # of vCPUs that can
|
|
|
|
* run on a pCPU is CONFIG_MAX_VM_NUM.
|
|
|
|
* vcpu_array address must be aligned to 64-bit for atomic access
|
|
|
|
* to avoid contention between offline_vcpu and posted interrupt handler
|
|
|
|
*/
|
|
|
|
struct acrn_vcpu *vcpu_array[CONFIG_MAX_VM_NUM] __aligned(8);
|
2018-12-03 09:15:28 +08:00
|
|
|
} __aligned(PAGE_SIZE); /* per_cpu_region size aligned with PAGE_SIZE */
|
2018-06-05 15:25:07 +08:00
|
|
|
|
2019-12-11 12:29:21 +08:00
|
|
|
extern struct per_cpu_region per_cpu_data[MAX_PCPU_NUM];
|
2018-06-05 15:25:07 +08:00
|
|
|
/*
|
|
|
|
* get percpu data for pcpu_id.
|
|
|
|
*/
|
|
|
|
#define per_cpu(name, pcpu_id) \
|
2018-10-24 13:36:02 +08:00
|
|
|
(per_cpu_data[(pcpu_id)].name)
|
2018-06-05 15:25:07 +08:00
|
|
|
|
|
|
|
/* get percpu data for current pcpu */
|
2019-04-22 05:52:12 +08:00
|
|
|
#define get_cpu_var(name) per_cpu(name, get_pcpu_id())
|
2018-07-15 17:41:35 +08:00
|
|
|
|
2018-06-05 15:25:07 +08:00
|
|
|
#endif
|