19 #include <linux/types.h>
20 #include <linux/string.h>
25 #include <linux/slab.h>
27 #include <linux/list.h>
30 #include <asm/tlbflush.h>
37 #include <asm/kvm_host.h>
40 #define TCES_PER_PAGE (PAGE_SIZE / sizeof(u64))
42 static long kvmppc_stt_npages(
unsigned long window_size)
55 for (i = 0; i < kvmppc_stt_npages(stt->
window_size); i++)
63 static int kvm_spapr_tce_fault(
struct vm_area_struct *vma,
struct vm_fault *vmf)
68 if (vmf->pgoff >= kvmppc_stt_npages(stt->
window_size))
69 return VM_FAULT_SIGBUS;
71 page = stt->
pages[vmf->pgoff];
77 static const struct vm_operations_struct kvm_spapr_tce_vm_ops = {
78 .fault = kvm_spapr_tce_fault,
83 vma->
vm_ops = &kvm_spapr_tce_vm_ops;
87 static int kvm_spapr_tce_release(
struct inode *
inode,
struct file *filp)
91 release_spapr_tce_table(stt);
96 .mmap = kvm_spapr_tce_mmap,
97 .release = kvm_spapr_tce_release,
116 stt = kzalloc(
sizeof(*stt) + npages *
sizeof(
struct page *),
125 for (i = 0; i < npages; i++) {
134 list_add(&stt->
list, &kvm->
arch.spapr_tce_tables);
143 for (i = 0; i < npages; i++)