From patchwork Fri Jun 17 10:30:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12885477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D389C43334 for ; Fri, 17 Jun 2022 10:31:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.351268.577856 (Exim 4.92) (envelope-from ) id 1o29FS-0003ah-IF; Fri, 17 Jun 2022 10:30:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 351268.577856; Fri, 17 Jun 2022 10:30:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o29FS-0003aa-F7; Fri, 17 Jun 2022 10:30:42 +0000 Received: by outflank-mailman (input) for mailman id 351268; Fri, 17 Jun 2022 10:30:41 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o29FR-0003aU-12 for xen-devel@lists.xenproject.org; Fri, 17 Jun 2022 10:30:41 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o29FQ-0000GD-Nm; Fri, 17 Jun 2022 10:30:40 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o29FQ-0003sg-DK; Fri, 17 Jun 2022 10:30:40 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From; bh=YulpAZhbVg6y+ee/fL/9bL7V1W2kdnst8Vz1P9ePPw0=; b=yf+iJk yI71j1TcQ4ladswWyndbvQfuGP+BeLRZoU4udUHEybiof1cl2Fr/+byepGeDvJasr+2dCKEBnxxBu DPB6qIORYjKdpEdJFJiyXbOStaI0yFq+dN7RFbQlrGIzeveTqzSRllFMOKZj0kJQtXhSRv74V1xNH 5FsmH/+gdpQ=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, jgross@suse.com, oleksandr_tyshchenko@epam.com, linux-kernel@vger.kernel.org, Julien Grall Subject: [PATCH] x86/xen: Remove undefined behavior in setup_features() Date: Fri, 17 Jun 2022 11:30:37 +0100 Message-Id: <20220617103037.57828-1-julien@xen.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 From: Julien Grall 1 << 31 is undefined. So switch to 1U << 31. Fixes: 5ead97c84fa7 ("xen: Core Xen implementation") Signed-off-by: Julien Grall Reviewed-by: Juergen Gross --- This was actually caught because I wasn't able to boot Linux 5.18 and onwards when built with GCC 7.3 and UBSAN enabled. There was no message but instead an early crash because the instruction "cli was used too early. This issue has always been there but it only shows after Linux switched from C89 to C11. --- drivers/xen/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/features.c b/drivers/xen/features.c index 7b591443833c..87f1828d40d5 100644 --- a/drivers/xen/features.c +++ b/drivers/xen/features.c @@ -42,7 +42,7 @@ void xen_setup_features(void) if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0) break; for (j = 0; j < 32; j++) - xen_features[i * 32 + j] = !!(fi.submap & 1<