From nobody Fri Feb 13 17:31:39 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.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 EBD9715E1FC for ; Thu, 18 Apr 2024 16:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457907; cv=none; b=ehkSKTP6tdPPcRA4sYvdK8ZuokTiGEkdcNFV0/9vpPQcQFx3XRJP5P1fh1+h6KftbE18fD3yuPaZ7lSC4OGbzCZ4CShz/d+Wq5v6rXUutWg6RoWk+Uq0UakVanuOm/K0Qe+8vF5aWNa8yO5uJdZcIqmIiBHxduEsrCg16zqoMzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457907; c=relaxed/simple; bh=uv6SeJOZqNMKJXrWuo9i8vh/kcHxg3z8em90y16wOHQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XiDLh/6pWYHO8tF4VVXkEy3S2FKP71Sd/bC7LeuW+xN3vvmtBEwjE4aIAdDuJZiKpiTErOOdet7birk2toteVXqQajh+fVO/GK+FSyrtEKBE9g2oOOjs/DGMFxYPNmYqGq3IhfSSE06iLOd+0cLbRXYwQeY5/oGMpg0cLPLrvoY= 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=BAI7O/PZ; arc=none smtp.client-ip=209.85.128.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="BAI7O/PZ" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-416e58bdc1eso6212265e9.3 for ; Thu, 18 Apr 2024 09:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713457904; x=1714062704; 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=d3k3yKff6xJXH10XLK8AgdBXbkXj7KdOIqksXGEh2rs=; b=BAI7O/PZNgVdcZPuwWyBKGyFTuywravQE0Lxntrgg3u+Uff3H9XchMVPrLR1Cw0hfd lJh4jTrNpfdywj6tNJrRSRSSao6Z6VXA6vZD+zZNydDK2KG1WVWBmAaJ89AZcJessngy FogRjpKY3R37AWEIsdn34XZF4WiwDJAwKxf8K55pfMlRFcNVqalynV1IpOrFUwT+5NCs jfcFhBo87DjxGOSrh3pZLWSKwDTexuPvufojP9mkfYxnAHmmCJ2r7Z9aBn20rXGiXjkf ibQlVzUJSrSOKaGsduJhWjnTr7xmwmt7/9iLjpHRhQwMieYTmYH/iYE7uYTEZBb/KoQH pXxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713457904; x=1714062704; 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=d3k3yKff6xJXH10XLK8AgdBXbkXj7KdOIqksXGEh2rs=; b=Oe3qKITIxmbAEYz/tPorAGquPyUD68VVgQYGyaYDwV9aZ/quEq420Cru/0sPwPWa8X KydpJeSP6ge9xXxLgs1bf0ZTdQj7DSCJaMypNYERZyXEQOxt3R+K8yUb/GBLflSA/epP 6CIZoffxD9nGfH7ludMeY+1uZPg/PDBiQkdqK+dczPkzBapuT07OA+qL3wGdq6test2C xT7RyB0Cfl8D3sokoUX554ZyzlWuiUZ5g4zRajlWl2koM44jg+1ceyOTEz50p+nTQ0gL 3S75mPj7yQyDy0zyvxC0qQ/Dij6QpRD3J8EYzFF4JZT+WwStBQ2Q99dU+4fQzyDX6Gvv w4Cg== X-Forwarded-Encrypted: i=1; AJvYcCWs1xPDZiqsmW4UlD6rx588RfFlAD4xyzPfJwIEFojbqxsww7AALz2+za9ieBsc/j8HPJp0F5wcZrdaaA0ZQGKTzKLi2lG7i4fYQnCG X-Gm-Message-State: AOJu0Yxvv7J76EN9ipb3+HxTPIoGsN3EcMhsYkpHJ8jkVWcxQdgiGXZ6 jRdcph8WpOsdBevPKflwWFhphfGNhBP0HxMOFVMt9p2gvWSK0DMjmVO+k58GEfce/nzs92tqtiH 8BHtKOXiJzehd03U54OvVwoQGzg== X-Google-Smtp-Source: AGHT+IGjXKYnowAl0A+gDIzd42aCq8JkZ+PEnaC8UoitJzLnXigFkbCRr4zVMgwW9T/SvrE5pwKJk83JUYctRFJ8200= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:600c:1d1b:b0:418:d6ae:a3fc with SMTP id l27-20020a05600c1d1b00b00418d6aea3fcmr17191wms.2.1713457904328; Thu, 18 Apr 2024 09:31:44 -0700 (PDT) Date: Thu, 18 Apr 2024 16:30:23 +0000 In-Reply-To: <20240418163025.1193763-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240418163025.1193763-2-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240418163025.1193763-3-sebastianene@google.com> Subject: [PATCH 1/4] KVM: arm64: Trap FFA_VERSION host call in pKVM From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The pKVM hypervisor initializes with FF-A version 1.0. Keep the supported version inside the host structure and prevent the host drivers from overwriting the FF-A version with an increased version. Without trapping the call, the host drivers can negotiate a higher version number with TEE which can result in a different memory layout described during the memory sharing calls. Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/ffa.c | 43 ++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 320f2eaa14a9..023712e8beeb 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -58,6 +58,7 @@ struct kvm_ffa_buffers { hyp_spinlock_t lock; void *tx; void *rx; + u32 ffa_version; }; =20 /* @@ -640,6 +641,39 @@ static bool do_ffa_features(struct arm_smccc_res *res, return true; } =20 +static void do_ffa_version(struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, ffa_req_version, ctxt, 1); + u32 current_version; + + hyp_spin_lock(&host_buffers.lock); + current_version =3D host_buffers.ffa_version; + if (FFA_MAJOR_VERSION(ffa_req_version) !=3D FFA_MAJOR_VERSION(current_ver= sion)) { + res->a0 =3D FFA_RET_NOT_SUPPORTED; + goto unlock; + } + + /* + * If the client driver tries to downgrade the version, we need to ask + * first if TEE supports it. + */ + if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(current_versio= n)) { + arm_smccc_1_1_smc(FFA_VERSION, ffa_req_version, 0, + 0, 0, 0, 0, 0, + res); + if (res->a0 =3D=3D FFA_RET_NOT_SUPPORTED) + goto unlock; + + host_buffers.ffa_version =3D ffa_req_version; + goto unlock; + } + + res->a0 =3D current_version; +unlock: + hyp_spin_unlock(&host_buffers.lock); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_res res; @@ -686,6 +720,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_= ctxt, u32 func_id) case FFA_MEM_FRAG_TX: do_ffa_mem_frag_tx(&res, host_ctxt); goto out_handled; + case FFA_VERSION: + do_ffa_version(&res, host_ctxt); + goto out_handled; } =20 if (ffa_call_supported(func_id)) @@ -726,6 +763,8 @@ int hyp_ffa_init(void *pages) if (FFA_MAJOR_VERSION(res.a0) !=3D 1) return -EOPNOTSUPP; =20 + host_buffers.ffa_version =3D res.a0; + arm_smccc_1_1_smc(FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0, &res); if (res.a0 !=3D FFA_SUCCESS) return -EOPNOTSUPP; @@ -772,9 +811,7 @@ int hyp_ffa_init(void *pages) .rx =3D rx, }; =20 - host_buffers =3D (struct kvm_ffa_buffers) { - .lock =3D __HYP_SPIN_LOCK_UNLOCKED, - }; + host_buffers.lock =3D __HYP_SPIN_LOCK_UNLOCKED; =20 return 0; } --=20 2.44.0.769.g3c40516874-goog From nobody Fri Feb 13 17:31:39 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 D72C817107D for ; Thu, 18 Apr 2024 16:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457909; cv=none; b=ujpWljqlJ/h2BGHuaWJ1P6kocjEYN959LB+eY+ELyn4+PdMsIWbE/wcctW0fSWcrVa67ASm++Z+X0sFm0bHeuf6zswqgPLjh9Khms1+JMcTulNsSVFilGp695bInG5ALCtNB+oyCVUC9jPxqon2M0nbbtaOxOS9ELydB7La7gjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457909; c=relaxed/simple; bh=bwRIdgpsHW/V76+UX+Cj8GF/pMxY2YesRhoOXmNznx4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CI3QI4fpybSucsPv7+7VDBVBk0kuKgqAq6c7XFfkjZYXnLcjwr3zP4Fd2lOQZVlkOgJJcX6Ut0c4NcA5VXMd7yeM2rnQiiGC1rxXHVwlvpN8DXarkvTLf6RpsT74kOvdz677xamJnTLJLt3em9gtLIahKe2DXo4aecykK914MmI= 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=A5AgEusH; arc=none smtp.client-ip=209.85.219.202 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="A5AgEusH" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-de4645bee83so1732656276.3 for ; Thu, 18 Apr 2024 09:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713457907; x=1714062707; 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=8p9c64neWTEzUroG7YZesoYglVijCCcHGMdjez+sjDY=; b=A5AgEusH6JFBz3k4qb4Jvm1m+2GYPpTnEwGmDc3QC7kwns88CbQ6/GilWnyqw2eF7s dm7p8EJix7am1UUmSGjsNF7zX7oV6VaUEchkw3TNfFEX3QL1yQKD8ffAWcZUUMbE0Dxf s9G2XdfaAPxVhxg8QKH02Tb4zHYbbJIWeg+5FYS2yuDVSg9hnm2Y/oVaj5dD876aZ6Fa yCU5lBeJXo61yjKt+DFlsZEYU04EesDEMXz44i9aPV45cKtA/+AIIRKnN/s7iIpM3CEs iYnRw2S1DAb9qyMp9WELNH2TyoH2cqgS2E+JngnjsCQfYcfkYEf1d1JO8aoCcymo1OTJ hVag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713457907; x=1714062707; 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=8p9c64neWTEzUroG7YZesoYglVijCCcHGMdjez+sjDY=; b=p83csAaHXesZLVFJ5jZGuP90DmWc+U+Ix3fpp6g1IxIBF9PjfRM2udEm3zmtzFI7km b93MMOATW9YiAIuXcU7S6IYGw1UwvQrQ6KSAXxzTNcHz1jjeCHKib6dt752yx0DApn6/ XmqnmW0IhBwSgCJETgrJ9kWZgpEDdij8C7u5n5yjFn0JhNTFgrEUDJzqjWSo7O1GnXS3 VDGEvOD25TJZp3TkSGXLZvwKtJ7wvSv2Jo45ENFxCzR1g5agczLs3C4E5BbgF0aD0Wg/ eHx/AxD4uxbqwBKncBYbwpEySui3Dve1B8sxjXlHf5rniBvnbFrHE0B/yol6Bgl4peG3 /dJQ== X-Forwarded-Encrypted: i=1; AJvYcCV7RDqYcLb1VrZJHddTtciQpyiJtJYGwDu09pgvX1q7F4vSYTkGQpxdd62S/j2JRHH3ajm1MS7wFz0yM4JJ6yC1rjonfcdoHVZqE7TW X-Gm-Message-State: AOJu0YyaHpPdMGMqjK87Mz3Q72PQKt25dwss/fK4cMvu1iGYUwRXL9St loeVyElCCqAxfCl3oSwolPCbQ4e8V/Yuc86XM+A6Qxo3asnJURU9qkDFwGkupRJih8JIhHqIDve J7aj+yhDLmsclIx/vfpVUeaafBA== X-Google-Smtp-Source: AGHT+IHpX3+77ZV25mCqXIANfzu2cm+jHFm8blOeRGiipeMLfzcogzWLO4ECeP8t8lYr9QlOgIVIHYowhRuQKDsITVs= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:2b8e:b0:dd9:1b94:edb5 with SMTP id fj14-20020a0569022b8e00b00dd91b94edb5mr293032ybb.10.1713457906943; Thu, 18 Apr 2024 09:31:46 -0700 (PDT) Date: Thu, 18 Apr 2024 16:30:24 +0000 In-Reply-To: <20240418163025.1193763-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240418163025.1193763-2-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240418163025.1193763-4-sebastianene@google.com> Subject: [PATCH 2/4] KVM: arm64: Add support for FFA_PARTITION_INFO_GET From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Handle the FFA_PARTITION_INFO_GET host call inside the pKVM hypervisor and copy the response message back to the host buffers. Save the returned FF-A version as we will need it later to interpret the response from the TEE. Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/ffa.c | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 023712e8beeb..d53f50c73acb 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -674,6 +674,49 @@ static void do_ffa_version(struct arm_smccc_res *res, hyp_spin_unlock(&host_buffers.lock); } =20 +static void do_ffa_part_get(struct arm_smccc_res *res, + struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, uuid0, ctxt, 1); + DECLARE_REG(u32, uuid1, ctxt, 2); + DECLARE_REG(u32, uuid2, ctxt, 3); + DECLARE_REG(u32, uuid3, ctxt, 4); + DECLARE_REG(u32, flags, ctxt, 5); + u32 off, count, sz, buf_sz; + + hyp_spin_lock(&host_buffers.lock); + if (!host_buffers.rx) { + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS); + goto out_unlock; + } + + arm_smccc_1_1_smc(FFA_PARTITION_INFO_GET, uuid0, uuid1, + uuid2, uuid3, flags, 0, 0, + res); + + if (res->a0 !=3D FFA_SUCCESS) + goto out_unlock; + + count =3D res->a2; + if (!count) + goto out_unlock; + + if (host_buffers.ffa_version > FFA_VERSION_1_0) { + buf_sz =3D sz =3D res->a3; + if (sz > sizeof(struct ffa_partition_info)) + buf_sz =3D sizeof(struct ffa_partition_info); + } else { + /* FFA_VERSION_1_0 lacks the size in the response */ + buf_sz =3D sz =3D 8; + } + + WARN_ON((count - 1) * sz + buf_sz > PAGE_SIZE); + for (off =3D 0; off < count * sz; off +=3D sz) + memcpy(host_buffers.rx + off, hyp_buffers.rx + off, buf_sz); +out_unlock: + hyp_spin_unlock(&host_buffers.lock); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_res res; @@ -723,6 +766,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_= ctxt, u32 func_id) case FFA_VERSION: do_ffa_version(&res, host_ctxt); goto out_handled; + case FFA_PARTITION_INFO_GET: + do_ffa_part_get(&res, host_ctxt); + goto out_handled; } =20 if (ffa_call_supported(func_id)) --=20 2.44.0.769.g3c40516874-goog From nobody Fri Feb 13 17:31:39 2026 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 3A39A171E5E for ; Thu, 18 Apr 2024 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457912; cv=none; b=GbOtCOfqbJNYPLxp/qPzhQkRGxV1QlWsWsL09m6roBu4IIv0Mf2r8cePngH2bhxoFuLRyK+pLQg9Q14353Dg81ClunUuLUAa0nPI5EkKmWRlrZUQgCEk5pacrnMWJjOqrQOgLH2+Z/yLDZ1Y1oWiMbX4jEasTi+K8SlWADY0dPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457912; c=relaxed/simple; bh=reTusRmlKdivguaCRBJs9NeNASz4hK8OyNTz/hTvqXQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tSylFOGxzSMAUEMJdujUcgVYz6HoTWaNSHzasjEWlqprhbHZJVA8bYwEHaCxAsyS0KWzZl7D8Nfm+7XAUabMMzE79C0SCNULVwdq+dw9iIeqnWny3RAGqQdEiKdkyr/0i7jRkOZcOlzXx4fKdGp7ItgetpIwV0ToitoW0POQ658= 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=iXjnS7tI; arc=none smtp.client-ip=209.85.128.201 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="iXjnS7tI" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-61ab7fc5651so19327477b3.2 for ; Thu, 18 Apr 2024 09:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713457909; x=1714062709; 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=JYz/Mm7XL97gcC37XQSh6FT+KtzHg82q93nX3l947mY=; b=iXjnS7tIyrM3FrBP7okFcGucQozESAuGdo+bfSadeiOxemf9xX8GCXlgIQcouQO1Ir 3tVVyTioNzKpKkyN6CU0m9Jsbg7nANNN1RqhEFEUhqhiTo0FiB4cpsHf0ic0f8ddgard dvo8zU1dISQIW5wQdo1m+86UTCJeZ+I8JKHRYo2asd+388ODfem9+ycbx3eVSOoMKQeg 0TB+baJ2TbR1hi5CM8mMvMwjVc/MFqWP+CTOQPvIG1pws32e6rzovQGcfQ2qAnidhqMM PyKkc4M84euSg1cOEGuqPGzjtnZG9JHEZKBZ9y6CIFG7qKAiblhRBbZZUIpJtrhOoeAZ rXgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713457909; x=1714062709; 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=JYz/Mm7XL97gcC37XQSh6FT+KtzHg82q93nX3l947mY=; b=h4dYFcBZZK4w7w44ZNe0gLO2DwfCbpfOagKel0ZeD6f8DbJkvxHpwbju6SFDjg2RmA BjHGpJUIiiUWTfH/1AhuWpVW62kvo/BDgbwXOFkzd4+hzFa3R8m5boYuPfL7Akt/DWgL 7tRjfOvNpA0LshSNlWbh+2eIeDM7YMpmPRBOvf3O956AZ4AhqhnWSdtmgER+eRbcB7wY tvuF8ZwYMhOnm+l89ZyTvPHe9aQltK1Id+gn7D/NJDUC7MXEG5XV7XQiMLZJfVqPiV/d me4R6ZqHTTvDdDc8tJrTsEOaVYCeUew6VuR0cNfar9yAjnV0MvlNkzr08tbldqb7uTZl 9mFQ== X-Forwarded-Encrypted: i=1; AJvYcCV60UhaKp8uetp+P01suskPVpPOO2+84HZbdFU+2S5JJjm46Js0+wYZV+01TfL1+l8rSmxPu5yowa7PWPz3qyMcAiLK5dkeHryxrG5E X-Gm-Message-State: AOJu0YxeCliBZtSPC4bHtLE/5/RFtALyKfcTH8gYkhrC28lKEWqaa1SA XMzueVLSe0tiS3TC9WDi/Hk6ka6jZE7JqfTq2quGK8c/G/VC4AubfM3rnQjpeDAO4OfziykyO6x 5Kx2RXuV89wiN0ukUL+MUxOcrNw== X-Google-Smtp-Source: AGHT+IGRr7uB8dyL1qZY2tNdLCo6bCgG9f2Ylok0Sq5MdDUUM2WXBpExMqrkM6rHCoVTKgjGEzcyP05psJEyfeFP8OM= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:2b08:b0:dda:c59c:3953 with SMTP id fi8-20020a0569022b0800b00ddac59c3953mr882660ybb.0.1713457909290; Thu, 18 Apr 2024 09:31:49 -0700 (PDT) Date: Thu, 18 Apr 2024 16:30:25 +0000 In-Reply-To: <20240418163025.1193763-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240418163025.1193763-2-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240418163025.1193763-5-sebastianene@google.com> Subject: [PATCH 3/4] KVM: arm64: Fix the identification range for the FF-A smcs From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The FF-A spec 1.2 reserves the following ranges for identifying FF-A calls: 0x84000060-0x840000FF: FF-A 32-bit calls 0xC4000060-0xC40000FF: FF-A 64-bit calls. Use the range identification according to the spec and allow calls that are currently out of the range(eg. FFA_MSG_SEND_DIRECT_REQ2) to be identified correctly. Signed-off-by: Sebastian Ene Acked-by: Will Deacon --- arch/arm64/kvm/hyp/include/nvhe/ffa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/ffa.h b/arch/arm64/kvm/hyp/inc= lude/nvhe/ffa.h index d9fd5e6c7d3c..146e0aebfa1c 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/ffa.h +++ b/arch/arm64/kvm/hyp/include/nvhe/ffa.h @@ -9,7 +9,7 @@ #include =20 #define FFA_MIN_FUNC_NUM 0x60 -#define FFA_MAX_FUNC_NUM 0x7F +#define FFA_MAX_FUNC_NUM 0xFF =20 int hyp_ffa_init(void *pages); bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id); --=20 2.44.0.769.g3c40516874-goog From nobody Fri Feb 13 17:31:39 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 BC204172BAA for ; Thu, 18 Apr 2024 16:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457914; cv=none; b=AZ/9snKI9sLZFn7NCFvBkpMRGxCGS00cVpmnOsafO4G6kMduBsOf2m6C/saCY2/HTHl66ePxVH9e6fwsa9I/qkn0uqmRR75FBJTApLYFmTHQE3aV5h6WnaHudJ4HeWLqXfKjOuZZSQ8obtgE3cHuMsek7CoFXsyPgi3uB6wKeuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713457914; c=relaxed/simple; bh=c2CK72lGJDZxhkE+vu1jRDsSGgFezzCof9rwe6Qg764=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AKL0NwINNOMzSgO8TbKabIs3gpOcMUaUB/OivocxaQSOrvmo0T61oRcKT23L0EZaBur8Si1GDYmX8ABScHq5AC8JFEpHnPfVsO3OrSqDtJ/YZHiR5YCcfdfqLROcHSgSHQzitwJ6t/Nj2U6WmCqcc3To+8bWYpleqZIqBpyjocE= 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=c33FeuoV; arc=none smtp.client-ip=209.85.219.202 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="c33FeuoV" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so2014126276.2 for ; Thu, 18 Apr 2024 09:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713457912; x=1714062712; 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=o/WdHir/Mi2mSDEW62XszsH6Iho8VZ+3enjU3uPIcDs=; b=c33FeuoVmUcQ0l0C4pwHQaC3m8gGLZAI3AId2TelkMcM8A3JPeBr3ZIsjrioymToj4 Xa0eyWUvWzwJmXR8P54KgR7lERWLP2x17qhZe7TdW/dKgnaRodgKgd+Mb/GbpRBV509p mvoxHfTcmSoHcJCdxnfbDKtCBP9KjFy+VZH4FufagmUzcfzA6fch2CkmHpsMAD95stMM jN6MmrWoTnwjt1SIqsDg2WEMCBKzmm5Lv45mu7WFd9GmdlHLigHUKWV6AVRSHOckCsWQ kthOx/RvFLO81kLzyLApEiRKjncxblJjGkrsSYRMeS3o5+YZyPptIITxeXgRymSh1HD8 8puw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713457912; x=1714062712; 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=o/WdHir/Mi2mSDEW62XszsH6Iho8VZ+3enjU3uPIcDs=; b=DHjbiLh6ES6ipVxt9j20Ir4aKcjb2df+VF82XmyMl9BZLDiZ0p+aRNlCj9AyBy/ljA YbYj5aEVfjcjQswnGPFymRPtG6EOF4ibNvAkkW3V0d3FW2DKgzoxGTh+Z37fcTSQHDBA ZCm3EA4RnoB4a4gdLgEmG1SynwHFUGddjpiYAjZ0pX5aGEwA6M4LZvblUfv89/HcUaLS 7srtWNwvNTq0eb4NsmKzdESIy3U1C4dNCktrq7GMrIZSRCojybVPC4Ei3omKOskNsqa4 tvkCN5JEZbiWQFiWu6f+yVMMQLXp5cPMX1jdRAtQVcjj+OPtuF7kWmClPulf66sp7NJc cPRg== X-Forwarded-Encrypted: i=1; AJvYcCVsq8vAddY+qZo7PTk9P3xGe47nQFO+n6DFVm2/Dlg1NtrWEM5H2rS+ulddXaEAi16ozqJEumMtD6J9G8QJqmmZafIZ2Y7W35E1ills X-Gm-Message-State: AOJu0YygnvOWDuhwPknBBm3QQh3f3loiSiZfItiuzHWl7urkv5Ncy2zo gENdN6+x/P53nxBRyDgDHnUEvIb5W+tRMU7UxsgmcQ4cpjnWTwGfxLcHiK8n9rz95LuzDBvwh0u WPqCg0J08tkoOMtmx3j5mRVNqtw== X-Google-Smtp-Source: AGHT+IFU3gG7mhRXP799oGDxBlPxLgFLfF8KRo1VK5xtAu+Ns8G5jem0y2bESQeN8vefdLLSBSCfbA/Pv4M4UuLpEoo= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:2b8e:b0:dc6:cd85:bcd7 with SMTP id fj14-20020a0569022b8e00b00dc6cd85bcd7mr831056ybb.3.1713457911701; Thu, 18 Apr 2024 09:31:51 -0700 (PDT) Date: Thu, 18 Apr 2024 16:30:26 +0000 In-Reply-To: <20240418163025.1193763-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240418163025.1193763-2-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240418163025.1193763-6-sebastianene@google.com> Subject: [PATCH 4/4] KVM: arm64: Use FF-A 1.1 with pKVM From: Sebastian Ene To: catalin.marinas@arm.com, james.morse@arm.com, jean-philippe@linaro.org, maz@kernel.org, oliver.upton@linux.dev, qperret@google.com, qwandor@google.com, sudeep.holla@arm.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, yuzenghui@huawei.com, lpieralisi@kernel.org Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that the layout of the structures is compatible with 1.1 it is time to probe the 1.1 version of the FF-A protocol inside the hypervisor. If the TEE doesn't support it, it should return the minimum supported version. Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/ffa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index d53f50c73acb..8633c8e0b09b 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -455,7 +455,7 @@ static __always_inline void do_ffa_mem_xfer(const u64 f= unc_id, memcpy(buf, host_buffers.tx, fraglen); =20 ep_mem_access =3D (void *)buf + - ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0); + ffa_mem_desc_offset(buf, 0, host_buffers.ffa_version); offset =3D ep_mem_access->composite_off; if (!offset || buf->ep_count !=3D 1 || buf->sender_id !=3D HOST_FFA_ID) { ret =3D FFA_RET_INVALID_PARAMETERS; @@ -534,7 +534,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *re= s, fraglen =3D res->a2; =20 ep_mem_access =3D (void *)buf + - ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0); + ffa_mem_desc_offset(buf, 0, host_buffers.ffa_version); offset =3D ep_mem_access->composite_off; /* * We can trust the SPMD to get this right, but let's at least @@ -789,7 +789,7 @@ int hyp_ffa_init(void *pages) if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2) return 0; =20 - arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_0, 0, 0, 0, 0, 0, 0, &res); + arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_1, 0, 0, 0, 0, 0, 0, &res); if (res.a0 =3D=3D FFA_RET_NOT_SUPPORTED) return 0; =20 --=20 2.44.0.769.g3c40516874-goog