From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::d42; helo=mail-io1-xd42.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 9F0AB21197051 for ; Thu, 6 Dec 2018 08:58:49 -0800 (PST) Received: by mail-io1-xd42.google.com with SMTP id r9so944447ioa.1 for ; Thu, 06 Dec 2018 08:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5rFTiXcPXmhdht4s912DXE8rZBZ0faHdC1DljK+Yyvs=; b=D7gzVhSE9rXm50Itl61xDLKFgIEDymDbkunrYcrke8fSi83eAiSqmPCHVFgsgHTgZR pJU0CrAk8/ioNp3zRvqbRPIQt+H+40zvPzcNiMQi87FMdUuTBPfMtct0loJLZc8thckr 3lN78Lcm/ecqCWuZ6pfUo+YX+D+7rDlpfci1I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5rFTiXcPXmhdht4s912DXE8rZBZ0faHdC1DljK+Yyvs=; b=N18TumkB4nYT8neIGoq1MbZTdvOxvxk0SlZnGYceUnJRZ5YNCEbvDtY/+wrkY1tDVx TDUcs1p6BTmDDP7B/VCvApTu22170dhcSXqePTPCNktWoFhRFND6m71qSR41wtlwlhv6 8ny92DUAPvFJeK4OxtcnA1izDI17wjE1CkDBBabTEg2CEWlI6Plbz62dSPMGOEyXUb0O kT6ChXyQLuITE81MDs73d9dBK4qQmVuZxBboEP0rNfHpZ1WXLol8QtZx0AEAre22SsxG GIAKtvx/loA818rFgEt+0qEI0+hIIvX7CW7pwCESA5GFTBRHBggeqD5QB1RSBs8r+lAl j2pQ== X-Gm-Message-State: AA+aEWY/2zjaPiTYH8HqJl8KhTGvz6uwoCucoXNH99dRR12mfXQV4RnS Sbed2nkTzxy6ri5ZJrtOM6KjQD9rbIhOuIQyi/pi0Q== X-Google-Smtp-Source: AFSGD/V9FNynUIdehgQh6nrucxL+ghwUsO/KbCp9OCX1m6Kleh60Wql7T3EyevWZhRKIlq9Vg1g5DVLP56Y9E4X5wv8= X-Received: by 2002:a5d:8415:: with SMTP id i21mr14911112ion.173.1544115528630; Thu, 06 Dec 2018 08:58:48 -0800 (PST) MIME-Version: 1.0 References: <1544011065-31305-1-git-send-email-sumit.garg@linaro.org> In-Reply-To: <1544011065-31305-1-git-send-email-sumit.garg@linaro.org> From: Ard Biesheuvel Date: Thu, 6 Dec 2018 17:58:34 +0100 Message-ID: To: Sumit Garg Cc: "edk2-devel@lists.01.org" , tee-dev@lists.linaro.org, Leif Lindholm Subject: Re: [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: , X-List-Received-Date: Thu, 06 Dec 2018 16:58:49 -0000 Content-Type: text/plain; charset="UTF-8" On Wed, 5 Dec 2018 at 12:58, Sumit Garg wrote: > > 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 Reviewed-by: Ard Biesheuvel Pushed as bc39c5cbea30..088a5334809d Thanks > --- > ArmPkg/Library/OpteeLib/OpteeSmc.h | 3 ++ > ArmPkg/Library/OpteeLib/Optee.c | 34 ++++++++++++++++---- > 2 files changed, 30 insertions(+), 7 deletions(-) > > 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; > -- > 2.7.4 >