Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5077774pxu; Thu, 10 Dec 2020 12:20:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQLvipoy77J1E4HR65hV6DAUFubYzXK0gC6Bp/vHkQH40CYeYR256YYakSWA98xYWrxtrk X-Received: by 2002:a17:906:145b:: with SMTP id q27mr8222944ejc.86.1607631616372; Thu, 10 Dec 2020 12:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607631615; cv=none; d=google.com; s=arc-20160816; b=HFpuW44XO9QjDhpc9N/7GuzeAIpa9ro1S3aPcVbLhz3AUdGToRSlNqEdvddfFMjuc+ gBOPCPCQ/In9Znp1Mmb2IShtkeTcyEu/1RMZ2FfSBI9fTrJaczOLKf0ioaMu5Nt/fqri Y0KH3AFB213/pPCVQnzK2HWkqobB5jyqphEaagBP4yC4ILSrh22z870aw/lnH/G2ku5w f8YAA7hDCQi7gCXnScxlepsNwtXjhZZMNzQ30rg+1SiYh0z76aiB2JqeJWQKHdGPo0BB 5gSkxg97+dA4AWwRPiMgNzWikGZ6jnd9RynM7e6Sza+EdlucFF41BKgWx07lkOFvMmL3 lLiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=5fN5ChdPk6fH90ggZf7w1lWtyXdKRHqfW7WHc/pgsVs=; b=bjB6hHPP0hXd67W1oYUWu/AIHzfhQAX+8Mwcp4zL+inplfFTOgwQCTQV0S1epmwDcR 6aa9jUWjZfZ4I0RxdDhInwUtFO02r4y3VzQFLZ64TQe2Fys64x+N6IazyhK3QSGGR+LH DlI9hj1deML/6fI/9KS3Gz1aSn/CBidN+wCL8Jr3paIIq3GqAy4WN5PJ6FJrQ3MDtYb5 cfZyakP8K/sdYFosY8WOfA37ANbt3CPitmAU5ZEWYqHSt+/3M5q6X2Bo9L9qxgTCqAzA d3wxvdrbQfuxvdl/B5rQdx+B3gy3/0UVp9RpL6bZns537jKkkwSdumudJmCLEOBDDNHS JhXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ckiewzsM; dkim=neutral (no key) header.i=@linutronix.de header.b=7Sv15HRz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si4049904edu.567.2020.12.10.12.19.52; Thu, 10 Dec 2020 12:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ckiewzsM; dkim=neutral (no key) header.i=@linutronix.de header.b=7Sv15HRz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393550AbgLJUQX (ORCPT + 99 others); Thu, 10 Dec 2020 15:16:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393785AbgLJUPs (ORCPT ); Thu, 10 Dec 2020 15:15:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23647C0613CF for ; Thu, 10 Dec 2020 12:15:07 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607631305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5fN5ChdPk6fH90ggZf7w1lWtyXdKRHqfW7WHc/pgsVs=; b=ckiewzsMmQUlBqMXgP4UCM+Np8mVHkkyuYZ55dFWcuWlHfyz/tgDeQPN8gOJwL71KCuDFp bTEV0UcVcW+THBv5y7dJyw0M+kQ1Riyvqn9OxQr3zwaLOv+uShsKUCjirolVbrlSa85oom iI6uU+J4mWFPa2hGzIZEAOuKh5iN+4FzvPkGUwZRJzd2A30gZdT6pTvBYw/wj4wJvz45Q9 4xL68/ICbZjy5ErILON+zndUZYGmqVaFb9ADzRqHWrpdGoR4T6W0smF9rTYGSgd1QHwNu0 XdkbiN6hBQ7XZ7qyI/o8e/Rwir0XY//nkekRFelqXb/XKTsF4qfFyF4RODMkvA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607631305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5fN5ChdPk6fH90ggZf7w1lWtyXdKRHqfW7WHc/pgsVs=; b=7Sv15HRz9k3S0goiNVwWDAqqbLafPJHvp7i7jT+K4bNnOThCzVhK/tC1gQGefAlx4Qus9O sPKSDB0EOeG3wDBg== To: Mark Rutland Cc: Peter Zijlstra , Juergen Gross , xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, luto@kernel.org, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Deep Shah , "VMware\, Inc." , Boris Ostrovsky , Stefano Stabellini Subject: x86/ioapic: Cleanup the timer_works() irqflags mess In-Reply-To: <20201210111008.GB88655@C02TD0UTHF1T.local> References: <20201120114630.13552-1-jgross@suse.com> <20201120114630.13552-6-jgross@suse.com> <20201120115943.GD3021@hirez.programming.kicks-ass.net> <20201209181514.GA14235@C02TD0UTHF1T.local> <87tusuzu71.fsf@nanos.tec.linutronix.de> <20201210111008.GB88655@C02TD0UTHF1T.local> Date: Thu, 10 Dec 2020 21:15:04 +0100 Message-ID: <87k0tpju47.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mark tripped over the creative irqflags handling in the IO-APIC timer delivery check which ends up doing: local_irq_save(flags); local_irq_enable(); local_irq_restore(flags); which triggered a new consistency check he's working on required for replacing the POPF based restore with a conditional STI. That code is a historical mess and none of this is needed. Make it straightforward use local_irq_disable()/enable() as that's all what is required. It is invoked from interrupt enabled code nowadays. Reported-by: Mark Rutland Signed-off-by: Thomas Gleixner Tested-by: Mark Rutland --- arch/x86/kernel/apic/io_apic.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1618,21 +1618,16 @@ static void __init delay_without_tsc(voi static int __init timer_irq_works(void) { unsigned long t1 = jiffies; - unsigned long flags; if (no_timer_check) return 1; - local_save_flags(flags); local_irq_enable(); - if (boot_cpu_has(X86_FEATURE_TSC)) delay_with_tsc(); else delay_without_tsc(); - local_irq_restore(flags); - /* * Expect a few ticks at least, to be sure some possible * glue logic does not lock up after one or two first @@ -1641,10 +1636,10 @@ static int __init timer_irq_works(void) * least one tick may be lost due to delays. */ - /* jiffies wrap? */ - if (time_after(jiffies, t1 + 4)) - return 1; - return 0; + local_irq_disable(); + + /* Did jiffies advance? */ + return time_after(jiffies, t1 + 4); } /* @@ -2117,13 +2112,12 @@ static inline void __init check_timer(vo struct irq_cfg *cfg = irqd_cfg(irq_data); int node = cpu_to_node(0); int apic1, pin1, apic2, pin2; - unsigned long flags; int no_pin1 = 0; if (!global_clock_event) return; - local_irq_save(flags); + local_irq_disable(); /* * get/set the timer IRQ vector: @@ -2191,7 +2185,6 @@ static inline void __init check_timer(vo goto out; } panic_if_irq_remap("timer doesn't work through Interrupt-remapped IO-APIC"); - local_irq_disable(); clear_IO_APIC_pin(apic1, pin1); if (!no_pin1) apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " @@ -2215,7 +2208,6 @@ static inline void __init check_timer(vo /* * Cleanup, just in case ... */ - local_irq_disable(); legacy_pic->mask(0); clear_IO_APIC_pin(apic2, pin2); apic_printk(APIC_QUIET, KERN_INFO "....... failed.\n"); @@ -2232,7 +2224,6 @@ static inline void __init check_timer(vo apic_printk(APIC_QUIET, KERN_INFO "..... works.\n"); goto out; } - local_irq_disable(); legacy_pic->mask(0); apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector); apic_printk(APIC_QUIET, KERN_INFO "..... failed.\n"); @@ -2251,7 +2242,6 @@ static inline void __init check_timer(vo apic_printk(APIC_QUIET, KERN_INFO "..... works.\n"); goto out; } - local_irq_disable(); apic_printk(APIC_QUIET, KERN_INFO "..... failed :(.\n"); if (apic_is_x2apic_enabled()) apic_printk(APIC_QUIET, KERN_INFO @@ -2260,7 +2250,7 @@ static inline void __init check_timer(vo panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a " "report. Then try booting with the 'noapic' option.\n"); out: - local_irq_restore(flags); + local_irq_enable(); } /*