From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (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 82045390981 for ; Thu, 2 Jul 2026 10:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782988759; cv=none; b=iNLazcKdAf/pkEQrQLho9B/7rbAVgmQ6/1QlVAzyLXOpvbos4M/OI3ogEFFdy/cEj7wpqWyxaBXRKljlZ4aucmTIRy4qMIrdjVy2GALMKG8Fay2h5QE4z/Tk84tbqrO5PNGNKbAFAz4DwT9I4OciyoH4kXgn1+DD1gazS0g/hMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782988759; c=relaxed/simple; bh=Jf+lw/4DCyppm63tP7dCDq4VU5ytrIjHJpO97z4Nh8Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cHSvBeO+HqKs2l5XHOIUA0JoJOazjDfX1ys8cANd1zw4b61P8sq4WzSd+9NRb5f1dukRacrS+kJm/Shf5S/TtcgkPRLAYv6XbQQqK1fdRA4KjNy3VTJlfiBWVP6MDAGlSadQO18RxJmLHas+pVgb6On4aM7humiMILkTs2SOi2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fN08XVyp; arc=none smtp.client-ip=209.85.218.73 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=flex--sebastianene.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fN08XVyp" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-c0b7b5536ddso137042666b.1 for ; Thu, 02 Jul 2026 03:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782988757; x=1783593557; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=S/B2rsvapQSn12m5d81J+topBC1cosRCvCMomhxQt+E=; b=fN08XVypErhJ4yW/F3BrSx5nr99GXl7huANp7xcn0Mn2RbCrDdQ+sifoZiwAIkjecp UpVAxfZUU9enfHUkwIiLKvgZpiTUlWcuGUtuU7iox4LY3FW+vaTOW0DtxLLL7/XSwB0p XI0OgjjzureQ1nwA13a4vxblwyCpINEG6FsHXJg3Mp0b6pBVDdsT3XkKTqdHwzgPqvO1 m7xIU5ePbR1WlC0z40eL5pvHUJzRqVDHteUuUCICcQ5+uMIP7S988rPqcmLzudYiXKS/ AmHwj+ozD1GfpzAdegVDSQ04bhwxugR9XD0MiswjL6RZh9JG7jwSxGjFdBwJXBel3C5E 2XGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782988757; x=1783593557; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=S/B2rsvapQSn12m5d81J+topBC1cosRCvCMomhxQt+E=; b=Yuxy1Zy1b8RRJkangcVl2EafmYgbbIDQb9tp/zUvDNHUJn/i0d1oAhNRaIOujcf/9i Hx2/IZQE/jbqi4wrCAn4X90e8mTA85VUi67Pfvyy9Mfke8a26XSV9VpqosV7yT3fQhv8 Ss5JVU16jbQAkQMLI0K6eknFeDfala3M03OpoYxvsSu1XbiorVu5w53HQ95p76ai6GQy wa8+diDQnWzPSiT9iQ2BTrPljPZg2Df4dM8uQkt+w+4nWrNkizXtB/UyHmCSmreIeEru yI/FVhIcDXnwtHwx4kiCih8OX0aFK0w2wUOxk2ZsxLpaFoBU+zYdpxQp2jKAGbVf/7p6 PVhg== X-Forwarded-Encrypted: i=1; AHgh+RqVMqZpAOJSGUTrKKG91tpYEe2jBriIvm57WobvqwB3FPzmmbkYb1a3iaodmtwGhPnUdqukRfsJDv6iEXA=@vger.kernel.org X-Gm-Message-State: AOJu0YwlZ9nM0DRXqtUEzC7oKcrKdVQnQBWK5+A1Og3ClPl2NEcM4Gn6 8E69D5MnVkLiVczsIZNe3RAqz6kEcn6LblqZlitMr1AIt9BRYxcRrLhsBvVNVV2qNLNRdbAhvh8 wq3qToXCijYDcKkRU3tNRi05mFP0QZA== X-Received: from ejcht18.prod.google.com ([2002:a17:907:6092:b0:c07:60f4:6d56]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:6c12:b0:bd5:18e8:1ac1 with SMTP id a640c23a62f3a-c12ae3ab429mr242035966b.5.1782988756892; Thu, 02 Jul 2026 03:39:16 -0700 (PDT) Date: Thu, 2 Jul 2026 10:38:42 +0000 In-Reply-To: <20260702103848.1647249-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260702103848.1647249-1-sebastianene@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260702103848.1647249-6-sebastianene@google.com> Subject: [PATCH v9 5/6] KVM: arm64: Ensure FFA ranges are page aligned From: Sebastian Ene To: catalin.marinas@arm.com, oupton@kernel.org, sudeep.holla@kernel.org, will@kernel.org Cc: 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, sebastianene@google.com, seiden@linux.ibm.com, smostafa@google.com, sumit.garg@kernel.org, suzuki.poulose@arm.com, vdonnefort@google.com, yuzenghui@huawei.com Content-Type: text/plain; charset="UTF-8" From: Mostafa Saleh Harden the check for the constituent memory region page alignment to prevent over-sharing when the negotiated FFA_PAGE_SIZE size is smaller than the system PAGE_SIZE. At the moment we only check that the size of the range is page aligned, and truncate the address to the page boundary which can annotate more memory than needed as being used by the FF-A. Fixes: 436090001776 ("KVM: arm64: Handle FFA_MEM_SHARE calls from the host") Signed-off-by: Mostafa Saleh Reviewed-by: Vincent Donnefort Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/ffa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 2e7ab7e3319d..9c96e72e522e 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -352,7 +352,7 @@ static u32 __ffa_host_share_ranges(struct ffa_mem_region_addr_range *ranges, u64 sz = (u64)range->pg_cnt * FFA_PAGE_SIZE; u64 pfn = hyp_phys_to_pfn(range->address); - if (!PAGE_ALIGNED(sz)) + if (!PAGE_ALIGNED(sz | range->address)) break; if (__pkvm_host_share_ffa(pfn, sz / PAGE_SIZE)) @@ -372,7 +372,7 @@ static u32 __ffa_host_unshare_ranges(struct ffa_mem_region_addr_range *ranges, u64 sz = (u64)range->pg_cnt * FFA_PAGE_SIZE; u64 pfn = hyp_phys_to_pfn(range->address); - if (!PAGE_ALIGNED(sz)) + if (!PAGE_ALIGNED(sz | range->address)) break; if (__pkvm_host_unshare_ffa(pfn, sz / PAGE_SIZE)) -- 2.55.0.rc0.799.gd6f94ed593-goog