arch/powerpc/kvm/book3s_rtas.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kvm/book3s_rtas.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kvm/book3s_rtas.c- Extension
.c- Size
- 6984 bytes
- Lines
- 308
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/kvm_host.hlinux/kvm.hlinux/err.hlinux/uaccess.hasm/kvm_book3s.hasm/kvm_ppc.hasm/hvcall.hasm/rtas.hasm/xive.h
Detected Declarations
struct rtas_handlerstruct rtas_token_definitionfunction kvm_rtas_set_xivefunction kvm_rtas_get_xivefunction kvm_rtas_int_offfunction kvm_rtas_int_onfunction rtas_name_matchesfunction rtas_token_undefinefunction list_for_each_entry_safefunction rtas_token_definefunction list_for_each_entryfunction kvm_vm_ioctl_rtas_define_tokenfunction kvmppc_rtas_hcallfunction kvmppc_rtas_tokens_freefunction list_for_each_entry_safeexport kvmppc_rtas_hcall
Annotated Snippet
struct rtas_handler {
void (*handler)(struct kvm_vcpu *vcpu, struct rtas_args *args);
char *name;
};
static struct rtas_handler rtas_handlers[] = {
#ifdef CONFIG_KVM_XICS
{ .name = "ibm,set-xive", .handler = kvm_rtas_set_xive },
{ .name = "ibm,get-xive", .handler = kvm_rtas_get_xive },
{ .name = "ibm,int-off", .handler = kvm_rtas_int_off },
{ .name = "ibm,int-on", .handler = kvm_rtas_int_on },
#endif
};
struct rtas_token_definition {
struct list_head list;
struct rtas_handler *handler;
u64 token;
};
static int rtas_name_matches(char *s1, char *s2)
{
struct kvm_rtas_token_args args;
return !strncmp(s1, s2, sizeof(args.name));
}
static int rtas_token_undefine(struct kvm *kvm, char *name)
{
struct rtas_token_definition *d, *tmp;
lockdep_assert_held(&kvm->arch.rtas_token_lock);
list_for_each_entry_safe(d, tmp, &kvm->arch.rtas_tokens, list) {
if (rtas_name_matches(d->handler->name, name)) {
list_del(&d->list);
kfree(d);
return 0;
}
}
/* It's not an error to undefine an undefined token */
return 0;
}
static int rtas_token_define(struct kvm *kvm, char *name, u64 token)
{
struct rtas_token_definition *d;
struct rtas_handler *h = NULL;
bool found;
int i;
lockdep_assert_held(&kvm->arch.rtas_token_lock);
list_for_each_entry(d, &kvm->arch.rtas_tokens, list) {
if (d->token == token)
return -EEXIST;
}
found = false;
for (i = 0; i < ARRAY_SIZE(rtas_handlers); i++) {
h = &rtas_handlers[i];
if (rtas_name_matches(h->name, name)) {
found = true;
break;
}
}
if (!found)
return -ENOENT;
d = kzalloc_obj(*d);
if (!d)
return -ENOMEM;
d->handler = h;
d->token = token;
list_add_tail(&d->list, &kvm->arch.rtas_tokens);
return 0;
}
int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp)
{
struct kvm_rtas_token_args args;
int rc;
if (copy_from_user(&args, argp, sizeof(args)))
return -EFAULT;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kvm_host.h`, `linux/kvm.h`, `linux/err.h`, `linux/uaccess.h`, `asm/kvm_book3s.h`, `asm/kvm_ppc.h`, `asm/hvcall.h`.
- Detected declarations: `struct rtas_handler`, `struct rtas_token_definition`, `function kvm_rtas_set_xive`, `function kvm_rtas_get_xive`, `function kvm_rtas_int_off`, `function kvm_rtas_int_on`, `function rtas_name_matches`, `function rtas_token_undefine`, `function list_for_each_entry_safe`, `function rtas_token_define`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.