Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp56227lfv; Tue, 12 Apr 2022 17:06:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjJme2+cfPgHcap3S82kx2VBNLO3enz5TEhlQlWGBIyR5eFgcl4Z8qIIeHwONESpXNu/vl X-Received: by 2002:a17:90a:ee81:b0:1cb:ade8:6c61 with SMTP id i1-20020a17090aee8100b001cbade86c61mr7736703pjz.167.1649808406024; Tue, 12 Apr 2022 17:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649808406; cv=none; d=google.com; s=arc-20160816; b=LsiPOgNs22BaszbFLfDMe7lIca3OjPhbhKnatQAUF+tcsHxbnjHc72ZDL93TJd2B5K +2jelKoXbOOqPtVE01Qfp9+18ijR+CZiITlT9u4lJKZhcMxGINENMr1kIo7MMLDnSpkf HCymrtiCnePETAdHtuYBXwMTW728hs98JqN4q/gbFHrJCibt81fFXGTXgk1bIlyQOg66 sVxdvjr2t/QEtx6w4WB7eIRW9oOFOuO8yCEuk8KU8thBffeNGxLbU4y+id+PL14pute6 U9Qa8DMPUvoshJWcydHP/6f2lpEE1M3SDDT2C6Ni3jCSEUPCYKXmU8YF4y51ucsliPdb P9YQ== 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=9PaeO1yoTw7dvGZZ0PRc0hGx0cBmvj6WVa7+40BVJ4E=; b=FKGg5m5KRBreE0qiqlbO5R58eSpD6vVGtrbstffwP5PAnDJ39f93wHJ4Au3Z6NhlPa P4UpRAQN24YVV9l+E12qhX4yzp98GVbwDd/nRldtckroeyra7KBL6aZdoyi2WKm6WeZ6 5deDxvaf1J5SgcTjKj9tC0kcwSK8jqFehSnOPa7rkcE5+FgDWefqYykDWDmCSRZ0wrij MQzhCBG2yngZBZaJxfNuaO3/wgRdHOUjXdJDHPCIEtHLpT2KtqsArWveEQ6DMX8m2UA1 C2p3Xx6a/tBM5DRpbEvvGSo4jp9My0NDHU/NNeUsteer8qdhA2zXTPXQmVJJU/2R7Ivt qzdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XlUVorIw; dkim=neutral (no key) header.i=@linutronix.de header.b=5rToMQK6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v7-20020a056a00148700b00505c06abccasi7347968pfu.255.2022.04.12.17.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 17:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XlUVorIw; dkim=neutral (no key) header.i=@linutronix.de header.b=5rToMQK6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7444015E8B1; Tue, 12 Apr 2022 15:03:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbiDLU6M (ORCPT + 99 others); Tue, 12 Apr 2022 16:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231665AbiDLU5i (ORCPT ); Tue, 12 Apr 2022 16:57:38 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9252414FFE9 for ; Tue, 12 Apr 2022 13:53:39 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649795661; 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=9PaeO1yoTw7dvGZZ0PRc0hGx0cBmvj6WVa7+40BVJ4E=; b=XlUVorIwjmIFMIc+DkdX5cA6QBXTWo/HOZTZegAyPCsN4FoHEzNXFRgqyzFz4nmuuhAveg jBdiBiTvHh4SNEySyFonWBCS20QMIgOaFr9SSleFaguouFXjTzSuU2Kh2GGKF2pmX2AG1o HqgQrb8JuPW2/JHcEV2il0q7ZalIY4YFBT35ROA/hl6ZGJxJSbMd3OJ7MITqH4R56HiwA3 MeOp/2K1Ak8OmAPlH9k1Ne9eqCKcNwj2VqbN12SqvSMc8v3h2cQnuz2W1voxL6V4IfYy+j Hd+82VUzQb3sRakCTT/55y6FCCLmQZL5DnmmVyO1f6pVuimwKx++38efDe11mw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649795661; 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=9PaeO1yoTw7dvGZZ0PRc0hGx0cBmvj6WVa7+40BVJ4E=; b=5rToMQK6B0RWVR9lVSmCh/M6NtlPCg382vXe6QDeihkgUjU1hmslw5DRZ3yrFPNS36L/+h og2C/vIlWKT6UDBQ== To: Daniel Vacek Cc: "H. Peter Anvin" , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, open list Subject: [PATCH] x86/apic: Clarify i82489DX bit overlap in APIC_LVT0 In-Reply-To: References: <20220202140244.1681140-1-neelx@redhat.com> <874k361liu.ffs@tglx> Date: Tue, 12 Apr 2022 22:34:21 +0200 Message-ID: <87ee22f3ci.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel stumbled over the undocumented bit overlap of the i82498DX external APIC and the TSC deadline timer configuration bit in modern APICs. Remove the i82489DX macro maze, use a i82489DX specific define in the apic code and document the overlap in a comment. Reported-by: Daniel Vacek Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apicdef.h | 6 ------ arch/x86/kernel/apic/apic.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) --- a/arch/x86/include/asm/apicdef.h +++ b/arch/x86/include/asm/apicdef.h @@ -95,12 +95,6 @@ #define APIC_LVTTHMR 0x330 #define APIC_LVTPC 0x340 #define APIC_LVT0 0x350 -#define APIC_LVT_TIMER_BASE_MASK (0x3 << 18) -#define GET_APIC_TIMER_BASE(x) (((x) >> 18) & 0x3) -#define SET_APIC_TIMER_BASE(x) (((x) << 18)) -#define APIC_TIMER_BASE_CLKIN 0x0 -#define APIC_TIMER_BASE_TMBASE 0x1 -#define APIC_TIMER_BASE_DIV 0x2 #define APIC_LVT_TIMER_ONESHOT (0 << 17) #define APIC_LVT_TIMER_PERIODIC (1 << 17) #define APIC_LVT_TIMER_TSCDEADLINE (2 << 17) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -320,6 +320,9 @@ int lapic_get_maxlvt(void) #define APIC_DIVISOR 16 #define TSC_DIVISOR 8 +/* i82489DX specific */ +#define I82489DX_BASE_DIVIDER (((0x2) << 18)) + /* * This function sets up the local APIC timer, with a timeout of * 'clocks' APIC bus clock. During calibration we actually call @@ -340,8 +343,14 @@ static void __setup_APIC_LVTT(unsigned i else if (boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER)) lvtt_value |= APIC_LVT_TIMER_TSCDEADLINE; + /* + * The i82489DX APIC uses bit 18 and 19 for the base divider. This + * overlaps with bit 18 on integrated APICs, but is not documented + * in the SDM. No problem though. i82489DX equipped systems do not + * have TSC deadline timer. + */ if (!lapic_is_integrated()) - lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV); + lvtt_value |= I82489DX_BASE_DIVIDER; if (!irqen) lvtt_value |= APIC_LVT_MASKED;