From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 126505C613 for ; Tue, 6 Jan 2026 01:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767661907; cv=none; b=d1nMnxG4tYlaHijDYIOvACHj+xg4xUX0MYiQrFrhPZwHLKv8vQwZBaepl9H2W9JCpa5PGU7CoocJN2N/O+igpRZE0/r+gXlDNxYFrzmscY7v8bf5ySADQWNy3th4YyGCY6swfjZKAQ+ZEluKS+r3ilOK0TbXlP+dZCTXmTZGfNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767661907; c=relaxed/simple; bh=7QxghaDm861CKYRDD8kHL8SgeDsapiSRzVIH2YrlMbI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SmmAPL4WP3cMUIYUpJOY+3gCw3KNOdtwseCvYhb/8Gg2NnJTCPwXH4tpnOA0poeYkBofSQmqqmxexaFrqt2WqIRPcwP2qN5qJMBfSPTrK13cITdfOYwy4Nv+L8P0K1hue18BlmvPdc5eRQopCcL62gGIHEfuR/NT7yodz6TX1yY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=AzMHvCZ5; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="AzMHvCZ5" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-8b2a4b6876fso61032285a.3 for ; Mon, 05 Jan 2026 17:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1767661905; x=1768266705; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=0M6wACUwu7ZPlV5A2pQScdlqF/ktZzTx82xX4yJbmJQ=; b=AzMHvCZ5noUOLq76H3wgVDeZVga1PMYfveV3Vyyow3RFYK9ESGd9lgRmHFhn70uD2u q6W1LyIqdY+gmgQCpuXEyu3vrfmdD/vbuMdbW9+jYrt86ZKKG6KT2IAQigiNWPdecntF p849tiLWhNYRJ1BHICE3ccv/Q7OytK/X47nXuSiJD7+q6E7foEdZUE9wDrWtbdb+lzhL xE0elh8KgvlU6oTb0O69lA5cJMbvbOoypy2IXU0rABObknxui9aOxc72FFFc25121M2m HodQ99och5nkGKA7g5SyynsYLovyehxuhEJhnJ4+iSx4GuvwDZhnq/egQVK2FlPdTXh4 hj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767661905; x=1768266705; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0M6wACUwu7ZPlV5A2pQScdlqF/ktZzTx82xX4yJbmJQ=; b=EsDt3tNEmR90kflY3F6ebeshpMUUykfyZyUJlBRMDGD2JRXoUiTSECC5mt09cltaYW ETHAEGFoLnSZJJGzQPCW0VzVBlo7oq8Xh0vGpkj9BpuD7gNrJ30BN7n5869QJQf6xM1c XVTYgj0d0uLT6MAkH6NmMFsG5jdVyC/HCIoVQl9W1OQfHOANaAn2WAMxwFKY+4S4D+dH w6ZTYc1CAlLWsM7/th8D7Co7jazgb6SoJNQdaKf9P5q2lxuARUv/r46K4d6Z+8x/OMG6 fpLPjExGnsfO/fn9oSJlyEkTy4hDa+Lvno10t484Btj1ftuxqqluGn9k4lf0/sPW4Tvs CYmQ== X-Gm-Message-State: AOJu0Yyk0JXZujAri2Cq71DkJswLLD+jLfPtrnMRFF+kZ4JTO884OZ9O javIOPtZLQjrqo/h2t/334VhR53wA2W0NC1sXK3KQxapUh8yp4is2X68CvGQuV7jCz4= X-Gm-Gg: AY/fxX6FbZYMR8QOoN/V1hFJKKPKLg5I2xriHqFmWwWUbt8kcAPaU0HExxBE8R5IlFz 6JIWVPyn1baD6g+fzZovfR5R/NAjhTUn+VOkVqlYOVMoF90aLgzOM8bzh+ABRAgR1fNukIfSEBA 7XpZZmKHCzgPWi4XwYgBaT+IHM5F9DmtxDB819qHhBMIK0NNf8jDpq9nbGn3LNRxFX/YD/3DOMJ IWBGJhJjDw1uvXt3oHMUmZ7jyAq3y/ecQOTEbG45BxK6cN+yViiQHyryMgljTkgIiV0BsqgalKx mqAKculKmUFnoVVkrncCWzDmbhB5FcXnhHgGih6CQjLnNYG8ia6UZf45BDhNh/0OAo/Hyuv1gqI EgFJj3rH3zNN/vImFCYhfDz/L3FthQmy0iza4le6l9uYloZEwShW+QlSJ/FGsLOMbWq+1k6Uui/ rQ251yRLWfHApxlJDYiwAcyasUvXkqg0KvLapFa5l1OHSCMOrqXZMUjWPE0QJ8Q+0Zbeo= X-Google-Smtp-Source: AGHT+IFxbvXmsKhVoiNfeU0gqUSCgEVUTzTPmXjaEEUemMygzC5mzPD60qjzhxEZyV6lPJlPXUhCBg== X-Received: by 2002:a05:620a:7105:b0:8be:e044:8cfa with SMTP id af79cd13be357-8c37eb8143fmr221733485a.40.1767661904885; Mon, 05 Jan 2026 17:11:44 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c37f4c964csm67177785a.22.2026.01.05.17.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 17:11:44 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vcvbr-00000001Ecf-3FnI; Mon, 05 Jan 2026 21:11:43 -0400 Date: Mon, 5 Jan 2026 21:11:43 -0400 From: Jason Gunthorpe To: "Aneesh Kumar K.V (Arm)" Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-coco@lists.linux.dev, Catalin Marinas , will@kernel.org, maz@kernel.org, tglx@linutronix.de, robin.murphy@arm.com, suzuki.poulose@arm.com, akpm@linux-foundation.org, steven.price@arm.com Subject: Re: [PATCH v2 0/4] Enforce host page-size alignment for shared buffers Message-ID: <20260106011143.GP125261@ziepe.ca> References: <20251221160920.297689-1-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251221160920.297689-1-aneesh.kumar@kernel.org> On Sun, Dec 21, 2025 at 09:39:16PM +0530, Aneesh Kumar K.V (Arm) wrote: > Hi all, > > This patch series addresses alignment requirements for buffers shared between > private-memory guests and the host. > > When running private-memory guests, the guest kernel must apply additional > constraints when allocating buffers that are shared with the hypervisor. These > shared buffers are also accessed by the host kernel and therefore must be > aligned to the host’s page size. > > Architectures such as Arm can tolerate realm physical address space PFNs being > mapped as shared memory, as incorrect accesses are detected and reported as GPC > faults. However, relying on this mechanism alone is unsafe and can still lead to > kernel crashes. > > This is particularly likely when guest_memfd allocations are mmapped and > accessed from userspace. Once exposed to userspace, it is not possible to > guarantee that applications will only access the intended 4K shared region > rather than the full 64K page mapped into their address space. Such userspace > addresses may also be passed back into the kernel and accessed via the linear > map, potentially resulting in a GPC fault and a kernel crash. > > To address this, the series introduces a new helper, `mem_encrypt_align()`, > which allows callers to enforce the required alignment for shared buffers. This explanation makes sense, but to maybe bottom line the requirement to something very simple.. In ARM64 the guest shared/private granule size must be >= the hypervisor PAGE_SIZE, which may be larger than the VM's natural PAGE_SIZE. Meaning we have to go through an change all the places doing shared/private stuff to work on a shared/private granual size. I think this is not just alignment, but allocation size as well? Jason