From patchwork Wed Mar 27 18:45:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 161273 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6829000jan; Wed, 27 Mar 2019 11:47:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqx11uqqkGY6VecEE4W8ADCC+I0MDUaulg2wA6r7EMJvQnR0cL7rqHdZ3O5frWyS3c6Uc6im X-Received: by 2002:a81:a6c5:: with SMTP id d188mr32792368ywh.46.1553712449362; Wed, 27 Mar 2019 11:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712449; cv=none; d=google.com; s=arc-20160816; b=jUQ4L7VpH9qwneomn5fiZG8reCE2Od+ojWttj1NyrASVIA+ZCHjXvRUqlxvT9GYYYN CW5k0TuuwCNlh36P0+hIvHyd8vhAKiemodWVKsLuFknXEzhj6/LCbfMWTZZJtHTIJ3pd G4Z3eydfVX4i05n1obXRTYRbKBCu6MbvclcbCdu0QHfogsu3Qk7+ArFtAqK8qBIYXjSF VB6rf6sqSE4GqSug4kQITQVBwAqal55Jmsvd2njxAC5d6NwBrUhJallV1dnEMMF7DSTE EQ+/cUhmEcT9/zwnPkJrF5MDIglqjZnDXoLb/ioLQJKDEgelU/nfUH4Kiq5hPU2pHx0B gobw== 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=dJRS3KM9HaH+9JVKfpxR4tj4nkWxdaaJMTn1ip0j9As=; b=chXyrTXhwylnrlTy0V0JIAbKe7HjE4I/A/GeYcAyNbupuOLdS92AsYm78acbEuhViW iUQFGPZ9OhXsodc2EYimIp2MbxU9Rb/+3lOTs0CfXJgkTJh7slJ/H20AL891NNQs0A1G QatQElkVWIWwdk/a3ehjjTSFYzHFVqTmlLyVTrgHPyb158J2tON4mOHIjGbXx8/eDeKZ x4wQfqO4SqTvlhu3kyQJTQ2SqcGRyIcWS+fRj3VMBotpwpLZMYYRZfwqsO8xWRka4ziB heOxu0f3GLA8XyblzlQ9JmgIUKsiaoeZd12x9GX0nILXpfi9X9l+cLzuUKzHJfkyTFgV B1Fg== 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 v66si6451102ywa.75.2019.03.27.11.47.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Mar 2019 11:47:29 -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 1h9DYk-0001lu-Er; Wed, 27 Mar 2019 18:45:58 +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 1h9DYi-0001lA-Rd for xen-devel@lists.xenproject.org; Wed, 27 Mar 2019 18:45:56 +0000 X-Inumbo-ID: 8e108d6e-50c0-11e9-bcc2-637fee61a28f Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 8e108d6e-50c0-11e9-bcc2-637fee61a28f; Wed, 27 Mar 2019 18:45:56 +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 9F44DA78; Wed, 27 Mar 2019 11:45:55 -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 6BFA83F557; Wed, 27 Mar 2019 11:45:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 27 Mar 2019 18:45:28 +0000 Message-Id: <20190327184531.30986-10-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 09/12] xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit 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 8.0 throws an error in the get_top_bit function: guest_walk.c:328:15: error: variable 'topbit' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] else if ( is_64bit_domain(d) ) ^~~~~~~~~~~~~~~~~~ This is happening because clang thinks that is_32bit_domain(d) is not the exact inverse of is_64bit_domain(d). So it expects a else case to handle the case where the latter call is false. In other part of the code, dealing with difference between 32-bit and 64-bit domain, we usually use if ( is_XXbit_domain ) ... else ... So use the same pattern here. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/guest_walk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c index 7db7a7321b..1bee198777 100644 --- a/xen/arch/arm/guest_walk.c +++ b/xen/arch/arm/guest_walk.c @@ -325,7 +325,7 @@ static unsigned int get_top_bit(struct domain *d, vaddr_t gva, register_t tcr) */ if ( is_32bit_domain(d) ) topbit = 31; - else if ( is_64bit_domain(d) ) + else { if ( ((gva & BIT_ULL(55)) && (tcr & TCR_EL1_TBI1)) || (!(gva & BIT_ULL(55)) && (tcr & TCR_EL1_TBI0)) )