Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/io/vlapic_priv.h
/*- | /*- | ||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||
* | * | ||||
* Copyright (c) 2013 Neel Natu <neel@freebsd.org> | * Copyright (c) 2013 Neel Natu <neel@freebsd.org> | ||||
* All rights reserved. | * All rights reserved. | ||||
* Copyright (c) 2019 Joyent, Inc. | |||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* 16 priority levels with at most one vector injected per level. | * 16 priority levels with at most one vector injected per level. | ||||
*/ | */ | ||||
#define ISRVEC_STK_SIZE (16 + 1) | #define ISRVEC_STK_SIZE (16 + 1) | ||||
#define VLAPIC_MAXLVT_INDEX APIC_LVT_CMCI | #define VLAPIC_MAXLVT_INDEX APIC_LVT_CMCI | ||||
#define VLAPIC_TMR_CNT 8 | |||||
struct vlapic; | struct vlapic; | ||||
struct vlapic_ops { | struct vlapic_ops { | ||||
int (*set_intr_ready)(struct vlapic *vlapic, int vector, bool level); | int (*set_intr_ready)(struct vlapic *vlapic, int vector, bool level); | ||||
int (*pending_intr)(struct vlapic *vlapic, int *vecptr); | int (*pending_intr)(struct vlapic *vlapic, int *vecptr); | ||||
void (*intr_accepted)(struct vlapic *vlapic, int vector); | void (*intr_accepted)(struct vlapic *vlapic, int vector); | ||||
void (*post_intr)(struct vlapic *vlapic, int hostcpu); | void (*post_intr)(struct vlapic *vlapic, int hostcpu); | ||||
void (*set_tmr)(struct vlapic *vlapic, int vector, bool level); | void (*set_tmr)(struct vlapic *vlapic, const uint32_t *result); | ||||
void (*enable_x2apic_mode)(struct vlapic *vlapic); | void (*enable_x2apic_mode)(struct vlapic *vlapic); | ||||
}; | }; | ||||
struct vlapic { | struct vlapic { | ||||
struct vm *vm; | struct vm *vm; | ||||
int vcpuid; | int vcpuid; | ||||
struct LAPIC *apic_page; | struct LAPIC *apic_page; | ||||
struct vlapic_ops ops; | struct vlapic_ops ops; | ||||
uint32_t esr_pending; | uint32_t esr_pending; | ||||
int esr_firing; | int esr_firing; | ||||
uint32_t tmr_pending; | |||||
struct callout callout; /* vlapic timer */ | struct callout callout; /* vlapic timer */ | ||||
struct bintime timer_fire_bt; /* callout expiry time */ | struct bintime timer_fire_bt; /* callout expiry time */ | ||||
struct bintime timer_freq_bt; /* timer frequency */ | struct bintime timer_freq_bt; /* timer frequency */ | ||||
struct bintime timer_period_bt; /* timer period */ | struct bintime timer_period_bt; /* timer period */ | ||||
struct mtx timer_mtx; | struct mtx timer_mtx; | ||||
/* | /* | ||||
Show All 11 Lines | struct vlapic { | ||||
/* | /* | ||||
* Copies of some registers in the virtual APIC page. We do this for | * Copies of some registers in the virtual APIC page. We do this for | ||||
* a couple of different reasons: | * a couple of different reasons: | ||||
* - to be able to detect what changed (e.g. svr_last) | * - to be able to detect what changed (e.g. svr_last) | ||||
* - to maintain a coherent snapshot of the register (e.g. lvt_last) | * - to maintain a coherent snapshot of the register (e.g. lvt_last) | ||||
*/ | */ | ||||
uint32_t svr_last; | uint32_t svr_last; | ||||
uint32_t lvt_last[VLAPIC_MAXLVT_INDEX + 1]; | uint32_t lvt_last[VLAPIC_MAXLVT_INDEX + 1]; | ||||
/* | |||||
* Store intended modifications to the trigger-mode register state. | |||||
* Along with the tmr_pending counter above, these are protected by the | |||||
* vIOAPIC lock and can only be modified under specific conditions: | |||||
* | |||||
* 1. When holding the vIOAPIC lock, and the vCPU to which the vLAPIC | |||||
* belongs is prevented from entering the VCPU_RUNNING state. | |||||
* 2. When the owning vCPU is in the VCPU_RUNNING state, and is | |||||
* applying the TMR modifications prior to interrupt injection. | |||||
*/ | |||||
uint32_t tmr_vec_deassert[VLAPIC_TMR_CNT]; | |||||
uint32_t tmr_vec_assert[VLAPIC_TMR_CNT]; | |||||
}; | }; | ||||
void vlapic_init(struct vlapic *vlapic); | void vlapic_init(struct vlapic *vlapic); | ||||
void vlapic_cleanup(struct vlapic *vlapic); | void vlapic_cleanup(struct vlapic *vlapic); | ||||
#endif /* _VLAPIC_PRIV_H_ */ | #endif /* _VLAPIC_PRIV_H_ */ |