From patchwork Wed Mar 27 18:45:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 161271 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6828976jan; Wed, 27 Mar 2019 11:47:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7HlojjisFQakFVwR9chRHFThM/d5431c0ftJEwHFGTiIAMiyurLOqWlHz59H9yQqZ2XYv X-Received: by 2002:a81:2d09:: with SMTP id t9mr2239358ywt.436.1553712448539; Wed, 27 Mar 2019 11:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712448; cv=none; d=google.com; s=arc-20160816; b=cMhrnU+sGRLTMFr6/q3C2hkJ51/0GTyXE5yo0fz+l9bk8ZdIZTg/ou+DDOtV3OcvMN qdPfTGU5+jAdQlvoTtXS2YbIS0wROqZ34HDizlmN3e3Qux0idZXM8s/wbIXGcRl+zx+F QgP5tkqRX9bcwDhAs8Srt54c1WybT9fPPhmiRcHs1GZqPgxTmp/jN9mAuOrMFeU0ej0u f45ScjjWaL4cQe5xCAEKKJpL4A1x+eBW2zYAgujXPH6PVzllW7tQOHBo1rwBnGB4y6yd KUrTT9iFtM6pcHDX3/A8eI+3ml4jZmvGVpjXlsLS/pvCTk8hK91K6Nh+JMdXEc3HEknG eGZg== 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=AhRi03kU6/Azx8E7KGJ7ezPHfhrzFac22xEajYLfl6Q=; b=IrO1HWmqcsocBmbp3ADFdj0HYq+/HF5Vi0W8lYHhC5bBpDwR8ds9Q7Au4kzFW/1E69 fG9sj9OhqjvpqdT980teBVfLiHpJWRhoH6E78q2IDeXxr8a9PUICi1Hn/ToiZZotAFyI u5YF4bIWffSF3A8K6UNG+ZI9AW1PZelS0LW3wKWL3UUpWul5LsLyNmDEiFZ9+CVxnISq CBUpxkUDYrQ6s9H3PdVryoowD9fnwhkDUfalqqcZ3W3Iq9EAGYj59ixdvxSHgqe+udby xHxMYEglov2TdZZaAB1yTzLaRrkaJ3YLDWcqnSqZLXNHfQ6sQFCXC5mIuAmcQVzAoCKk EAzQ== 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 7si9758310ywc.169.2019.03.27.11.47.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Mar 2019 11:47:28 -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 1h9DYZ-0001hk-S6; Wed, 27 Mar 2019 18:45:47 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9DYY-0001hZ-GE for xen-devel@lists.xenproject.org; Wed, 27 Mar 2019 18:45:46 +0000 X-Inumbo-ID: 87c0f8e0-50c0-11e9-9d59-237d42e54f21 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 87c0f8e0-50c0-11e9-9d59-237d42e54f21; Wed, 27 Mar 2019 18:45: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 1A6BD1596; Wed, 27 Mar 2019 11:45:45 -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 DB29B3F557; Wed, 27 Mar 2019 11:45:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 27 Mar 2019 18:45:21 +0000 Message-Id: <20190327184531.30986-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190327184531.30986-1-julien.grall@arm.com> References: <20190327184531.30986-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 02/12] xen/arm: fix get_cpu_info() when built with clang 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: Artem_Mygaiev@epam.com, Oleksandr_Tyshchenko@epam.com, Julien Grall , sstabellini@kernel.org, Andrii_Anisov@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Clang understands the GCCism in use here, but still complains that sp is unitialised. In such cases, resort to the older versions of this code, which directly read sp into the temporary variable. Note that we still keep the GCCism in the default case, as it causes GCC to create rather better assembly. This is based on the x86 counterpart. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/include/asm-arm/current.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/include/asm-arm/current.h b/xen/include/asm-arm/current.h index c4af66fbb9..6b7c1df64d 100644 --- a/xen/include/asm-arm/current.h +++ b/xen/include/asm-arm/current.h @@ -28,8 +28,16 @@ struct cpu_info { static inline struct cpu_info *get_cpu_info(void) { +#ifdef __clang__ + unsigned long sp; + + asm ("mov %0, sp" : "=r" (sp)); +#else register unsigned long sp asm ("sp"); - return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + STACK_SIZE - sizeof(struct cpu_info)); +#endif + + return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + + STACK_SIZE - sizeof(struct cpu_info)); } #define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)