From patchwork Fri Feb 23 16:47: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: 129456 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp813802lja; Fri, 23 Feb 2018 08:50:02 -0800 (PST) X-Google-Smtp-Source: AG47ELv0CI+fJRNogCpWb8IH8qz1fHjSQIhEPfY+JfzCQRzKdGtN4LvliG+NCyuXZ+wLA69ZOm6y X-Received: by 10.36.85.129 with SMTP id e123mr2422272itb.56.1519404602398; Fri, 23 Feb 2018 08:50:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404602; cv=none; d=google.com; s=arc-20160816; b=vfmGeOivQJGWHzsdU+a5f3aHUNjKktsS9uMWwI07lGpQhd7CSGRhapYNmtBOTEpZxr frjL5PB7Yh9TP1/L8cUNFsFBrA2uzLM5FNVLNBAGI/+B/Grer53CzrjfecSy3QGobGBq NptUiS5ygknvVFaWr1o8O30ezfOK/cQUY8+MMmrJzD2bguOGPPtk5fKMafsgAyQPOETh xyeL4ZpGgmiA8FmQLMCBT5m6eXOIzkh2ycwV2xRjPZAnhFY8PVj7dJrS7UH0T5NSLVJw kaFIhK2Vaen90RSYReLGIj7qD2s+AO3x2n587Wp8mAq0sPcVqEJIDU8smIqR/GvFXojB 3tMA== 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:arc-authentication-results; bh=ZgGCIv4UMySKAXi0fQJavGU/hzH+RKJWEdEIyP1zofY=; b=EO2wdbpu9GMrveuR33I65pQe7fx3Gmr9CsSv2bPrQOgezmJy6DrhHUBtuy7y25G6mh cf76rNYn3EHTvrql52zXaxHXxeA45vLHkbOjRF8UI/zTX8iqY8HpFv5tksRg/ep9vUAW AAKSzwo28BVapghN40WL1vIbXF0RZCgj+bxsBR7GsLNfsdFiRd5CTWaKbnr5i2tlNyeM 9jkshYERHqULNw5Nm8Fn2n/2vzCrdPn8M0iTyz4uRZBLKerm3OdSqjBFVFqmKhDuyOth oVduwH5DnmkaN0FERLT+6ehPUw+3S1JFwgRpYTf09xIV+Bs1Ilq7TFQec+jUyV7wKBtd OrhA== 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 a1si1403291ith.83.2018.02.23.08.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 08:50:02 -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 1epGWW-0003vQ-R3; Fri, 23 Feb 2018 16:48:40 +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 1epGWV-0003lu-0k for xen-devel@lists.xen.org; Fri, 23 Feb 2018 16:48:39 +0000 X-Inumbo-ID: 9f0b2421-18b9-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 9f0b2421-18b9-11e8-b9b1-635ca7ef6cff; Fri, 23 Feb 2018 16:50:15 +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 F0E8B15BE; Fri, 23 Feb 2018 08:48:31 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE3593F25C; Fri, 23 Feb 2018 08:48:30 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 23 Feb 2018 16:47:53 +0000 Message-Id: <20180223164753.27311-20-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223164753.27311-1-julien.grall@arm.com> References: <20180223164753.27311-1-julien.grall@arm.com> Cc: Andre Przywara , Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v4 19/19] xen/arm: vpsci: Rework the logic to start AArch32 vCPU in Thumb mode 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" 32-bit domain is able to select the instruction (ARM vs Thumb) to use when boot a new vCPU via CPU_ON. This is indicated via bit[0] of the entry point address (see "T32 support" in PSCI v1.1 DEN0022D). bit[0] must be cleared when setting the PC. At the moment, Xen is setting the CPSR.T but never clear bit[0]. Clear it to match the specification. At the same time, slighlty rework the code to make clear thumb is only for 32-bit domain. Lastly, take the opportunity to switch is_thumb from int to bool. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Reviewed-by: Andre Przywara --- Changes in v4: - Add Stefano's reviewed-by - Add Andre's reviewed-by Changes in v3: - Patch added --- xen/arch/arm/vpsci.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index 1729f7071e..9f4e5b8844 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -28,7 +28,7 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point, struct domain *d = current->domain; struct vcpu_guest_context *ctxt; int rc; - int is_thumb = entry_point & 1; + bool is_thumb = entry_point & 1; register_t vcpuid; vcpuid = vaffinity_to_vcpuid(target_cpu); @@ -62,6 +62,13 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point, if ( is_32bit_domain(d) ) { ctxt->user_regs.cpsr = PSR_GUEST32_INIT; + /* Start the VCPU with THUMB set if it's requested by the kernel */ + if ( is_thumb ) + { + ctxt->user_regs.cpsr |= PSR_THUMB; + ctxt->user_regs.pc64 &= ~(u64)1; + } + ctxt->user_regs.r0_usr = context_id; } #ifdef CONFIG_ARM_64 @@ -71,10 +78,6 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point, ctxt->user_regs.x0 = context_id; } #endif - - /* Start the VCPU with THUMB set if it's requested by the kernel */ - if ( is_thumb ) - ctxt->user_regs.cpsr |= PSR_THUMB; ctxt->flags = VGCF_online; domain_lock(d);