From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (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 E84F6397335 for ; Tue, 12 May 2026 12:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778589894; cv=none; b=pQZZGgSS++WvNSpqjvOzmzq4IwKbtDVKKYhNyXMzuHdrvCTwqppBbPp8UdjS7n78Og+XSCrRrqggRzTVx3mSIHZCSUNCZELy11K3abGOSyKH9wRrG4phieRQYuErWM4snMBwHwLsC81Y8iJLPkqgagYFENnT+zT0C1XIZiKK7Fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778589894; c=relaxed/simple; bh=Vzz3LLh3VPIk14pwmyaIkrVC+/KhEDSVg2MHBSMF+s8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=XokBH50v40Mn9HwmrKMJPRrgyQxT5IXZfNuguqahN6IAx8Ttr6BG1EcrFTSJPGw4vqFC6zVc1Sn/WzEKyI8d5AvZIQFNjHr6pncr2caTX7uMjYKEVuAd+04vTeQo2L47NmrAyDvzJ/J86aSA+A80NCx95o1RNQ5zAycPBiS7KdU= 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=ESvmiHRG; arc=none smtp.client-ip=209.85.221.74 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="ESvmiHRG" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-44f65835b77so3812298f8f.2 for ; Tue, 12 May 2026 05:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778589884; x=1779194684; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=5fj8/TCAT99B/0+ZH0DB55n65AvGpzqDY+eLZ0gMn24=; b=ESvmiHRGzLPmOcAna0OdoRxVF4dI6A8aniRZdBOMkVTAAhjgqahn+DInonIMJfagRn ODuwiE7TqFvQmPDy5hXbiuwKpQL5jdC2Kntr/+tCgqHP0dHs+exuCUrkfLxGcfuGokTX ng3rLgFThdhEAHPhbbdL10Ha2P8nrFrGlvTQKlUwePPQl3p1+PTHwdKirG94B3C62M2d Tm4n0u4WdbY15oMFWug2gRiPXKVQfrCC3uVys1qmvFy1ci1LJpcZ55WsHpZB7JElT3JD c2deag6fAIIIoQDZiCDX7gGWcnRUft7shIWkUA2s3pIwJkV9QGuJ/kgEVoEMKgizD+ct QJVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778589884; x=1779194684; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5fj8/TCAT99B/0+ZH0DB55n65AvGpzqDY+eLZ0gMn24=; b=bToAMEKJXg1R0xscKs9cqV+VDnBCHRungc7/mIcPnvZfJjjJahoSJDgzIRfNTWDxBl /J/QMMe7oixnn4H+65VZBxIfrEiHp4uD16x6ZEWDvTAal2/yiAmhIw5o+kONXxuHFUFw NjfHAS40oaULJBUIEYY/s1D3PcB45jFyKLfi01rrSb18/puhMijakC99vvJ6udli5OFK Mv7Du3hr4xb5avCq+aI3dKaU2jjP0ScWNtWVRgaYhbCc58dYNlFg2iEFT0zgf37V2RB4 v7044YBkLkMDsIXeop6K67UVnEYXkcUHfkpXzv+6xjIlowx6g1K13DKGDbEajT7vel1H 9xWQ== X-Forwarded-Encrypted: i=1; AFNElJ8iYqa4LCgL7WHItvgNbBKq2BFOK0vtbwsZSse19I/sRjajt47mgh5VcLf9hBGmUrd3OEWRDuHGpLn3MHs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8o69FuXXJZGMiuuXF5+Ih0Ib+XFw5AIZ0UobVfKtIfBFGd4vX MT7n1k78TlC+CbdDQNGDsq40QNhc+MsxylJcOdDq+vnFJbchW/cE8gojYUTy/MKEFQckJRx/rKx w7wD2IoStKnfPYgGfrYYMRunvqS418A== X-Received: from wrnj12.prod.google.com ([2002:adf:ea4c:0:b0:43c:f5f6:7a44]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c4a4:b0:48a:906b:14ca with SMTP id 5b1f17b1804b1-48e8fe7cdfbmr41959835e9.20.1778589884289; Tue, 12 May 2026 05:44:44 -0700 (PDT) Date: Tue, 12 May 2026 12:44:40 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260512124442.1899107-1-sebastianene@google.com> Subject: [PATCH v3 0/2] arm_ffa, KVM: Fix FF-A emad offset calculations From: Sebastian Ene To: catalin.marinas@arm.com, maz@kernel.org, oupton@kernel.org, sudeep.holla@kernel.org, will@kernel.org Cc: joey.gouly@arm.com, korneld@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, mrigendra.chaubey@gmail.com, perlarsen@google.com, sebastianene@google.com, suzuki.poulose@arm.com, vdonnefort@google.com, yuzenghui@huawei.com Content-Type: text/plain; charset="UTF-8" Hi all, This series fixes the Endpoint Memory Access Descriptor (EMAD) offset calculations and adds the necessary bounds checks for both the core FF-A driver and the pKVM hypervisor. Prior to FF-A version 1.1, the memory region header didn't specify an explicit offset for the EMADs, leading to the assumption that they immediately follow the header. However, from v1.1 onwards, the specification dictates using the `ep_mem_offset` field to determine the start of the memory access array. The patches in this series address this by: 1. Updating the core `arm_ffa` firmware driver to correctly calculate the descriptor offset using `ep_mem_offset` rather than defaulting to `sizeof(struct ffa_mem_region)`. It also introduces bounds checking against `max_fragsize`. 2. Enhancing the pKVM hypervisor validation logic to no longer strictly enforce that the descriptor strictly follows the header, aligning it with the driver behavior and the FF-A specification, while also ensuring the offset falls within the mailbox buffer bounds. Changelog ######### v2 -> this: - Fixed typo in nvhe/ffa.c (missing sizeof) v1 -> v2: - For pKVM, removed the strict placement enforcement for `ep_mem_offset` as it is not compliant with the spec, and avoids making assumptions about the driver's memory layout. Link to: ######## v2: https://lore.kernel.org/all/20260430160241.1934777-1-sebastianene@google.com/ v1: https://lore.kernel.org/all/ae9KN9nkOgDYJcGP@google.com/T/#t Sebastian Ene (2): firmware: arm_ffa: Fix Endpoint Memory Access Descriptor offset calculation KVM: arm64: Validate the offset to the mem access descriptor arch/arm64/kvm/hyp/nvhe/ffa.c | 24 ++++++++++++++++++------ drivers/firmware/arm_ffa/driver.c | 14 ++++++++++---- include/linux/arm_ffa.h | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) -- 2.54.0.563.g4f69b47b94-goog