The patch titled hpet: fix the possibility of insane return value of hpet_calibrate() against SMI has been added to the -mm tree. Its filename is hpet-fix-the-possibility-of-insane-return-value-of-hpet_calibrate-against-smi.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: hpet: fix the possibility of insane return value of hpet_calibrate() against SMI From: Yasunori Goto <y-goto@xxxxxxxxxxxxxx> hpet_calibrate() has a possibility of miss-calibration due to SMI. If SMI interrupts in the while loop of calibration, then return value will be big. This change calibrates until stabilizing by the return value with a small value. Signed-off-by: Yasunori Goto <y-goto@xxxxxxxxxxxxxx> Acked-by: Clemens Ladisch <clemens@xxxxxxxxxx> Acked-by: Vojtech Pavlik <vojtech@xxxxxxx> Cc: Robert Picco <Robert.Picco@xxxxxx> Cc: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/char/hpet.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff -puN drivers/char/hpet.c~hpet-fix-the-possibility-of-insane-return-value-of-hpet_calibrate-against-smi drivers/char/hpet.c --- a/drivers/char/hpet.c~hpet-fix-the-possibility-of-insane-return-value-of-hpet_calibrate-against-smi +++ a/drivers/char/hpet.c @@ -713,7 +713,7 @@ static struct ctl_table_header *sysctl_h */ #define TICK_CALIBRATE (1000UL) -static unsigned long hpet_calibrate(struct hpets *hpetp) +static unsigned long __hpet_calibrate(struct hpets *hpetp) { struct hpet_timer __iomem *timer = NULL; unsigned long t, m, count, i, flags, start; @@ -750,6 +750,25 @@ static unsigned long hpet_calibrate(stru return (m - start) / i; } +static unsigned long hpet_calibrate(struct hpets *hpetp) +{ + unsigned long ret = ~0UL, tmp; + + /* + * Try to calibrate until return value becomes stable small value. + * If SMI interruption occurs in calibration loop, the return value + * will be big. This avoids its impact. + */ + do { + tmp = __hpet_calibrate(hpetp); + if (ret <= tmp) + break; + ret = tmp; + } while (1); + + return ret; +} + int hpet_alloc(struct hpet_data *hdp) { u64 cap, mcfg; _ Patches currently in -mm which might be from y-goto@xxxxxxxxxxxxxx are linux-next.patch hpet-fix-the-possibility-of-insane-return-value-of-hpet_calibrate-against-smi.patch hpet-fix-the-possibility-of-insane-return-value-of-hpet_calibrate-against-smi-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html