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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 62EA4CEFC23 for ; Tue, 8 Oct 2024 15:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YsqpEHSxQs1WSXGDQ6CWUY1+FoJF5J2RonY3yGje8Cw=; b=4XQm/PWqt9y2aVaLDKMiFM5G8g 3IK5KpO5+63ZHmCvlb2D8hnrDh6zbLM91YImFovuxqBLs23F0Tkls86CWXk/VRPR5Kp2fcbPvL2PE rKuUF6ZA5QuZHiygnAp7uPoMmVSxNsdNBto55SBbKFIEJexdRMcNZT2om+bw+dEk8yRz2RxFHPP6M QECADX0yCe8xkQcY+QSM7Ig+oXLu/FjHlIV4iepAzq1qnKmsobYYiset6IlFltxlzs475/gqsaBQW JjcQZBaAj8O6MeAW7f7RVmpPivzN2wOPF4iGH6Z/7BIlRzLYrg/vD110Gzjms/+MsEFKvAOvcOhmB W0II+qrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syBwy-00000006Kb5-48Bm; Tue, 08 Oct 2024 15:16:36 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syBvb-00000006KN0-0uJC for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2024 15:15:15 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7afcd322cabso40472685a.1 for ; Tue, 08 Oct 2024 08:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1728400508; x=1729005308; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YsqpEHSxQs1WSXGDQ6CWUY1+FoJF5J2RonY3yGje8Cw=; b=CjGc0ZaI0cNwELluqCdIAGo81XZUcMxgGZDOLh+nhYmyUFi597SNwOl4OON5BtlJYS xYMMwAqeSUGjdUxSfWDAuWAkG+BAc1jPCTFBD09ZIGH1ZQrkBXFRCha4A9CRRvFgUuzz 71iNbYTPd8o2eCl4MQcgqDuuMBnssYiciBcmwe2Yu8x8VNX2RosKzznk9WrEBXxeszmK 8DRhXQEChA/HY/l8I25tFw/amis9EqFUQrNkh8zdB9WeSFpJKepsbTqO48xBR4feLUvl d+xF/qAuHYUXCyu/jYDhQdKwE/GU/fskAnfPn780cpD+WR30KZFlXkVyf7UJ7wIPYT1a +6fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728400508; x=1729005308; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YsqpEHSxQs1WSXGDQ6CWUY1+FoJF5J2RonY3yGje8Cw=; b=gC5NC8JIwoICcaESN7nuAH8aHohikWORClez2mHHupjHkcvNbzVDZA7WG+JY5ZqTP/ me73DVCz4/DhE5nMxp/8bT60IzILLi741xFNVXlJK4pJdetz9NJZJ5xkvkA/ZJ8fdhh1 FcCWz1gyTA3TaCJ2A7L4J1OHKrLk5UVl+Zd/HCiw5eOxuFfOSi4nLQc3yN9jU/Y1VX4z gakJvxJag+1ptOfrNggQtEqDYTqWksxB9KBBdZj/ITY4VMaw7J0/i5nlzbCStWXhGUWp nia2hRwgq4xW5PaHIdRlT1G3rYzcg8keojfrSttXF7KESdcrBXMH559ihO8SG7IGFbpo Gppw== X-Forwarded-Encrypted: i=1; AJvYcCXYCtiS4DDLNa4ogsssieRU6A98yDNBXxHy50Xd3bBOTl8pLWC2htt8b7mMYrGI15RHJBJMkW4VNj0cvcdFojSx@lists.infradead.org X-Gm-Message-State: AOJu0YyUY3HlzUFYrAFOHmR6BKVijfPsIWbI+tKliCJ093J0FpChdvmv ar0MZy33WAErvn9xZOqO0PhyUEtxFJ23RuvAuJci6eO3KBGv5/TQgj0IVmpsvLs= X-Google-Smtp-Source: AGHT+IH2uRC2UfcD0r1BF9aCv8jK6ZDJjGODQUbS2anKumzSrd3t/zuWy5T9g/mXSSYSymaMjGgK/Q== X-Received: by 2002:a05:620a:192a:b0:7a9:b114:471d with SMTP id af79cd13be357-7ae6f4541a6mr2723208285a.33.1728400508653; Tue, 08 Oct 2024 08:15:08 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-128-5.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.128.5]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae75764d2dsm361159185a.117.2024.10.08.08.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 08:15:07 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1syBvW-00684j-QA; Tue, 08 Oct 2024 12:15:06 -0300 Date: Tue, 8 Oct 2024 12:15:06 -0300 From: Jason Gunthorpe To: Will Deacon Cc: Yang Shi , nicolinc@nvidia.com, james.morse@arm.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [v3 PATCH] iommu/arm-smmu-v3: Fix L1 stream table index calculation for 32-bit sid size Message-ID: <20241008151506.GC762027@ziepe.ca> References: <20241004180405.555194-1-yang@os.amperecomputing.com> <20241008133458.GA10474@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241008133458.GA10474@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241008_081514_468931_05E8C8BE X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 08, 2024 at 02:34:58PM +0100, Will Deacon wrote: > This all looks a bit messy to me. The architecture guarantees that > 2-level stream tables are supported once we hit 7-bit SIDs and, although > the driver relaxes this to > 8-bit SIDs, we'll never run into overflow > problems in the linear table code above. My original point was about the confidential compute position (sigh) that the untrusted hypverisor should not corrupt the driver. So your statement is architecturally true, but we never check that IDR0_ST_LVL_2LVL is set if IDR1_SIDSIZE > 2**7, and so we can get into this situation where the hypervisor could trigger some kind of bad behavior. > So I'm inclined to take Daniel's one-liner [1] which just chucks the > 'ULL' suffix into the 2-level case. Otherwise, we're in a weird I think you should take it and let better be for the CC crowd. Jason