Skip to content

Commit 5ae09fc

Browse files
leoliu-ocWangYuli
authored andcommitted
x86/hpet: Read HPET directly if panic in progress
zhaoxin inclusion category: other ------------------- When the clocksource of the system is HPET,a CPU executing read_hpet might be interrupted by #GP/#PF to executing the panic,this may lead to read_hpet dead loops: CPU x CPU x ---- ---- read_hpet() arch_spin_trylock(&hpet.lock) [CPU x got the hpet.lock] #GP/#PF happened panic() kmsg_dump() pstore_dump() pstore_record_init() ktime_get_real_fast_ns() read_hpet() [dead loops] To avoid this dead loops, read HPET directly if panic in progress. Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
1 parent 6d4eb57 commit 5ae09fc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/x86/kernel/hpet.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,12 @@ static u64 read_hpet(struct clocksource *cs)
804804
if (in_nmi())
805805
return (u64)hpet_readl(HPET_COUNTER);
806806

807+
/*
808+
* Read HPET directly if panic in progress.
809+
*/
810+
if (unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID))
811+
return (u64)hpet_readl(HPET_COUNTER);
812+
807813
/*
808814
* Read the current state of the lock and HPET value atomically.
809815
*/

0 commit comments

Comments
 (0)