From patchwork Sat Apr 4 10:26:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11474159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8093B912 for ; Sat, 4 Apr 2020 10:27:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50490206CC for ; Sat, 4 Apr 2020 10:27:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="YlH0HS7i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50490206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg15-00008D-QQ; Sat, 04 Apr 2020 10:27:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg13-00007y-V8 for xen-devel@lists.xenproject.org; Sat, 04 Apr 2020 10:27:05 +0000 X-Inumbo-ID: d21e80dc-765e-11ea-be07-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d21e80dc-765e-11ea-be07-12813bfff9fa; Sat, 04 Apr 2020 10:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=O8qi6CyUcG6jB4s0EzoV2dMvYHGdJrUt2FlFqXtPOl8=; b=YlH0HS7iY7bQCuXO+2W9jQewuq 9DBzxuGAVlalJMPEKMMvBaMGojlJDJXFcseVSdRSadg7AjhSDt6P+gUKexJ4kGxx62OyBkYpmOrDg BSQ1IC0EkeiC7dbc+SQetgs/mzoi0hVZL5zY/Jx9n5YBFtmYpjr3obwlrRTeIULJ5gs8=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg0y-0005A3-Or; Sat, 04 Apr 2020 10:27:00 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jKg0y-0005h7-FD; Sat, 04 Apr 2020 10:27:00 +0000 From: Julien Grall To: xen-devel@lists.xenproject.org Subject: [PATCH v2 1/3] xen/x86: ioapic: Use true/false in bad_ioapic_register() Date: Sat, 4 Apr 2020 11:26:54 +0100 Message-Id: <20200404102656.29730-2-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200404102656.29730-1-julien@xen.org> References: <20200404102656.29730-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall bad_ioapic_register() is returning a bool, so we should switch to true/false. Signed-off-by: Julien Grall Reviewed-by: Wei Liu Acked-by: Jan Beulich --- Changes in v2: - Add Wei's reviewed-by - Fix typo - Add Jan's acked-by --- xen/arch/x86/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index e98e08e9c8..9868933287 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -2531,10 +2531,10 @@ static __init bool bad_ioapic_register(unsigned int idx) { printk(KERN_WARNING "I/O APIC %#x registers return all ones, skipping!\n", mp_ioapics[idx].mpc_apicaddr); - return 1; + return true; } - return 0; + return false; } void __init init_ioapic_mappings(void) From patchwork Sat Apr 4 10:26:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11474183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC6E6912 for ; Sat, 4 Apr 2020 10:29:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A731C206CC for ; Sat, 4 Apr 2020 10:29:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="lYSb1LSD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A731C206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg13-00007m-Hy; Sat, 04 Apr 2020 10:27:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg12-00007c-35 for xen-devel@lists.xenproject.org; Sat, 04 Apr 2020 10:27:04 +0000 X-Inumbo-ID: d34b573c-765e-11ea-83d8-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d34b573c-765e-11ea-83d8-bc764e2007e4; Sat, 04 Apr 2020 10:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tfFVWRUSZu9j4nuBTdDQtZgNGvWVZ0KeLmsF37oncn4=; b=lYSb1LSDsK4LQLRmC/221C9uaQ cpIoJrN20CpRgoVrxhB1I0hcGplKKYi862PDbJ03iBd8wBb0oxv7+5V4dXKhW3bwQeJbN+1FdQfPQ 15qKvMlcn/wYP834CWsFI5XkyoJdzW0gKv71V5xzdiHUxQVXGBilRtAbemEoDtSosrgQ=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg10-0005AO-2Z; Sat, 04 Apr 2020 10:27:02 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jKg0z-0005h7-Os; Sat, 04 Apr 2020 10:27:02 +0000 From: Julien Grall To: xen-devel@lists.xenproject.org Subject: [PATCH v2 2/3] xen/x86: ioapic: Rename init_ioapic_mappings() to ioapic_init() Date: Sat, 4 Apr 2020 11:26:55 +0100 Message-Id: <20200404102656.29730-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200404102656.29730-1-julien@xen.org> References: <20200404102656.29730-1-julien@xen.org> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall The function init_ioapic_mappings() is doing more than initialization mappings. It is also initialization the number of IRQs/GSIs supported. So rename the function to ioapic_init(). Signed-off-by: Julien Grall Reviewed-by: Roger Pau Monné Acked-by: Jan Beulich --- Changes in v2: - Rename to ioapic_init() rather than init_ioapic(). - Add Roger's reviewed-by - Add Jan's acked-by --- xen/arch/x86/apic.c | 2 +- xen/arch/x86/io_apic.c | 2 +- xen/include/asm-x86/io_apic.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index cde67cd87e..71f4efb2fe 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -978,7 +978,7 @@ __next: boot_cpu_physical_apicid = get_apic_id(); x86_cpu_to_apicid[0] = get_apic_id(); - init_ioapic_mappings(); + ioapic_init(); } /***************************************************************************** diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 9868933287..8233eb44e1 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -2537,7 +2537,7 @@ static __init bool bad_ioapic_register(unsigned int idx) return false; } -void __init init_ioapic_mappings(void) +void __init ioapic_init(void) { unsigned long ioapic_phys; unsigned int i, idx = FIX_IO_APIC_BASE_0; diff --git a/xen/include/asm-x86/io_apic.h b/xen/include/asm-x86/io_apic.h index 998905186b..e006b2b8dd 100644 --- a/xen/include/asm-x86/io_apic.h +++ b/xen/include/asm-x86/io_apic.h @@ -180,7 +180,7 @@ extern int io_apic_get_version (int ioapic); extern int io_apic_get_redir_entries (int ioapic); extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low); -extern void init_ioapic_mappings(void); +extern void ioapic_init(void); extern void ioapic_suspend(void); extern void ioapic_resume(void); From patchwork Sat Apr 4 10:26:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11474179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B128F14B4 for ; Sat, 4 Apr 2020 10:28:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D94120719 for ; Sat, 4 Apr 2020 10:28:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="TuJHMQQh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D94120719 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg1A-00009w-77; Sat, 04 Apr 2020 10:27:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg18-00009X-VH for xen-devel@lists.xenproject.org; Sat, 04 Apr 2020 10:27:10 +0000 X-Inumbo-ID: d3dd9e94-765e-11ea-be07-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d3dd9e94-765e-11ea-be07-12813bfff9fa; Sat, 04 Apr 2020 10:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DJghX+ClWFBEitlSEELmqx/5BPYM3zMSGVJh1wbvZ88=; b=TuJHMQQh4eitbo26HRtC5Q6B8O csvGa7LKROzysYT28ACKFjztwxcx1O6sAjCpbKA25n0JRkMn06iMIJDR6Yx42szv24YAtm6+VWGby tAfZ0aYaYqX5g6+30z6pLqa6a8d2KIwDqIO1Zxt7vnQOv8PP0RA3cDaFgiQhHQo1Xca0=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jKg11-0005AU-B2; Sat, 04 Apr 2020 10:27:03 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jKg11-0005h7-28; Sat, 04 Apr 2020 10:27:03 +0000 From: Julien Grall To: xen-devel@lists.xenproject.org Subject: [PATCH v2 3/3] xen/x86: ioapic: Simplify ioapic_init() Date: Sat, 4 Apr 2020 11:26:56 +0100 Message-Id: <20200404102656.29730-4-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200404102656.29730-1-julien@xen.org> References: <20200404102656.29730-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall Since commit 9facd54a45 "x86/ioapic: Add register level checks to detect bogus io-apic entries", Xen is able to cope with IO APICs not mapped in the fixmap. Therefore the whole logic to allocate a fake page for some IO APICs is unnecessary. With the logic removed, the code can be simplified a lot as we don't need to go through all the IO APIC if SMP has not been detected or a bogus zero IO-APIC address has been detected. To avoid another level of tabulation, the simplification is now moved in its own function. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich --- Changes in v2: - Don't set ioapic_phys twice in a row - Rename init_ioapic_mappings() to ioapic_init_mappings() - Use paddr_t rather than unsigned long - Move nr_irq_gsis = 0 in ioapic_init_mappings() --- xen/arch/x86/io_apic.c | 61 +++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 8233eb44e1..878ee5192d 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -2537,34 +2537,26 @@ static __init bool bad_ioapic_register(unsigned int idx) return false; } -void __init ioapic_init(void) +static void __init ioapic_init_mappings(void) { - unsigned long ioapic_phys; unsigned int i, idx = FIX_IO_APIC_BASE_0; - union IO_APIC_reg_01 reg_01; - if ( smp_found_config ) - nr_irqs_gsi = 0; + nr_irqs_gsi = 0; + for ( i = 0; i < nr_ioapics; i++ ) { - if ( smp_found_config ) - { - ioapic_phys = mp_ioapics[i].mpc_apicaddr; - if ( !ioapic_phys ) - { - printk(KERN_ERR "WARNING: bogus zero IO-APIC address " - "found in MPTABLE, disabling IO/APIC support!\n"); - smp_found_config = false; - skip_ioapic_setup = true; - goto fake_ioapic_page; - } - } - else + union IO_APIC_reg_01 reg_01; + paddr_t ioapic_phys = mp_ioapics[i].mpc_apicaddr; + + if ( !ioapic_phys ) { - fake_ioapic_page: - ioapic_phys = __pa(alloc_xenheap_page()); - clear_page(__va(ioapic_phys)); + printk(KERN_ERR + "WARNING: bogus zero IO-APIC address found in MPTABLE, disabling IO/APIC support!\n"); + smp_found_config = false; + skip_ioapic_setup = true; + break; } + set_fixmap_nocache(idx, ioapic_phys); apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08Lx (%08lx)\n", __fix_to_virt(idx), ioapic_phys); @@ -2576,19 +2568,22 @@ void __init ioapic_init(void) continue; } - if ( smp_found_config ) - { - /* The number of IO-APIC IRQ registers (== #pins): */ - reg_01.raw = io_apic_read(i, 1); - nr_ioapic_entries[i] = reg_01.bits.entries + 1; - nr_irqs_gsi += nr_ioapic_entries[i]; - - if ( rangeset_add_singleton(mmio_ro_ranges, - ioapic_phys >> PAGE_SHIFT) ) - printk(KERN_ERR "Failed to mark IO-APIC page %lx read-only\n", - ioapic_phys); - } + /* The number of IO-APIC IRQ registers (== #pins): */ + reg_01.raw = io_apic_read(i, 1); + nr_ioapic_entries[i] = reg_01.bits.entries + 1; + nr_irqs_gsi += nr_ioapic_entries[i]; + + if ( rangeset_add_singleton(mmio_ro_ranges, + ioapic_phys >> PAGE_SHIFT) ) + printk(KERN_ERR "Failed to mark IO-APIC page %lx read-only\n", + ioapic_phys); } +} + +void __init ioapic_init(void) +{ + if ( smp_found_config ) + ioapic_init_mappings(); nr_irqs_gsi = max(nr_irqs_gsi, highest_gsi() + 1);