1bbf45ba5SHollis Blanchard /* 2bbf45ba5SHollis Blanchard * This program is free software; you can redistribute it and/or modify 3bbf45ba5SHollis Blanchard * it under the terms of the GNU General Public License, version 2, as 4bbf45ba5SHollis Blanchard * published by the Free Software Foundation. 5bbf45ba5SHollis Blanchard * 6bbf45ba5SHollis Blanchard * This program is distributed in the hope that it will be useful, 7bbf45ba5SHollis Blanchard * but WITHOUT ANY WARRANTY; without even the implied warranty of 8bbf45ba5SHollis Blanchard * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9bbf45ba5SHollis Blanchard * GNU General Public License for more details. 10bbf45ba5SHollis Blanchard * 11bbf45ba5SHollis Blanchard * You should have received a copy of the GNU General Public License 12bbf45ba5SHollis Blanchard * along with this program; if not, write to the Free Software 13bbf45ba5SHollis Blanchard * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14bbf45ba5SHollis Blanchard * 15bbf45ba5SHollis Blanchard * Copyright IBM Corp. 2007 16bbf45ba5SHollis Blanchard * 17bbf45ba5SHollis Blanchard * Authors: Hollis Blanchard <hollisb@us.ibm.com> 18bbf45ba5SHollis Blanchard * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> 19bbf45ba5SHollis Blanchard */ 20bbf45ba5SHollis Blanchard 21bbf45ba5SHollis Blanchard #include <linux/errno.h> 22bbf45ba5SHollis Blanchard #include <linux/err.h> 23bbf45ba5SHollis Blanchard #include <linux/kvm_host.h> 24bbf45ba5SHollis Blanchard #include <linux/module.h> 25bbf45ba5SHollis Blanchard #include <linux/vmalloc.h> 26bbf45ba5SHollis Blanchard #include <linux/fs.h> 27bbf45ba5SHollis Blanchard #include <asm/cputable.h> 28bbf45ba5SHollis Blanchard #include <asm/uaccess.h> 29bbf45ba5SHollis Blanchard #include <asm/kvm_ppc.h> 3083aae4a8SHollis Blanchard #include <asm/tlbflush.h> 3173e75b41SHollis Blanchard #include "timing.h" 32fad7b9b5SPaul Mackerras #include "../mm/mmu_decl.h" 33bbf45ba5SHollis Blanchard 3446f43c6eSMarcelo Tosatti #define CREATE_TRACE_POINTS 3546f43c6eSMarcelo Tosatti #include "trace.h" 3646f43c6eSMarcelo Tosatti 37bbf45ba5SHollis Blanchard gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) 38bbf45ba5SHollis Blanchard { 39bbf45ba5SHollis Blanchard return gfn; 40bbf45ba5SHollis Blanchard } 41bbf45ba5SHollis Blanchard 42bbf45ba5SHollis Blanchard int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) 43bbf45ba5SHollis Blanchard { 44*a1b37100SGleb Natapov return !(v->arch.msr & MSR_WE) || !!(v->arch.pending_exceptions); 45bbf45ba5SHollis Blanchard } 46bbf45ba5SHollis Blanchard 47bbf45ba5SHollis Blanchard 48bbf45ba5SHollis Blanchard int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) 49bbf45ba5SHollis Blanchard { 50bbf45ba5SHollis Blanchard enum emulation_result er; 51bbf45ba5SHollis Blanchard int r; 52bbf45ba5SHollis Blanchard 53bbf45ba5SHollis Blanchard er = kvmppc_emulate_instruction(run, vcpu); 54bbf45ba5SHollis Blanchard switch (er) { 55bbf45ba5SHollis Blanchard case EMULATE_DONE: 56bbf45ba5SHollis Blanchard /* Future optimization: only reload non-volatiles if they were 57bbf45ba5SHollis Blanchard * actually modified. */ 58bbf45ba5SHollis Blanchard r = RESUME_GUEST_NV; 59bbf45ba5SHollis Blanchard break; 60bbf45ba5SHollis Blanchard case EMULATE_DO_MMIO: 61bbf45ba5SHollis Blanchard run->exit_reason = KVM_EXIT_MMIO; 62bbf45ba5SHollis Blanchard /* We must reload nonvolatiles because "update" load/store 63bbf45ba5SHollis Blanchard * instructions modify register state. */ 64bbf45ba5SHollis Blanchard /* Future optimization: only reload non-volatiles if they were 65bbf45ba5SHollis Blanchard * actually modified. */ 66bbf45ba5SHollis Blanchard r = RESUME_HOST_NV; 67bbf45ba5SHollis Blanchard break; 68bbf45ba5SHollis Blanchard case EMULATE_FAIL: 69bbf45ba5SHollis Blanchard /* XXX Deliver Program interrupt to guest. */ 70bbf45ba5SHollis Blanchard printk(KERN_EMERG "%s: emulation failed (%08x)\n", __func__, 71bbf45ba5SHollis Blanchard vcpu->arch.last_inst); 72bbf45ba5SHollis Blanchard r = RESUME_HOST; 73bbf45ba5SHollis Blanchard break; 74bbf45ba5SHollis Blanchard default: 75bbf45ba5SHollis Blanchard BUG(); 76bbf45ba5SHollis Blanchard } 77bbf45ba5SHollis Blanchard 78bbf45ba5SHollis Blanchard return r; 79bbf45ba5SHollis Blanchard } 80bbf45ba5SHollis Blanchard 81bbf45ba5SHollis Blanchard void kvm_arch_hardware_enable(void *garbage) 82bbf45ba5SHollis Blanchard { 83bbf45ba5SHollis Blanchard } 84bbf45ba5SHollis Blanchard 85bbf45ba5SHollis Blanchard void kvm_arch_hardware_disable(void *garbage) 86bbf45ba5SHollis Blanchard { 87bbf45ba5SHollis Blanchard } 88bbf45ba5SHollis Blanchard 89bbf45ba5SHollis Blanchard int kvm_arch_hardware_setup(void) 90bbf45ba5SHollis Blanchard { 91bbf45ba5SHollis Blanchard return 0; 92bbf45ba5SHollis Blanchard } 93bbf45ba5SHollis Blanchard 94bbf45ba5SHollis Blanchard void kvm_arch_hardware_unsetup(void) 95bbf45ba5SHollis Blanchard { 96bbf45ba5SHollis Blanchard } 97bbf45ba5SHollis Blanchard 98bbf45ba5SHollis Blanchard void kvm_arch_check_processor_compat(void *rtn) 99bbf45ba5SHollis Blanchard { 1009dd921cfSHollis Blanchard *(int *)rtn = kvmppc_core_check_processor_compat(); 101bbf45ba5SHollis Blanchard } 102bbf45ba5SHollis Blanchard 103bbf45ba5SHollis Blanchard struct kvm *kvm_arch_create_vm(void) 104bbf45ba5SHollis Blanchard { 105bbf45ba5SHollis Blanchard struct kvm *kvm; 106bbf45ba5SHollis Blanchard 107bbf45ba5SHollis Blanchard kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL); 108bbf45ba5SHollis Blanchard if (!kvm) 109bbf45ba5SHollis Blanchard return ERR_PTR(-ENOMEM); 110bbf45ba5SHollis Blanchard 111bbf45ba5SHollis Blanchard return kvm; 112bbf45ba5SHollis Blanchard } 113bbf45ba5SHollis Blanchard 114bbf45ba5SHollis Blanchard static void kvmppc_free_vcpus(struct kvm *kvm) 115bbf45ba5SHollis Blanchard { 116bbf45ba5SHollis Blanchard unsigned int i; 117988a2caeSGleb Natapov struct kvm_vcpu *vcpu; 118bbf45ba5SHollis Blanchard 119988a2caeSGleb Natapov kvm_for_each_vcpu(i, vcpu, kvm) 120988a2caeSGleb Natapov kvm_arch_vcpu_free(vcpu); 121988a2caeSGleb Natapov 122988a2caeSGleb Natapov mutex_lock(&kvm->lock); 123988a2caeSGleb Natapov for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) 124bbf45ba5SHollis Blanchard kvm->vcpus[i] = NULL; 125988a2caeSGleb Natapov 126988a2caeSGleb Natapov atomic_set(&kvm->online_vcpus, 0); 127988a2caeSGleb Natapov mutex_unlock(&kvm->lock); 128bbf45ba5SHollis Blanchard } 129bbf45ba5SHollis Blanchard 130ad8ba2cdSSheng Yang void kvm_arch_sync_events(struct kvm *kvm) 131ad8ba2cdSSheng Yang { 132ad8ba2cdSSheng Yang } 133ad8ba2cdSSheng Yang 134bbf45ba5SHollis Blanchard void kvm_arch_destroy_vm(struct kvm *kvm) 135bbf45ba5SHollis Blanchard { 136bbf45ba5SHollis Blanchard kvmppc_free_vcpus(kvm); 137bbf45ba5SHollis Blanchard kvm_free_physmem(kvm); 138bbf45ba5SHollis Blanchard kfree(kvm); 139bbf45ba5SHollis Blanchard } 140bbf45ba5SHollis Blanchard 141bbf45ba5SHollis Blanchard int kvm_dev_ioctl_check_extension(long ext) 142bbf45ba5SHollis Blanchard { 143bbf45ba5SHollis Blanchard int r; 144bbf45ba5SHollis Blanchard 145bbf45ba5SHollis Blanchard switch (ext) { 146588968b6SLaurent Vivier case KVM_CAP_COALESCED_MMIO: 147588968b6SLaurent Vivier r = KVM_COALESCED_MMIO_PAGE_OFFSET; 148588968b6SLaurent Vivier break; 149bbf45ba5SHollis Blanchard default: 150bbf45ba5SHollis Blanchard r = 0; 151bbf45ba5SHollis Blanchard break; 152bbf45ba5SHollis Blanchard } 153bbf45ba5SHollis Blanchard return r; 154bbf45ba5SHollis Blanchard 155bbf45ba5SHollis Blanchard } 156bbf45ba5SHollis Blanchard 157bbf45ba5SHollis Blanchard long kvm_arch_dev_ioctl(struct file *filp, 158bbf45ba5SHollis Blanchard unsigned int ioctl, unsigned long arg) 159bbf45ba5SHollis Blanchard { 160bbf45ba5SHollis Blanchard return -EINVAL; 161bbf45ba5SHollis Blanchard } 162bbf45ba5SHollis Blanchard 163bbf45ba5SHollis Blanchard int kvm_arch_set_memory_region(struct kvm *kvm, 164bbf45ba5SHollis Blanchard struct kvm_userspace_memory_region *mem, 165bbf45ba5SHollis Blanchard struct kvm_memory_slot old, 166bbf45ba5SHollis Blanchard int user_alloc) 167bbf45ba5SHollis Blanchard { 168bbf45ba5SHollis Blanchard return 0; 169bbf45ba5SHollis Blanchard } 170bbf45ba5SHollis Blanchard 17134d4cb8fSMarcelo Tosatti void kvm_arch_flush_shadow(struct kvm *kvm) 17234d4cb8fSMarcelo Tosatti { 17334d4cb8fSMarcelo Tosatti } 17434d4cb8fSMarcelo Tosatti 175bbf45ba5SHollis Blanchard struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) 176bbf45ba5SHollis Blanchard { 17773e75b41SHollis Blanchard struct kvm_vcpu *vcpu; 17873e75b41SHollis Blanchard vcpu = kvmppc_core_vcpu_create(kvm, id); 17973e75b41SHollis Blanchard kvmppc_create_vcpu_debugfs(vcpu, id); 18073e75b41SHollis Blanchard return vcpu; 181bbf45ba5SHollis Blanchard } 182bbf45ba5SHollis Blanchard 183bbf45ba5SHollis Blanchard void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) 184bbf45ba5SHollis Blanchard { 18573e75b41SHollis Blanchard kvmppc_remove_vcpu_debugfs(vcpu); 186db93f574SHollis Blanchard kvmppc_core_vcpu_free(vcpu); 187bbf45ba5SHollis Blanchard } 188bbf45ba5SHollis Blanchard 189bbf45ba5SHollis Blanchard void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) 190bbf45ba5SHollis Blanchard { 191bbf45ba5SHollis Blanchard kvm_arch_vcpu_free(vcpu); 192bbf45ba5SHollis Blanchard } 193bbf45ba5SHollis Blanchard 194bbf45ba5SHollis Blanchard int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) 195bbf45ba5SHollis Blanchard { 1969dd921cfSHollis Blanchard return kvmppc_core_pending_dec(vcpu); 197bbf45ba5SHollis Blanchard } 198bbf45ba5SHollis Blanchard 199bbf45ba5SHollis Blanchard static void kvmppc_decrementer_func(unsigned long data) 200bbf45ba5SHollis Blanchard { 201bbf45ba5SHollis Blanchard struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; 202bbf45ba5SHollis Blanchard 2039dd921cfSHollis Blanchard kvmppc_core_queue_dec(vcpu); 20445c5eb67SHollis Blanchard 20545c5eb67SHollis Blanchard if (waitqueue_active(&vcpu->wq)) { 20645c5eb67SHollis Blanchard wake_up_interruptible(&vcpu->wq); 20745c5eb67SHollis Blanchard vcpu->stat.halt_wakeup++; 20845c5eb67SHollis Blanchard } 209bbf45ba5SHollis Blanchard } 210bbf45ba5SHollis Blanchard 211bbf45ba5SHollis Blanchard int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 212bbf45ba5SHollis Blanchard { 213bbf45ba5SHollis Blanchard setup_timer(&vcpu->arch.dec_timer, kvmppc_decrementer_func, 214bbf45ba5SHollis Blanchard (unsigned long)vcpu); 215bbf45ba5SHollis Blanchard 216bbf45ba5SHollis Blanchard return 0; 217bbf45ba5SHollis Blanchard } 218bbf45ba5SHollis Blanchard 219bbf45ba5SHollis Blanchard void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) 220bbf45ba5SHollis Blanchard { 221ecc0981fSHollis Blanchard kvmppc_mmu_destroy(vcpu); 222bbf45ba5SHollis Blanchard } 223bbf45ba5SHollis Blanchard 224bbf45ba5SHollis Blanchard void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 225bbf45ba5SHollis Blanchard { 2269dd921cfSHollis Blanchard kvmppc_core_vcpu_load(vcpu, cpu); 227bbf45ba5SHollis Blanchard } 228bbf45ba5SHollis Blanchard 229bbf45ba5SHollis Blanchard void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 230bbf45ba5SHollis Blanchard { 2319dd921cfSHollis Blanchard kvmppc_core_vcpu_put(vcpu); 232bbf45ba5SHollis Blanchard } 233bbf45ba5SHollis Blanchard 234d0bfb940SJan Kiszka int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, 235d0bfb940SJan Kiszka struct kvm_guest_debug *dbg) 236bbf45ba5SHollis Blanchard { 237f5d0906bSHollis Blanchard return -EINVAL; 238bbf45ba5SHollis Blanchard } 239bbf45ba5SHollis Blanchard 240bbf45ba5SHollis Blanchard static void kvmppc_complete_dcr_load(struct kvm_vcpu *vcpu, 241bbf45ba5SHollis Blanchard struct kvm_run *run) 242bbf45ba5SHollis Blanchard { 2435cf8ca22SHollis Blanchard ulong *gpr = &vcpu->arch.gpr[vcpu->arch.io_gpr]; 244bbf45ba5SHollis Blanchard *gpr = run->dcr.data; 245bbf45ba5SHollis Blanchard } 246bbf45ba5SHollis Blanchard 247bbf45ba5SHollis Blanchard static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu, 248bbf45ba5SHollis Blanchard struct kvm_run *run) 249bbf45ba5SHollis Blanchard { 2505cf8ca22SHollis Blanchard ulong *gpr = &vcpu->arch.gpr[vcpu->arch.io_gpr]; 251bbf45ba5SHollis Blanchard 252bbf45ba5SHollis Blanchard if (run->mmio.len > sizeof(*gpr)) { 253bbf45ba5SHollis Blanchard printk(KERN_ERR "bad MMIO length: %d\n", run->mmio.len); 254bbf45ba5SHollis Blanchard return; 255bbf45ba5SHollis Blanchard } 256bbf45ba5SHollis Blanchard 257bbf45ba5SHollis Blanchard if (vcpu->arch.mmio_is_bigendian) { 258bbf45ba5SHollis Blanchard switch (run->mmio.len) { 259bbf45ba5SHollis Blanchard case 4: *gpr = *(u32 *)run->mmio.data; break; 260bbf45ba5SHollis Blanchard case 2: *gpr = *(u16 *)run->mmio.data; break; 261bbf45ba5SHollis Blanchard case 1: *gpr = *(u8 *)run->mmio.data; break; 262bbf45ba5SHollis Blanchard } 263bbf45ba5SHollis Blanchard } else { 264bbf45ba5SHollis Blanchard /* Convert BE data from userland back to LE. */ 265bbf45ba5SHollis Blanchard switch (run->mmio.len) { 266bbf45ba5SHollis Blanchard case 4: *gpr = ld_le32((u32 *)run->mmio.data); break; 267bbf45ba5SHollis Blanchard case 2: *gpr = ld_le16((u16 *)run->mmio.data); break; 268bbf45ba5SHollis Blanchard case 1: *gpr = *(u8 *)run->mmio.data; break; 269bbf45ba5SHollis Blanchard } 270bbf45ba5SHollis Blanchard } 271bbf45ba5SHollis Blanchard } 272bbf45ba5SHollis Blanchard 273bbf45ba5SHollis Blanchard int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu, 274bbf45ba5SHollis Blanchard unsigned int rt, unsigned int bytes, int is_bigendian) 275bbf45ba5SHollis Blanchard { 276bbf45ba5SHollis Blanchard if (bytes > sizeof(run->mmio.data)) { 277bbf45ba5SHollis Blanchard printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, 278bbf45ba5SHollis Blanchard run->mmio.len); 279bbf45ba5SHollis Blanchard } 280bbf45ba5SHollis Blanchard 281bbf45ba5SHollis Blanchard run->mmio.phys_addr = vcpu->arch.paddr_accessed; 282bbf45ba5SHollis Blanchard run->mmio.len = bytes; 283bbf45ba5SHollis Blanchard run->mmio.is_write = 0; 284bbf45ba5SHollis Blanchard 285bbf45ba5SHollis Blanchard vcpu->arch.io_gpr = rt; 286bbf45ba5SHollis Blanchard vcpu->arch.mmio_is_bigendian = is_bigendian; 287bbf45ba5SHollis Blanchard vcpu->mmio_needed = 1; 288bbf45ba5SHollis Blanchard vcpu->mmio_is_write = 0; 289bbf45ba5SHollis Blanchard 290bbf45ba5SHollis Blanchard return EMULATE_DO_MMIO; 291bbf45ba5SHollis Blanchard } 292bbf45ba5SHollis Blanchard 293bbf45ba5SHollis Blanchard int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, 294bbf45ba5SHollis Blanchard u32 val, unsigned int bytes, int is_bigendian) 295bbf45ba5SHollis Blanchard { 296bbf45ba5SHollis Blanchard void *data = run->mmio.data; 297bbf45ba5SHollis Blanchard 298bbf45ba5SHollis Blanchard if (bytes > sizeof(run->mmio.data)) { 299bbf45ba5SHollis Blanchard printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__, 300bbf45ba5SHollis Blanchard run->mmio.len); 301bbf45ba5SHollis Blanchard } 302bbf45ba5SHollis Blanchard 303bbf45ba5SHollis Blanchard run->mmio.phys_addr = vcpu->arch.paddr_accessed; 304bbf45ba5SHollis Blanchard run->mmio.len = bytes; 305bbf45ba5SHollis Blanchard run->mmio.is_write = 1; 306bbf45ba5SHollis Blanchard vcpu->mmio_needed = 1; 307bbf45ba5SHollis Blanchard vcpu->mmio_is_write = 1; 308bbf45ba5SHollis Blanchard 309bbf45ba5SHollis Blanchard /* Store the value at the lowest bytes in 'data'. */ 310bbf45ba5SHollis Blanchard if (is_bigendian) { 311bbf45ba5SHollis Blanchard switch (bytes) { 312bbf45ba5SHollis Blanchard case 4: *(u32 *)data = val; break; 313bbf45ba5SHollis Blanchard case 2: *(u16 *)data = val; break; 314bbf45ba5SHollis Blanchard case 1: *(u8 *)data = val; break; 315bbf45ba5SHollis Blanchard } 316bbf45ba5SHollis Blanchard } else { 317bbf45ba5SHollis Blanchard /* Store LE value into 'data'. */ 318bbf45ba5SHollis Blanchard switch (bytes) { 319bbf45ba5SHollis Blanchard case 4: st_le32(data, val); break; 320bbf45ba5SHollis Blanchard case 2: st_le16(data, val); break; 321bbf45ba5SHollis Blanchard case 1: *(u8 *)data = val; break; 322bbf45ba5SHollis Blanchard } 323bbf45ba5SHollis Blanchard } 324bbf45ba5SHollis Blanchard 325bbf45ba5SHollis Blanchard return EMULATE_DO_MMIO; 326bbf45ba5SHollis Blanchard } 327bbf45ba5SHollis Blanchard 328bbf45ba5SHollis Blanchard int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) 329bbf45ba5SHollis Blanchard { 330bbf45ba5SHollis Blanchard int r; 331bbf45ba5SHollis Blanchard sigset_t sigsaved; 332bbf45ba5SHollis Blanchard 33345c5eb67SHollis Blanchard vcpu_load(vcpu); 33445c5eb67SHollis Blanchard 335bbf45ba5SHollis Blanchard if (vcpu->sigset_active) 336bbf45ba5SHollis Blanchard sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); 337bbf45ba5SHollis Blanchard 338bbf45ba5SHollis Blanchard if (vcpu->mmio_needed) { 339bbf45ba5SHollis Blanchard if (!vcpu->mmio_is_write) 340bbf45ba5SHollis Blanchard kvmppc_complete_mmio_load(vcpu, run); 341bbf45ba5SHollis Blanchard vcpu->mmio_needed = 0; 342bbf45ba5SHollis Blanchard } else if (vcpu->arch.dcr_needed) { 343bbf45ba5SHollis Blanchard if (!vcpu->arch.dcr_is_write) 344bbf45ba5SHollis Blanchard kvmppc_complete_dcr_load(vcpu, run); 345bbf45ba5SHollis Blanchard vcpu->arch.dcr_needed = 0; 346bbf45ba5SHollis Blanchard } 347bbf45ba5SHollis Blanchard 3489dd921cfSHollis Blanchard kvmppc_core_deliver_interrupts(vcpu); 349bbf45ba5SHollis Blanchard 350bbf45ba5SHollis Blanchard local_irq_disable(); 351bbf45ba5SHollis Blanchard kvm_guest_enter(); 352bbf45ba5SHollis Blanchard r = __kvmppc_vcpu_run(run, vcpu); 353bbf45ba5SHollis Blanchard kvm_guest_exit(); 354bbf45ba5SHollis Blanchard local_irq_enable(); 355bbf45ba5SHollis Blanchard 356bbf45ba5SHollis Blanchard if (vcpu->sigset_active) 357bbf45ba5SHollis Blanchard sigprocmask(SIG_SETMASK, &sigsaved, NULL); 358bbf45ba5SHollis Blanchard 35945c5eb67SHollis Blanchard vcpu_put(vcpu); 36045c5eb67SHollis Blanchard 361bbf45ba5SHollis Blanchard return r; 362bbf45ba5SHollis Blanchard } 363bbf45ba5SHollis Blanchard 364bbf45ba5SHollis Blanchard int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) 365bbf45ba5SHollis Blanchard { 3669dd921cfSHollis Blanchard kvmppc_core_queue_external(vcpu, irq); 36745c5eb67SHollis Blanchard 36845c5eb67SHollis Blanchard if (waitqueue_active(&vcpu->wq)) { 36945c5eb67SHollis Blanchard wake_up_interruptible(&vcpu->wq); 37045c5eb67SHollis Blanchard vcpu->stat.halt_wakeup++; 37145c5eb67SHollis Blanchard } 37245c5eb67SHollis Blanchard 373bbf45ba5SHollis Blanchard return 0; 374bbf45ba5SHollis Blanchard } 375bbf45ba5SHollis Blanchard 376bbf45ba5SHollis Blanchard int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, 377bbf45ba5SHollis Blanchard struct kvm_mp_state *mp_state) 378bbf45ba5SHollis Blanchard { 379bbf45ba5SHollis Blanchard return -EINVAL; 380bbf45ba5SHollis Blanchard } 381bbf45ba5SHollis Blanchard 382bbf45ba5SHollis Blanchard int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, 383bbf45ba5SHollis Blanchard struct kvm_mp_state *mp_state) 384bbf45ba5SHollis Blanchard { 385bbf45ba5SHollis Blanchard return -EINVAL; 386bbf45ba5SHollis Blanchard } 387bbf45ba5SHollis Blanchard 388bbf45ba5SHollis Blanchard long kvm_arch_vcpu_ioctl(struct file *filp, 389bbf45ba5SHollis Blanchard unsigned int ioctl, unsigned long arg) 390bbf45ba5SHollis Blanchard { 391bbf45ba5SHollis Blanchard struct kvm_vcpu *vcpu = filp->private_data; 392bbf45ba5SHollis Blanchard void __user *argp = (void __user *)arg; 393bbf45ba5SHollis Blanchard long r; 394bbf45ba5SHollis Blanchard 395bbf45ba5SHollis Blanchard switch (ioctl) { 396bbf45ba5SHollis Blanchard case KVM_INTERRUPT: { 397bbf45ba5SHollis Blanchard struct kvm_interrupt irq; 398bbf45ba5SHollis Blanchard r = -EFAULT; 399bbf45ba5SHollis Blanchard if (copy_from_user(&irq, argp, sizeof(irq))) 400bbf45ba5SHollis Blanchard goto out; 401bbf45ba5SHollis Blanchard r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); 402bbf45ba5SHollis Blanchard break; 403bbf45ba5SHollis Blanchard } 404bbf45ba5SHollis Blanchard default: 405bbf45ba5SHollis Blanchard r = -EINVAL; 406bbf45ba5SHollis Blanchard } 407bbf45ba5SHollis Blanchard 408bbf45ba5SHollis Blanchard out: 409bbf45ba5SHollis Blanchard return r; 410bbf45ba5SHollis Blanchard } 411bbf45ba5SHollis Blanchard 412bbf45ba5SHollis Blanchard int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) 413bbf45ba5SHollis Blanchard { 414bbf45ba5SHollis Blanchard return -ENOTSUPP; 415bbf45ba5SHollis Blanchard } 416bbf45ba5SHollis Blanchard 417bbf45ba5SHollis Blanchard long kvm_arch_vm_ioctl(struct file *filp, 418bbf45ba5SHollis Blanchard unsigned int ioctl, unsigned long arg) 419bbf45ba5SHollis Blanchard { 420bbf45ba5SHollis Blanchard long r; 421bbf45ba5SHollis Blanchard 422bbf45ba5SHollis Blanchard switch (ioctl) { 423bbf45ba5SHollis Blanchard default: 424bbf45ba5SHollis Blanchard r = -EINVAL; 425bbf45ba5SHollis Blanchard } 426bbf45ba5SHollis Blanchard 427bbf45ba5SHollis Blanchard return r; 428bbf45ba5SHollis Blanchard } 429bbf45ba5SHollis Blanchard 430bbf45ba5SHollis Blanchard int kvm_arch_init(void *opaque) 431bbf45ba5SHollis Blanchard { 432bbf45ba5SHollis Blanchard return 0; 433bbf45ba5SHollis Blanchard } 434bbf45ba5SHollis Blanchard 435bbf45ba5SHollis Blanchard void kvm_arch_exit(void) 436bbf45ba5SHollis Blanchard { 437bbf45ba5SHollis Blanchard } 438