Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp245861rwl; Tue, 4 Apr 2023 23:09:58 -0700 (PDT) X-Google-Smtp-Source: AKy350bs0bTgnp3m9tMncoiaU6Aq5L2TE3sUwjyKUP8iRcmNTu/IvsLPSCUzScr66/ReYurM9W9R X-Received: by 2002:aa7:9425:0:b0:625:c9bd:57de with SMTP id y5-20020aa79425000000b00625c9bd57demr3993573pfo.30.1680674997677; Tue, 04 Apr 2023 23:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680674997; cv=none; d=google.com; s=arc-20160816; b=bZWzl0Vwxk/FPBY+qlhZCU6Y8qmxpOKjoMX2slYaqWrXWqySjwwTJvbrsEJH+GucKV 5SbcTmnrbt0OeteMF8zHQm3mJryZSg6wRpnepkijEB/q4+U71njJdAuZRSIjNoo4F0vg n3SH0qdciKmHmfm+fQJpQn+U26QzrEPjE2vR5AvszQEYC4j5Hj1auHKHR1aeWMqz8ggS 7gZFCkB1jSeCpGxsBoI8+dHqatHN24keU1zjVjrve7DqrgguokCGkXdpZ0ZLcfjnnnvE J0cd9JAqmZtJ+Ik6/oPFfJiv+TIbihFhR2k2o9ZdqplGtRIard+mpO1f8AmnDJZlBEMa wqhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=E47lcGeX7oRDxZbyOSFg0jGNPGzor2gT02CjEeXUgmg=; b=jIjibixravjEURMe6q1zLKJDY/OOOmvB0EUkS2XmItr8son+w+6aRc1l7oGbd8ZJM5 f+TPPFICgxfpVdpx/nchwqqPjE1th3PCWrXIWTxKV6NKAc32AWxlPI+crQP10WU3Im1u lFOzCj45riVqO8mvs2T5bnxm5j5QeVlGPFzPxjVhpEjF/RFCz7rWgGfszh2Mv2O43EVq PGNHtt8c6CQddCAGTH7JWLd8ZjNhowep4mpVMZ0jpWaBt+iSUM1VG6SuUmOxUXqoOBZX c4w762ACGbSrfEg3k6ekxSIdmDtXLzNu822oREWBlxZoxueXsUvIHDDs6Y1BBm2QD8XE 29wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=lMtq3AFX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a63fa46000000b0050be5b718ebsi11242965pgk.272.2023.04.04.23.09.39; Tue, 04 Apr 2023 23:09:57 -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=@tesarici.cz header.s=mail header.b=lMtq3AFX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236897AbjDEGHL (ORCPT + 99 others); Wed, 5 Apr 2023 02:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjDEGHK (ORCPT ); Wed, 5 Apr 2023 02:07:10 -0400 Received: from bee.tesarici.cz (bee.tesarici.cz [IPv6:2a03:3b40:fe:2d4::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3955173A; Tue, 4 Apr 2023 23:07:07 -0700 (PDT) Received: from meshulam.tesarici.cz (unknown [213.235.133.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 930E71488AE; Wed, 5 Apr 2023 08:07:04 +0200 (CEST) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=none dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tesarici.cz; s=mail; t=1680674825; bh=E47lcGeX7oRDxZbyOSFg0jGNPGzor2gT02CjEeXUgmg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lMtq3AFXTTmDJx+MKXTAwJMv2djOS0e94inGODa70g4Yqfl72zlkQBBta/TKqIQol xa8ZSfSi0QbAEjnm6YAyzrDwLFe30Fhh8hfcxozIWw6wroUNoaa5CEopVBa1V5trZn hm37zZTyw4QBJUgvkzFKQW1Smer3o6p8HDJ+1JoxKW+7T8diWqCF663QDDx1akkagl 4jQIELn20eP9it18itCfTGcc97jsSdsDmNVrD+RnvpBAMaqhYWk1WJE5b79m/TeDz5 QqaEQQYi+2IKEQJ9TmjmxoG0phbVpkdXUlTiy8ZA/9FxhrPwWwi+6LTfNpH4MculWS SbRWQNAyqhfUw== Date: Wed, 5 Apr 2023 08:07:03 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Dexuan Cui Cc: Dexuan-Linux Cui , Petr Tesarik , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Konrad Rzeszutek Wilk , Jianxiong Gao , David Stevens , Joerg Roedel , "open list:DMA MAPPING HELPERS" , open list , Roberto Sassu , "Michael Kelley (LINUX)" , Tianyu Lan , "linux-hyperv@vger.kernel.org" Subject: Re: [PATCH v1 2/2] swiotlb: Fix slot alignment checks Message-ID: <20230405080703.61c6d60a@meshulam.tesarici.cz> In-Reply-To: References: <20230405064019.6258ebb3@meshulam.tesarici.cz> <20230405072801.05bb94ef@meshulam.tesarici.cz> <20230405075034.3c36bb77@meshulam.tesarici.cz> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: *** 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 Wed, 5 Apr 2023 06:00:13 +0000 Dexuan Cui wrote: > > From: Petr Tesa=C5=99=C3=ADk > > Sent: Tuesday, April 4, 2023 10:51 PM =20 > > > ... > > > Argh, you're right. This is a braino. The alignment mask is in fact an > > > INVERTED mask, i.e. it masks off bits that are not relevant for the > > > alignment. The more strict alignment needed the more bits must be set, > > > so the individual alignment constraints must be combined with an OR > > > instead of an AND. > > > > > > Can you apply the following change and check if it fixes the issue? = =20 > >=20 > > Actually, this will not work either. The mask is used to mask off both = =20 > It works for me. Yes, as long as the original (non-bounced) address is aligned at least to a 2K boundary, it appears to work. ;-) > > high address bits and low address bits (below swiotlb slot granularity). > >=20 > > What should help is this: > > ... =20 > This also works for me. >=20 > Thanks, *either* version can resolve the issue for me :-) Thank you for testing! I will write a proper commit message and submit a fix. Embarassing... *sigh* Can I add your Tested-by? Petr T