arch/riscv/kvm/vcpu_sbi_sta.c
Source file repositories/reference/linux-study-clean/arch/riscv/kvm/vcpu_sbi_sta.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kvm/vcpu_sbi_sta.c- Extension
.c- Size
- 5611 bytes
- Lines
- 234
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kconfig.hlinux/kernel.hlinux/kvm_host.hlinux/mm.hlinux/sizes.hasm/bug.hasm/current.hasm/kvm_vcpu_sbi.hasm/page.hasm/sbi.hasm/uaccess.h
Detected Declarations
function Copyrightfunction kvm_riscv_vcpu_record_steal_timefunction kvm_sbi_sta_steal_time_set_shmemfunction kvm_sbi_ext_sta_handlerfunction kvm_sbi_ext_sta_probefunction kvm_sbi_ext_sta_get_state_reg_countfunction kvm_sbi_ext_sta_get_regfunction kvm_sbi_ext_sta_set_regfunction KVM_REG_RISCV_SBI_STA_REG
Annotated Snippet
if (IS_ENABLED(CONFIG_32BIT)) {
gpa_t hi = upper_32_bits(vcpu->arch.sta.shmem);
new_shmem = value;
new_shmem |= hi << 32;
} else {
new_shmem = value;
}
break;
case KVM_REG_RISCV_SBI_STA_REG(shmem_hi):
if (IS_ENABLED(CONFIG_32BIT)) {
gpa_t lo = lower_32_bits(vcpu->arch.sta.shmem);
new_shmem = ((gpa_t)value << 32);
new_shmem |= lo;
} else if (value != 0) {
return -EINVAL;
}
break;
default:
return -ENOENT;
}
if (new_shmem != INVALID_GPA && !IS_ALIGNED(new_shmem, 64))
return -EINVAL;
vcpu->arch.sta.shmem = new_shmem;
return 0;
}
const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_sta = {
.extid_start = SBI_EXT_STA,
.extid_end = SBI_EXT_STA,
.handler = kvm_sbi_ext_sta_handler,
.probe = kvm_sbi_ext_sta_probe,
.reset = kvm_riscv_vcpu_sbi_sta_reset,
.state_reg_subtype = KVM_REG_RISCV_SBI_STA,
.get_state_reg_count = kvm_sbi_ext_sta_get_state_reg_count,
.get_state_reg = kvm_sbi_ext_sta_get_reg,
.set_state_reg = kvm_sbi_ext_sta_set_reg,
};
Annotation
- Immediate include surface: `linux/kconfig.h`, `linux/kernel.h`, `linux/kvm_host.h`, `linux/mm.h`, `linux/sizes.h`, `asm/bug.h`, `asm/current.h`, `asm/kvm_vcpu_sbi.h`.
- Detected declarations: `function Copyright`, `function kvm_riscv_vcpu_record_steal_time`, `function kvm_sbi_sta_steal_time_set_shmem`, `function kvm_sbi_ext_sta_handler`, `function kvm_sbi_ext_sta_probe`, `function kvm_sbi_ext_sta_get_state_reg_count`, `function kvm_sbi_ext_sta_get_reg`, `function kvm_sbi_ext_sta_set_reg`, `function KVM_REG_RISCV_SBI_STA_REG`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.