From patchwork Tue Feb 9 20:01:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8265421 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 310149F38B for ; Tue, 9 Feb 2016 20:04:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0894320268 for ; Tue, 9 Feb 2016 20:04:43 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2819C201EC for ; Tue, 9 Feb 2016 20:04:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTEU3-0001dk-IW; Tue, 09 Feb 2016 20:01:59 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTEU0-0001by-Fi for xen-devel@lists.xen.org; Tue, 09 Feb 2016 20:01:56 +0000 Received: from [193.109.254.147] by server-15.bemta-14.messagelabs.com id 09/CB-10115-4B54AB65; Tue, 09 Feb 2016 20:01:56 +0000 X-Env-Sender: prvs=8403a2554=Andrew.Cooper3@citrix.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1455048114!22653768!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15520 invoked from network); 9 Feb 2016 20:01:55 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 9 Feb 2016 20:01:55 -0000 X-IronPort-AV: E=Sophos;i="5.22,422,1449532800"; d="scan'208";a="330665324" From: Andrew Cooper To: Xen-devel Date: Tue, 9 Feb 2016 20:01:47 +0000 Message-ID: <1455048108-5045-8-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455048108-5045-1-git-send-email-andrew.cooper3@citrix.com> References: <1455048108-5045-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 7/8] xen/x86: Fix get_cpu_info() when built with clang X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clang understands the GCCism in use here, but still complains that sp is unintialised. In such cases, resort to the older version of this code, which directly reads %rsp into the temporary variable. Note that we still keep the GCCism in the default case, as it causes GCC to create rather better assembly. Signed-off-by: Andrew Cooper --- CC: Jan Beulich --- xen/include/asm-x86/current.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index f011d2d..15b99ff 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -47,7 +47,13 @@ struct cpu_info { static inline struct cpu_info *get_cpu_info(void) { +#ifdef __clang__ + /* Clang complains that sp in the else case is not initialised. */ + unsigned long sp; + asm ( "mov %%rsp, %0" : "=r" (sp) ); +#else register unsigned long sp asm("rsp"); +#endif return (struct cpu_info *)((sp & ~(STACK_SIZE-1)) + STACK_SIZE) - 1; }