From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 97C5F47279B for ; Thu, 30 Apr 2026 16:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777564971; cv=none; b=O8CTZFV+vMV4jSl2jBCD3SytVl0QLx9liwvuBHMqs5wX5KxcF+rI81Bu82q7W1eAT8QRsMG9HPiCYhOVQl6DGfjRNbzBws8xePKiz8s4GIG4K4oZJLKK4s8cEHwvBhV7VwEjmjE8P2a7Vj5PfhIhGeuPSB5wNbIzh9Ou/cFtCvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777564971; c=relaxed/simple; bh=WVJLqy3r6bzkLBth79KRaspMMTHZDGP6okQuQEbTpG0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YYGNbFD6NP89mI3khkkWlQmJiEwpHZeC0uKLj3NxUfg4FlzBEX85xAE/b0Qq+trbSreQn/Vmlx89QjIiJrtl3PX6gvWRfDD1Ra2y/zK9vPfWYb2sMt/9u20vtXQH9HvNf8VG0czNEGwUsdhzWPIg/PqacZouuLIVMFKl9/TjIoE= 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=lzskMy3B; arc=none smtp.client-ip=209.85.128.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="lzskMy3B" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488bd1ee9e7so12447285e9.1 for ; Thu, 30 Apr 2026 09:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777564968; x=1778169768; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Mz8D/T3QxACqjwu+5huws7UhafLI3x5hmsgeMhwaaFA=; b=lzskMy3BUmybBQsizxs8Kbx0IDM5fhJ54ssfayBZ5jD/Qgk/7txS1Gr58oQiv6qGG9 h/AcIu9XNfW8HpEUZRSstf6nQnBVAxd0jyiY3ItTKdoHPV96M9eR9adzGRKVYHU13CB9 9ncuIaG6AImOu+xFT1sqb4kmqnll2WcfPAi+tbZva60ZLZsfTp22aOe56f6LjdoTYhFO eMKEzheJ0W67eTCUBmkeZZkyK3yRaUprPE5ulIa9zwYM/oqQTrhC9E2h0otFuhFXDzdB U/ubbKbqG8YjaD1Wojryn4Z2AmR9Xi8SurlArIyzTwJLhBTvUK6UJzZTy4511GOejlLa yn9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777564968; x=1778169768; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Mz8D/T3QxACqjwu+5huws7UhafLI3x5hmsgeMhwaaFA=; b=QVnDqWBvl/KmMa6TEz/UKxU7Tuj42u2Fyia6a3ZIaL/8Y++ant6qxI2dAfQjg2jDSp v7lqrkN9PI79tq++USrRdsogPFoj0YNwNxn5e88vWeYYXc3EvGnCJbubP6nXWmfjqSZu Lg3yZ1t5+dDtExaKXRxat4Eod1Cv5KkWNji6OROGGtrGjMf63EU6SmgGpwk5ihdfJRVI LG3C9qj81MYWE+Ij74A6dH8tGvzl8e7apI6t6fO8aFZh+XMB/3oVIxtJOn0V+LDGrzrB tcQnapKLLdZIOl9ReeaB0eKVn6nnC7y/QcDWC1tZMm4eg6PyzTpugOsZ0OwU/zrOPfx/ Ffaw== X-Forwarded-Encrypted: i=1; AFNElJ/IE5gIqFSjZkCDx5XS5ND5FXBiSp3YJ3++g5ImFgF3orK336j3fR600sVMnfokBlm3tuVDuYfrm94S12k=@vger.kernel.org X-Gm-Message-State: AOJu0YwAAd3UA9a+1nytP7Hg4+AI0VZvGNDY2idXvwUbSHkHyfc426eu ylUeYu1CeqT32RRiZ9odbpvLMiAVK+coW9qI19Qx3COy9Q5atTJQsI/Ue7lcJl4VU+cl6OVs0uh ymaQge1mmY+H0UCBpRL4rDGAryK+TXQ== X-Received: from wrqr3.prod.google.com ([2002:a5d:4983:0:b0:43d:6f5f:8c52]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a40a:b0:480:1d0b:2d32 with SMTP id 5b1f17b1804b1-48a8444a342mr47560585e9.12.1777564967927; Thu, 30 Apr 2026 09:02:47 -0700 (PDT) Date: Thu, 30 Apr 2026 16:02:39 +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.545.g6539524ca2-goog Message-ID: <20260430160241.1934777-1-sebastianene@google.com> Subject: [PATCH v2 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. Changes since v1: - 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 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.545.g6539524ca2-goog