From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A99B3B3C1D for ; Fri, 10 Jul 2026 06:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783666353; cv=none; b=hSyiggPPWu9sFFzTPEFmmBZ7hz8dFy2ux2yGxSIFNO6sNwaXjfloj6ljH72/QI42qKZ3C4fUjP53cE6YnAcRyZzPpKdxcwQvIO3a4jqT4KrIwWzTWV1AJ+df/mrA5xtB6hZrl7kUGSHmwrZc/wp1OLEtkxYqJWIwmjEoLTm3MsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783666353; c=relaxed/simple; bh=Mv9GgaDQNtRYGWTm1gQ1mOi3EDQMpCPvxhm+2f/VXS4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r7HcFQ53Jgq0Lqm8+s9nFAlJviaG6lUxjg8KnIlWThpKkqwBLJ5jFaRpQqCR3rMO83sYDqfwKTlUn6UKUagRB9GsPhmmYzV9I/TMvgjtwpC87Gt+c2ZQBIKLToPolceCAYQ+cu79CAOsGWQ6Dw1Yc9GtImbSveyQyfwABBHAG10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=nQFGASQK; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=kqkiPC5n; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="nQFGASQK"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="kqkiPC5n" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66A3mqLF3629882 for ; Fri, 10 Jul 2026 06:52:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= XrgIQqUK3QvZGUscE0xgRqyYIXIAIug38pWr4S569hs=; b=nQFGASQKFBt5JKz2 a0cvyXcYY9LWmx1+NIh3qLQSYp21vAnfq+np9JYotZ4qZR8FbQ7ZbPZl2MTJy9kD IQnDoUN4Rhgf8dap/5aakFzTBh6Yq3nLjtWA8FC/YQcWmgpHZwcPSQQSsHhfTNmp LjfN6uGP6aKbkGncNX7fnMyH8wv34Gasti5E8Fj8JqKbGi8/w4F2OVg1eLwhDuMO tISQMv4dEt4AQ/HdL2xzDItKViuRWz531CHz5HbTJzhaGLhMRpcoRRruiHwNFfaV QAO1GRA38gy+LT/4xB0j8OtNZj1/5KgkDHeJ4v0HltiMuB5FMozc4FOXby0N2JRP yC64gg== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fahv8j1ps-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 10 Jul 2026 06:52:31 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3811ae55313so639574a91.3 for ; Thu, 09 Jul 2026 23:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1783666351; x=1784271151; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XrgIQqUK3QvZGUscE0xgRqyYIXIAIug38pWr4S569hs=; b=kqkiPC5nsfgGE+cCNik1+4DaSBvxQlcPJk6hvZPJy+LyTwfQcPddzHYG/LKddKjo67 oAPzzVTImqNFvnXp06wSxnuO7I5u6WFUj5UUsgWbdqPktmrJR6NuwtyMFwAcopAWHUfN RnMkNpeRd9g7A3NQBS2zTJxU6cPVfpOuIPp+3dtUr9z/Ga7XzY8asEoWFxR/c7BrEqu5 xnccPItBeUy812j9v1JCZKS2tgZdG4P0undxG+hf3FaF6zcy8Gm1n4bGlu1cgHdLkTEE rwttDqfnV7bfkhv1x1GVV3fa6kyhKFK2mXE1ttnrqlU/OBscpxOohvoGwQqdKcs04SUf zdUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783666351; x=1784271151; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XrgIQqUK3QvZGUscE0xgRqyYIXIAIug38pWr4S569hs=; b=U8EDF8uzO012fzFu+TxQovUXMJrX6RPmKMR5GQcdqQFC3orEEMRFlNEopcw3mmwseo WFvl/w058rRabhLhAvghf+kz/DUMcREb41kKf5wveURFYbLoU3ulg4Y84r1aXrnM5Vln nQDeFhKaut0Oxi6m64LvwNdKnAHMufrsTaJPkLkW/dQEjxY7Sj69eZsNMiCJIgzswOAU 9BbFRqRH2KG70G6JJLf0o9ayczlI9WlDmMvDcbeSg1fN1B4s3BlyNGxSbZczrnjQFnaN kbNyZPGHoqwFp0yu4dgcglm6QID9Jm4JDmmfflRfaBPFedUvT2n14mAkOoOLDUYj8RUv 39uw== X-Forwarded-Encrypted: i=1; AHgh+Rqe+CWmf2WdUIzwkLMmWNiGgF1afbF/vJxUDsrY/OH1KUZhFNrn/ZXJNb1vyzgWgeQOGpWWtxS3wWSo20U=@vger.kernel.org X-Gm-Message-State: AOJu0Yw21FAJ+rbJlqN9ufsaFuSIb7bRY+u4a6OPatI2GZ6BuaybLYnD sZj9LhLAJSKxvkIdtxYy9hyp0xpaAblp479o9iamBGoxs8DVIoOJyMok96K4or5yp5aMP6H7p1q pRRnswOIqnzAlccM7B+1NosEhYmAt2xCdBK3Kwl2CMis5zuqwdFLXRTiCgIFjqYFF9ew= X-Gm-Gg: AfdE7cnzMveoRZz86uIHpUS9e2xBg7THoeezZkoBhjiKUCFWF2R0daOE5BIMDH/RLA0 AzBzqO1wF77eMX32/xSJ7N5197SYZGi4UYUiaomSemWNxVeYL9/GeOgYtMorH+wQKhKm40nKnMt 0nZ2c0DmZ7uyRqqLvjbqbvGprR9Dhdb99nUpSY40/kRfHec1wmueQma8cQjYXFhB7NSmorLL3mF t9BZZtthlwpB2yiNUVBZLkuVAdFX2fxaxGRhVRU1FZtQpucdNUPeHS55SIV5CYmQKADRSgbC1Dv Obe2Ni05Pw8U5F8mvdN/s+8sNxjPhM7dDiKq2+OQOVS2HqLx3Vbo7wQnxOdfOWmcdq46K9tG/Wr d8NTe8BS8FRfYXV0rvp0LBX6dX+HDwJUy2a6vWrvi X-Received: by 2002:a17:903:41c9:b0:2cc:dacc:fe27 with SMTP id d9443c01a7336-2ccea45ab1fmr102817205ad.30.1783666350598; Thu, 09 Jul 2026 23:52:30 -0700 (PDT) X-Received: by 2002:a17:903:41c9:b0:2cc:dacc:fe27 with SMTP id d9443c01a7336-2ccea45ab1fmr102816995ad.30.1783666350060; Thu, 09 Jul 2026 23:52:30 -0700 (PDT) Received: from [10.217.223.121] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9bdb56fsm55577545ad.15.2026.07.09.23.52.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jul 2026 23:52:29 -0700 (PDT) Message-ID: Date: Fri, 10 Jul 2026 12:22:25 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/6] tee: Add kernel client object invoke helper To: Amirreza Zarrabi Cc: Basant Kumar , Apurupa Pattapu , Arun Kumar Neelakantam , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, jenswi@kernel.org, Sumit Garg , Bjorn Andersson , Konrad Dybcio References: <20260707-qcom_uefisecapp_migrate_qcomtee-v1-0-f659cbd5d04c@oss.qualcomm.com> <20260707-qcom_uefisecapp_migrate_qcomtee-v1-2-f659cbd5d04c@oss.qualcomm.com> <651db8ad-ff57-4369-8401-f51bb7ea46f5@oss.qualcomm.com> Content-Language: en-US From: Harshal Dev In-Reply-To: <651db8ad-ff57-4369-8401-f51bb7ea46f5@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: vd1bofZHSCTgF3V-85eHfJ9cr1kQh73V X-Proofpoint-ORIG-GUID: vd1bofZHSCTgF3V-85eHfJ9cr1kQh73V X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEwMDA2MyBTYWx0ZWRfX9u9bXgRFHgL6 5eHLJFPyqAy6DoIXeYByygHxxd9nC3S5INDC0Rfz+JXxIDTKyuxmahKSikkKmn0RPpmXiLaxG1c aPTd+WEFDshuhGmRNP6qwpfuIleU4fM= X-Authority-Analysis: v=2.4 cv=funsol4f c=1 sm=1 tr=0 ts=6a5096af cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=P-IC7800AAAA:8 a=EUspDBNiAAAA:8 a=1nvLbgvQa2DmmGW0PDoA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 a=d3PnA9EDa4IxuAV0gXij:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEwMDA2MyBTYWx0ZWRfX2DC+0TJd6dBP ezLAk10P+0NHLmChN3dfprXmB6hVPPn/VMtya8YJMFYK2MaLAHmgjnKNPKT1+p5uP5SoM3+n1NC VlI6r8z5oZTmMJBYRzqRNWc8UYeCuOsvm+4j4hOh+NET/qRM4Nx3whJvfcDGTzmoFV+7K9xy5El 5xGzeDuDj5Hh+Z1bReeQji12Na2EXLCyi/QzpGIAboCJ3MUNFud7+CkfrYJ1gh5nKITIDQd8URC yQ3KVZD+a6cFECBzQM9mNpBUDl2557vGwfjSdZzQ/QpRGjpfZq3RMu5+FZTOeo1/JyXN2PGXKni 2r/sV6uNfw5XO5ptTx0R6QKAhKV1WQ9DUsKxPTXdqAuZI1bMvAfjuVUoISircCzL+0uOb0Wzq9T su7X6N3l03n9iHcANm0OZwhwBslwHYdbsjK1PKMTwCZqjvnFNLBwD/JpvPm8MaivdepGgSooRd5 BaXgqS9yBuZrFMGUgrw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-10_01,2026-07-09_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607100063 Hi Amir, On 7/8/2026 11:59 AM, Amirreza Zarrabi wrote: > Hi Harshal, > > On 7/7/2026 4:11 PM, Harshal Dev wrote: >> From: Amirreza Zarrabi >> >> Kernel clients can open a TEE context and invoke regular TA commands >> through tee_client_invoke_func(). However, there is currently no >> equivalent helper for invoking TEE objects. >> >> Add tee_client_object_invoke_func() as a kernel client API for issuing >> object invocation requests. The helper checks that the backend provides >> object_invoke_func() before setting the MSB of the object-id and forwarding >> the request. The MSB of the object-id informs the TEE backend that the >> object is invoked from a kernel context. >> >> This allows TEE backends that support privileged object-based calls from >> the kernel-space. >> >> Signed-off-by: Amirreza Zarrabi >> Signed-off-by: Harshal Dev >> --- >> drivers/tee/tee_core.c | 13 +++++++++++++ >> include/linux/tee_drv.h | 13 +++++++++++++ >> 2 files changed, 26 insertions(+) >> >> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c >> index 7f986d7fb47f..0783802fd010 100644 >> --- a/drivers/tee/tee_core.c >> +++ b/drivers/tee/tee_core.c >> @@ -1413,6 +1413,19 @@ int tee_client_invoke_func(struct tee_context *ctx, >> } >> EXPORT_SYMBOL_GPL(tee_client_invoke_func); >> >> +int tee_client_object_invoke_func(struct tee_context *ctx, >> + struct tee_ioctl_object_invoke_arg *arg, >> + struct tee_param *param) >> +{ >> + if (!ctx->teedev->desc->ops->object_invoke_func) >> + return -EINVAL; >> + >> + /* Indicate that this object is being invoked from a kernel context. */ >> + arg->id = arg->id | BIT(63); > > Setting this bit is a qcomtee backend requirement and should not be > exposed to the TEE subsystem. > > Kernel users of qcomtee_object_invoke() should use the normal object ID > value. For example, access to the initial ROOT maybe represented as > TEE_OBJREF_NULL | BIT_ULL(63), but the upper bit must be managed by the > qcomtee backend for any return object, i.e. The backend should also set > BIT_ULL(63) automatically on each returned object ID. > Callers should treat the ID as opaque and must not manipulate the upper bit directly. I agree with this argument. Since we only invoke QTEE returned objects from tee_client_object_invoke_func(), the QCOMTEE back-end should set the MSB of the object-id when returning QTEE objects to TEE kernel client. It should also drop the MSB of the object-id for both invoked QTEE objects and QTEE objects passed as arguments by a kernel client. We are already taking care of dropping the MSB from the object-id for invoked QCOMTEE objects from kernel-space. I believe the correct place for setting and unsetting the MSB for QCOMTEE objects being passed as arguments are here: https://elixir.bootlin.com/linux/v7.1/source/drivers/tee/qcomtee/call.c#L181 https://elixir.bootlin.com/linux/v7.1/source/drivers/tee/qcomtee/call.c#L125 Once the object-id is allocated by the back-end, we can check if the kernel_ctx flag is set in oic. If so, we set the object-id's MSB before marshaling the object-id to a tee-param. Similarly, when an object-id is passed by the kernel client, and kernel_ctx flag is set, we unset the object-id's MSB before marshaling it from a tee-param. Do let me know if you're aligned with this approach for achieving kernel context awareness without TEE front-end or client involvement. In-effect we're offloading this context information to QTEE object ids. Regards, Harshal > >> + return ctx->teedev->desc->ops->object_invoke_func(ctx, arg, param); >> +} >> +EXPORT_SYMBOL_GPL(tee_client_object_invoke_func); >> + >> int tee_client_cancel_req(struct tee_context *ctx, >> struct tee_ioctl_cancel_arg *arg) >> { >> diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h >> index e561a26f537a..ca99c6b747a8 100644 >> --- a/include/linux/tee_drv.h >> +++ b/include/linux/tee_drv.h >> @@ -283,6 +283,19 @@ int tee_client_invoke_func(struct tee_context *ctx, >> struct tee_ioctl_invoke_arg *arg, >> struct tee_param *param); >> >> +/** >> + * tee_client_object_invoke_func() - Invoke a TEE object from kernel space >> + * @ctx: TEE Context >> + * @arg: Invoke arguments, see description of >> + * struct tee_ioctl_object_invoke_arg >> + * @param: Parameters for the object invocation >> + * >> + * Return: On success, returns 0; on failure, returns < 0. >> + */ >> +int tee_client_object_invoke_func(struct tee_context *ctx, >> + struct tee_ioctl_object_invoke_arg *arg, >> + struct tee_param *param); >> + >> /** >> * tee_client_cancel_req() - Request cancellation of the previous open-session >> * or invoke-command operations in a Trusted Application >> > > Regards, > Amir >