Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1026990imm; Mon, 21 May 2018 19:45:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpO2X+5shK5JPa+p6lFlaWVVCzlPxR1DPf/+sSKpCmNiZ9nA2PWAAOkEEbW5T/CeRNuK+vI X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr23158518plv.176.1526957131913; Mon, 21 May 2018 19:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526957131; cv=none; d=google.com; s=arc-20160816; b=vjbIXwrQSaq6cktqNK+0Ru8RNKqVbEhcik4I7ezqI4Fh2Op1Zw3smjnawvbWIapwwh s5RGGwYvdMNhE4Lh5fjLSgEFhGaRYQet5Ucwhh294RnFnvcw5NxiEichIskukqxHuTnR +n8YGvaPxWI+tIZaYxMteOulp1dSk7RMfKcEfwlmLs90nQaOkn9JChJ0Q8E0K+hQ0/f1 I/887d5kt4EJQed8Gv/KwrHSQNJUkjzy+1iM7tenbewaN34vh167wCdUcxWQwZf28a1Y GTbJpw3kNjaT9k8NKcr58Pw0q5H4Jwm8xXMTghn/m9wlqj49X6h5Bt3aQMpkjRHO6lDy LeqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Z1X1iLnGQNgGd3A8TzWcmSWS4xrdSDANMOZ4HzfH/lA=; b=eI8rAWfkkmfPZfLgxjjt8o0wpoz7Q8v1z9KFNJkJyDbzzgJgOmuJqRDSbLNa6IA0Ad C6uos/Qsnu+H5WEvfCPxt6Hre5BQuK9daZSwdhz+Ny7WbOjmr2KJv2JzEyuinyGM/0uW Sk2XG4e9paRnDfH7FsU1Qa9xPL7MAD82MCEzXknH7srH676/Lk+To8n/Y7gC+EoTrJBx w2SLC/crIdK5nnI+fnH51rjL2xs23Am96f0tFIKNpLBHYIfm/FWsTksrxh0NPESyomEF R3zL4j46PUxQzdXH/Q5p3e8Jr1RpQmY3C2m6qKSUtfku7fcDZRXHw6CF7sX2EBAj5O+L vojw== 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 j6-v6si15495839pfb.25.2018.05.21.19.45.14; Mon, 21 May 2018 19:45:31 -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 S1752518AbeEVCpG (ORCPT + 99 others); Mon, 21 May 2018 22:45:06 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:3767 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751601AbeEVCpE (ORCPT ); Mon, 21 May 2018 22:45:04 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="40188472" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 May 2018 10:45:02 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 354574B3EF2E; Tue, 22 May 2018 10:45:00 +0800 (CST) Received: from localhost.localdomain (10.167.226.106) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Tue, 22 May 2018 10:44:59 +0800 Subject: Re: [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates() To: Thomas Gleixner CC: , , , References: <20180426054452.32308-1-douly.fnst@cn.fujitsu.com> From: Dou Liyang Message-ID: Date: Tue, 22 May 2018 10:44:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 354574B3EF2E.A927A X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, At 05/19/2018 08:32 PM, Thomas Gleixner wrote: > 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. > Oops, sorry, when I reread, my changelog even made me misunderstand. the patch hided it. void __init idt_setup_apic_and_irq_gates(void) ... for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) ^^^^^^^^^^^^^^^^^^^ ... for_each_clear_bit_from(i, system_vectors, NR_VECTORS) What I want to say is:   In the APIC=n system, the FIRST_SYSTEM_VECTOR is equal to   NR_VECTORS, So all entries has been set by for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR)        ...   the following setup code for APIC=n is redundant. Just setup gates for   APIC=y. If it is OK, I will send v2. Thanks, dou >> 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 > > > >