From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.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 D1F503164AA for ; Tue, 26 May 2026 15:19:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808796; cv=none; b=A7KpiPCyyo7HfujC2hHpLYmJcX8VeN8BdcSvw9B6ccp7MDlxACy2SkJA5zR0n7ChO8kMjSUlgc/AgjeKBmzePkMOh1df86U96q6CGyTI1m/f81jcIW75LCuLzmfk+3N764PMaoVZDgPWTVTzlXie721oHsFR+85hmhRgSKTizkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808796; c=relaxed/simple; bh=g2V0AM6ILggz6CDLnm+0G6e8Ih7ixVmLsP2s6I6BhEI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VqEdIgH1doLBwC+9/WyRu/BEo91XoBTJ6mJjDHX+n2LEjkVn364Z85kKfanm/SdkQi3C8BZtAbJgZuvXVdJRWxT677kXTdYRr0uBr3qh1takSV66icNqbuf7wxPft7rTjzkIvmGexc7Ag68DFwVt7k5ak52ezorPMlsToqT4VE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ikwP8aae; arc=none smtp.client-ip=209.85.221.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--smostafa.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ikwP8aae" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-44f65835b77so7761107f8f.2 for ; Tue, 26 May 2026 08:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779808793; x=1780413593; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=85gj1ffDyGndAMiyS2A+jf4wwjz9v1ON8M3WpC1uUQ4=; b=ikwP8aaexgLe2k0J7ojr0+MTinbVwSnwQ0Vral41tJMKV/MS4xGOLJfAiRdQlz6vCh du1Af58GoG1T0K1QbRX8uNjynyoq+v/IYknHh4H/TvgZmaiQo2RMkb1k+poQt3Dg558a J/n9i/LaSfJLHdfVoBjz2E6CIHycumdUtZHK0MLi7HrYIJZOXTdAouVqkkksqNXddS9B ds806FS52Nsijx/TNms7ABugJcQEpExEgoNlJhun21ZY1NRs88zB/B+O3tWI4sg0kkI1 fyHaQJNodHsmNmYPyqMKjtCZOCMi+T3F2EcB80WgHJySjm3fZtc8hEN0cv9pgz/+0gON s/2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779808793; x=1780413593; h=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; bh=85gj1ffDyGndAMiyS2A+jf4wwjz9v1ON8M3WpC1uUQ4=; b=nKotqflLsXMXzR1j1SWZMEIhfA0bSJDLi90Gg4SESMKexvhSCZbB+KiH+ePjpYBqys P+/P84u2GV4L4YFd77tufLB5hRbnApNXb8Ph6nWijQTvCuJQp1/E5xMrhdq6dFXYDZra 7Ia2Z+3QLPYNwdnSzt5UM+m5DKaRvzuedriUZ0LF17NdN7N0krkyCMrPqIUDSU5tEsd2 /zEi66NWq2SiSvPq93KnBDLqzJmCz90mFoIDyuDnad3Oeqtle6ufdp6xZkW2adkBHmNP iUnuU418WxEuGXlzghWphyQm2XgzcHLdR/z4s30uQ12dXt9Z1LPgA9FwVKxkjWeq/0a7 7yzQ== X-Forwarded-Encrypted: i=1; AFNElJ8YALcgCkVkBtVezFjIVZ6k6aYo3cDKeKVfAfxbngni7HTXS5FGIeMzBr/UytMp3kcQlSFtyQFrwbxqmIk=@vger.kernel.org X-Gm-Message-State: AOJu0YxU7dNnJZ1sgwgVeMBo87ZBGSaWUlLo4LfuKEal/NMOMtyM7S5c rZz+reG7QGQZj1sy79JksbUHDYaL3/vXlaZKkS9ymYtwklyBdVdL8t7jJj9DvpBbbwtCJ6++SDJ aphR3t/YYDSmZRw== X-Received: from wrbdq16.prod.google.com ([2002:a05:6000:cd0:b0:43f:dbbf:52fd]) (user=smostafa job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2883:b0:43c:f66e:f24 with SMTP id ffacd0b85a97d-45eb38c8b80mr33942919f8f.35.1779808792997; Tue, 26 May 2026 08:19:52 -0700 (PDT) Date: Tue, 26 May 2026 15:19:34 +0000 In-Reply-To: <20260526151934.3783707-1-smostafa@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260526151934.3783707-1-smostafa@google.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260526151934.3783707-7-smostafa@google.com> Subject: [PATCH v5 6/6] KVM: arm64: Ensure FFA ranges are page aligned From: Mostafa Saleh To: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: maz@kernel.org, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, jens.wiklander@linaro.org, sumit.garg@kernel.org, sebastianene@google.com, vdonnefort@google.com, sudeep.holla@kernel.org, Mostafa Saleh Content-Type: text/plain; charset="UTF-8" At the moment we only check that the size of the range is page aligned, and truncate the address to the page boundary. This make an assumption that TZ will do the same. Harden this check by also checking that the base address is aligned and reject it otherwise. Signed-off-by: Mostafa Saleh --- 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 79de358333e4..ea39e3362efe 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.54.0.746.g67dd491aae-goog