Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2221975rwa; Mon, 22 Aug 2022 04:29:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jC4n31PiUHr2NqkxJVKWQLLVXmNgTZtkCLZsTZwR3CWMAkjPCN3tMTn7QvifYvyAevs/p X-Received: by 2002:a17:907:2da4:b0:731:2772:59d9 with SMTP id gt36-20020a1709072da400b00731277259d9mr12252662ejc.751.1661167783539; Mon, 22 Aug 2022 04:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661167783; cv=none; d=google.com; s=arc-20160816; b=uzbvRZE55hJfSVGM/G2A9owa0btAC8qacO/3P6smXy9fBAehmERmhTgKpWaLzzNEG9 SdOrSgW1DJMManZ0XcizgRiZ5SCBXhXq9wMUoGsF2yE7GCEZ+wv2P2Hdvww79r5be/MC GbafPMqvu+GhfPu5rxNSZ3nAgDkEe31x9pOIgGDFfg/vI0ZnRDsIO8RqqU3lO+xeTPab T8+LIRn8cDs8Rt+0x3dVS0GR0w85JJ7i43BgSR+KuHKcfb4AuqydFBf8XgRo0i3W+wzc 7WbmT6jzJnHBbXcQ+fsPCvRgKYIRkF3HUOt7RaHqYgxEGidg+tbaJfEQHop89jeEcOYC OmVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YNVjeYI2nPEVx61J8iSfNtxwDJBnDqCx6z5D+BwBZZw=; b=lE1h+6t5wGz1WYj8Y5yWWkkONFhU/IqFQ8Gb3MEgywxa2exe6WnVv8uwxaSOtPSMG3 VMh8RO7asr36ab8As3kCWHmgmz8X/IrZcDNWnMfcu3F5kNXlpPV+69CSwKZZf4+guG42 +beUig8XriQLwrAQzATknKG+ABoaFQAVzKpj1q8fnyXrll/UEXrb6+ZFjZVJoAwQq80U w2u7/K8quxNod5yifaejaCphb+S3p9QlPIilKAOst5euC+z788dsZhYbqyBMMHQuYBk9 q6QK6RQGj7dgpjry7c0fg0bfsEfA2bU8i+KR03QbBykNlsIOyCilwhjtm6IG1g4GLrtU HCyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Jxf1IV4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b0072ee27ef788si7209627ejc.838.2022.08.22.04.29.17; Mon, 22 Aug 2022 04:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Jxf1IV4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbiHVLRW (ORCPT + 99 others); Mon, 22 Aug 2022 07:17:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbiHVLRS (ORCPT ); Mon, 22 Aug 2022 07:17:18 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C41A32D8D for ; Mon, 22 Aug 2022 04:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YNVjeYI2nPEVx61J8iSfNtxwDJBnDqCx6z5D+BwBZZw=; b=Jxf1IV4W3/EzX0MGWvdwzKDwng zPOG5m4IJYNsD2JWFxqyawSMhMglPzWldAw8JvaWuMCTOIZx94xvPb3myseWMOu3j8R3cit3OzagE vatWXcsl+50NPOi8T9KpySW1c51HGPDIc1Z56HCE3OJ1Ss5FPzoE9GVZVpio+DJu95/CzS7Vwt9k2 e7lsG9nJrcxAIxTrF7GOJVXlNrWq9yT7Bgg0ZO4Hn6grEnJwG85/yma7sYSN/nJP3d/5wZK6Hh0Gn tKiPrpfOkmdaU4hLU6l92zv4L8xF5tLZMAX+3/nCbjLM9xZ0UZ4WXv/rH3P7C2eplPa8v37jlP0nD +Z4iNrDQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ5QT-0083BY-TY; Mon, 22 Aug 2022 11:17:02 +0000 Date: Mon, 22 Aug 2022 04:17:01 -0700 From: Christoph Hellwig To: Chao Gao Cc: Dongli Zhang , linux-kernel@vger.kernel.org, iommu@lists.linux.dev, hch@infradead.org, m.szyprowski@samsung.com, robin.murphy@arm.com, jxgao@google.com, konrad.wilk@oracle.com Subject: Re: [PATCH v2] swiotlb: avoid potential left shift overflow Message-ID: References: <20220819084537.52374-1-chao.gao@intel.com> <38c58aa0-11c7-f553-95fd-292fd4944a75@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 20, 2022 at 09:42:38AM +0800, Chao Gao wrote: > In an internal effort to measure the impact of swiotlb size to IO > performance of confidential VM (e.g., TDX VM), we simply added > SWIOTLB_ANY to the default io_tlb_mem to lift the restriction on swiotlb > size. Then we hit this issue and worked out this fix. I posted this > fix because I think the fix by itself is helpful because it removes the > implicit dependency of the left-shift in slot_addr() on swiotlb size and > then someone trying to lift the size limitation won't hit the same issue. SWIOTLB_ANY is used for real, so I think this is a legitimate fix. I'll apply it.