From patchwork Mon Oct 1 18:57:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147927 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4263582lji; Mon, 1 Oct 2018 11:59:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV630CqTRQMJFMxoJpgz9V+FtEesTUAJaJ6IBmKJ84Xnaq0yQ5RRf2ftpO+8Fpl4a3cIIFwcO X-Received: by 2002:a24:c782:: with SMTP id t124-v6mr11441102itg.137.1538420396600; Mon, 01 Oct 2018 11:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538420396; cv=none; d=google.com; s=arc-20160816; b=QczVNw5jpfCidzGY5Iy4zTOOxNsJXc3z9NKJct2cDmDS5CjzMhvCtxPZfIrHs7MShU 55l00CwVErHmxBlawEBOj9ea+AO2HTXF+jJQCK8QyRMOsKEuVplXM/RtHr+xtVkljHEy E1l/ZRBL9smuqDMZUqVIoXrTDPyG+oD1TWjo/R7jz8iS1Mbt27s4Le9BHPQECje+RC50 mwcSWpItRSdOA7xY8uVVN0ypR2E/q6dtuAux7ykfo2c8Q8d3XO7QuKBkYHxM+y9IZCnL Iue3m3ce4qZ9nJz9J07Vism3tmwpPnYPoDpJG6Vl91513HNX4aeWhTO/InEnjUi1qDDz jK5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from; bh=cvoFL3gGM+N3e89GDElYvujOQc2Xbyebq+JTZteNUEE=; b=v730EIl9mjm/5e4gncd3Iz59BsZcrck+HySbACN3910QgD8cLbxcpgsNnXVfxV4Bs3 a5mcJ3hd6fAhmEetLpCysYGABXp6Q5T26/A4/JyKNwaULtex3EI9/x7KQ+pLUUcn1skB uPT8bcOWgFeqLWCD/du58/ok0GRoGyAh+rJ6PF3nBHueaHvyU5dzNqjA2HCP2aLZVdz3 9Ea1IxhjLRw9fEfK1G2pD6r+UXuG0Aa7a4xJc5qfSGZWxoazFMg1hu1QG+v7tBiLvCd2 IBdRR87iT6nL66it2QkGRI+rq3Ms/a/PNjAWsJtb5sEuLpxxIs2ebNIVsfjJJUOJVd8R s9+w== 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 q185-v6si6853119itb.115.2018.10.01.11.59.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 11:59:56 -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 1g73Ns-0001FD-IJ; Mon, 01 Oct 2018 18:57:32 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g73Nr-0001F5-Cf for xen-devel@lists.xenproject.org; Mon, 01 Oct 2018 18:57:31 +0000 X-Inumbo-ID: 02cf32bc-c5ac-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 02cf32bc-c5ac-11e8-a6a9-d7ebe60f679a; Mon, 01 Oct 2018 18:58:40 +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 666341596; Mon, 1 Oct 2018 11:57:29 -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 28C4B3F5B7; Mon, 1 Oct 2018 11:57:28 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 1 Oct 2018 19:57:17 +0100 Message-Id: <20181001185721.15467-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001185721.15467-1-julien.grall@arm.com> References: <20181001185721.15467-1-julien.grall@arm.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/3] tools/libxl: Rename libxl__arch_domain_build_info_acpi_setdefault to... 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: wei.liu2@citrix.com, Julien Grall , sstabellini@kernel.org, ian.jackson@eu.citrix.com, roger.pau@citrix.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" libxl__arch_domain_build_info_setdefault A follow-up will require to modify default of multiple fields of build_info. So rename the function accordingly. No functional change. Signed-off-by: Julien Grall Reviewed-by: Roger Pau Monné Acked-by: Wei Liu --- Changes in v3: - Add Roger's reviewed-by - Add Wei's acked-by --- tools/libxl/libxl_arch.h | 3 +-- tools/libxl/libxl_arm.c | 4 ++-- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_x86.c | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index c8ccaaf14c..5ab0c95974 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -65,8 +65,7 @@ _hidden int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq); _hidden -void libxl__arch_domain_build_info_acpi_setdefault( - libxl_domain_build_info *b_info); +void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info); _hidden int libxl__arch_extra_memory(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index baa0d38e01..699fd9ddc6 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1110,9 +1110,9 @@ int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq) return xc_domain_bind_pt_spi_irq(CTX->xch, domid, irq, irq); } -void libxl__arch_domain_build_info_acpi_setdefault( - libxl_domain_build_info *b_info) +void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info) { + /* ACPI is disabled by default */ libxl_defbool_setdefault(&b_info->acpi, false); } diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index dcfde7787e..580320d272 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -215,7 +215,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (!b_info->event_channels) b_info->event_channels = 1023; - libxl__arch_domain_build_info_acpi_setdefault(b_info); + libxl__arch_domain_build_info_setdefault(b_info); libxl_defbool_setdefault(&b_info->dm_restrict, false); switch (b_info->type) { diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index 6f670b03b5..81523a568f 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -613,8 +613,7 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, return rc; } -void libxl__arch_domain_build_info_acpi_setdefault( - libxl_domain_build_info *b_info) +void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info) { libxl_defbool_setdefault(&b_info->acpi, true); } From patchwork Mon Oct 1 18:57:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147926 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4263565lji; Mon, 1 Oct 2018 11:59:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV61cvUO26RHN1c+xF88P62mAhjjA+9/D4/7MoJLMOX1FrD7MQgL1SOoi+13oZhIw242GceTt X-Received: by 2002:a02:5c8f:: with SMTP id w15-v6mr8846514jad.109.1538420395656; Mon, 01 Oct 2018 11:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538420395; cv=none; d=google.com; s=arc-20160816; b=U02nHTFG4firw59/akBV8/S52Ly7AouBdT/WVbQph+ZtuzByCdGVo0a9DHPfpMi3q5 dHwXBYXrmTB36PTEaSKl3jGYK45ryXHHH19J9udzfDm6s5YNJs9F5+0sxyB0aibjsIF8 ChXfWAp28CPr9sEO6oB2PtrvOar92SgQ5dsvD002mOTZXqv9MbgkOLDd71FvXCOiH7A3 ye7G3WHIyLx0P58NxCX+b30MZl6UqUhJQqPSY8o3IzQY/HbSR4jp84+ubLye1MZJzNwJ rOCl1fLphg1j245koBJ+LUH/kFQWrPai7ZG3odM47mtaKXr9Gup1MST1QSYdms9wkOY7 q1ZA== 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; bh=Tyrazoy1zeFyOV+gpOi1ePZQ8Va2MNFVlvDNGvJDRGc=; b=QO/cvE+9kVwWEWcXi7SijYWsgXwHg4IrYvgrSHc0RHA8+1GZT5zf05e+hjHFn0Go6B iCxPxbV+I8ETjh+ufMIZX0M8reGlnwZWt4jRANINbWrF0ZZgn7jcGtp3JaWjrA6tcbUs +ojbThnIXlYk+lATOvGkaOrA/zg4CkXGDZR3qCIqee32CcLgIYb0DrdZufm9fVEeu+SK hC3stmWPKzd8X5AydY6VK4Wk95QUiXA54v+aFluRseL4bU1wGY2iZRI3KKoxCGvl+VF5 Zi2ND2bBNwgWdWOMCVEvB9QQSLHf6Qm1Za2tIqLUlS0CIvqeGQ/e56a+kkJcqVvcGx+F fTFQ== 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 t21-v6si6741422itf.16.2018.10.01.11.59.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 11:59:55 -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 1g73Nw-0001Fs-GK; Mon, 01 Oct 2018 18:57:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g73Nv-0001FZ-46 for xen-devel@lists.xenproject.org; Mon, 01 Oct 2018 18:57:35 +0000 X-Inumbo-ID: 059d4b42-c5ac-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 059d4b42-c5ac-11e8-a6a9-d7ebe60f679a; Mon, 01 Oct 2018 18:58:45 +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 200431596; Mon, 1 Oct 2018 11:57:34 -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 D73A33F5B7; Mon, 1 Oct 2018 11:57:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 1 Oct 2018 19:57:20 +0100 Message-Id: <20181001185721.15467-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001185721.15467-1-julien.grall@arm.com> References: <20181001185721.15467-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 2/2] 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: wei.liu2@citrix.com, Julien Grall , sstabellini@kernel.org, ian.jackson@eu.citrix.com, roger.pau@citrix.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. Lastly, rename vgic_v3_rdist_count to reflect the value return by the helper. Reported-by: Shameerali Kolothum Thodi Signed-off-by: Julien Grall Tested-by: Shameer Kolothum --- Changes in v2: - Rename vgic_v3_rdist_count to vgic_v3_max_rdist_count - Fixup #re-distributors - Fix typoes - Add Shameer's tested tag --- xen/arch/arm/gic-v3.c | 14 +++++++++++--- xen/arch/arm/vgic-v3.c | 21 ++++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index c98a163ee7..2c1454f425 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1265,7 +1265,8 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, if ( res ) return res; - res = fdt_property_cell(fdt, "#redistributor-regions", gicv3.rdist_count); + res = fdt_property_cell(fdt, "#redistributor-regions", + d->arch.vgic.nr_regions); if ( res ) return res; @@ -1274,8 +1275,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 use 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 ) @@ -1466,6 +1469,7 @@ static inline bool gic_dist_supports_dvis(void) } static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset) + { struct acpi_subtable_header *header; struct acpi_madt_generic_interrupt *host_gicc, *gicc; @@ -1503,7 +1507,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..efe824c6fb 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1640,7 +1640,11 @@ static int vgic_v3_vcpu_init(struct vcpu *v) return 0; } -static inline unsigned int vgic_v3_rdist_count(struct domain *d) +/* + * Return the maximum number possible of re-distributor regions for + * a given domain. + */ +static inline unsigned int vgic_v3_max_rdist_count(struct domain *d) { /* * Normally there is only one GICv3 redistributor region. @@ -1662,7 +1666,7 @@ static int vgic_v3_real_domain_init(struct domain *d) int rdist_count, i, ret; /* Allocate memory for Re-distributor regions */ - rdist_count = vgic_v3_rdist_count(d); + rdist_count = vgic_v3_max_rdist_count(d); rdist_regions = xzalloc_array(struct vgic_rdist_region, rdist_count); if ( !rdist_regions ) @@ -1695,8 +1699,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 use 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 @@ -1825,7 +1840,7 @@ int vgic_v3_init(struct domain *d, int *mmio_count) } /* GICD region + number of Redistributors */ - *mmio_count = vgic_v3_rdist_count(d) + 1; + *mmio_count = vgic_v3_max_rdist_count(d) + 1; /* one region per ITS */ *mmio_count += vgic_v3_its_count(d); From patchwork Mon Oct 1 18:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147925 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4263553lji; Mon, 1 Oct 2018 11:59:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV61DrBKBe3qPMh6PL63qSfj068HOG4fFue1NcW6fEZQz0qJUjuP9Rlg22juQWYNr1YP3QBTq X-Received: by 2002:a24:46cd:: with SMTP id j196-v6mr10964808itb.0.1538420394607; Mon, 01 Oct 2018 11:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538420394; cv=none; d=google.com; s=arc-20160816; b=fLBMctyOC/YtYQNsSj5Hf7mI1d1tsq0KkTCZIxxUv2zFd1Y1iwAOKv0w/pnzVGyloL zrONzrOYQY04op2th6eWqM/sy6HAu+ZrbT4vnz63uxS/aZSUygUDCtgNwp8hvZmPPVPT BtdiZ9pwAi3UptSBzlmmW2tzKcgKl4RGtwi9QL7zPaSS3KvFdY3a3szfBufZSX/Xowun qykIOCSK98cUkoo61BmubbYbX7+ESk/rHct8eeKgFFQftlgyN37O2qTwg34XnaPq2wuT XGacMUs+NglSuDGMw2Yu42qNf64IBLnL48KYkbTjTzKVDSCs/nT5CL+Lf8TRqOVuc4Aw ncKQ== 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; bh=DnQJjWtiZ8NvXqTLEcPin0NyNYlVcdtLFY/tdyE4LUE=; b=gMPusayT0DrIwPOKczLyCp0WfCN5ftxFYzWyq32B4VYkCLHMQr170YJ/GDBdA2VzMI 3qln8MmNZZm6WGo4QrKGh75D7yYZyh9qfM9OpOl6IKg3SbvC37pK3WfzDLlijYNhOj7a AlbTF2+52TLRMm5g2wDMToNWlr5DOZpl8llRPcyWa+LWsCScotd0hmXpLYYu6DuhIgm3 j9JhCr6NevlJfk3XFae6510p7Qmw/DnNNWeV1L9bQ9wQRSbmy0gssZ+y6uxAZmTN31bJ Uc7F+0tEUZdW36KxXn9jkQXphLNH6CSZVvRhTHlUCvVldzbvZ+xIMsELHIqrOWgHT0CN pfrQ== 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 c4-v6si8597354jag.62.2018.10.01.11.59.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 11:59:54 -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 1g73Ny-0001GZ-V7; Mon, 01 Oct 2018 18:57:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g73Nx-0001GA-1l for xen-devel@lists.xenproject.org; Mon, 01 Oct 2018 18:57:37 +0000 X-Inumbo-ID: 06854964-c5ac-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 06854964-c5ac-11e8-a6a9-d7ebe60f679a; Mon, 01 Oct 2018 18:58:47 +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 9F5E77A9; Mon, 1 Oct 2018 11:57:35 -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 622A13F5B7; Mon, 1 Oct 2018 11:57:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 1 Oct 2018 19:57:21 +0100 Message-Id: <20181001185721.15467-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001185721.15467-1-julien.grall@arm.com> References: <20181001185721.15467-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v3 3/3] tools/libxl: Switch Arm guest type to PVH 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: wei.liu2@citrix.com, Julien Grall , sstabellini@kernel.org, ian.jackson@eu.citrix.com, roger.pau@citrix.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, the toolstack is considering Arm guest always PV. However, they are very similar to PVH because HW virtualization extension are used and QEMU is not started. So switch Arm guest type to PVH. To keep compatibility with toolstack creating Arm guest with PV type (e.g libvirt), libxl will now convert those guests to PVH. Furthermore, the default type for Arm in xl will now be PVH to allow smooth transition for user. Signed-off-by: Julien Grall Reviewed-by: Roger Pau Monné Acked-by: Wei Liu --- This was discussed at Xen Summit and also in various thread on xen-devel. The latest one was when Andrew sent a patch to deny guest creation on Arm with XEN_DOMCTL_CDF_hap unset. I suspect we first implemented Arm guest as PV in libxl because PVH was non-existent and the type was easier to avoid spawning QEMU. Note that Linux and Xen are already considering Arm guest as PVH. Changes in v3: - Properly reset u.pvh - Update documentation and print - Return ERROR_INVAL rather than ERROR_FAIL Changes in v2: - Rather than denying PV guest, convert them to PVH --- docs/man/xl.cfg.pod.5.in | 5 +++-- tools/libxl/libxl_arch.h | 3 ++- tools/libxl/libxl_arm.c | 26 ++++++++++++++++++++++++-- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_x86.c | 3 ++- tools/xl/xl_parse.c | 4 ++++ 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index b72718151b..b1c0be14cd 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -80,13 +80,14 @@ single host must be unique. =item B Specifies that this is to be a PV domain, suitable for hosting Xen-aware -guest operating systems. This is the default. +guest operating systems. This is the default on x86. =item B Specifies that this is to be an PVH domain. That is a lightweight HVM-like guest without a device model and without many of the emulated devices -available to HVM guests. Note that this mode requires a PVH aware kernel. +available to HVM guests. Note that this mode requires a PVH aware kernel on +x86. This is the default on Arm. =item B diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index 5ab0c95974..930570ef1e 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -65,7 +65,8 @@ _hidden int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq); _hidden -void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info); +void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, + libxl_domain_build_info *b_info); _hidden int libxl__arch_extra_memory(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 699fd9ddc6..25dc3defc6 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -953,7 +953,11 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, int rc; uint64_t val; - assert(info->type == LIBXL_DOMAIN_TYPE_PV); + if (info->type != LIBXL_DOMAIN_TYPE_PVH) { + LOG(ERROR, "Unsupported Arm guest type %s", + libxl_domain_type_to_string(info->type)); + return ERROR_INVAL; + } /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ. */ val = MASK_INSR(HVM_PARAM_CALLBACK_TYPE_PPI, @@ -1110,10 +1114,28 @@ int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq) return xc_domain_bind_pt_spi_irq(CTX->xch, domid, irq, irq); } -void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info) +void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, + libxl_domain_build_info *b_info) { /* ACPI is disabled by default */ libxl_defbool_setdefault(&b_info->acpi, false); + + /* + * Arm guest are now considered as PVH by the toolstack. To allow + * compatibility with previous toolstack, PV guest are automatically + * converted to PVH. + */ + if (b_info->type != LIBXL_DOMAIN_TYPE_PV) + return; + + LOG(WARN, "Converting PV guest to PVH."); + LOG(WARN, "Arm guest are now PVH."); + LOG(WARN, "Please fix your configuration file/toolstack."); + + /* Re-initialize type to PVH and all associated fields to defaults. */ + memset(&b_info->u, '\0', sizeof(b_info->u)); + b_info->type = LIBXL_DOMAIN_TYPE_INVALID; + libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PVH); } /* diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index fe97eebdea..320dbed3c6 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -215,7 +215,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (!b_info->event_channels) b_info->event_channels = 1023; - libxl__arch_domain_build_info_setdefault(b_info); + libxl__arch_domain_build_info_setdefault(gc, b_info); libxl_defbool_setdefault(&b_info->dm_restrict, false); switch (b_info->type) { diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index 81523a568f..8b6759c089 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -613,7 +613,8 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, return rc; } -void libxl__arch_domain_build_info_setdefault(libxl_domain_build_info *b_info) +void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, + libxl_domain_build_info *b_info) { libxl_defbool_setdefault(&b_info->acpi, true); } diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 971ec1bc56..0bda28152b 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1286,7 +1286,11 @@ void parse_config_data(const char *config_source, } if (c_info->type == LIBXL_DOMAIN_TYPE_INVALID) +#if defined(__arm__) || defined(__aarch64__) + c_info->type = LIBXL_DOMAIN_TYPE_PVH; +#else c_info->type = LIBXL_DOMAIN_TYPE_PV; +#endif xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);