From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B12EC7619A for ; Wed, 5 Apr 2023 06:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236670AbjDEGHL (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@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