Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5594398imm; Sat, 19 May 2018 05:34:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpgx9lvQFoVjsV2xO511wU94HBudDyGgEo5runN0ruikbMWLpuzygzPRJ6V7N29TmolPyYz X-Received: by 2002:a17:902:5709:: with SMTP id k9-v6mr13087703pli.165.1526733240241; Sat, 19 May 2018 05:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526733240; cv=none; d=google.com; s=arc-20160816; b=OznfXr1eG3/lU15HZJJnESSMBBYnresUKxRkr/YcPM9rUbVgiC56a9o3oSY+X1q5Ih So/XydrAE1fGLTHSbGelkZLjSsI7hEs+FPu5WCWWMIuGpfMzt7Iz8Uc+f9L2WwTyyQKZ G0Y1zUeQ7MTw57S3dXW2XeQxoZcHsiZ90Lvj2uPdFI3tnO3Knw5vlOTO59hrtDab/zvz TgQN08ykHB1PmUtCeYBZviSlj4s507bzbrEdjMpaeHx4EiABIbFcb57WZVp7fJOTLAkP ULWsjirZ47mkg9S0vc9sCBQrXcK3DHWB7MmgRZNW4EpY0F7hOLk5PRT/6MOnEgnPfGYY DykQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=Xz5vGJszuxjgO1NhwfWHRcqtw3mEvRSkRtjEJC+NDqA=; b=Kn7HJDxJt1TTZHw+wCBH7xK3bIWVajRLV7sK1TK+NqR4TmVONHukKm/B3rsVwMjYqT 2jfX8bMo/8aYep+UCTNeaDaJVlYPqMH1+rg9lodYl72jbc4wKLACM4lQvhb2JCWC4dJJ ZPT8ldZeFXLx2lqWiETJj7T4MHOZMBf+Kmw3YKJpVYzu5BlrQXm1aB9+v5PC5Gxy2cN3 gw3SR8AlwKJyADJVNKK5sVnh9ipRIgmfl+V8ODUUK0CSA1pYGZXLPxHlafv4vLLqrNsL Fsak4Pju3bovEbzN7AAJ3TyjcJ1JnjDeBVojDWz1IxDVoDbWPznW8gicK0StyDO8RPuf CRxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73-v6si9735074pfh.315.2018.05.19.05.33.44; Sat, 19 May 2018 05:34:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228AbeESMdB (ORCPT + 99 others); Sat, 19 May 2018 08:33:01 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55695 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbeESMc7 (ORCPT ); Sat, 19 May 2018 08:32:59 -0400 Received: from p4fea4eb5.dip0.t-ipconnect.de ([79.234.78.181] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fK12e-0000w4-3n; Sat, 19 May 2018 14:32:56 +0200 Date: Sat, 19 May 2018 14:32:55 +0200 (CEST) From: Thomas Gleixner To: Dou Liyang cc: x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com Subject: Re: [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates() In-Reply-To: <20180426054452.32308-1-douly.fnst@cn.fujitsu.com> Message-ID: References: <20180426054452.32308-1-douly.fnst@cn.fujitsu.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Apr 2018, Dou Liyang wrote: > The vectors between FIRST_SYSTEM_VECTOR and NR_VECTORS are special IRQ > vectors used by the SMP architecture. But, if X86_LOCAL_APIC=n, it will > not be used, and the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS. Correct, but that function has nothing to do with FIRST_SYSTEM_VECTOR. > diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c > index 2c3a1b4294eb..8b4174890706 100644 > --- a/arch/x86/kernel/idt.c > +++ b/arch/x86/kernel/idt.c > @@ -317,15 +317,16 @@ void __init idt_setup_apic_and_irq_gates(void) > set_intr_gate(i, entry); > } > > - for_each_clear_bit_from(i, system_vectors, NR_VECTORS) { > + /* > + * If X86_LOCAL_APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS > + * Just consider the X86_LOCAL_APIC=y case > + */ > #ifdef CONFIG_X86_LOCAL_APIC > + for_each_clear_bit_from(i, system_vectors, NR_VECTORS) { > set_bit(i, system_vectors); > set_intr_gate(i, spurious_interrupt); > -#else > - entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR); > - set_intr_gate(i, entry); > -#endif > } > +#endif That change breaks the LOCAL_APIC=n case in a subtle way. What the function does is to set _ALL_ entries starting from FIRST_EXTERNAL_VECTOR up to NR_VECTORS in the IDT to a known target, except those which are already occupied by a system vector. So for APIC=y this sets them to: spurious vector and for APIC=n it sets it to the corresppnding vector entry. You remove the latter... Thanks, tglx