Hi Chenggang, Have a doubt about the old code. On 2018/4/12 PM 12:58, chenggang.qin@xxxxxxxxxxxxxxxxx Wrote: > From: Andy Lutomirski <luto@xxxxxxxxxx> > > commit: 9d05041679904b12c12421cbcf9cb5f4860a8d7b upstream > > 32-bit kernels handle nested NMIs in C. Enable the exact same > handling on 64-bit kernels as well. This isn't currently > necessary, but it will become necessary once the asm code starts > allowing limited nesting. > > ...... > -static inline void nmi_nesting_preprocess(struct pt_regs *regs) > +dotraplinkage notrace void > +do_nmi(struct pt_regs *regs, long error_code) > { > + if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) { > + this_cpu_write(nmi_state, NMI_LATCHED); > + return; > + } > + this_cpu_write(nmi_state, NMI_EXECUTING); > + this_cpu_write(nmi_cr2, read_cr2()); > +nmi_restart: > + Here if there are more than 2 NMIs nested, but the nmi_state is always NMI_LATCHED. > > - /* On i386, may loop back to preprocess */ > - nmi_nesting_postprocess(); > + if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) > + write_cr2(this_cpu_read(nmi_cr2)); > + if (this_cpu_dec_return(nmi_state)) > + goto nmi_restart; > } But here at most re-execute 2 NMIs, so some nmi lost ? And cr2 is always the first NMI's cr2. CR2 is wrong for the later NMIs. > void stop_nmi(void) > Thanks & Regards Qixuan Wu.