From patchwork Tue Sep 4 19:21:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 145949 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4051905ljw; Tue, 4 Sep 2018 12:24:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSkL2GM8ppvZYf9uVJaxxL37ZDPaPgePbjCyKdflcfIh+i4LVBRz3XMt4oAYObTlOtsJMW X-Received: by 2002:a37:f50f:: with SMTP id l15-v6mr29251903qkk.251.1536089074742; Tue, 04 Sep 2018 12:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536089074; cv=none; d=google.com; s=arc-20160816; b=TuOrLL0Z+v6Rv4CrcvbS5ZXJekoyNP/S39IUl+sQx1GcSLGxa3K+xFwDbnrZNJbnJ6 dqf5mLSYl3I7AsjuojGaHXI6m2V8UzQFUkLhO+5IplrNIbPw7Kcv/AfDgLjQn2OfK2EA S6oUIcU6S2AYIqXi3I9lZSAw9n6GN9H7mLPuZ7w3rGGLtl8ZvlcJDSG5iXoK9PfIM4rE QOx/V6lzSVMSY69Aq7kLcpKm6hflIwgu6/tS92wICLX6YaskVK64WUqpSYWwCpYdC5EC ZipTw9pdrdDFYpvW/gmXixVzkrqh0AIDq8CPr5r6RNyEM6dWk8hRp/Gle+f0nZgYZQFk rabg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=l6DpgYTUfVRNE3ktWpPBgSGRjB0fggzrtL8MgQoDCEA=; b=JLUZHH9+64KxtLgX52WiK2rU6jN06MmNtgsB/0v6HFnCpmHqdJtyVkakvp3/pdnRgV 8HMIJPuOv7hr1EHO869jzbaciCicmileHTxsahVUW96MWXctf9aLVQXXgJH68l6/i3Os wUY2dXTpPeQMaO4QH5D5z3aZzNww5xNwb62cC23HS5BUDTNSbsjm1SXTDmS++beQxMQb GNSQPpcYw6I2PkBKviA27fb5Yer9kwSFGZrIery6vzfgU4JuPOX//iHWk/Eb4HeWblup 1zfaC+OZggdTNOxv5U5vdb4lv35CnI3BwHYxMT9rKGiKFMLE5+f7stSwydysJMhHELJR DZiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m187-v6si3422914qkb.191.2018.09.04.12.24.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 12:24:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1fxGtp-0005Qj-B3; Tue, 04 Sep 2018 19:22:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fxGtn-0005QR-Pd for xen-devel@lists.xenproject.org; Tue, 04 Sep 2018 19:22:03 +0000 X-Inumbo-ID: ea137df4-b077-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id ea137df4-b077-11e8-a6a9-d7ebe60f679a; Tue, 04 Sep 2018 19:22:51 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B458F1596; Tue, 4 Sep 2018 12:22:01 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 826DC3F575; Tue, 4 Sep 2018 12:22:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Sep 2018 20:21:51 +0100 Message-Id: <20180904192153.17210-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180904192153.17210-1-julien.grall@arm.com> References: <20180904192153.17210-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 1/3] [not-for-unstable] xen/arm: vgic-v3: Delay the initialization of the domain information 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: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, shameerali.kolothum.thodi@huawei.com, Andrew Cooper MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A follow-up patch will require to know the number of vCPUs when initializating the vGICv3 domain structure. However this information is not available at domain creation. This is only known once XEN_DOMCTL_max_vpus is called for that domain. In order to get the max vCPUs around, delay the domain part of the vGIC v3 initialization until the first vCPU of the domain is initialized. Signed-off-by: Julien Grall --- Cc: Andrew Cooper This is nasty but I can't find a better way for Xen 4.11 and older. This is not necessary for unstable as the number of vCPUs is known at domain creation. Andrew, I have CCed you to know whether you have a better idea where to place this call on Xen 4.11 and older. --- xen/arch/arm/vgic-v3.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 4b42739a52..df1bab3a35 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1573,9 +1573,11 @@ static const struct mmio_handler_ops vgic_distr_mmio_handler = { .write = vgic_v3_distr_mmio_write, }; +static int vgic_v3_real_domain_init(struct domain *d); + static int vgic_v3_vcpu_init(struct vcpu *v) { - int i; + int i, rc; paddr_t rdist_base; struct vgic_rdist_region *region; unsigned int last_cpu; @@ -1584,6 +1586,19 @@ static int vgic_v3_vcpu_init(struct vcpu *v) struct domain *d = v->domain; /* + * This is the earliest place where the number of vCPUs is + * known. This is required to initialize correctly the vGIC v3 + * domain structure. We only to do that when vCPU 0 is + * initilialized. + */ + if ( v->vcpu_id == 0 ) + { + rc = vgic_v3_real_domain_init(d); + if ( rc ) + return rc; + } + + /* * Find the region where the re-distributor lives. For this purpose, * we look one region ahead as we have only the first CPU in hand. */ @@ -1641,7 +1656,7 @@ static inline unsigned int vgic_v3_rdist_count(struct domain *d) GUEST_GICV3_RDIST_REGIONS; } -static int vgic_v3_domain_init(struct domain *d) +static int vgic_v3_real_domain_init(struct domain *d) { struct vgic_rdist_region *rdist_regions; int rdist_count, i, ret; @@ -1733,6 +1748,16 @@ static int vgic_v3_domain_init(struct domain *d) return 0; } +static int vgic_v3_domain_init(struct domain *d) +{ + /* + * The domain initialization for vGIC v3 is delayed until the first vCPU + * is created. This because the initialization may require to know the + * number of vCPUs that is not known when creating the domain. + */ + return 0; +} + static void vgic_v3_domain_free(struct domain *d) { vgic_v3_its_free_domain(d); From patchwork Tue Sep 4 19:21:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 145951 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4051976ljw; Tue, 4 Sep 2018 12:24:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZmJkL52nRTIbI1i5Iwaf/I8m0PuemVCK36Fib2+ln+z5chIoDbtAlHqwMZnbI1f75laDX5 X-Received: by 2002:ab0:60ae:: with SMTP id f14-v6mr18461434uam.153.1536089080624; Tue, 04 Sep 2018 12:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536089080; cv=none; d=google.com; s=arc-20160816; b=Dx4TP5T7kctv5uzy3Yk3PSYUbmC8GzqSm1Q1M4HhR8GgRoTym4CloPSwEF9rrYzxCC RYn/sWs3w15wBktUZiVLbtOSjUhCG+5llSeiiDfh5fuXccdGx1NJsBtlZunTCqlAU22Q K9JUlOBtvfvG0hLl0t3MDEYr8S3ImkQKtmYnamm3wrWZA05i7wrti3tD/ghSifwA7ULK 6N2tDIXvjMXQOu0E/CHel+aMayzElKB465UiIcc3Y84CQiR3Zf6vS0xhgN/3LuEvInoO lIVtH4CRyYOCsRCJFXY3hMTg3Po3I3AvTQUDiUJBIDNLeU9Pto8OBFBSPZmMjchpp38s I7og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=X3nev+kZEwz/YlV+F/miqOHY7iNLKGJ/Xe94JIVJIBk=; b=LvWZzggY8zeHC2W9fvdTHx8qC9zizvPAzNHOAzduhyDre6CInu7ADXWrpSe2tzTqPw pZPtgVP9nItsjS6f4VK/qbs3tmcoicG5LR9+ivW+5VwhVOpxJDwIxw2M8StYrTAMa4vA VhJ1mptcJbXS6gT8dfblOVZ/CWgZgvtuqyaHr1v7bSfo80CJzZHE1VS4cak8EjmxHoQr wCbovhZOalonIJytglv9rwhJPfHw7vJthpu7PhxWxyzNQGe3A/lA8Jxy+38ENuxu8iDj Nc7GZ6YBUZiXU9RG6UmF2TA0Mcq+yEJVgkVTW59TnnP3KxiEALNL8KYP7KEYxLuYA8qh PEsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i189-v6si7073688vkc.178.2018.09.04.12.24.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 12:24:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1fxGtp-0005Qs-LS; Tue, 04 Sep 2018 19:22:05 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fxGto-0005QW-2O for xen-devel@lists.xenproject.org; Tue, 04 Sep 2018 19:22:04 +0000 X-Inumbo-ID: 931407a2-b077-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 931407a2-b077-11e8-a8a5-bc764e045a96; Tue, 04 Sep 2018 21:20:25 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CE3B15AD; Tue, 4 Sep 2018 12:22:03 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F24263F575; Tue, 4 Sep 2018 12:22:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Sep 2018 20:21:52 +0100 Message-Id: <20180904192153.17210-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180904192153.17210-1-julien.grall@arm.com> References: <20180904192153.17210-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 2/3] xen/arm: vgic-v3: Don't create empty re-distributor regions 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: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, shameerali.kolothum.thodi@huawei.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, Xen is assuming the hardware domain will have the same number of re-distributor regions as the host. However, as the number of CPUs or the stride (e.g on GICv4) may be different we end up exposing regions which does not contain any re-distributors. When booting, Linux will go through all the re-distributor region to check whether a property (e.g vPLIs) is available accross all the re-distributors. This will result to a data abort on empty regions because there are no underlying re-distributor. So we need to limit the number of regions exposed to the hardware domain. The code reworked to only expose the minimun number of regions required by the hardware domain. It is assumed the regions will be populated starting from the first one. Reported-by: Shameerali Kolothum Thodi Signed-off-by: Julien Grall --- xen/arch/arm/gic-v3.c | 10 ++++++++-- xen/arch/arm/vgic-v3.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index b2ed0f8b55..4a984cfb12 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1274,8 +1274,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, * GIC has two memory regions: Distributor + rdist regions * CPU interface and virtual cpu interfaces accessesed as System registers * So cells are created only for Distributor and rdist regions + * The hardware domain may not used all the regions. So only copy + * what is necessary. */ - new_len = new_len * (gicv3.rdist_count + 1); + new_len = new_len * (d->arch.vgic.nr_regions + 1); hw_reg = dt_get_property(gic, "reg", &len); if ( !hw_reg ) @@ -1503,7 +1505,11 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset) /* Add Generic Redistributor */ size = sizeof(struct acpi_madt_generic_redistributor); - for ( i = 0; i < gicv3.rdist_count; i++ ) + /* + * The hardware domain may not used all the regions. So only copy + * what is necessary. + */ + for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) { gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len); gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index df1bab3a35..9f729862da 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1695,8 +1695,19 @@ static int vgic_v3_real_domain_init(struct domain *d) d->arch.vgic.rdist_regions[i].first_cpu = first_cpu; first_cpu += size / GICV3_GICR_SIZE; + + if ( first_cpu >= d->max_vcpus ) + break; } + /* + * The hardware domain may not used all the re-distributors + * regions (e.g when the number of vCPUs does not match the + * number of pCPUs). Update the number of regions to avoid + * exposing unused region as they will not get emulated. + */ + d->arch.vgic.nr_regions = i + 1; + d->arch.vgic.intid_bits = vgic_v3_hw.intid_bits; } else From patchwork Tue Sep 4 19:21:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 145948 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4051880ljw; Tue, 4 Sep 2018 12:24:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbTk2dF8MJ2ScV6UyEuaTC/0QbUTVkdkwWpz3UzikuWFgXoryDV2wa4mQdg7t2A1tBv/H4r X-Received: by 2002:ac8:690b:: with SMTP id e11-v6mr31472784qtr.214.1536089073125; Tue, 04 Sep 2018 12:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536089073; cv=none; d=google.com; s=arc-20160816; b=IoOjqg7U6nXM+z7iydUx6/sLDR7N4A7xHS1ZpO0pCZFM3/CLP2hVEFk3W556DIWUZE zpX7JS/u22v0M7bNPQyPIv65fsjap29kI4UxPKdOBhTqGRIVRNwETMQiWrwHgWlKnOhK 6XQKKBJEHnF5Qrrj2do9MlfDToaG5LiNVqAIejCAm8iCaPH0C4cO/t+lYvRJAjaWtFV/ 8a9GbfvDYU3GmPDwDUM9Aas3KjrMkueNnSCLGlMwfOnk9yTv0PHOdKj/SZSCc9byYd1o ZIREBy0PN8RkkYcqPPlTi00JHoVxft+ueq8IN5PJ7QYwQloy+69gI8Z5MO3yF7A1K0F9 gZHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=Vq7hi0kio8eGuNgdDTJaipaWoRkgqwGZJsvdqHv8UiU=; b=iTJ/U3cuKymozPLMwaSU1azeAr+xhCc+/s74qHEOTAXprgpROLHYSrud2YiXFctAfP LnVEcPBZINLqAqX2aGcfQYmJ7HiS7NJCQMM8h9iPdzt6HSkjoEmLqMJXOAqeiv+1FkRN hgSY4ojIRCiEZC+N3X4iUlMazCxnz4J6My/9SFVc+E/GAvbyoFLDWhKQDPL6pvJwy08Q 9+jeAieeaMoLcGVJIjKOuntPMudy0QR6wx9KRZsZ+OjDfZTOIVQw3J6ZMHCtKXMCvK+Q tVYhkTsohhB4tvjv4sWvbZk4qokhpptasxdwMn5nxjHo9r3oKYGuCZPIXevKsxib/oXm 8rVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id t16-v6si7269075qvk.10.2018.09.04.12.24.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 12:24:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1fxGtq-0005Qy-VH; Tue, 04 Sep 2018 19:22:06 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fxGtp-0005Qf-8a for xen-devel@lists.xenproject.org; Tue, 04 Sep 2018 19:22:05 +0000 X-Inumbo-ID: 93f2b1c4-b077-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 93f2b1c4-b077-11e8-a8a5-bc764e045a96; Tue, 04 Sep 2018 21:20:26 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7C35715BE; Tue, 4 Sep 2018 12:22:04 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4AB4D3F575; Tue, 4 Sep 2018 12:22:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Sep 2018 20:21:53 +0100 Message-Id: <20180904192153.17210-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180904192153.17210-1-julien.grall@arm.com> References: <20180904192153.17210-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 3/3] xen/arm: vgic-v3-its: Make vgic_v3_its_free_domain idempotent 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: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, shameerali.kolothum.thodi@huawei.com, Andrew Cooper MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vgic_v3_its_free_domain may be called before vgic_v3_its_init_domain if the vGIC was failing to initalize itself. This means the list would be unitialized and result in a crash. Thankfully, we only allow ITS for the hardware domain. So the crash is not a security issue. Fix it by checking whether the list the NULL. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Cc: Andrew Cooper --- xen/arch/arm/vgic-v3-its.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 32061c6b03..9edd97c4e7 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -1548,6 +1548,10 @@ void vgic_v3_its_free_domain(struct domain *d) { struct virt_its *pos, *temp; + /* Cope with unitialized vITS */ + if ( list_head_is_null(&d->arch.vgic.vits_list) ) + return; + list_for_each_entry_safe( pos, temp, &d->arch.vgic.vits_list, vits_list ) { list_del(&pos->vits_list);