Mahesh J Salgaonkar <mahesh@xxxxxxxxxxxxxxxxxx> writes: > From: Mahesh Salgaonkar <mahesh@xxxxxxxxxxxxxxxxxx> > > This patch introduces a mce hook which is invoked at the time of guest > exit to facilitate the host-side handling of machine check exception > before the exception is passed on to the guest. This hook will be invoked > from host virtual mode from KVM (before exiting the guest with > KVM_EXIT_NMI reason) for machine check exception that occurs in the guest. Hi Mahesh, This patch doesn't meaningfully abstract anything. opal_machine_check_guest() doesn't call opal, or do anything opal specific. It just passes the evt struct back to code in mce.c, which is where the struct came from in the first place. > --- a/arch/powerpc/platforms/powernv/opal.c > +++ b/arch/powerpc/platforms/powernv/opal.c > @@ -479,6 +479,32 @@ int opal_machine_check(struct pt_regs *regs) > return 0; > } > > +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE > +/* > + * opal_machine_check_guest() is a hook which is invoked at the time > + * of guest exit to facilitate the host-side handling of machine check > + * exception before the exception is passed on to the guest. This hook > + * is invoked from host virtual mode from KVM (before exiting the guest > + * with KVM_EXIT_NMI reason) for machine check exception that occurs in > + * the guest. > + * > + * Currently no action is performed in the host other than printing the > + * event information. The machine check exception is passed on to the > + * guest kernel and the guest kernel will attempt for recovery. > + */ > +int opal_machine_check_guest(struct machine_check_event *evt) > +{ > + /* Print things out */ > + if (evt->version != MCE_V1) { > + pr_err("Machine Check Exception, Unknown event version %d !\n", > + evt->version); > + return 0; > + } > + machine_check_print_event_info(evt); > + return 0; > +} > +#endif Called from kvmppc_handle_exit_hv(): + if (ppc_md.machine_check_exception_guest) + ppc_md.machine_check_exception_guest( + &vcpu->arch.mce_evt); break; Just call machine_check_print_event_info() directly from kvmppc_handle_exit_hv(). You'll need to export symbol it, but that's all AFAICS, I don't think it even needs any #ifdefs. If we ever want to do anything different we can change the code then. cheers