From patchwork Fri Nov 16 06:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 151293 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp69515ljp; Thu, 15 Nov 2018 22:57:45 -0800 (PST) X-Google-Smtp-Source: AJdET5djRr9o9O/eyzoNZ1T9HjXYRPtUFRd0Gzt2wG7qEixql+Tsb0nI8Rw2uLaKg6F/YvoYobK0 X-Received: by 2002:aa7:8254:: with SMTP id e20-v6mr9961198pfn.164.1542351465415; Thu, 15 Nov 2018 22:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542351465; cv=none; d=google.com; s=arc-20160816; b=w7EdChnV5gjT+J+YA90kHKc5ySAJbejQcRenfzXAAVcgoSdyKeR7c0NtWPsl7eklXV gDSoVVuzxDkzyMZd42uBWWvNah7PzrsCBL3Ah7jPtV+qpUs73VHFcZTT9YnLm8a0jjO9 sx3pNEc0UxDL6ltXYuk4RQGwS1vcRxna+VBTHw0xtw6lR9jcG3xjCeGhWBsHlUB6rEaH O0e3gHe1P7wC0yIaMEBtD+0ZvZrtgI+p8ELQse7wnx6+hdqGvetR0WDK2nRjYBmN7/Ub 17P9rMQjP3pSnR05e2nBjfiT7sMDXR+o9C5afyfN8pDRVDAmLfYYBnFVUPdAktZWDv3U uHDg== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=jsMidW7aYIUWNk/66xSJBp1ZLVbRfkJvPXZjt9eLwno=; b=XisZn+lT0PusoS08+x7NmLH6nN2Ng/RfLcpT8SW3afsilfMm//m4mI0PcB4eE2LR85 QTlem+noJygLJftc06yiSBJQ58nwY2wtcmJC5y0dc2KH1plJ2AD6OT4/fuVxdj3M/Rmt LxvlXA0OYov2ynSbRnKqcRN5fpL1K90lqOQ6VRIYS5Gys46+J9MAaVdOAZel0+sZbc1V 2Bet6sV6UHftznXPrCMzjXKu1fc8p8WiUz2j/MKVkQydmLiQ3eJXAwYM1rEyzaDQQp2h Yd55OKBgWrAYdBLoPRz+IkX0g2kghi+e5srF9qSjhtiiZBF7ZWMb+fYqVHzdrXns0Yt4 1EdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a2qgyvQE; 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 q128si16223690pfc.179.2018.11.15.22.57.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 22:57:45 -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=a2qgyvQE; 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 0E4B321191F27; Thu, 15 Nov 2018 22:57:45 -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::442; helo=mail-pf1-x442.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 7E18221191747 for ; Thu, 15 Nov 2018 22:57:43 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id c72so6256892pfc.6 for ; Thu, 15 Nov 2018 22:57:43 -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:in-reply-to:references; bh=wjnQPR+L8nS2430Ovk07Vc9Qly6UvRMHkTeLFqnx6/s=; b=a2qgyvQEx24FjaQtdXDVPJ66JlIUpsLlIqZzxygrNteEsGm8/1Djq5FGf5hZQWeyM6 24L6OM0BOLOInQRfZj/nT9ofOE6TQdGX5pAZrVcRhmc4PjJQ/Ri+AXvehBZMeK3Lit6/ VeCfJiae3rTm8Tsh30PegrURwZKUplO3wfNgk= 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:in-reply-to :references; bh=wjnQPR+L8nS2430Ovk07Vc9Qly6UvRMHkTeLFqnx6/s=; b=HcNHbFWjaB2V+tMBn+aHETtAqgIntAMuhZmAUtbFdSXOE02av7K+TCM3vMnmvJ1dSI HlUE7SjN4asiSxCLNDl0qDdV/av5+2Y15bNXALh+blHxQyLaMbB5sQPs985xcN6Bb1JL WyinWXeWqMAMZ4YGGCTq1Qj1zUziIEsWIewILKiVhNjL3I3VCMbqfglufMbmv6Dz4ROY /wDaxn8ziu4mXwClrQPuRaQfbIKKeZMpbtPorfVZTvs626wzo0P+otXExpgMihPlBM24 OENJ4EAFfEYrlS2er/8isWartpRoHY/uwtRsh4m/EehFqy4cYgM4zKezQZKOlD5AaDME 3e5A== X-Gm-Message-State: AGRZ1gJ4h8RHRNr1Dr2pbzcnj17wu5Ptrj/duZf4BJZtqrk/31TCx5hc QFf+MboFP4AZu5bo0HEn6IrIOA== X-Received: by 2002:a63:1766:: with SMTP id 38mr8655856pgx.299.1542351463176; Thu, 15 Nov 2018 22:57:43 -0800 (PST) Received: from localhost.localdomain ([203.160.91.226]) by smtp.gmail.com with ESMTPSA id h134sm2835905pfe.27.2018.11.15.22.57.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 22:57:42 -0800 (PST) From: Ming Huang To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org Date: Fri, 16 Nov 2018 14:56:54 +0800 Message-Id: <20181116065702.30559-8-ming.huang@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20181116065702.30559-1-ming.huang@linaro.org> References: <20181116065702.30559-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 07/15] Hisilicon/D0x: Fix secure boot bug in FlashFvbDxe 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: huangming23@huawei.com, xinliang.liu@linaro.org, john.garry@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, zhangfeng56@huawei.com, michael.d.kinney@intel.com, lersek@redhat.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" When SECURE_BOOT_ENABLE is TRUE, FlashFvbDxe should use gEfiAuthenticatedVariableGuid, When SECURE_BOOT_ENABLE is FALSE, gEfiVariableGuid should be used. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang --- Silicon/Hisilicon/HisiPkg.dec | 1 + Platform/Hisilicon/D03/D03.dsc | 5 +++++ Platform/Hisilicon/D05/D05.dsc | 5 +++++ Platform/Hisilicon/D06/D06.dsc | 5 +++++ Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf | 2 ++ Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c | 14 ++++++++++++-- 6 files changed, 30 insertions(+), 2 deletions(-) -- 2.9.5 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec index 404a3ae4af9d..af9359e4d0e0 100644 --- a/Silicon/Hisilicon/HisiPkg.dec +++ b/Silicon/Hisilicon/HisiPkg.dec @@ -278,6 +278,7 @@ [PcdsFixedAtBuild] gHisiTokenSpaceGuid.Pcdsoctype|0|UINT32|0x00000061 gHisiTokenSpaceGuid.PcdSerDesFlowCtrlFlag|0|UINT32|0x40000056 + gHisiTokenSpaceGuid.PcdIsSecureBoot|FALSE|BOOLEAN|0x40000058 [PcdsFeatureFlag] gHisiTokenSpaceGuid.PcdIsItsSupported|FALSE|BOOLEAN|0x00000065 diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc index aa1da5d61f83..ba3096672db0 100644 --- a/Platform/Hisilicon/D03/D03.dsc +++ b/Platform/Hisilicon/D03/D03.dsc @@ -281,6 +281,11 @@ [PcdsFixedAtBuild.common] gHisiTokenSpaceGuid.PcdHb0Rb2IoSize|0xffff #64K gHisiTokenSpaceGuid.Pcdsoctype|0x1610 + !if $(SECURE_BOOT_ENABLE) == TRUE + gHisiTokenSpaceGuid.PcdIsSecureBoot|TRUE + !else + gHisiTokenSpaceGuid.PcdIsSecureBoot|FALSE + !endif ################################################################################ # diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc index 1040466633ef..b8500cef8742 100644 --- a/Platform/Hisilicon/D05/D05.dsc +++ b/Platform/Hisilicon/D05/D05.dsc @@ -422,6 +422,11 @@ [PcdsFixedAtBuild.common] gHisiTokenSpaceGuid.PcdHb1Rb7IoSize|0x10000 #64K gHisiTokenSpaceGuid.Pcdsoctype|0x1610 + !if $(SECURE_BOOT_ENABLE) == TRUE + gHisiTokenSpaceGuid.PcdIsSecureBoot|TRUE + !else + gHisiTokenSpaceGuid.PcdIsSecureBoot|FALSE + !endif ################################################################################ # diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc index 1a479c160e80..b6ef9fedf0a7 100644 --- a/Platform/Hisilicon/D06/D06.dsc +++ b/Platform/Hisilicon/D06/D06.dsc @@ -243,6 +243,11 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE gArmTokenSpaceGuid.PcdPciIoTranslation|0x0 + !if $(SECURE_BOOT_ENABLE) == TRUE + gHisiTokenSpaceGuid.PcdIsSecureBoot|TRUE + !else + gHisiTokenSpaceGuid.PcdIsSecureBoot|FALSE + !endif ################################################################################ # diff --git a/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf b/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf index f8be4741ef7c..47965a707032 100644 --- a/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf +++ b/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf @@ -44,6 +44,7 @@ [LibraryClasses] UefiRuntimeLib [Guids] + gEfiAuthenticatedVariableGuid gEfiSystemNvDataFvGuid gEfiVariableGuid @@ -62,6 +63,7 @@ [Pcd.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked + gHisiTokenSpaceGuid.PcdIsSecureBoot gHisiTokenSpaceGuid.PcdSFCMEM0BaseAddress [Depex] diff --git a/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c b/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c index e18cc9e06ec2..309941d6fe4d 100644 --- a/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c +++ b/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c @@ -189,7 +189,11 @@ InitializeFvAndVariableStoreHeaders ( // VARIABLE_STORE_HEADER // VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + (UINTN)FirmwareVolumeHeader->HeaderLength); - CopyGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid); + if (PcdGetBool (PcdIsSecureBoot)) { + CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); + } else { + CopyGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid); + } VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength; VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; @@ -220,6 +224,7 @@ ValidateFvHeader ( VARIABLE_STORE_HEADER* VariableStoreHeader; UINTN VariableStoreLength; UINTN FvLength; + EFI_GUID *Guid; FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress; @@ -258,7 +263,12 @@ ValidateFvHeader ( VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + (UINTN)FwVolHeader->HeaderLength); // Check the Variable Store Guid - if ( CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) == FALSE ) + if (PcdGetBool (PcdIsSecureBoot)) { + Guid = &gEfiAuthenticatedVariableGuid; + } else { + Guid = &gEfiVariableGuid; + } + if (CompareGuid (&VariableStoreHeader->Signature, Guid) == FALSE) { DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Variable Store Guid non-compatible\n")); return EFI_NOT_FOUND;