From patchwork Wed Dec 5 11:57:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 152888 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9206516ljp; Wed, 5 Dec 2018 03:58:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WN6+Bwc+Em8wL/0PAq+PcxCrr+DGeh9YQBpKRrumc4/UBbbsRSw7Hz7gL0cxjgWBZplJgU X-Received: by 2002:a62:c101:: with SMTP id i1mr24062762pfg.80.1544011111445; Wed, 05 Dec 2018 03:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544011111; cv=none; d=google.com; s=arc-20160816; b=z9ALrbO9KqVxuxVLUjblCzO2kqxCVzKti3iVJ1Vg94HOS16+Od3nwH9o52Ra3ULhXg lywzPt60mOmHBRtD9+OmwwMeJvcB/nahmY/WUlq9nJ4y/VMxLvLGzdkEvGhzLiuwO7zL D3p2fJvr1DESa5d3JbYYXQs/j7+ClXF1zxnBThS9hj/8dIIHB/IwQIi5pqNCko6CuJgf vY9kfCdevTmjJFngWgTJ2fR8wE3uWSDMnRhyFJTwTdTOc3dpPsnoZSQ/VdC39oddpicl nxlr1PChr6/h5GRwFS2E4iprF+gJBF+kwwkRgzToqjyGFOo8vhN1eDHkVpKEcZsa27ZI lwrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=wYsgO76wMUomUJq92CTVrMZk7fEKML93XEtV0n2YTlA=; b=UTCYfMKEOytmDRTqCqYOjpVcSYCMMKhoEAaZtt1Zh0nItgbZ5WV2+X/QWSrX6H7XJt GYK5o19T/AK+79gxL9zi37N79nlgd4qgKHo7X5glFHk8WiJstPrflK2WiKnNG8ptYckD gCJUJBdzasEeTFrbyMCfCGZfyo0EBfNkHZdNNoMSSQxVOQdr1JmuhcUNcEdp5D+2eiQd jbsHV7szlQaiRfgMkD6LeFY6jCswz3aKcBOa7PmqVoGnH/UjV+zQ1+BSNeca60NLRHnX /slac8+rhB2rwLb0siLlENl/Cgur/uZprmBBMNQcX+gOjIX1ue0UbXVraFjFy+ezzV37 c9Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BjkK8yCl; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id b6si18771807pgg.2.2018.12.05.03.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 03:58:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BjkK8yCl; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9682F2119924A; Wed, 5 Dec 2018 03:58:29 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=sumit.garg@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 70C9A21194861 for ; Wed, 5 Dec 2018 03:58:28 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id y4so8908728pgc.12 for ; Wed, 05 Dec 2018 03:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BAKzLcgtOfxWIw9g89d8ezIjq6ovmC4APA9Eu6QLcgc=; b=BjkK8yCl9D4M9YR/4h3gIredRHhtCw2EM8LCBrFI0JRbn5wxldF5fs10UuFO+sQPax /3nD0fnfhOlZ9y/x1CI09t6OlObz4ZUgEyChHYwhBR8+0HhVmEkwVtMhvDD4VVL1w7te 1xyEHqqbSEkWd0rZS9jahqxTmx4MH8w9GoNmM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BAKzLcgtOfxWIw9g89d8ezIjq6ovmC4APA9Eu6QLcgc=; b=Ms8ud/3QeFXOac27NGVq0d5bAeqs8WZSoJWf2sKh1ST6tJ3VuwZPmbVEFJ8i7Rp93Y XDSk4FlDcAKOjJ4rZMOwHViklP/VWhzyZ8dOntKbD8EGyXP3h86vHtpAR+cG/qU/ZEei ouOXHWXgfCb029Dc28PqxHFNqY9diln9djJU1lPlT+b739Nb/BJFnutMCZoiXNxZjKDc 1bxjVcmpuI7F5H8Uh4cMMu3FfgnpLjrvFSOs3yW5GjLULZGgD8BM3zVMXI0UYkULmtI9 W2NazVPSLlmJnfP2w9D71r5iiR+v08klPBfRaXHeRdQo+AQ77Oe2cGD/wWKGLfGcgef8 vGUA== X-Gm-Message-State: AA+aEWZgzW6xZbze4kc5NE6d2Xhc3W6XCCtDDIyg0pkDYLVxkK2KdWhE xX+9AiAlOKnPFuXNO7WX9PCS6mZtGSM= X-Received: by 2002:a63:30c8:: with SMTP id w191mr20751904pgw.120.1544011107486; Wed, 05 Dec 2018 03:58:27 -0800 (PST) Received: from localhost.localdomain ([117.196.235.131]) by smtp.gmail.com with ESMTPSA id f6sm29267039pfg.188.2018.12.05.03.58.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Dec 2018 03:58:27 -0800 (PST) From: Sumit Garg To: edk2-devel@lists.01.org Date: Wed, 5 Dec 2018 17:27:45 +0530 Message-Id: <1544011065-31305-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [PATCH v1 1/1] ArmPkg/OpteeLib: Add dummy RPC handler X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tee-dev@lists.linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add dummy RPC handler for RPCs that are not implemented as control should be returned back to OP-TEE in case any RPC is invoked. Cc: Ard Biesheuvel Cc: Leif Lindholm Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg --- ArmPkg/Library/OpteeLib/OpteeSmc.h | 3 ++ ArmPkg/Library/OpteeLib/Optee.c | 34 ++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Ard Biesheuvel diff --git a/ArmPkg/Library/OpteeLib/OpteeSmc.h b/ArmPkg/Library/OpteeLib/OpteeSmc.h index 9cccd81810c9..6209782aaed7 100644 --- a/ArmPkg/Library/OpteeLib/OpteeSmc.h +++ b/ArmPkg/Library/OpteeLib/OpteeSmc.h @@ -25,6 +25,9 @@ #define OPTEE_SMC_SHARED_MEMORY_CACHED 1 +#define OPTEE_SMC_RETURN_UNKNOWN_FUNCTION 0xffffffff +#define OPTEE_SMC_RETURN_RPC_PREFIX_MASK 0xffff0000 +#define OPTEE_SMC_RETURN_RPC_PREFIX 0xffff0000 #define OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT 0xffff0004 #define OPTEE_MESSAGE_COMMAND_OPEN_SESSION 0 diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c index 55dcc7853b59..ed2a03c593c2 100644 --- a/ArmPkg/Library/OpteeLib/Optee.c +++ b/ArmPkg/Library/OpteeLib/Optee.c @@ -123,6 +123,17 @@ OpteeInit ( return EFI_SUCCESS; } +STATIC +BOOLEAN +IsOpteeSmcReturnRpc ( + UINT32 Return + ) +{ + return (Return != OPTEE_SMC_RETURN_UNKNOWN_FUNCTION) && + ((Return & OPTEE_SMC_RETURN_RPC_PREFIX_MASK) == + OPTEE_SMC_RETURN_RPC_PREFIX); +} + /** Does Standard SMC to OP-TEE in secure world. @@ -147,13 +158,22 @@ OpteeCallWithArg ( while (TRUE) { ArmCallSmc (&ArmSmcArgs); - if (ArmSmcArgs.Arg0 == OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT) { - // - // A foreign interrupt was raised while secure world was - // executing, since they are handled in UEFI a dummy RPC is - // performed to let UEFI take the interrupt through the normal - // vector. - // + if (IsOpteeSmcReturnRpc (ArmSmcArgs.Arg0)) { + switch (ArmSmcArgs.Arg0) { + case OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT: + // + // A foreign interrupt was raised while secure world was + // executing, since they are handled in UEFI a dummy RPC is + // performed to let UEFI take the interrupt through the normal + // vector. + // + break; + + default: + // Do nothing in case RPC is not implemented. + break; + } + ArmSmcArgs.Arg0 = OPTEE_SMC_RETURN_FROM_RPC; } else { break;