Received: by 10.213.65.68 with SMTP id h4csp2215092imn; Sun, 8 Apr 2018 22:43:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx49olta7u6OUpkjVoiJ3s6rp7Ok+P7dcSKYTcxEcLtgWj3Li1koooYoWhiTnxp1P1nk8ocmZ X-Received: by 10.99.6.198 with SMTP id 189mr24644174pgg.131.1523252610921; Sun, 08 Apr 2018 22:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523252610; cv=none; d=google.com; s=arc-20160816; b=hGaD8ZNnoZbG8XgVli6jFSkTBs73LeEchRmc+IKtvD6T1MtbRNFIpWXtA5RYL0qRcK bP1FLWlvDiLhqwJrJ1m3z85gaZV4aSccauJw9xv66VEQM0XWfgY1c7NLlqfobpk/QuQ+ Qk5r1c0DXOfoQ5m2Xqy+x0Rbzplc0ORT1KCef+P8Ef3ujekALm1KvNP/eB6HK6ji9zjU nYzDz4tLu8CgOMjSaFAMibV3COTOkdkX25+usoAG+eB6YXkEFLTIhd7AqUZoDXkJfDBo 2oBHabTLuTxYaYFm1reKlweUT04Nz+wzWZhQSREVeDtxaXo2Fw2fWrbqowZXcMijJCV5 A+6w== 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:to:subject:arc-authentication-results; bh=TGUnuijWxUn5pbQFGEBgnriD1GNW4Bw0q+QrC0wrPt8=; b=rKNrU8zVcIu4B7D9Wjtk1F9809OJhJrYS4KGOxRT6G/ZHT756+QgQgxW+6AUC46hfj uliHZujNJKpKdQ35/xiubr0GTGLt4J0YxkgZ4ZntQOM2gdwnsukjCwQxTxTZbLiNbMRN z30nkZiD3/SU8Ev3L8/zypN7GydWpl95aN313GQMtKp9s/czYxSgX30mdiLqjrDpKExL nhyYprdEhClHwQ3Wv1m/G+L13TwU28JUcxdT+6WE/Y3IFDReJXFlCJ2gJxbnWpxzHFly czjc9RJH0Aa3XIGxzScEAOTODS0QLCZLy8ygCiXFDl1O5/GfdjoKn2hFexH1szVUo1TO cXIg== 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 i1-v6si13000483plt.5.2018.04.08.22.42.53; Sun, 08 Apr 2018 22:43:30 -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 S1751751AbeDIFhz (ORCPT + 99 others); Mon, 9 Apr 2018 01:37:55 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:43452 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750895AbeDIFhy (ORCPT ); Mon, 9 Apr 2018 01:37:54 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="38702747" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Apr 2018 13:37:51 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 1652F4D0EFE7; Mon, 9 Apr 2018 13:37:43 +0800 (CST) Received: from localhost.localdomain (10.167.226.106) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 9 Apr 2018 13:37:44 +0800 Subject: Re: [RFC PATCH] x86/acpi: Prevent x2apic id -1 from being accounted To: Li RongQing , , , , , , , References: <1523187531-29837-1-git-send-email-lirongqing@baidu.com> From: Dou Liyang Message-ID: Date: Mon, 9 Apr 2018 13:37:41 +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: <1523187531-29837-1-git-send-email-lirongqing@baidu.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 1652F4D0EFE7.AE2AD 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 RongQing, Is there an local x2apic whose ID is 0xFFFFFFFF in your machine? At 04/08/2018 07:38 PM, Li RongQing wrote: > local_apic_id of acpi_madt_local_x2apic is u32, it is converted to > int when checked by default_apic_id_valid() and return true if it is > larger than 0x7fffffff, this is wrong > For x2apic enabled systems, - the byte length of X2APIC ID is 4, and it can be larger than 0x7fffffff in theory - the ->apic_id_valid points to x2apic_apic_id_valid(), which always return _ture_ , not default_apic_id_valid(). Thanks, dou > and if local_apic_id is invalid, we should prevent it from being > accounted > > This fixes a bug that Purley platform displays too many possible cpu > > Signed-off-by: Li RongQing > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: Dou Liyang > --- > arch/x86/include/asm/apic.h | 4 ++-- > arch/x86/kernel/acpi/boot.c | 10 ++++++---- > arch/x86/kernel/apic/apic_common.c | 2 +- > arch/x86/kernel/apic/apic_numachip.c | 2 +- > arch/x86/kernel/apic/x2apic.h | 2 +- > arch/x86/kernel/apic/x2apic_phys.c | 2 +- > arch/x86/kernel/apic/x2apic_uv_x.c | 2 +- > arch/x86/xen/apic.c | 2 +- > 8 files changed, 14 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h > index 40a3d3642f3a..08acd954f00e 100644 > --- a/arch/x86/include/asm/apic.h > +++ b/arch/x86/include/asm/apic.h > @@ -313,7 +313,7 @@ struct apic { > /* Probe, setup and smpboot functions */ > int (*probe)(void); > int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); > - int (*apic_id_valid)(int apicid); > + int (*apic_id_valid)(u32 apicid); > int (*apic_id_registered)(void); > > bool (*check_apicid_used)(physid_mask_t *map, int apicid); > @@ -486,7 +486,7 @@ static inline unsigned int read_apic_id(void) > return apic->get_apic_id(reg); > } > > -extern int default_apic_id_valid(int apicid); > +extern int default_apic_id_valid(u32 apicid); > extern int default_acpi_madt_oem_check(char *, char *); > extern void default_setup_apic_routing(void); > > diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c > index 7a37d9357bc4..7412564dc2a7 100644 > --- a/arch/x86/kernel/acpi/boot.c > +++ b/arch/x86/kernel/acpi/boot.c > @@ -200,7 +200,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) > { > struct acpi_madt_local_x2apic *processor = NULL; > #ifdef CONFIG_X86_X2APIC > - int apic_id; > + u32 apic_id; > u8 enabled; > #endif > > @@ -222,10 +222,12 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) > * to not preallocating memory for all NR_CPUS > * when we use CPU hotplug. > */ > - if (!apic->apic_id_valid(apic_id) && enabled) > + if (!apic->apic_id_valid(apic_id)) { > printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); > - else > - acpi_register_lapic(apic_id, processor->uid, enabled); > + return 0; > + } > + > + acpi_register_lapic(apic_id, processor->uid, enabled); > #else > printk(KERN_WARNING PREFIX "x2apic entry ignored\n"); > #endif > diff --git a/arch/x86/kernel/apic/apic_common.c b/arch/x86/kernel/apic/apic_common.c > index a360801779ae..02b4839478b1 100644 > --- a/arch/x86/kernel/apic/apic_common.c > +++ b/arch/x86/kernel/apic/apic_common.c > @@ -40,7 +40,7 @@ int default_check_phys_apicid_present(int phys_apicid) > return physid_isset(phys_apicid, phys_cpu_present_map); > } > > -int default_apic_id_valid(int apicid) > +int default_apic_id_valid(u32 apicid) > { > return (apicid < 255); > } > diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c > index 134e04506ab4..78778b54f904 100644 > --- a/arch/x86/kernel/apic/apic_numachip.c > +++ b/arch/x86/kernel/apic/apic_numachip.c > @@ -56,7 +56,7 @@ static u32 numachip2_set_apic_id(unsigned int id) > return id << 24; > } > > -static int numachip_apic_id_valid(int apicid) > +static int numachip_apic_id_valid(u32 apicid) > { > /* Trust what bootloader passes in MADT */ > return 1; > diff --git a/arch/x86/kernel/apic/x2apic.h b/arch/x86/kernel/apic/x2apic.h > index b107de381cb5..a49b3604027f 100644 > --- a/arch/x86/kernel/apic/x2apic.h > +++ b/arch/x86/kernel/apic/x2apic.h > @@ -1,6 +1,6 @@ > /* Common bits for X2APIC cluster/physical modes. */ > > -int x2apic_apic_id_valid(int apicid); > +int x2apic_apic_id_valid(u32 apicid); > int x2apic_apic_id_registered(void); > void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest); > unsigned int x2apic_get_apic_id(unsigned long id); > diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c > index e2829bf40e4a..b5cf9e7b3830 100644 > --- a/arch/x86/kernel/apic/x2apic_phys.c > +++ b/arch/x86/kernel/apic/x2apic_phys.c > @@ -101,7 +101,7 @@ static int x2apic_phys_probe(void) > } > > /* Common x2apic functions, also used by x2apic_cluster */ > -int x2apic_apic_id_valid(int apicid) > +int x2apic_apic_id_valid(u32 apicid) > { > return 1; > } > diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c > index f11910b44638..efaf2d4f9c3c 100644 > --- a/arch/x86/kernel/apic/x2apic_uv_x.c > +++ b/arch/x86/kernel/apic/x2apic_uv_x.c > @@ -557,7 +557,7 @@ static void uv_send_IPI_all(int vector) > uv_send_IPI_mask(cpu_online_mask, vector); > } > > -static int uv_apic_id_valid(int apicid) > +static int uv_apic_id_valid(u32 apicid) > { > return 1; > } > diff --git a/arch/x86/xen/apic.c b/arch/x86/xen/apic.c > index 2163888497d3..5e53bfbe5823 100644 > --- a/arch/x86/xen/apic.c > +++ b/arch/x86/xen/apic.c > @@ -112,7 +112,7 @@ static int xen_madt_oem_check(char *oem_id, char *oem_table_id) > return xen_pv_domain(); > } > > -static int xen_id_always_valid(int apicid) > +static int xen_id_always_valid(u32 apicid) > { > return 1; > } >