From patchwork Wed Oct 2 18:00:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 175035 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1091161ill; Wed, 2 Oct 2019 11:02:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfklbiAgmtwMDRD4D9r0fcliEYaSJGYJvy7BKoCkz7i3wJVVVmf2mWuZFKQswd15lYDhgF X-Received: by 2002:a5e:de01:: with SMTP id e1mr4321400iok.195.1570039360441; Wed, 02 Oct 2019 11:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570039360; cv=none; d=google.com; s=arc-20160816; b=dmsIlC6aqu54X7bJGKOno1bWCiKTkRTzNT8PUYLEdC9hHs0GetLNlPjiOzIa4TYH7u qWV2XulJQ82dA0tJBQoGKABNeuY/LIhgvR4fT1aZMWtbnAtpMPJpOs5vKUAUrNUnYYRp xtFWvmnMd7sLgkVGgJxCw3cwadpWPKgoZ9JPDXDvA8ksElxFJThGyTQ8BuAI8BRbANTE ryTBgSGTsZlrouwpJzGYBzMBKAgH3uqWWXKOtkJRvjRTIXcu3J3ItwDwWHOb6QkFfjrL lBpG6Cdjy4t7cm8bQ8cyeHFMT85UtruRqLOTRkfQnf9foWJQg5hp83CTJ+kHUsOFHoz5 NccQ== 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=3DzOC9+Y4cV5J5ZTqqQrFTJC9TxNukXxeXrjad+cvfI=; b=DJDCxiPb8Oa90cFW1nCib8qgBHaW8U/K+svYPXbWHAPCh92VQTwUOMyc7o2Wwz/FfD bK/nF7C+WnMvjNL5R+Xnx9f37JVOnjQ3tcIGxRXswV924Nw9i60DwahvlGt13UVQk0zi fyMHtkhizAN/I3xq7OpVw3AcIrAoY9lMcMMNGe18RABYIuUU6q/ixi+Zr9U4HUJypGdk 2bAlrsxbOTuwsjsxN4bTpuh4+zSSdI3yS5nUFzh8whK46qyIITho+VA+O8yjx5s2LcsD J345/PMdtMQK1M0ZqnKZqP1Y2TXH0+QwrOhgzAGrhXeVvoTy7NguB6r9KGvG7AU49dVU GBTw== 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 t5si20398244ilg.68.2019.10.02.11.02.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Oct 2019 11:02:40 -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 1iFivn-0005HJ-B6; Wed, 02 Oct 2019 18:00:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iFivm-0005H8-7h for xen-devel@lists.xenproject.org; Wed, 02 Oct 2019 18:00:54 +0000 X-Inumbo-ID: 934094e2-e53e-11e9-b588-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by localhost (Halon) with ESMTP id 934094e2-e53e-11e9-b588-bc764e2007e4; Wed, 02 Oct 2019 18:00:53 +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 2BFC41597; Wed, 2 Oct 2019 11:00:53 -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 41EEF3F706; Wed, 2 Oct 2019 11:00:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 2 Oct 2019 19:00:42 +0100 Message-Id: <20191002180047.17144-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191002180047.17144-1-julien.grall@arm.com> References: <20191002180047.17144-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 1/6] 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, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall 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 GCCism is still kept in default because other compilers (e.g. clang) may also define __GNUC__, so AFAIK there are no proper way to detect properly GCC. This means that in the event Xen is ported to a new compiler, the code will need to be updated. But that likely not going to be the only place where Xen will need to be adapted... This is based on the x86 counterpart. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Update the commit message to explain the ordering in the code. - Add Stefano's acked-by --- 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 1653e89d30..80503578cf 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)