From patchwork Thu Feb 15 15:02:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 128457 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1846859ljc; Thu, 15 Feb 2018 07:05:42 -0800 (PST) X-Google-Smtp-Source: AH8x225/ypjpeLDDEzgG3cezLMYlDCj/IbKuclXsZjpCMT1usNDTXwF4TY9nK1Qxzqz+7pNOpfBv X-Received: by 10.202.215.86 with SMTP id o83mr1905756oig.125.1518707142448; Thu, 15 Feb 2018 07:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518707142; cv=none; d=google.com; s=arc-20160816; b=NQd/pO8BOqDcCqhXv15Vam67cilnOpfICb1lgLoah5ly6a1gOlmRgwjimysB5zHCGG JDRW5Rz64EeQ1beY2z/Ju0Hwl/vP0ODv17a8HKZFabtu+ARzimZjcwPXv3RTUVVI0sdd 0azmi3+fBWvL9//reQFDAMAcf56sVznWkNRHc9lVY2llRSDMMAD8k6JJxhNFLPIxcg7c 8pmhQ9m2B+AgoBaabP3hl2/1MLt+kguVk9VwGAaMl7jdLEK5VuqMUcHGBZplQY538DVs 6OtRi/wKAoLmMeBkIJ+DZcvaOHPbazkKcYA9qqvfwTtA2ax8SCrgafOFhf1q+ILQBLIA P5kg== 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=uTGBTk2AJDyI9pmU2IanUrmkx38ZnBdKDs5QSOFIKaI=; b=hf6DGk0MG/uGQv/DoaJGH/SR2FSDvmDhKsI99ipxh5s+tkjsyZlPcurUbBLmRfWa1n gvlqqgTO1vRD4bEvhWgsFqcBydE/vNxkN3NN8I/n50NfJxH4oKQdESQTotZiUh8k7tp0 uJQJy6Ekei80cZA3fWkQ9IsAfoKeQHoHrVeuA+h8sIfbr7gFSjun5HoLn7DOFfbshL1g DpQhAYeydI2z/79VzyYBtTFTlATc4ziyU3thzxX5Q4xS7r3zCfGHfXaT0f4xiJj+jrwo ElPnYAGqum5yxYn0ZRS1nV1XxaeAc3QGMrkPVYEurE2DshSM2EkEQmMPTL2fHb55fQ6A 0xCA== 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 k34si1462658ioi.117.2018.02.15.07.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 07:05:42 -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 1emL4K-0002FX-VS; Thu, 15 Feb 2018 15:03:28 +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 1emL4K-00028n-FH for xen-devel@lists.xen.org; Thu, 15 Feb 2018 15:03:28 +0000 X-Inumbo-ID: 8b9d4e1c-1261-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 8b9d4e1c-1261-11e8-b9b1-635ca7ef6cff; Thu, 15 Feb 2018 15:04:39 +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 3FED21610; Thu, 15 Feb 2018 07:03:22 -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 30B213F41F; Thu, 15 Feb 2018 07:03:21 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 15 Feb 2018 15:02:48 +0000 Message-Id: <20180215150248.28922-18-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180215150248.28922-1-julien.grall@arm.com> References: <20180215150248.28922-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v3 17/17] 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 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);