Merge "feat(spmd): initialize SCR_EL3.EEL2 bit at RESET" into integration
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index 40e3df8..9959a3e 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -161,6 +161,10 @@
 				${MBEDTLS_SOURCES}
 endif
 
+ifeq ($(CROS_WIDEVINE_SMC),1)
+BL31_SOURCES		+=	services/oem/chromeos/widevine_smc_handlers.c
+endif
+
 BL31_DEFAULT_LINKER_SCRIPT_SOURCE := bl31/bl31.ld.S
 
 ifneq ($(findstring gcc,$(notdir $(LD))),)
diff --git a/docs/process/contributing.rst b/docs/process/contributing.rst
index ef9ebd3..33b3533 100644
--- a/docs/process/contributing.rst
+++ b/docs/process/contributing.rst
@@ -7,8 +7,12 @@
 -  Make sure you have a Github account and you are logged on both
    `developer.trustedfirmware.org`_ and `review.trustedfirmware.org`_.
 
+   Also make sure that you have registered your full name and email address in
+   your `review.trustedfirmware.org`_ profile. Otherwise, the Gerrit server
+   might reject patches you attempt to post for review.
+
 -  If you plan to contribute a major piece of work, it is usually a good idea to
-   start a discussion around it on the mailing list. This gives everyone
+   start a discussion around it on the `TF-A mailing list`_. This gives everyone
    visibility of what is coming up, you might learn that somebody else is
    already working on something similar or the community might be able to
    provide some early input to help shaping the design of the feature.
@@ -17,16 +21,16 @@
    it explicitly in the email thread and ensure that the changes that include
    Third Party IP are made in a separate patch (or patch series).
 
--  Clone `Trusted Firmware-A`_ on your own machine as described in
+-  Clone the Trusted Firmware-A source code on your own machine as described in
    :ref:`prerequisites_get_source`.
 
--  Create a local topic branch based on the `Trusted Firmware-A`_ ``master``
+-  Create a local topic branch based on the Trusted Firmware-A ``master``
    branch.
 
 Making Changes
 ==============
 
--  Ensure commits adhere to the the project's :ref:`Commit Style`.
+-  Ensure commits adhere to the project's :ref:`Commit Style`.
 
 -  Make commits of logical units. See these general `Git guidelines`_ for
    contributing to a project.
@@ -93,13 +97,21 @@
 Submitting Changes
 ==================
 
+.. note::
+   Please follow the `How to Contribute Code`_ section of the OpenCI
+   documentation for general instructions on setting up Gerrit and posting
+   patches there. The rest of this section provides details about patch
+   submission rules specifically for the TF-A project.
+
--  Submit your changes for review at https://review.trustedfirmware.org
-   targeting the ``integration`` branch.
+-  Submit your changes for review using the ``git review`` command.
 
--  Add reviewers for your patch:
+   This will automatically rebase them onto the upstream ``integration`` branch,
+   as required by TF-A's patch submission process.
 
-   -  At least one code owner for each module modified by the patch. See the list
-      of modules and their :ref:`code owners`.
+-  From the Gerrit web UI, add reviewers for your patch:
+
+   -  At least one code owner for each module modified by the patch. See the
+      list of modules and their :ref:`code owners`.
 
    -  At least one maintainer. See the list of :ref:`maintainers`.
 
@@ -167,26 +179,54 @@
 Add CI Configurations
 =====================
 
--  TF-A uses Jenkins tool for Continuous Integration and testing activities.
-   Various CI Jobs are deployed which run tests on every patch before being
-   merged. So each of your patches go through a series of checks before they
-   get merged on to the master branch. Kindly ensure, that everytime you add
-   new files under your platform, they are covered under the following two sections:
+TF-A uses Jenkins for Continuous Integration and testing activities. Various CI
+jobs are deployed to run tests on every patch before being merged. Each of your
+patches go through a series of checks before they get merged on to the master
+branch. Kindly ensure that every time you add new files under your platform,
+they are covered by the following two sections.
 
 Coverity Scan
 -------------
 
+The TF-A project makes use of `Coverity Scan` for static analysis, a service
+offered by Synopsys for open-source projects. This tool is able to find defects
+and vulnerabilities in a code base, such as dereferences of NULL pointers, use
+of uninitialized data, control flow issues and many other things.
+
--  ``Coverity Scan analysis`` is one of the tests we perform on our source code
-   at regular intervals. We maintain a build script ``tf-cov-make`` which contains the
-   build configurations of various platforms in order to cover the entire source
-   code being analysed by Coverity.
+The TF-A source code is submitted daily to this service for analysis. Results of
+the latest and previous scans, as well as the complete list of defects it
+detected, are accessible online from
+https://scan.coverity.com/projects/arm-software-arm-trusted-firmware.
 
--  When you submit your patches for review containing new source files, please
-   ensure to include them for the ``Coverity Scan analysis`` by adding the
-   respective build configurations in the ``tf-cov-make`` build script.
+The `tf-a-ci-scripts repository`_ contains scripts to run the Coverity Scan
+tools on the integration branch of the TF-A code base and make them available on
+https://scan.coverity.com. These scripts get executed daily by the
+`tf-a-coverity Jenkins job`_.
 
--  In this section you find the details on how to append your new build
-   configurations for Coverity scan analysis illustrated with examples:
+In order to maintain a high level of coverage, including on newly introduced
+code, it is important to maintain the appropriate TF-A CI scripts. Details of
+when to update these scripts and how to do so follow.
+
+We maintain a build script - ``tf-cov-make`` - which contains the build
+configurations of various platforms in order to cover the entire source code
+being analysed by Coverity.
+
+When you submit your patches for review, and if they contain new source files,
+`TF-A CI static checks job`_ might report that these files are not covered. In
+this case, the job's console output will show the following error message::
+
+   ****** Newly added files detection check for Coverity Scan analysis on patch(es) ******
+
+   Result : FAILURE
+
+   New source files have been identified in your patch..
+   some/dir/file.c
+
+   please ensure to include them for the ``Coverity Scan analysis`` by adding
+   the respective build configurations in the ``tf-cov-make`` build script.
+
+In this section you find the details on how to append your new build
+configurations for Coverity scan analysis illustrated with examples:
 
 #. We maintain a separate repository named `tf-a-ci-scripts repository`_
    for placing all the test scripts which will be executed by the CI Jobs.
@@ -194,9 +234,9 @@
 #. In this repository, ``tf-cov-make`` script is located at
    ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make``
 
-#. Edit `tf-cov-make`_ script by appending all the possible build configurations with
-   the specific ``build-flags`` relevant to your platform, so that newly added
-   source files get built and analysed by Coverity.
+#. Edit the `tf-cov-make`_ script by appending all the possible build
+   configurations with the specific build flags relevant to your platform, so
+   that newly added source files get built and analysed by Coverity.
 
 #. For better understanding follow the below specified examples listed in the
    ``tf-cov-make`` script.
@@ -220,45 +260,44 @@
     make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all
     make PLAT=poplar $(common_flags) all
 
--  In this case for ``Hikey`` boards additional ``build-flags`` has been included
-   along with the ``commom_flags`` to cover most of the files relevant to it.
+-  In this case for ``Hikey`` boards additional build flags have been included
+   along with the ``common_flags`` to cover most of the files relevant to it.
 
 -  Similar to this you can still find many other different build configurations
    of various other platforms listed in the ``tf-cov-make`` script. Kindly refer
    them and append your build configurations respectively.
 
-Test Build Configuration (``tf-l1-build-plat``)
------------------------------------------------
+Test Build Configurations
+-------------------------
 
--  Coverity Scan analysis, runs on a daily basis and will not be triggered for
-   every individual trusted-firmware patch.
+We have CI jobs which run a set of test configurations on every TF-A patch
+before they get merged upstream.
 
--  Considering this, we have other distinguished CI jobs which run a set of test
-   configurations on every patch, before they are being passed to ``Coverity scan analysis``.
+At the bare minimum, TF-A code should build without any errors for every
+supported platform - and every feature of this platform. To make sure this is
+the case, we maintain a set of build tests. ``tf-l1-build-plat`` is the test
+group which holds all build tests for all platforms. So be kind enough to
+verify that your newly added files are covered by such a build test.
 
--  ``tf-l1-build-plat`` is the test group, which holds the test configurations
-   to build all the platforms. So be kind enough to verify that your newly added
-   files are built as part of one of the existing platform configurations present
-   in ``tf-l1-build-plat`` test group.
+If this is not the case, please follow the instructions below to add the
+appropriate files. We will illustrate this with an example for the ``Hikey``
+platform.
 
--  In this section you find the details on how to add the appropriate files,
-   needed to build your newly introduced platform as part of ``tf-l1-build-plat``
-   test group, illustrated with an example:
-
--  Lets consider ``Hikey`` platform:
-   In the `tf-a-ci-scripts repository`_ we need to add a build configuration file ``hikey-default``
-   under tf_config folder, ``tf_config/hikey-default`` listing all the build parameters
-   relevant to it.
+-  In the `tf-a-ci-scripts repository`_ we need to add a build configuration file
+   ``hikey-default`` under ``tf_config/`` folder. ``tf_config/hikey-default``
+   must list all the build parameters relevant to it.
 
 .. code:: shell
 
-   #Hikey Build Parameters
+   # Hikey Build Parameters
    CROSS_COMPILE=aarch64-none-elf-
    PLAT=hikey
 
--  Further a test-configuration file ``hikey-default:nil`` need to be added under the
-   test group, ``tf-l1-build-plat`` located at ``tf-a-ci-scripts/group/tf-l1-build-plat``,
-   to allow the platform to be built as part of this group.
+-  Further another file, ``hikey-default:nil``, needs to be added under
+   ``group/tf-l1-build-plat/`` folder to allow the platform to be built as part
+   of this test group. ``group/tf-l1-build-plat/hikey-default:nil`` file just
+   needs to exist but does not contain anything meaningful, apart from a
+   mandatory copyright notice:
 
 .. code:: shell
 
@@ -268,7 +307,11 @@
    # SPDX-License-Identifier: BSD-3-Clause
    #
 
--  As illustrated above, you need to add the similar files supporting your platform.
+-  As illustrated above, you need to add similar files supporting your platform.
+
+For a more elaborate explanation of the TF-A CI scripts internals, including how
+to add more complex tests beyond a simple build test, please refer to the `TF-A
+CI scripts overview`_ section of the OpenCI documentation.
 
 Binary Components
 =================
@@ -289,11 +332,10 @@
 
 --------------
 
-*Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved.*
+*Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.*
 
 .. _developer.trustedfirmware.org: https://developer.trustedfirmware.org
 .. _review.trustedfirmware.org: https://review.trustedfirmware.org
-.. _Trusted Firmware-A: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
 .. _Git guidelines: http://git-scm.com/book/ch5-2.html
 .. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html
 .. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io
@@ -302,3 +344,7 @@
 .. _TF-A mailing list: https://lists.trustedfirmware.org/mailman3/lists/tf-a.lists.trustedfirmware.org/
 .. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/
 .. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make
+.. _How to Contribute Code: https://tf-ci-users-guide.readthedocs.io/en/latest/#how-to-contribute-code
+.. _TF-A CI scripts overview: https://tf-ci-users-guide.readthedocs.io/en/latest/#tf-a-ci-scripts-overview
+.. _tf-a-coverity Jenkins job: https://ci.trustedfirmware.org/job/tf-a-coverity/
+.. _TF-A CI static checks job: https://ci.trustedfirmware.org/job/tf-a-static-checks/
diff --git a/include/services/oem/chromeos/widevine_smc_handlers.h b/include/services/oem/chromeos/widevine_smc_handlers.h
new file mode 100644
index 0000000..a5251d7
--- /dev/null
+++ b/include/services/oem/chromeos/widevine_smc_handlers.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2024, The ChromiumOS Authors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CROS_WIDEVINE_SMC_HANDLERS_H
+#define CROS_WIDEVINE_SMC_HANDLERS_H
+
+#include <lib/smccc.h>
+
+/*******************************************************************************
+ * Defines for CrOS OEM Service queries
+ ******************************************************************************/
+
+/* 0xC300C050 - 0xC300C05F are CrOS OEM service calls */
+#define CROS_OEM_SMC_ID 0xC050
+#define CROS_OEM_SMC_CALL_ID(func_num)                                         \
+	((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) |                                \
+	 ((SMC_64) << FUNCID_CC_SHIFT) | (OEN_OEM_START << FUNCID_OEN_SHIFT) | \
+	 (CROS_OEM_SMC_ID) | ((func_num) & FUNCID_NUM_MASK))
+
+enum cros_drm_set {
+	CROS_DRM_SET_TPM_AUTH_PUB = 0U,
+	CROS_DRM_SET_HARDWARE_UNIQUE_KEY = 1U,
+	CROS_DRM_SET_ROOT_OF_TRUST = 2U,
+};
+
+/*******************************************************************************
+ * Defines for runtime services func ids
+ ******************************************************************************/
+
+/* Sets the TPM auth public key. The maximum size is 128 bytes.
+ * |x1| is the length of the data, |x2| is the physical address of the data.
+ */
+#define CROS_OEM_SMC_DRM_SET_TPM_AUTH_PUB_FUNC_ID \
+	CROS_OEM_SMC_CALL_ID(CROS_DRM_SET_TPM_AUTH_PUB)
+
+/* Sets the hardware unique key. The maximum size is 32 bytes.
+ * |x1| is the length of the data, |x2| is the physical address of the data.
+ */
+#define CROS_OEM_SMC_DRM_SET_HARDWARE_UNIQUE_KEY_FUNC_ID \
+	CROS_OEM_SMC_CALL_ID(CROS_DRM_SET_HARDWARE_UNIQUE_KEY)
+
+/* Sets the widevine root of trust. The maximum size is 32 bytes.
+ * |x1| is the length of the data, |x2| is the physical address of the data.
+ */
+#define CROS_OEM_SMC_DRM_SET_ROOT_OF_TRUST_FUNC_ID \
+	CROS_OEM_SMC_CALL_ID(CROS_DRM_SET_ROOT_OF_TRUST)
+
+#define is_cros_oem_smc(_call_id) (((_call_id) & 0xFFF0U) == CROS_OEM_SMC_ID)
+
+struct cros_oem_data {
+	uint8_t *buffer;
+	const uint32_t max_length;
+	uint32_t length;
+};
+
+extern struct cros_oem_data cros_oem_tpm_auth_pk;
+
+extern struct cros_oem_data cros_oem_huk;
+
+extern struct cros_oem_data cros_oem_rot;
+
+#endif /* CROS_WIDEVINE_SMC_HANDLERS_H */
diff --git a/lib/libc/libc.mk b/lib/libc/libc.mk
index 633386c..03e1fb3 100644
--- a/lib/libc/libc.mk
+++ b/lib/libc/libc.mk
@@ -6,3 +6,6 @@
 #
 
 include lib/libc/libc_common.mk
+
+LIBC_SRCS	+=	$(addprefix lib/libc/,		\
+			memset.c)
diff --git a/lib/libc/libc_common.mk b/lib/libc/libc_common.mk
index fb8117f..4879818 100644
--- a/lib/libc/libc_common.mk
+++ b/lib/libc/libc_common.mk
@@ -14,7 +14,6 @@
 			memcpy_s.c			\
 			memmove.c			\
 			memrchr.c			\
-			memset.c			\
 			printf.c			\
 			putchar.c			\
 			puts.c				\
diff --git a/make_helpers/arch_features.mk b/make_helpers/arch_features.mk
index bb4e224..5d538cc 100644
--- a/make_helpers/arch_features.mk
+++ b/make_helpers/arch_features.mk
@@ -20,48 +20,48 @@
 
 # Enable the features which are mandatory from ARCH version 8.1 and upwards.
 ifeq "8.1" "$(word 1, $(sort 8.1 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_PAN				:=	1
-ENABLE_FEAT_VHE				:=	1
+ENABLE_FEAT_PAN				?=	1
+ENABLE_FEAT_VHE				?=	1
 endif
 
 # Enable the features which are mandatory from ARCH version 8.2 and upwards.
 ifeq "8.2" "$(word 1, $(sort 8.2 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_RAS				:=	1
+ENABLE_FEAT_RAS				?=	1
 endif
 
 # Enable the features which are mandatory from ARCH version 8.4 and upwards.
 ifeq "8.4" "$(word 1, $(sort 8.4 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_SEL2			:=	1
-ENABLE_TRF_FOR_NS			:=	1
-ENABLE_FEAT_DIT				:=	1
+ENABLE_FEAT_SEL2			?=	1
+ENABLE_TRF_FOR_NS			?=	1
+ENABLE_FEAT_DIT				?=	1
 endif
 
 # Enable the features which are mandatory from ARCH version 8.5 and upwards.
 ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_RNG				:=	1
-ENABLE_FEAT_SB				:=	1
+ENABLE_FEAT_RNG				?=	1
+ENABLE_FEAT_SB				?=	1
 
 # Enable Memory tagging, Branch Target Identification for aarch64 only.
 ifeq ($(ARCH), aarch64)
-	mem_tag_arch_support		:= 	yes
+	mem_tag_arch_support		?= 	yes
 endif #(ARCH=aarch64)
 
 endif
 
 # Enable the features which are mandatory from ARCH version 8.6 and upwards.
 ifeq "8.6" "$(word 1, $(sort 8.6 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_ECV				:=	1
-ENABLE_FEAT_FGT				:=	1
+ENABLE_FEAT_ECV				?=	1
+ENABLE_FEAT_FGT				?=	1
 endif
 
 # Enable the features which are mandatory from ARCH version 8.7 and upwards.
 ifeq "8.7" "$(word 1, $(sort 8.7 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_HCX				:=	1
+ENABLE_FEAT_HCX				?=	1
 endif
 
 # Enable the features which are mandatory from ARCH version 8.9 and upwards.
 ifeq "8.9" "$(word 1, $(sort 8.9 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
-ENABLE_FEAT_TCR2			:=	1
+ENABLE_FEAT_TCR2			?=	1
 endif
 
 #
diff --git a/services/oem/chromeos/widevine_smc_handlers.c b/services/oem/chromeos/widevine_smc_handlers.c
new file mode 100644
index 0000000..83c6ccc
--- /dev/null
+++ b/services/oem/chromeos/widevine_smc_handlers.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2024, The ChromiumOS Authors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+#include <stdint.h>
+#include <string.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/psci/psci.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <services/oem/chromeos/widevine_smc_handlers.h>
+#include <tools_share/uuid.h>
+
+#define CROS_OEM_TPM_AUTH_PK_MAX_LEN 128
+#define CROS_OEM_HUK_LEN 32
+#define CROS_OEM_ROT_LEN 32
+
+static uint8_t cros_oem_tpm_auth_pk_buffer[CROS_OEM_TPM_AUTH_PK_MAX_LEN];
+static uint8_t cros_oem_huk_buffer[CROS_OEM_HUK_LEN];
+static uint8_t cros_oem_rot_len_buffer[CROS_OEM_ROT_LEN];
+
+struct cros_oem_data cros_oem_tpm_auth_pk = {
+	.buffer = cros_oem_tpm_auth_pk_buffer,
+	.max_length = sizeof(cros_oem_tpm_auth_pk_buffer),
+};
+
+struct cros_oem_data cros_oem_huk = {
+	.buffer = cros_oem_huk_buffer,
+	.max_length = sizeof(cros_oem_huk_buffer),
+};
+
+struct cros_oem_data cros_oem_rot = {
+	.buffer = cros_oem_rot_len_buffer,
+	.max_length = sizeof(cros_oem_rot_len_buffer),
+};
+
+static uintptr_t cros_write_data(struct cros_oem_data *data,
+				 u_register_t length, u_register_t address,
+				 void *handle)
+{
+	uintptr_t aligned_address;
+	uintptr_t aligned_size;
+	int32_t rc;
+
+	if (data->length) {
+		SMC_RET1(handle, PSCI_E_ALREADY_ON);
+	}
+
+	if (length > data->max_length) {
+		SMC_RET1(handle, PSCI_E_INVALID_PARAMS);
+	}
+
+	aligned_address = page_align(address, DOWN);
+	aligned_size = page_align(length + (address - aligned_address), UP);
+
+	/*
+	 * We do not validate the passed in address because we are trusting the
+	 * non-secure world at this point still.
+	 */
+	rc = mmap_add_dynamic_region(aligned_address, aligned_address,
+				     aligned_size, MT_MEMORY | MT_RO | MT_NS);
+	if (rc != 0) {
+		SMC_RET1(handle, PSCI_E_INVALID_ADDRESS);
+	}
+
+	memcpy(data->buffer, (void *)address, length);
+	data->length = length;
+
+	mmap_remove_dynamic_region(aligned_address, aligned_size);
+	SMC_RET1(handle, SMC_OK);
+}
+
+/* Handler for servicing specific SMC calls. */
+static uintptr_t cros_oem_svc_smc_handler(uint32_t smc_fid, u_register_t x1,
+					  u_register_t x2, u_register_t x3,
+					  u_register_t x4, void *cookie,
+					  void *handle, u_register_t flags)
+{
+	switch (smc_fid) {
+	case CROS_OEM_SMC_DRM_SET_TPM_AUTH_PUB_FUNC_ID:
+		return cros_write_data(&cros_oem_tpm_auth_pk, x1, x2, handle);
+	case CROS_OEM_SMC_DRM_SET_HARDWARE_UNIQUE_KEY_FUNC_ID:
+		return cros_write_data(&cros_oem_huk, x1, x2, handle);
+	case CROS_OEM_SMC_DRM_SET_ROOT_OF_TRUST_FUNC_ID:
+		return cros_write_data(&cros_oem_rot, x1, x2, handle);
+	default:
+		WARN("Unimplemented OEM Call: 0x%x\n", smc_fid);
+		SMC_RET1(handle, SMC_UNK);
+	}
+}
+
+/* Register OEM Service Calls as runtime service */
+DECLARE_RT_SVC(cros_oem_svc_smc_handler, OEN_OEM_START, OEN_OEM_END,
+	       SMC_TYPE_FAST, NULL, cros_oem_svc_smc_handler);
diff --git a/services/spd/opteed/opteed.mk b/services/spd/opteed/opteed.mk
index f394744..289b3e7 100644
--- a/services/spd/opteed/opteed.mk
+++ b/services/spd/opteed/opteed.mk
@@ -33,3 +33,11 @@
 $(eval $(call add_define,OPTEE_ALLOW_SMC_LOAD))
 include lib/libfdt/libfdt.mk
 endif
+
+CROS_WIDEVINE_SMC		:=	0
+ifeq ($(CROS_WIDEVINE_SMC),1)
+ifeq ($(OPTEE_ALLOW_SMC_LOAD),0)
+$(error When CROS_WIDEVINE_SMC=1, OPTEE_ALLOW_SMC_LOAD must also be 1)
+endif
+$(eval $(call add_define,CROS_WIDEVINE_SMC))
+endif
diff --git a/services/spd/opteed/opteed_main.c b/services/spd/opteed/opteed_main.c
index ab9896e..83b001a 100644
--- a/services/spd/opteed/opteed_main.c
+++ b/services/spd/opteed/opteed_main.c
@@ -33,6 +33,7 @@
 #include <libfdt.h>
 #endif  /* OPTEE_ALLOW_SMC_LOAD */
 #include <plat/common/platform.h>
+#include <services/oem/chromeos/widevine_smc_handlers.h>
 #include <tools_share/uuid.h>
 
 #include "opteed_private.h"
@@ -61,7 +62,7 @@
 	0xb1eafba3, 0x5d31, 0x4612, 0xb9, 0x06,
 	0xc4, 0xc7, 0xa4, 0xbe, 0x3c, 0xc0);
 
-#define OPTEED_FDT_SIZE 256
+#define OPTEED_FDT_SIZE 1024
 static uint8_t fdt_buf[OPTEED_FDT_SIZE] __aligned(CACHE_WRITEBACK_GRANULE);
 
 #else
@@ -299,6 +300,62 @@
 }
 #endif /* COREBOOT */
 
+#if CROS_WIDEVINE_SMC
+/*
+ * Adds a options/widevine node with the widevine table information to a device
+ * tree. Returns zero on success or if there is no widevine table information;
+ * failure code otherwise.
+ */
+static int add_options_widevine_node(void *fdt)
+{
+	int ret;
+
+	ret = fdt_begin_node(fdt, "options");
+	if (ret)
+		return ret;
+
+	ret = fdt_begin_node(fdt, "op-tee");
+	if (ret)
+		return ret;
+
+	ret = fdt_begin_node(fdt, "widevine");
+	if (ret)
+		return ret;
+
+	if (cros_oem_tpm_auth_pk.length) {
+		ret = fdt_property(fdt, "tcg,tpm-auth-public-key",
+				   cros_oem_tpm_auth_pk.buffer,
+				   cros_oem_tpm_auth_pk.length);
+		if (ret)
+			return ret;
+	}
+
+	if (cros_oem_huk.length) {
+		ret = fdt_property(fdt, "op-tee,hardware-unique-key",
+				   cros_oem_huk.buffer, cros_oem_huk.length);
+		if (ret)
+			return ret;
+	}
+
+	if (cros_oem_rot.length) {
+		ret = fdt_property(fdt, "google,widevine-root-of-trust-ecc-p256",
+				   cros_oem_rot.buffer, cros_oem_rot.length);
+		if (ret)
+			return ret;
+	}
+
+	ret = fdt_end_node(fdt);
+	if (ret)
+		return ret;
+
+	ret = fdt_end_node(fdt);
+	if (ret)
+		return ret;
+
+	return fdt_end_node(fdt);
+}
+#endif /* CROS_WIDEVINE_SMC */
+
 /*
  * Creates a device tree for passing into OP-TEE. Currently is populated with
  * the coreboot table address.
@@ -326,6 +383,12 @@
 		return ret;
 #endif /* COREBOOT */
 
+#if CROS_WIDEVINE_SMC
+	ret = add_options_widevine_node(fdt_buf);
+	if (ret)
+		return ret;
+#endif /* CROS_WIDEVINE_SMC */
+
 	ret = fdt_end_node(fdt_buf);
 	if (ret)
 		return ret;