Merge "QcomModulePkg: Append new platform type in protocol header"
diff --git a/QcomModulePkg/Include/Library/BootLinux.h b/QcomModulePkg/Include/Library/BootLinux.h
index 4d1e3d3..ef6c532 100644
--- a/QcomModulePkg/Include/Library/BootLinux.h
+++ b/QcomModulePkg/Include/Library/BootLinux.h
@@ -78,6 +78,12 @@
#define DECOMPRESS_SIZE_FACTOR 8
#define ALIGNMENT_MASK_4KB 4096
#define MAX_NUMBER_OF_LOADED_IMAGES 32
+/* Size of the header that is used in case the boot image has
+ * a uncompressed kernel + appended dtb */
+#define PATCHED_KERNEL_HEADER_SIZE 20
+/* String used to determine if the boot image has
+ * a uncompressed kernel + appended dtb */
+#define PATCHED_KERNEL_MAGIC "UNCOMPRESSED_IMG"
typedef VOID (*LINUX_KERNEL) (UINT64 ParametersBase,
UINT64 Reserved0,
@@ -117,6 +123,7 @@
UINT64 RamdiskLoadAddr;
UINT32 RamdiskSize;
UINT32 RamdiskOffset;
+ UINT32 PatchedKernelHdrSize;
CHAR8 *FinalCmdLine;
CHAR8 *CmdLine;
BOOLEAN BootingWith32BitKernel;
diff --git a/QcomModulePkg/Include/Protocol/EFIASN1X509.h b/QcomModulePkg/Include/Protocol/EFIASN1X509.h
new file mode 100644
index 0000000..97b0377
--- /dev/null
+++ b/QcomModulePkg/Include/Protocol/EFIASN1X509.h
@@ -0,0 +1,176 @@
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _EFIASN1X509_H
+#define _EFIASN1X509_H
+
+#include <Uefi.h>
+
+#define QCOM_ASN1X509_PROTOCOL_REVISION 0x0000000000010001
+#define EFI_ASN1X509_PROTOCOL_GUID \
+{ \
+ 0x408ec123, 0x134e, 0x4b80, \
+ { 0x91, 0x42, 0xb8, 0x9a, 0xe, 0x08, 0xf8, 0xb3 } \
+}
+
+extern EFI_GUID gEfiQcomASN1X509ProtocolGuid;
+
+typedef struct _QCOM_ASN1X509_PROTOCOL QcomAsn1x509Protocol;
+
+#define MAX_LEN 4096
+#define SIGNATURE_SHA256_LEN 256
+#define E_ASN1_FAILURE 5
+#define EFI_FAILURE (80)
+
+/* Program defined basic ASN1 data types for better reading/understanding
+ AndroidVerifiedBoot data types */
+#define INTEGER struct secasn1_data_type
+#define OBJECT_IDENTIFIER struct secasn1_data_type
+#define CHARACTER_STRING struct secasn1_data_type
+#define OCTET_STRING struct secasn1_data_type
+#define BIT_STRING struct secasn1_data_type
+#define SEQUENCE secasn1_data_type
+
+/* ASN data tags that are not defined in SecBoot_asn1.h */
+#define SECASN1_CHARACTER_STRING_TYPE (0x1D)
+#define SECX509_ISSUER_ID_TAG (0x81)
+#define SECX509_SUBJECT_ID_TAG (0x82)
+#define SECX509_VERSION_TAG (0xA0)
+#define SECX509_EXTENSION_TAG (0xA3)
+#define SECASN1_GTIME_TYPE (0x24)
+
+/**
+ * AndroidVerifiedBootSignature DEFINITIONS ::=
+ * BEGIN
+ * FormatVersion ::= INTEGER
+ * Certificate ::= Certificate
+ * AlgorithmIdentifier ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ * AuthenticatedAttributes ::= SEQUENCE {
+ * target CHARACTER STRING,
+ * length INTEGER
+ * }
+ * Signature ::= OCTET STRING
+ * END
+ **/
+typedef struct verif_boot_sig_st {
+ CONST UINT8 *formatversion;
+ UINTN FormatVersionLen;
+ CONST UINT8 *certificate;
+ UINTN CertificateLen;
+ CONST UINT8 *algorithm_id;
+ UINTN AlgorithmIdLen;
+ CONST UINT8 *auth_attr;
+ UINTN AuthAttrLen;
+ CONST UINT8 *sig;
+ UINTN SigLen;
+} VERIFIED_BOOT_SIG;
+
+typedef struct rsa_st {
+ CONST UINT8 *algorithm_id;
+ CONST UINT8 *RSAPublicKey;
+} RSA;
+
+/**
+* Certificate ::= SEQUENCE {
+* tbsCertificate TBSCertificate,
+* signatureAlgorithm AlgorithmIdentifier,
+* signature BIT STRING
+* }
+**/
+typedef struct certificate_st {
+ CONST UINT8 *tbscertificate;
+ UINTN TbsCertificateLen;
+ CONST UINT8 *algorithmIdentifier;
+ UINTN AlgorithmIdentifierLen;
+ CONST UINT8 *signature;
+ UINTN SignatureLen;
+} CERTIFICATE;
+
+/* ASN.1 data holder */
+typedef struct secasn1_data_type
+{
+ CONST UINT8 *data;
+ CONST UINT8 *data_bound;
+ UINT32 Len;
+} secasn1_data_type;
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_GET_AUTHATTR_FIELDS)(
+ IN QcomAsn1x509Protocol *This,
+ IN CONST UINT8 *data,
+ IN UINTN Len,
+ OUT secasn1_data_type *target,
+ OUT secasn1_data_type *length);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_GET_RSA_FROM_CERTIFICATE)(
+ IN QcomAsn1x509Protocol *This,
+ IN CERTIFICATE *certificate,
+ OUT RSA *out_key);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_GET_RSA_FROM_VB_SIGNATURE)(
+ IN QcomAsn1x509Protocol *This,
+ IN VERIFIED_BOOT_SIG *vb_signature,
+ OUT RSA *out_key);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_GET_SIG_FROM_VB_SIGNATURE)(
+ IN QcomAsn1x509Protocol *This,
+ IN VERIFIED_BOOT_SIG *vbsignature,
+ OUT secasn1_data_type *signature);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_GET_KEYMATERIAL_FROM_RSA)(
+ IN QcomAsn1x509Protocol *This,
+ IN RSA *key,
+ OUT secasn1_data_type *out_modulus,
+ OUT secasn1_data_type *out_public_exp);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_VERIFY_VB_SIGNATURE)(
+ IN QcomAsn1x509Protocol *This,
+ IN CONST UINT8 *data,
+ IN UINTN Len,
+ OUT VERIFIED_BOOT_SIG *out_vb_signaure);
+
+typedef EFI_STATUS (EFIAPI *QCOM_ASN1X509_VERIFY_OEM_CERTIFICATE)(
+ IN QcomAsn1x509Protocol *This,
+ IN CONST UINT8 *data,
+ IN UINTN Len,
+ OUT CERTIFICATE *certificate);
+
+typedef struct _QCOM_ASN1X509_PROTOCOL {
+ UINT64 Revision;
+ QCOM_ASN1X509_GET_AUTHATTR_FIELDS ASN1X509GetAuthAttrFields;
+ QCOM_ASN1X509_GET_KEYMATERIAL_FROM_RSA ASN1X509GetKeymaterial;
+ QCOM_ASN1X509_GET_RSA_FROM_CERTIFICATE ASN1X509GetRSAFromCert;
+ QCOM_ASN1X509_GET_RSA_FROM_VB_SIGNATURE ASN1X509GetRSAFromVBSig;
+ QCOM_ASN1X509_GET_SIG_FROM_VB_SIGNATURE ASN1X509GetSigFromVBSig;
+ QCOM_ASN1X509_VERIFY_OEM_CERTIFICATE ASN1X509VerifyOEMCertificate;
+ QCOM_ASN1X509_VERIFY_VB_SIGNATURE ASN1X509VerifyVBSig;
+}QcomAsn1x509Protocol;
+
+#endif
diff --git a/QcomModulePkg/Include/Protocol/EFISecRSA.h b/QcomModulePkg/Include/Protocol/EFISecRSA.h
new file mode 100644
index 0000000..b27fb38
--- /dev/null
+++ b/QcomModulePkg/Include/Protocol/EFISecRSA.h
@@ -0,0 +1,247 @@
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __EFISECRSA_H__
+#define __EFISECRSA_H__
+
+/*===========================================================================
+ INCLUDE FILES
+===========================================================================*/
+#include <Uefi.h>
+
+/*===========================================================================
+ MACRO DECLARATIONS
+===========================================================================*/
+/** @ingroup
+ Protocol version.
+*/
+#define QCOM_SECRSA_PROTOCOL_REVISION 0x0000000000010001
+/* Protocol GUID definition */
+/** @ingroup efi_secrsa_protocol */
+#define EFI_SECRSA_PROTOCOL_GUID \
+{ \
+ 0xeb7a442a, 0xcef4, 0x40a7, \
+ { 0xa8, 0xae, 0x5a, 0x2e, 0x7f, 0x48, 0xe1, 0x72 } \
+}
+
+typedef UINT32 Blong;
+#define RSA_MAX_KEY_SIZE 4128 //redefinition in secboot_types.h
+ ///< Maximum key size in bits
+#define BLONG_SIZE sizeof(Blong) ///< Bytes per digit
+#define BN_BITS_PER_WORD (BLONG_SIZE * 8) ///< Bit per digit
+#define BLONGS_PER_KEY (RSA_MAX_KEY_SIZE + 8 * BLONG_SIZE -1) / (8 * BLONG_SIZE)
+///< Digits per key
+#define BYTES_TO_BLONG_SHIFT 2 ///< bytes/sizeof(BLONG)
+#define BLONG_MAX_ELEMENTS BLONGS_PER_KEY
+#define NUMBER_OF_RANDOM_WORDS 3
+// n. of 32 bit words for the random values 96 bits /32 (size of bit word);
+// // number of random 32 bit words
+#define WORD_SIZE_32 BLONG_SIZE
+#define MASKED_LENGTH (WORD_SIZE_32 * NUMBER_OF_RANDOM_WORDS)
+// 96 bits (masked by multiplication)
+#define MASKED_MAX_ELEMENT (BLONG_MAX_ELEMENTS + MASKED_LENGTH)
+// ELEMENT:= message or key
+
+typedef struct {
+ Blong Akey[BLONGS_PER_KEY]; ///< Make room for multiplication
+ INT32 Nlen; ///< Current length of a
+} BigInt;
+
+/*RSA key data structure with sign.
+ sign is needed when the second form of private key
+ is provided */
+typedef struct S_BIGINT {
+ BigInt Bi;
+ INT32 Sign;
+} S_BIGINT;
+
+/*RSA padding type. PKCS #1 v2.1*/
+typedef enum {
+ /*PKCS1 v1.5 signature*/
+ CE_RSA_PAD_PKCS1_V1_5_SIG = 1,
+ /*PKCS1 v1.5 encryption*/
+ CE_RSA_PAD_PKCS1_V1_5_ENC = 2,
+ /*OAEP Encryption*/
+ CE_RSA_PAD_PKCS1_OAEP = 3,
+ /*PSS Signature*/
+ CE_RSA_PAD_PKCS1_PSS = 4,
+ /* No Padding */
+ CE_RSA_NO_PAD = 5,
+ /*PSS with unknown saltlen*/
+ CE_RSA_PAD_PKCS1_PSS_AUTORECOVER_SALTLEN = 6,
+ CE_RSA_PAD_INVALID = 0x7FFFFFFF,
+} CE_RSA_PADDING_TYPE;
+
+/** RSA PKCS key */
+typedef struct CE_RSA_KEY {
+ /** Type of key, CE_RSA_PRIVATE or CE_RSA_PUBLIC */
+ INT32 Type;
+ /** RSA key bit length **/
+ INT32 BitLength;
+ /** The public exponent */
+ S_BIGINT *e;
+ /** The private exponent */
+ S_BIGINT *d;
+ /** The modulus */
+ S_BIGINT *N;
+ /** The p factor of N */
+ S_BIGINT *p;
+ /** The q factor of N */
+ S_BIGINT *q;
+ /** The 1/q mod p CRT param */
+ S_BIGINT *qP;
+ /** The d mod (p - 1) CRT param */
+ S_BIGINT *dP;
+ /** The d mod (q - 1) CRT param */
+ S_BIGINT *dQ;
+} CE_RSA_KEY;
+
+/* error codes */
+typedef enum {
+ E_SECMATH_SUCCESS = 0, ///< Result OK
+ E_SECMATH_FAILURE, ///< Generic Error */
+ E_SECMATH_NOP, ///< Not a failure but no operation performed
+ E_SECMATH_FAIL_TESTVECTOR, ///< Algorithm failed test vectors */
+ E_SECMATH_BUFFER_OVERFLOW, ///< Not enough space for output */
+ E_SECMATH_MEM, ///< Out of memory */
+ E_SECMATH_INVALID_ARG, ///< Generic invalid argument */
+ E_SECMATH_INVALID_PRIME_SIZE, ///< Invalid size of prime requested */
+ E_SECMATH_NOT_SUPPORTED ///< Operation not supported
+} SECMATH_ERRNO_ET;
+
+/*index of hash algorithm used for generating signature */
+typedef enum {
+ CE_HASH_IDX_NULL = 0x1,
+ CE_HASH_IDX_SHA1 = 0x2,
+ CE_HASH_IDX_SHA256 = 0x3,
+ CE_HASH_IDX_SHA224 = 0x4,
+ CE_HASH_IDX_SHA384 = 0x5,
+ CE_HASH_IDX_SHA512 = 0x6,
+ CE_HASH_IDX_SHA256_SHA1 = 0x7,
+ CE_HASH_IDX_MAX = 0x8,
+ CE_HASH_IDX_INVALID = 0x7FFFFFFF
+} CE_HASH_IDX;
+
+/*sign*/
+#define S_BIGINT_POS 0 /* positive */
+#define S_BIGINT_NEG 1 /* negative */
+
+/* equalities */
+#define S_BIGINT_LT -1 /* less than */
+#define S_BIGINT_EQ 0 /* equal to */
+#define S_BIGINT_GT 1 /* greater than */
+
+typedef enum {
+ /* Result OK */
+ CE_SUCCESS = E_SECMATH_SUCCESS,
+ /* Generic Error */
+ CE_ERROR_FAILURE = E_SECMATH_FAILURE,
+ /* Not a failure but no operation was performed */
+ CE_ERROR_NOP = E_SECMATH_NOP,
+ /* Algorithm failed test vectors */
+ CE_ERROR_FAIL_TESTVECTOR = E_SECMATH_FAIL_TESTVECTOR,
+ /* Not enough space for output */
+ CE_ERROR_BUFFER_OVERFLOW = E_SECMATH_BUFFER_OVERFLOW,
+ /* Out of memory */
+ CE_ERROR_NO_MEMORY = E_SECMATH_MEM,
+ /* Generic invalid argument */
+ CE_ERROR_INVALID_ARG = E_SECMATH_INVALID_ARG,
+ /* Invalid size of prime requested */
+ CE_ERROR_INVALID_SIZE = E_SECMATH_INVALID_PRIME_SIZE,
+ /* Operation not supported */
+ CE_ERROR_NOT_SUPPORTED = E_SECMATH_NOT_SUPPORTED,
+ /* invalid signature */
+ CE_ERROR_INVALID_SIGNATURE = 0x1000,
+ /* decrypt error */
+ CE_ERROR_DECRYPT_ERROR = 0x1002,
+ /* invalid packet */
+ CE_ERROR_INVALID_PACKET = 0x1003,
+ /* message too long */
+ CE_ERROR_MESSAGE_TOO_LONG = 0x1004,
+} CeErrorType;
+
+/*CE RSA Key Type*/
+typedef enum {
+ CE_RSA_KEY_PUBLIC = 0, /*public key*/
+ CE_RSA_KEY_PRIVATE = 1, /*private key in non CRT representation*/
+ CE_RSA_KEY_PRIVATE_CRT = 2, /*private key in CRT representation*/
+ CE_RSA_KEY_PRIVATE_PUBLIC = 3, /*private/public key pair*/
+ CE_RSA_KEY_PRIVATE_CRT_PUBLIC = 4, /*private CRT/public key pair*/
+ CE_RSA_KEY_INVALID = 0x7FFFFFFF
+} CE_RSA_KEY_TYPE;
+
+/*===========================================================================
+ EXTERNAL VARIABLES
+===========================================================================*/
+/** @ingroup */
+extern EFI_GUID gEfiQcomSecRSAProtocolGuid;
+
+/*===========================================================================
+ TYPE DEFINITIONS
+===========================================================================*/
+/** @cond */
+/* Protocol declaration. */
+typedef struct _QCOM_SECRSA_PROTOCOL QcomSecRsaProtocol;
+/** @endcond */
+
+/*===========================================================================
+ FUNCTION DEFINITIONS
+===========================================================================*/
+typedef EFI_STATUS (EFIAPI *QCOM_SECRSA_BIGINT_READ_BIN)(
+ IN QcomSecRsaProtocol *This,
+ IN CONST UINT8 *buf,
+ IN UINT32 BufLen,
+ OUT BigInt *bigint_buf);
+
+typedef EFI_STATUS (EFIAPI *QCOM_SECRSA_VERIFY_SIGNATURE)(
+ IN QcomSecRsaProtocol *This,
+ IN CE_RSA_KEY *key,
+ IN CE_RSA_PADDING_TYPE PaddingType,
+ IN VOID *padding_info,
+ IN INT32 HashIdx,
+ IN UINT8 *hash,
+ IN INT32 HashLen,
+ IN CONST UINT8 *signature_ptr,
+ IN UINT32 SignatureLen);
+/*====================================================================
+ PROTOCOL INTERFACE
+===========================================================================*/
+/** @ingroup
+ @par Summary
+ SECRSA Protocol interface.
+
+ @par Parameters
+ @inputprotoparams
+*/
+typedef struct _QCOM_SECRSA_PROTOCOL {
+ UINT64 Revision;
+ QCOM_SECRSA_BIGINT_READ_BIN SecRSABigIntReadBin;
+ QCOM_SECRSA_VERIFY_SIGNATURE SecRSAVerifySig;
+}QcomSecRsaProtocol;
+
+#endif /* __EFIVERIFIEDBOOT_H__ */
diff --git a/QcomModulePkg/Library/BootLib/BootLinux.c b/QcomModulePkg/Library/BootLib/BootLinux.c
index 2be5bef..8e569c6 100644
--- a/QcomModulePkg/Library/BootLib/BootLinux.c
+++ b/QcomModulePkg/Library/BootLib/BootLinux.c
@@ -183,10 +183,11 @@
if (!DtboImgInvalid) {
// appended device tree
Dtb = DeviceTreeAppended ((VOID *)(BootParamlistPtr->ImageBuffer +
- BootParamlistPtr->PageSize),
- BootParamlistPtr->KernelSize,
- DtbOffset,
- (VOID *)BootParamlistPtr->DeviceTreeLoadAddr);
+ BootParamlistPtr->PageSize +
+ BootParamlistPtr->PatchedKernelHdrSize),
+ BootParamlistPtr->KernelSize,
+ DtbOffset,
+ (VOID *)BootParamlistPtr->DeviceTreeLoadAddr);
if (!Dtb) {
if (DtbOffset >= BootParamlistPtr->KernelSize) {
DEBUG ((EFI_D_ERROR, "Dtb offset goes beyond the kernel size\n"));
@@ -229,7 +230,8 @@
/*It is the case of DTB overlay Get the Soc specific dtb */
FinalDtbHdr = SocDtb =
GetSocDtb ((VOID *)(BootParamlistPtr->ImageBuffer +
- BootParamlistPtr->PageSize),
+ BootParamlistPtr->PageSize +
+ BootParamlistPtr->PatchedKernelHdrSize),
BootParamlistPtr->KernelSize,
DtbOffset,
(VOID *)BootParamlistPtr->DeviceTreeLoadAddr);
@@ -332,9 +334,28 @@
Kptr = (struct kernel64_hdr *)*KernelLoadAddr;
} else {
- Kptr = BootParamlistPtr->ImageBuffer + BootParamlistPtr->PageSize;
+ Kptr = (struct kernel64_hdr *)(BootParamlistPtr->ImageBuffer
+ + BootParamlistPtr->PageSize);
+ DEBUG ((EFI_D_INFO, "Uncompressed kernel in use\n"));
+ /* Patch kernel support only for 64-bit */
+ if (!AsciiStrnCmp ((char*)(BootParamlistPtr->ImageBuffer
+ + BootParamlistPtr->PageSize), PATCHED_KERNEL_MAGIC,
+ sizeof (PATCHED_KERNEL_MAGIC) - 1)) {
+ DEBUG ((EFI_D_VERBOSE, "Patched kernel detected\n"));
- /* Uncompress kernel - zImage*/
+ /* The size of the kernel is stored at start of kernel image + 16
+ * The dtb would start just after the kernel */
+ gBS->CopyMem ((VOID *)DtbOffset, (VOID *) (BootParamlistPtr->ImageBuffer
+ + BootParamlistPtr->PageSize + sizeof (PATCHED_KERNEL_MAGIC)
+ - 1), sizeof (*DtbOffset));
+
+ BootParamlistPtr->PatchedKernelHdrSize = PATCHED_KERNEL_HEADER_SIZE;
+ Kptr = (struct kernel64_hdr *)((VOID *)Kptr +
+ BootParamlistPtr->PatchedKernelHdrSize);
+ gBS->CopyMem ((VOID *)*KernelLoadAddr, (VOID *)Kptr,
+ BootParamlistPtr->KernelSize);
+ }
+
if (Kptr->magic_64 != KERNEL64_HDR_MAGIC) {
*KernelLoadAddr =
(EFI_PHYSICAL_ADDRESS) (BootParamlistPtr->BaseMemory |
diff --git a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
index 42ba162..952d016 100644
--- a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
@@ -613,8 +613,7 @@
INT32 MinPlatIdLen)
{
- if (CurDtbInfo == NULL ||
- PlatProp == NULL) {
+ if (CurDtbInfo == NULL) {
DEBUG ((EFI_D_VERBOSE, "Input parameters null\n"));
return EFI_INVALID_PARAMETER;
}
@@ -676,8 +675,7 @@
CONST CHAR8 *BoardProp,
INT32 LenBoardId)
{
- if (CurDtbInfo == NULL ||
- BoardProp == NULL) {
+ if (CurDtbInfo == NULL) {
DEBUG ((EFI_D_VERBOSE, "Input parameters null\n"));
return EFI_INVALID_PARAMETER;
}
diff --git a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
index 2f04b29..b9d6dbd 100644
--- a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
+++ b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
@@ -1605,11 +1605,10 @@
if (Status == EFI_SUCCESS) {
FastbootOkay ("");
goto out;
- } else {
- FastbootFail ("Error Updating partition Table\n");
- goto out;
}
}
+ FastbootFail ("Error Updating partition Table\n");
+ goto out;
}
sparse_header = (sparse_header_t *)mFlashDataBuffer;
@@ -1700,6 +1699,17 @@
}
out:
+ if (!AsciiStrnCmp (arg, "system", AsciiStrLen ("system")) &&
+ GetAVBVersion () == AVB_1 &&
+ !IsEnforcing () &&
+ (FlashResult == EFI_SUCCESS)) {
+ // reset dm_verity mode to enforcing
+ Status = EnableEnforcingMode (TRUE);
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "failed to update verity mode: %r\n", Status));
+ }
+ }
+
LunSet = FALSE;
}
diff --git a/makefile b/makefile
index 1a09f4c..d36115f 100644
--- a/makefile
+++ b/makefile
@@ -43,14 +43,18 @@
UBSAN_GCC_FLAG_ALIGNMENT :=
endif
-ifeq ($(ENABLE_LE_VARIANT), true)
- ENABLE_LE_VARIANT := 1
+ifeq ($(TARGET_ARCHITECTURE), arm)
LOAD_ADDRESS := 0X8FB00000
else
- ENABLE_LE_VARIANT := 0
LOAD_ADDRESS := 0X9FA00000
endif
+ifeq ($(ENABLE_LE_VARIANT), true)
+ ENABLE_LE_VARIANT := 1
+else
+ ENABLE_LE_VARIANT := 0
+endif
+
.PHONY: all cleanall
all: ABL_FV_ELF