subsequently queried for the VM.  This capability is only supported by
 HV KVM, and can only be set before any VCPUs have been created.
 
+7.12 KVM_CAP_PPC_FWNMI
+
+Architectures: ppc
+Parameters: none
+
+With this capability a machine check exception in the guest address
+space will cause KVM to exit the guest with NMI exit reason. This
+enables QEMU to build error log and branch to guest kernel registered
+machine check handling routine. Without this capability KVM will
+branch to guests' 0x200 interrupt vector.
+
 8. Other capabilities.
 ----------------------
 
 
        cpumask_t need_tlb_flush;
        cpumask_t cpu_in_guest;
        u8 radix;
+       u8 fwnmi_enabled;
        pgd_t *pgtable;
        u64 process_table;
        struct dentry *debugfs_dir;
 
        OFFSET(KVM_ENABLED_HCALLS, kvm, arch.enabled_hcalls);
        OFFSET(KVM_VRMA_SLB_V, kvm, arch.vrma_slb_v);
        OFFSET(KVM_RADIX, kvm, arch.radix);
+       OFFSET(KVM_FWNMI, kvm, arch.fwnmi_enabled);
        OFFSET(VCPU_DSISR, kvm_vcpu, arch.shregs.dsisr);
        OFFSET(VCPU_DAR, kvm_vcpu, arch.shregs.dar);
        OFFSET(VCPU_VPA, kvm_vcpu, arch.vpa.pinned_addr);
 
                /* Disable this on POWER9 until code handles new HPTE format */
                r = !!hv_enabled && !cpu_has_feature(CPU_FTR_ARCH_300);
                break;
+#endif
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+       case KVM_CAP_PPC_FWNMI:
+               r = hv_enabled;
+               break;
 #endif
        case KVM_CAP_PPC_HTM:
                r = cpu_has_feature(CPU_FTR_TM_COMP) &&
                break;
        }
 #endif /* CONFIG_KVM_XICS */
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+       case KVM_CAP_PPC_FWNMI:
+               r = -EINVAL;
+               if (!is_kvmppc_hv_enabled(vcpu->kvm))
+                       break;
+               r = 0;
+               vcpu->kvm->arch.fwnmi_enabled = true;
+               break;
+#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
        default:
                r = -EINVAL;
                break;
 
 #define KVM_CAP_SPAPR_TCE_VFIO 142
 #define KVM_CAP_X86_GUEST_MWAIT 143
 #define KVM_CAP_ARM_USER_IRQ 144
+#define KVM_CAP_PPC_FWNMI 145
 
 #ifdef KVM_CAP_IRQ_ROUTING