Files
Haoyu Tang d6b6dc3bc0 hv: riscv improve vSBI base extension implementation
Replace SBI passthrough with proper virtualization of base extension
queries. For the Service VM, forward actual machine vendor/arch/impl
IDs from the underlying SBI. For guest VMs, provide dummy ACRN-specific
IDs to maintain isolation.

Changes:
- Return vSBI spec version 2.0 for GET_SPEC_VERSION
- Return ACRN implementation ID (55) and version for GET_IMP_ID/GET_IMP_VERSION
- Forward real mvendorid/marchid/mimpid to Service VM
- Provide dummy vendor/arch/impl IDs (0/0/0) to guest VMs
- Store machine IDs in vm_arch structure during VM initialization
- Remove unnecessary SBI passthrough for base extension queries

This provides better isolation and control over the virtual SBI
interface exposed to guests.

Tracked-On: #8851
Signed-off-by: Haoyu Tang <haoyu.tang@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2025-12-26 07:57:51 +08:00

54 lines
1.6 KiB
C

/*
* Copyright (C) 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RISCV_VSBI_H
#define RISCV_VSBI_H
#include <types.h>
#include <version.h>
#define VSBI_SPEC_VERSION_MAJOR 0x2U
#define VSBI_SPEC_VERSION_MINOR 0x0U
#define VSBI_SPEC_VERSION (VSBI_SPEC_VERSION_MAJOR << 24 | VSBI_SPEC_VERSION_MINOR)
#define VSBI_ACRN_VERSION_MAJOR HV_API_MAJOR_VERSION
#define VSBI_ACRN_VERSION_MINOR HV_API_MINOR_VERSION
#define VSBI_ACRN_VERSION (VSBI_ACRN_VERSION_MAJOR << 24 | VSBI_ACRN_VERSION_MINOR)
#define VSBI_ACRN_IMPID 55U /* FIXME: once official ID confirmed */
#define VSBI_ACRN_MVENDORID 0U /* dummy MVENDORID for guest VM */
#define VSBI_ACRN_MARCHID 0U /* dummy MARCHID for guest VM */
#define VSBI_ACRN_MIMPID 0U /* dummy MIMPID for guest VM */
#define MAX_NUM_SUPPORTED_VSBI_EXT 8
#define MAX_VSBI_EXTENSION_NAME 16
/* TODO: This ID is distributed by SBI.
* For now just hardcode a random value that isn't used.
* Change to official ID when ACRN gets an ID.
*/
#define SBI_ACRN_IMPL_ID 0x900
#define SBI_EID_ACRN (SBI_EID_FIRMWARE_START + SBI_ACRN_IMPL_ID)
struct vsbi_ret {
uint64_t value;
bool vcpu_retain_pc;
};
struct acrn_vsbi_extension {
const char *name;
uint64_t eid_start;
uint64_t eid_end;
int32_t (*handler)(struct acrn_vcpu *vcpu, uint64_t eid,
uint64_t fid, uint64_t *args, struct vsbi_ret *out);
int32_t (*probe)(struct acrn_vm *vm);
};
int32_t vsbi_exit_handler(struct acrn_vcpu *vcpu);
void init_vsbi(struct acrn_vm *vm);
const struct acrn_vsbi_extension *vcpu_find_extension(struct acrn_vcpu *vcpu, uint64_t eid);
#endif /* RISCV_VSBI_H */