From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 32C3E3E3141 for ; Tue, 30 Jun 2026 10:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782814987; cv=none; b=BGKwpVPk26rNu8cvH9TCPoRYmHvAkQ4lQzhQ0cgqJqp5en9u8mQa7LdzGAIdprCfxcblODAg3XH6tt9tAqxaueDCd2YyMBb9Z7Yv2pBap9WCBeuBuNL+vPyIMLkfqioFnQrGgTLW9bbTw8ST/LEMABdw1ytrkXMj1HRKuyzQhPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782814987; c=relaxed/simple; bh=xO1vPXr6jVIbv3ACOnD7BWtFjQzhqCaDlWJshtXaouc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mKnT99xkVp74xBSk1FWX2wpuojCdfVqvuIozLIz/8Yu8vIxw3MAL4bT/x67VleUw/k6drh8yqXpmsurcWXgkMwux7hkSAHyXC0BywZe04Hce0ZpsXdMGjHSvROVApp+CvSz6ETsx5vrl/UH+JzPvZgvg+83zfaIErFIU86Ys8TI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=G97qzq/2; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="G97qzq/2" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-49242f97da7so41775e9.0 for ; Tue, 30 Jun 2026 03:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782814984; x=1783419784; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7eQrlr1iqvdXSCnGA9eKw5Pz71hnIxvtQ5reJnEwINc=; b=G97qzq/2yYcDdF3c2IBc4U67JdD+AZWTMe7LgsM+e0tHFQCzpF5FeUe+73MrLPVDM8 GGXiWfWQsBzovVbk04AmIDOCfSt11joBytJBmAlE7lYIXc0RlCqzHVzJzxTIwuAkcZ4z FlZAz6n3+2LZJvEH0ZnaAm/UfDJVTij1+RXjW6gMYvRIDLzysObEwF3Q8/5Do3wzMuEE yNsC7vndirZ7J3WZs4vwe9ZyZjP8poyLECt59/yxmZdl0nPgwquQraQrc4H/nyeMFWTi aiENY0vBoLthTuKiGxq3YCR4RT5JjSMpkCubLD2Hzhz6WFzetbg2FWCQ61nPxUbx7q+A qAYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782814984; x=1783419784; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=7eQrlr1iqvdXSCnGA9eKw5Pz71hnIxvtQ5reJnEwINc=; b=ZWIorhGycnYHrAH80iunkHnKA0kw5Z+WOZq1qBMGG0s3zGj+y0/p6/eszND5yI+cIl q4U2iyR22MNF880Z+UozuL0+2sRX3IeEpPQHYoHJ6KIJxjr4BAkhpeUFdRIJgMn9q/rv MF5lk2aep41uQ5OnSzekvijlJ550yXM/BYSc8e0oIMisYU/3oYsD0Eb2zIBwmdmop0Ga eklFeW8HIwFwDL4VGctthXrdtjum8orGHY4PXtAvQlV+Sfpwd/MTgUVqKB8OZrFFhPYI 9dlNXuWXBaBRT7cKFYb4WcC8DljbWOfL1wup3EgS/CRfrd/bZDZhLQIETwB4tD3eaIzp 2bUQ== X-Forwarded-Encrypted: i=1; AFNElJ8LF+UbxESFvcXnkKsL+N8S+OZrFYzIPI7j5+JYllCzJXcyZXthIvMqUIdXfqhSOPeWoG0E4MeDUwEK9Q8=@vger.kernel.org X-Gm-Message-State: AOJu0YwP6Bb7ivFi5omwgi2QQK38inh+FpRuH0/dAkUC9U612dQH3jqD 8kBD7caI+FZ6rO/4bc8tnZBQuSu81hNy4kXmYUGUIaNrNjzjOANeYJT206MUM/wQfw== X-Gm-Gg: AfdE7clA0lLPOC1lEgvS+kLbXxsLcwqPubWrl06Z4fB9ct7iuByYQUa4bqbDGDc0OEb ge0Cctr8vbuztBu28wRYz/x8Y2eQkDy/30X5KFIDdsLDg7TusJDElWaQh1SmuGxpxgZXR3YNdy5 ikzJ6d4oI3XuZxWLPasBfo1cIMquqkI6xWZ8PugOnGk36BUjpD1sRhglVPUUBN1d/zL+KCZnWxy eP/A2sOv3PpSs3481L0jdRz5zH9/eCiuxQfujtX6NijikVFeof3Uas+tNFNzV/OaYx8QsNREGk0 ucCoOmTraj0TnERGbKIsJ72P6qWzh7e65SiJu/DR7TSWk8lga9hF0BvzwWLOVjmGlLsCqUlMtC+ 3DUJiGoUGv6BYUXhKvdQQDjF27w2fJKfvwGd2UoGxCxRJBn+ezjOVpiqbyOU26WqiQcIKDAniWM YKFAboc8xcEpqkVn21H4cZ4yVBHJ9jYA5i5fP1qSgSK7qOUZXQ+nzbdMPkkakV7A== X-Received: by 2002:a05:600c:4314:b0:493:b86f:c913 with SMTP id 5b1f17b1804b1-493bd77921amr14605e9.1.1782814984019; Tue, 30 Jun 2026 03:23:04 -0700 (PDT) Received: from google.com (140.240.76.34.bc.googleusercontent.com. [34.76.240.140]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493b8cd8bccsm63196105e9.8.2026.06.30.03.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 03:23:03 -0700 (PDT) Date: Tue, 30 Jun 2026 10:22:59 +0000 From: Mostafa Saleh To: Sebastian Ene Cc: Vincent Donnefort , catalin.marinas@arm.com, oupton@kernel.org, sudeep.holla@kernel.org, will@kernel.org, jens.wiklander@linaro.org, joey.gouly@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, maz@kernel.org, mrigendra.chaubey@gmail.com, op-tee@lists.trustedfirmware.org, perlarsen@google.com, seiden@linux.ibm.com, sumit.garg@kernel.org, suzuki.poulose@arm.com, yuzenghui@huawei.com Subject: Re: [PATCH v7 6/7] KVM: arm64: Ensure FFA ranges are page aligned Message-ID: References: <20260617145130.3729015-1-sebastianene@google.com> <20260617145130.3729015-7-sebastianene@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: > Hey Vincent, > > > I failed to parse this > > > > But I see > > > > /* The base IPA of the constituent memory region, aligned to 4 kiB */ > > > > So it sounds fair to prevent oversharing when PAGE_SIZE > 4KiB > > > > I think the problem is when you have a mismatch between FFA_PAGE_SIZE > and the system PAGE_SIZE. We expect a fixed FFA_PAGE_SIZE of 4kb and > this is enforced by : > https://elixir.bootlin.com/linux/v7.1.2/source/arch/arm64/kvm/hyp/nvhe/ffa.c#L761 > > if FFA_PAGE_SIZE = 4kb and PAGE_SIZE = 16kb you can end up annotating more pages with FF-A then > needed when the range->address is unaligned. > > It took me a while to understand this so I guess it is better to rephrase the commit msg. The problem here is that we only check alignment for size and not the address. And the code later (__pkvm_host_unshare_ffa()) uses pfn which truncates the extra bits. So, in case we have an unaligned address and an aligned the size, it will round down the address while the actual size spans an extra page. For example if base = 0xFFF and size = 0x1000. pKVM will share (0-0x1000) while the actual range spans till 0x1FFF causing FFA to access an extra page that was not shared by pKVM. Thanks, Mostafa