arch/riscv/kvm/vcpu_sbi_fwft.c
Source file repositories/reference/linux-study-clean/arch/riscv/kvm/vcpu_sbi_fwft.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kvm/vcpu_sbi_fwft.c- Extension
.c- Size
- 14112 bytes
- Lines
- 581
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/err.hlinux/kvm_host.hasm/cpufeature.hasm/sbi.hasm/kvm_vcpu_sbi.hasm/kvm_vcpu_sbi_fwft.h
Detected Declarations
struct kvm_sbi_fwft_featurefunction kvm_fwft_is_defined_featurefunction kvm_sbi_fwft_misaligned_delegation_supportedfunction kvm_sbi_fwft_reset_misaligned_delegationfunction kvm_sbi_fwft_set_misaligned_delegationfunction kvm_sbi_fwft_get_misaligned_delegationfunction try_to_set_pmmfunction kvm_sbi_fwft_pointer_masking_pmlen_supportedfunction kvm_sbi_fwft_pointer_masking_pmlen_initfunction kvm_sbi_fwft_reset_pointer_masking_pmlenfunction kvm_sbi_fwft_set_pointer_masking_pmlenfunction kvm_sbi_fwft_get_pointer_masking_pmlenfunction kvm_sbi_fwft_get_configfunction kvm_fwft_get_featurefunction kvm_sbi_fwft_setfunction kvm_sbi_fwft_getfunction kvm_sbi_ext_fwft_handlerfunction kvm_sbi_ext_fwft_initfunction kvm_sbi_ext_fwft_deinitfunction kvm_sbi_ext_fwft_resetfunction kvm_sbi_ext_fwft_get_reg_countfunction kvm_sbi_ext_fwft_get_reg_idfunction kvm_sbi_ext_fwft_get_regfunction kvm_sbi_ext_fwft_set_reg
Annotated Snippet
struct kvm_sbi_fwft_feature {
/**
* @id: Feature ID
*/
enum sbi_fwft_feature_t id;
/**
* @first_reg_num: ONE_REG index of the first ONE_REG register
*/
unsigned long first_reg_num;
/**
* @supported: Check if the feature is supported on the vcpu
*
* This callback is optional, if not provided the feature is assumed to
* be supported
*/
bool (*supported)(struct kvm_vcpu *vcpu);
/**
* @init: Probe and initialize the feature on the vcpu
*
* This callback is optional. If provided, it will be called during
* vcpu initialization to probe the feature availability and perform
* any necessary initialization. Returns true if the feature is supported
* and initialized successfully, false otherwise.
*/
bool (*init)(struct kvm_vcpu *vcpu);
/**
* @reset: Reset the feature value irrespective whether feature is supported or not
*
* This callback is mandatory
*/
void (*reset)(struct kvm_vcpu *vcpu);
/**
* @set: Set the feature value
*
* Return SBI_SUCCESS on success or an SBI error (SBI_ERR_*)
*
* This callback is mandatory
*/
long (*set)(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf,
bool one_reg_access, unsigned long value);
/**
* @get: Get the feature current value
*
* Return SBI_SUCCESS on success or an SBI error (SBI_ERR_*)
*
* This callback is mandatory
*/
long (*get)(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf,
bool one_reg_access, unsigned long *value);
};
static const enum sbi_fwft_feature_t kvm_fwft_defined_features[] = {
SBI_FWFT_MISALIGNED_EXC_DELEG,
SBI_FWFT_LANDING_PAD,
SBI_FWFT_SHADOW_STACK,
SBI_FWFT_DOUBLE_TRAP,
SBI_FWFT_PTE_AD_HW_UPDATING,
SBI_FWFT_POINTER_MASKING_PMLEN,
};
static bool kvm_fwft_is_defined_feature(enum sbi_fwft_feature_t feature)
{
int i;
for (i = 0; i < ARRAY_SIZE(kvm_fwft_defined_features); i++) {
if (kvm_fwft_defined_features[i] == feature)
return true;
}
return false;
}
static bool kvm_sbi_fwft_misaligned_delegation_supported(struct kvm_vcpu *vcpu)
{
return misaligned_traps_can_delegate();
}
static void kvm_sbi_fwft_reset_misaligned_delegation(struct kvm_vcpu *vcpu)
{
struct kvm_vcpu_config *cfg = &vcpu->arch.cfg;
cfg->hedeleg &= ~MIS_DELEG;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/err.h`, `linux/kvm_host.h`, `asm/cpufeature.h`, `asm/sbi.h`, `asm/kvm_vcpu_sbi.h`, `asm/kvm_vcpu_sbi_fwft.h`.
- Detected declarations: `struct kvm_sbi_fwft_feature`, `function kvm_fwft_is_defined_feature`, `function kvm_sbi_fwft_misaligned_delegation_supported`, `function kvm_sbi_fwft_reset_misaligned_delegation`, `function kvm_sbi_fwft_set_misaligned_delegation`, `function kvm_sbi_fwft_get_misaligned_delegation`, `function try_to_set_pmm`, `function kvm_sbi_fwft_pointer_masking_pmlen_supported`, `function kvm_sbi_fwft_pointer_masking_pmlen_init`, `function kvm_sbi_fwft_reset_pointer_masking_pmlen`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.