From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-242.mta1.migadu.com [95.215.58.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16B8B3C76AD for ; Mon, 17 Aug 2026 12:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.242 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786968661; cv=none; b=qDIW3OYm2Mczh/Px4y+/NdEg/v3LW6z/0KunLLUB24AM5skPeCNLjEJ5UtWN/vUyxpPVlS9RKfMdz9HEAyIOVhvX8y7mOBQbhkqNgoh1gf1ScC5o9q2EJw04BVgaiofIXoXXZZafdtT5hLMq1HYoL3ifexboY5TtOQuoLu13z+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786968661; c=relaxed/simple; bh=HixNdaF24ntDEuguIuhpK7haYmS/JSSrlBPi1Y1tptI=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=tDl70I/dWI4Wzi+wgiaaKsYha9de2iX8oXDi6N+N8Jiq9A653tqH53uxAZGA9zdADxqXL/oRwUiW4vXRLl2P9dnZDCGpjjPex8CCie+DIIET1OKs3g4mRn6pkahmibypIwPfuhhzJPYquJPbTpwL4CCmdqfnjqINXxgpT30ghxo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QeEsg/dq; arc=none smtp.client-ip=95.215.58.242 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QeEsg/dq" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=HixNdaF24ntDEuguIuhpK7haYmS/JSSrlBPi1Y1tptI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786968655; v=1; x=1787573455; b=QeEsg/dqo1TZKqifzrBNzsykZmrFrlTHIwqmU/NfoUZuilMqfjcwRFQWsUqqIc1hgw0/A0kg JvEop+e9FDiowsS/ZKpFBBgvwCfaYypnG3Eq7CzMxKIlFsxztHVZ7HgwayE3nz2eXd+UkW0TJqe HoN2VbcomdRbSPmB6Q4EDzfU= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost (185.201.63.253) by smtp.migadu.com with ESMTPS id f0badc6dc42a8a86; Mon, 17 Aug 2026 12:10:55 +0000 X-Migadu-Flow: FLOW_OUT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 17 Aug 2026 14:10:39 +0200 Message-Id: Cc: =?utf-8?q?Adrian_Barna=C5=9B?= , "Albert Ou" , "Alexander Gordeev" , "Alexandre Ghiti" , "Andy Lutomirski" , "Borislav Petkov" , "Brendan Jackman" , "Catalin Marinas" , "Christian Borntraeger" , "Dave Hansen" , "David Hildenbrand" , "Gerald Schaefer" , "Heiko Carstens" , "Huacai Chen" , "Ingo Molnar" , "Len Brown" , "Palmer Dabbelt" , "Paul Walmsley" , "Pavel Machek" , "Peter Zijlstra" , "H. Peter Anvin" , "Rafael J. Wysocki" , "Ryan Roberts" , "Sven Schnelle" , "Thomas Gleixner" , "Uladzislau Rezki" , "Vasily Gorbik" , "WANG Xuerui" , "Will Deacon" , , , , , , , , Subject: Re: [PATCH 1/6] set_memory: add number of pages parameter to set_direct_map APIs From: "Brendan Jackman" To: "Mike Rapoport (Microsoft)" , "Andrew Morton" X-Mailer: aerc 0.21.0 References: <20260816-execmem-set-vm-perms-v0-2-v1-0-90944a3ad43f@kernel.org> <20260816-execmem-set-vm-perms-v0-2-v1-1-90944a3ad43f@kernel.org> In-Reply-To: <20260816-execmem-set-vm-perms-v0-2-v1-1-90944a3ad43f@kernel.org> On Sun Aug 16, 2026 at 12:59 PM CEST, Mike Rapoport (Microsoft) wrote: > When set_direct_map APIs were introduced by the commit d253ca0c3865 > ("x86/mm/cpa: Add set_direct_map_*() functions") the single page > parameter made sense because the initial callers (vmalloc and > hibernation) had sets of unsorted struct pages that required changes of > their mappings in the direct map. > > Since there is an increasing demand for direct map manipulation and it > is also desirable to be able to update larger physically contiguous > mappings, for example an entire large folio, extend set_direct_map APIs > to receive number of pages parameter. > > As there is still only a handful of callers, change the existing > functions directly and update all the call sites rather than adding > wrappers for single page case. > > Signed-off-by: Mike Rapoport (Microsoft) I think if we add this arg we also need to specify how the implementations are supposed to behave when they fail midway? IIUC the incumbent answer for stuff like this is: - The implementation might leave partial modifications behind when it fails. The caller needs to deal with that. - ... But, that's gonna be due to allocation failure. So the caller can just do the inverse operation in the failure path as a cleanup, and assume that inverse operation succeeds since the pagetables are already allocated up to the failure point. I guess it's worth making that a sort of explicit contract since it makes certain implementation details load-bearing, e.g. I think... - It forces the pagetable update algorithm to work in a fixed order. - it forbids us to e.g. merge PTEs into a PMD if the region might be pending such a cleanup, since it would force that cleanup to reallocate a PTE table.