From patchwork Fri Mar 2 19:06:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 130577 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1610483lja; Fri, 2 Mar 2018 11:08:19 -0800 (PST) X-Google-Smtp-Source: AG47ELtcGdsT1fMGAUuW76+xN/8sbBN2KGubkrXXXmDRMxHTqp3UitxONSzp+Sgmao+ogqRXqWJo X-Received: by 10.107.165.146 with SMTP id o140mr7406101ioe.52.1520017698918; Fri, 02 Mar 2018 11:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520017698; cv=none; d=google.com; s=arc-20160816; b=yePKFjdfGr10zMSMmzjo4ZjKVZXNJoOcPKuWc9ZQf/ijx1eQ6kbCJWQbIwgCOBQz3C qnyhDVwleOHOYfvaskBHZ/cG06Uq7HztqcuI9OgY6nXs7TowII1vEl8iPUojLqAK89R9 6RxznaSoZt0ZTl0MawbUcQjjNjXHOLUXQkjCLNLly/Od40Y7m6lYByoAzzxK43oLyxB0 LWsmpnGyNeMtvLqPv40Q3oUM9qHEcwIutBdBltQpRvdVfdw9ElNEDz9Gzj0OLoJ7VjPc VzCzQ4LiGI93YJleeGZj8A/ivM5U7umsk/klEINff/JjDG6kPylYm1myx48ZkhUaLSBd 4jRg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dmarc-filter:arc-authentication-results; bh=0wkZVH0x9DLbDEMjBlSOIarKAoqrzKV8ylrwC8ewRW4=; b=UVgbTKuZwxqd/5P0vGE0WfkesMKUYO0+5zBMbKWUS07WVBZeRIcUHIuZosbsDvzy+3 ptKpDg0Sw/Gt824w0g9VerNECxcZk8WltCAVosrqLs2OOJvJlMA8XedRAgj25NPMmU1F G7Mb0pHJ45FYXRaFLQTzUPh5w67rWhUkzYSAIZDnVS7F41tWlTFVW8uwvM3juT1F4j4p xyRZcKfrOQjiK3L/d2k5GzVzazkBE6BVtA+jqKAHwWq6NK02+hsbKGZMoCyDxBhZukpv 922rbl4cm25SGFBdKaQ6LGMMTbSYt5TCSevV09HrivtiDjp+3w9CJCpDtB3z3n+ZHDC+ BHUw== 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 f3si4714988ioe.29.2018.03.02.11.08.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Mar 2018 11:08:18 -0800 (PST) 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.84_2) (envelope-from ) id 1erq0Y-000800-Bc; Fri, 02 Mar 2018 19:06:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1erq0X-0007q9-BR for xen-devel@lists.xen.org; Fri, 02 Mar 2018 19:06:17 +0000 X-Inumbo-ID: 10096cb7-1e4d-11e8-b9b1-635ca7ef6cff Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTPS id 10096cb7-1e4d-11e8-b9b1-635ca7ef6cff; Fri, 02 Mar 2018 19:08:16 +0000 (UTC) Received: from localhost.localdomain (unknown [12.248.85.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A98DF21795; Fri, 2 Mar 2018 19:06:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A98DF21795 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org From: Stefano Stabellini To: julien.grall@arm.com Date: Fri, 2 Mar 2018 11:06:03 -0800 Message-Id: <1520017568-24427-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520017568-24427-1-git-send-email-sstabellini@kernel.org> References: <1520017568-24427-1-git-send-email-sstabellini@kernel.org> Cc: sstabellini@kernel.org, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v4 2/7] xen/arm: Park CPUs with a MIDR different from the boot CPU. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall From: Julien Grall Xen does not properly support big.LITTLE platform. All vCPUs of a guest will always have the MIDR of the boot CPU (see arch_domain_create). At best the guest may see unreliable performance (vCPU switching between big and LITTLE), at worst the guest will become unreliable or insecure. This is becoming more apparent with branch predictor hardening in Linux because they target a specific kind of CPUs and may not work on other CPUs. For the time being, park any CPUs with a MDIR different from the boot CPU. This will be revisited in the future once Xen gains understanding of big.LITTLE. [1] https://lists.xenproject.org/archives/html/xen-devel/2016-12/msg00826.html Signed-off-by: Julien Grall Reviewed-by: Oleksandr Tyshchenkko Reviewed-by: Stefano Stabellini Acked-by: Jan Beulich --- docs/misc/xen-command-line.markdown | 10 ++++++++++ xen/arch/arm/smpboot.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index f73990f..7b80119 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -985,6 +985,16 @@ supported only when compiled with XSM on x86. Control Xens use of the APEI Hardware Error Source Table, should one be found. +### hmp-unsafe (arm) +> `= ` + +> Default : `false` + +Say yes at your own risk if you want to enable heterogenous computing +(such as big.LITTLE). This may result to an unstable and insecure +platform. When the option is disabled (default), CPUs that are not +identical to the boot CPU will be parked and not used by Xen. + ### hpetbroadcast > `= ` diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 1255185..7ea4e41 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,13 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_mask); /* representing HT and core siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask); +/* + * By default non-boot CPUs not identical to the boot CPU will be + * parked. + */ +static bool __read_mostly opt_hmp_unsafe = false; +boolean_param("hmp-unsafe", opt_hmp_unsafe); + static void setup_cpu_sibling_map(int cpu) { if ( !zalloc_cpumask_var(&per_cpu(cpu_sibling_mask, cpu)) || @@ -255,6 +263,9 @@ void __init smp_init_cpus(void) else acpi_smp_init_cpus(); + if ( opt_hmp_unsafe ) + warning_add("WARNING: HMP COMPUTING HAS BEEN ENABLED.\n" + "It has implications on the security and stability of the system.\n"); } int __init @@ -292,6 +303,21 @@ void start_secondary(unsigned long boot_phys_offset, init_traps(); + /* + * Currently Xen assumes the platform has only one kind of CPUs. + * This assumption does not hold on big.LITTLE platform and may + * result to instability and insecure platform. Better to park them + * for now. + */ + if ( !opt_hmp_unsafe && + current_cpu_data.midr.bits != boot_cpu_data.midr.bits ) + { + printk(XENLOG_ERR "CPU%u MIDR (0x%x) does not match boot CPU MIDR (0x%x).\n", + smp_processor_id(), current_cpu_data.midr.bits, + boot_cpu_data.midr.bits); + stop_cpu(); + } + mmu_init_secondary_cpu(); gic_init_secondary_cpu();