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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0C9CC7EE31 for ; Thu, 26 Jun 2025 18:45:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5463F6B00A0; Thu, 26 Jun 2025 14:45:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F6FB6B00AB; Thu, 26 Jun 2025 14:45:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E6EC6B00AC; Thu, 26 Jun 2025 14:45:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 28F706B00A0 for ; Thu, 26 Jun 2025 14:45:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B135C1D3DB9 for ; Thu, 26 Jun 2025 18:45:12 +0000 (UTC) X-FDA: 83598429264.23.FE443F2 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf16.hostedemail.com (Postfix) with ESMTP id C1588180010 for ; Thu, 26 Jun 2025 18:45:10 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hLP472CC; spf=pass (imf16.hostedemail.com: domain of leon@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750963511; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zqOZ0nvJoY2kvs0ans1k/jor+XKnKoBEFfFm8tFXKgw=; b=VRFpsZoUMpNZYzr4DxtMCh65n4LiJJQi2SB9yG5vYUd1wHw0SFoS9G74OEBn/wEsiyNA9E sdGpTZfxpqr01GWSFWST1PlkmkydOALs0PIBt3OxTJOgKQuF28l6/OBbj0MVtPHy6rOo7A 2rnKpOgLKK2QQPmDn1oPRttvcihpo8w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hLP472CC; spf=pass (imf16.hostedemail.com: domain of leon@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750963511; a=rsa-sha256; cv=none; b=VotY4+A3qlHdb9goo6Qmh6iRvGJR8FH99SQJzZweoJKEGSou69b4aG0+airdaLEA+2YDpw NjIf6qO+SMU04YnhqAeTh0fvMbrCGojO9m4G9lKnq0YhcVZif09inuRRrsSYSHlaRzFoIZ KfvofLVBvTcYipbl3RGXRhsqsTnyQrs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id A3BCB4375D; Thu, 26 Jun 2025 18:45:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC281C4CEEB; Thu, 26 Jun 2025 18:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750963509; bh=qpuwIbsfFlx+vQqZ7u2g19cFy4P5mUElZNbXy5mDaBA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hLP472CCTg+PhX1yKdunFpJsdMOjYvhGyAgWrimK7DWPKkMd17pKMc1fIfwaPlCPA JIJRXr+shFAtyLcZe8XBwbY11mrvGDzVdJ3RsltqtREBwQkFGd8GfGcQGFurfXwhRi Gh6t0AupUp/xt8ImCbK8nrHJ6hmurZkalNqu+4nWd0M/d9ZfOF4iAVk+oNuFVT055z IXMV0SFHieGPFmST8cP/2Lrg5B0eeTJyP2e7jxgpdTCHDGUFGS4ovBwL7ynEjAeKFJ dwGKMZLnO96ObPriGbwvv4YKtLXuQsSnKwE/DIyBvIi2T6xOA6FnnFe1RuVAtw0cbK QWmFFBkB6n4+g== Date: Thu, 26 Jun 2025 21:45:04 +0300 From: Leon Romanovsky To: Alexander Potapenko Cc: Marek Szyprowski , Christoph Hellwig , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Robin Murphy , Joerg Roedel , Will Deacon , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Marco Elver , Dmitry Vyukov , Masami Hiramatsu , Mathieu Desnoyers , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux.dev, virtualization@lists.linux.dev, kasan-dev@googlegroups.com, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 5/8] kmsan: convert kmsan_handle_dma to use physical addresses Message-ID: <20250626184504.GK17401@unreal> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: C1588180010 X-Stat-Signature: 75fign98sif4tm9qcnfjx4wi5rrafh1r X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1750963510-954982 X-HE-Meta: U2FsdGVkX19Skc7ONonMNQ5aU5i5plsiu5UWj/aavAqSzfwqBTa5ryeiFWR8PS1cV8/R0R3lwYjQKCdWTLZtGaqWBaFzai1oc0bkyw4gLt2Uw0ozDzTxgUXQGlw1pj1yzYQ9P+r81X9RnOq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sIZ3u0PjN2qionH8QpR0IVXNPSImuq5LUcgOVPCcxgFa7lECnvyLaiH+cFFqDG9Fq5423xTAD/u8UV+wL/y6DsrltnRRw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jun 26, 2025 at 07:43:06PM +0200, Alexander Potapenko wrote: > On Wed, Jun 25, 2025 at 3:19 PM Leon Romanovsky wrote: > > > > From: Leon Romanovsky > > Hi Leon, > > > > > Convert the KMSAN DMA handling function from page-based to physical > > address-based interface. > > > > The refactoring renames kmsan_handle_dma() parameters from accepting > > (struct page *page, size_t offset, size_t size) to (phys_addr_t phys, > > size_t size). > > Could you please elaborate a bit why this is needed? Are you fixing > some particular issue? It is soft of the fix and improvement at the same time. Improvement: It allows direct call to kmsan_handle_dma() without need to convert from phys_addr_t to struct page for newly introduced dma_map_phys() routine. Fix: It prevents us from executing kmsan for addresses that don't have struct page (for example PCI_P2PDMA_MAP_THRU_HOST_BRIDGE pages), which we are doing with original code. dma_map_sg_attrs() -> __dma_map_sg_attrs() -> dma_direct_map_sg() -> PCI_P2PDMA_MAP_THRU_HOST_BRIDGE and nents > 0 -> kmsan_handle_dma_sg(); -> kmsan_handle_dma(g_page(item) <---- this is "fake" page. We are trying to build DMA API that doesn't require struct pages. > > > A PFN_VALID check is added to prevent KMSAN operations > > on non-page memory, preventing from non struct page backed address, > > > > As part of this change, support for highmem addresses is implemented > > using kmap_local_page() to handle both lowmem and highmem regions > > properly. All callers throughout the codebase are updated to use the > > new phys_addr_t based interface. > > KMSAN only works on 64-bit systems, do we actually have highmem on any of these? I don't know, but the original code had this check: 344 if (PageHighMem(page)) 345 return; Thanks