Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A7CEC64E7B for ; Wed, 2 Dec 2020 18:04:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0C2CA221FC for ; Wed, 2 Dec 2020 18:04:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C2CA221FC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.42943.77273 (Exim 4.92) (envelope-from ) id 1kkWTY-0008C1-6V; Wed, 02 Dec 2020 18:03:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 42943.77273; Wed, 02 Dec 2020 18:03:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kkWTY-0008Bu-3E; Wed, 02 Dec 2020 18:03:36 +0000 Received: by outflank-mailman (input) for mailman id 42943; Wed, 02 Dec 2020 18:03:35 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kkWTW-0008Bp-TT for xen-devel@lists.xenproject.org; Wed, 02 Dec 2020 18:03:35 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kkWTU-00087d-PD; Wed, 02 Dec 2020 18:03:32 +0000 Received: from [54.239.6.185] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kkWTU-0006Hm-CH; Wed, 02 Dec 2020 18:03:32 +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:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=h1RaJKZGs67HCwMBIg/HMcjp3ktjOJpM+aawCccispI=; b=tnQ4qzLgm/JXK+eUKqHCvHlEeQ +oj5pJgeOTU2+n/lWUQzJpmUowpkCkD5cGGmUF2vxCYw4lL8DFnleuNjmsd0HhPTl5385M13J6+pZ rzG5Qdn1HGTzGRzaPNHUlWYNCayb4TPI9HymTApvux1xVe+JRLn5kW2+dAPuXDjx2ZRk=; Subject: Re: [PATCH] xen/iommu: vtd: Fix undefined behavior pci_vtd_quirks() To: "Tian, Kevin" , "xen-devel@lists.xenproject.org" Cc: Julien Grall References: <20201119145216.29280-1-julien@xen.org> From: Julien Grall Message-ID: Date: Wed, 2 Dec 2020 18:03:30 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi, On 30/11/2020 02:50, Tian, Kevin wrote: >> From: Julien Grall >> Sent: Thursday, November 19, 2020 10:52 PM >> >> From: Julien Grall >> >> When booting Xen with CONFIG_USBAN=y on Sandy Bridge, UBSAN will >> throw >> the following splat: >> >> (XEN) >> ================================================================ >> ================ >> (XEN) UBSAN: Undefined behaviour in quirks.c:449:63 >> (XEN) left shift of 1 by 31 places cannot be represented in type 'int' >> (XEN) ----[ Xen-4.11.4 x86_64 debug=y Not tainted ]---- >> >> [...] >> >> (XEN) Xen call trace: >> (XEN) [] ubsan.c#ubsan_epilogue+0xa/0xad >> (XEN) [] >> __ubsan_handle_shift_out_of_bounds+0xb4/0x145 >> (XEN) [] pci_vtd_quirk+0x3d3/0x74f >> (XEN) [] >> iommu.c#domain_context_mapping+0x45b/0x46f >> (XEN) [] iommu.c#setup_hwdom_device+0x22/0x3a >> (XEN) [] pci.c#setup_one_hwdom_device+0x8c/0x124 >> (XEN) [] pci.c#_setup_hwdom_pci_devices+0xbb/0x2f7 >> (XEN) [] pci.c#pci_segments_iterate+0x4c/0x8c >> (XEN) [] setup_hwdom_pci_devices+0x25/0x2c >> (XEN) [] >> iommu.c#intel_iommu_hwdom_init+0x52/0x2f3 >> (XEN) [] iommu_hwdom_init+0x4e/0xa4 >> (XEN) [] dom0_construct_pv+0x23c8/0x2476 >> (XEN) [] construct_dom0+0x6c/0xa3 >> (XEN) [] __start_xen+0x4651/0x4b55 >> (XEN) [] __high_start+0x53/0x55 >> >> Note that splat is from 4.11.4 and not staging. Although, the problem is >> still present. >> >> This can be solved by making the first operand unsigned int. >> >> Signed-off-by: Julien Grall > > Reviewed-by: Kevin Tian Thanks! I have committed the patch. Cheers, -- Julien Grall