From patchwork Mon Jul 22 21:39:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169435 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012276ilk; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH1Wf0GqBDo1JgvBRkJNCkfJ59qdsjZF8skAv3+I/FIf1YECSug6EgejNMTXat7Mb5xpjN X-Received: by 2002:a02:cc6c:: with SMTP id j12mr32765775jaq.102.1563831676706; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831676; cv=none; d=google.com; s=arc-20160816; b=QTzPzPeRja2cb1+5kkV248y4+9af/UtbAn9o3qrX4uTAueYiRRN/GU+cErL9XOk9+u XCBJlzAMao88ET9xixZKj6El9muOAni1xCAgMtZwT5/FJ3DqFyeoQvqv0LlAl6t7UiDW 8IMIWiJv4pFNxmfC+mmREnxVpHGh97w9ZS5IhjRz9Lz7w+aO4g5qyBfIH+ZR/p1pNIaf Bo+Q26ah1bsS82kyUXcdHict/o0BmjzMxEFplaI/U9xiC8USVd5Ca0QmebONi5h2YBe0 YXNIvUGD1DCTzjbUTP35TaRxW17xn3VKl0bgLLC9jvkS83QTSX5i9ahfQ0umQcYoQWl/ VWug== 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=qabRMnCZNnT/C98bR8vgyonKlMdToMxJx0KwlVo85AE=; b=J+YNpCT4AtVp8Dkbfkc+9AReOmNcAv3sqwxPg5s2b7UyS/W1nOFHN98iGXbAYQkBR3 Wn1nCVWgNlBXAKVjMJRacrqWaU7ytuVZDstLx0MrH3I0oMCVRVINaqahXlb5qdn5wsIl A8qYXZM+1hP5s3Zn4jiaUGqMKG6ykGN1qnqfXIHXbgvctHsvatWsmlUhulJeiIAFW5/Q Bxw++Y/v/gkp4hi7MuSOurkFP/39imJQjJZI/LRFnTxvCib+7w7YNEGt6qlMnK8s+ejR QwjwxWdaN0Gm5D4nW4yJLbtaRMo3o9zi+1hHFgEC6NdmWgmXqU6OPWK9FzbWyf1jpOyt YS1w== 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 g21si819888ion.115.2019.07.22.14.41.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:16 -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 1hpg2q-00033N-My; Mon, 22 Jul 2019 21:40:32 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2n-0002w5-Su for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:29 +0000 X-Inumbo-ID: 5281e7ca-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 5281e7ca-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:28 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 589FF344; Mon, 22 Jul 2019 14:40:28 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A67F13F71F; Mon, 22 Jul 2019 14:40:27 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:48 +0100 Message-Id: <20190722213958.5761-26-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190722213958.5761-1-julien.grall@arm.com> References: <20190722213958.5761-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 25/35] xen/arm32: head: Rework and document check_cpu_mode() 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A branch in the success case can be avoided by inverting the branch condition. At the same time, remove a pointless comment as Xen can only run at Hypervisor Mode. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 13793e85d8..0959c4f044 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -205,6 +205,16 @@ secondary_switched: b launch ENDPROC(init_secondary) +/* + * Check if the CPU supports virtualization extensions and has been booted + * in Hypervisor mode. + * + * This function will never return when the CPU doesn't support + * virtualization extensions or is booted in another mode than + * Hypervisor mode. + * + * Clobbers r0 - r3 + */ check_cpu_mode: /* Check that this CPU has Hyp mode */ mrc CP32(r0, ID_PFR1) @@ -219,15 +229,12 @@ check_cpu_mode: mrs r0, cpsr and r0, r0, #0x1f /* Mode is in the low 5 bits of CPSR */ teq r0, #0x1a /* Hyp Mode? */ - beq hyp + moveq pc, lr /* Yes, return */ /* OK, we're boned. */ PRINT("- Xen must be entered in NS Hyp mode -\r\n") PRINT("- Please update the bootloader -\r\n") b fail - -hyp: PRINT("- Xen starting in Hyp mode -\r\n") - mov pc, lr ENDPROC(check_cpu_mode) zero_bss: