mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-07-27 08:50:58 +00:00
Initialize the VM's time_delta to provide a consistent time offset for guests, and properly initialize vcpu timer-related CSRs (htimedelta and vstimecmp) to enable guest timer virtualization. Changes: - Add time_delta field to vm_arch structure to track VM time offset - Initialize time_delta to -cpu_ticks() at VM creation, making guest time start from 0 - Save/restore htimedelta CSR in vcpu load/unload paths - Initialize vcpu's htimedelta from VM's time_delta - Reset vstimecmp to invalid value (0xffffffffffffffff) on vcpu reset - Add SSTC (Sstc extension) capability check Tracked-On: #8851 Signed-off-by: Haoyu Tang <haoyu.tang@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>
37 lines
763 B
C
37 lines
763 B
C
/*
|
|
* Copyright (C) 2023-2025 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef RISCV_VM_H_
|
|
#define RISCV_VM_H_
|
|
|
|
#include <vm_configurations.h>
|
|
#include <vuart.h>
|
|
#include <fdt_api.h>
|
|
|
|
#include <asm/guest/vsbi.h>
|
|
|
|
#define INVALID_PIO_IDX -1U
|
|
#define UART_PIO_IDX0 INVALID_PIO_IDX
|
|
/* FIXME: dummy. to be implemented later */
|
|
#define EMUL_PIO_IDX_MAX 1U
|
|
|
|
struct vm_arch {
|
|
const struct acrn_vsbi_extension *vsbi_exts[MAX_NUM_SUPPORTED_VSBI_EXT];
|
|
uint16_t n_vsbi_exts;
|
|
uint64_t mvendorid;
|
|
uint64_t marchid;
|
|
uint64_t mimpid;
|
|
|
|
int64_t time_delta;
|
|
};
|
|
|
|
struct acrn_vcpu;
|
|
struct acrn_vm;
|
|
uint32_t vcpu_get_vhartid(struct acrn_vcpu *vcpu);
|
|
struct acrn_vcpu *vcpu_from_vhartid(struct acrn_vm *vm, uint32_t vhartid);
|
|
|
|
#endif /* RISCV_VM_H_ */
|