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::443; helo=mail-pf1-x443.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (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 8DF4721190733 for ; Wed, 14 Nov 2018 23:09:58 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id v9-v6so9237964pff.2 for ; Wed, 14 Nov 2018 23:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gIafDo/PNqQKoDaWQ/zPSfpZQAl7NA3pNnJN1//W3u8=; b=ityWd8W5IK+c3wu1PkOCA0foytgeyF0B0iYBRVFNjffKVhtZAJiIh7vTYD1IolTyLL zK2sDfldseeZdEyzyGa6FVrAx8gLXgclXq3wdLiGmLLGKXedPuj2m3RVbFEwEAr2oT08 1pocjIS7/oPssk+f9dPdIC1lSoe/r0gQCoXfU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gIafDo/PNqQKoDaWQ/zPSfpZQAl7NA3pNnJN1//W3u8=; b=mrIIH+SoiyiWtCuQyEIK7c9Jd3Jb31U2oAkpgGDBC3iLHQvc2oWZy1J05exT0sKWLI tF4am0C5cct9dln49VVsHvktHSprju6XuSrbrHeELNls6SmO0vgB5fx3mPIXrPDS+dVQ tLS0c/W7KeWxi2b1nN8Lao4XhrtBMfFVNtqi+GrHj9wLaGrfWumeVyjrlU8y3Mi7zuFa rWE5qyP4R/tdW7jztseaI1PQnzVDb3HaQmKZ81hp5M+FAtG3w2Cy9akF1kRoddw0IEqq 1ml9PKGmZfKED+cAKfkzAvQ4VrLeRXtaQI42kbktuY/fkaWrjQNhNcf6N03kQvhZDCaH DpUA== X-Gm-Message-State: AGRZ1gJpjGuXACnGNDqwF6e7aWwXRtTPNMKCPbB3GUWHegf4Z/HwBJ03 zOFEZi3722pbYvgcVicbSwH+edHJI6w= X-Google-Smtp-Source: AJdET5dVI8ZTXL++MAgqi8ognHYBspr0dne+kJp301LbAgLSMRCcFnx9XcQC6dUhfNiUMpakS7aAvw== X-Received: by 2002:a62:6547:: with SMTP id z68-v6mr5104679pfb.169.1542265797855; Wed, 14 Nov 2018 23:09:57 -0800 (PST) Received: from [10.71.0.106] ([64.64.108.195]) by smtp.gmail.com with ESMTPSA id i88-v6sm55800050pfi.66.2018.11.14.23.09.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 23:09:57 -0800 (PST) To: Leif Lindholm Cc: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, michael.d.kinney@intel.com, lersek@redhat.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org, zhangfeng56@huawei.com References: <20181029033249.45363-1-ming.huang@linaro.org> <20181029033249.45363-8-ming.huang@linaro.org> <20181113235711.72e2yv3o7xcztnqc@bivouac.eciton.net> From: Ming Huang Message-ID: <3ad0bff0-9145-63b7-da12-42da08ce63fa@linaro.org> Date: Thu, 15 Nov 2018 15:09:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181113235711.72e2yv3o7xcztnqc@bivouac.eciton.net> Subject: Re: [PATCH edk2-platforms v1 07/12] 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: , X-List-Received-Date: Thu, 15 Nov 2018 07:09:58 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/14/2018 7:57 AM, Leif Lindholm wrote: > On Mon, Oct 29, 2018 at 11:32:44AM +0800, Ming Huang wrote: >> 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(-) >> >> diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec >> index 404a3ae4af..8c197fa3c1 100644 >> --- a/Silicon/Hisilicon/HisiPkg.dec >> +++ b/Silicon/Hisilicon/HisiPkg.dec >> @@ -278,6 +278,7 @@ >> >> gHisiTokenSpaceGuid.Pcdsoctype|0|UINT32|0x00000061 >> gHisiTokenSpaceGuid.PcdSerDesFlowCtrlFlag|0|UINT32|0x40000056 >> + gHisiTokenSpaceGuid.PcdIsSecureBoot|FALSE|BOOLEAN|0x50000013 > > Why a token ID completely separate from the surrounding ones? I add this Pcd in another .dec file and then move it to HisiPkg.dec. I will modify the token ID. > >> >> [PcdsFeatureFlag] >> gHisiTokenSpaceGuid.PcdIsItsSupported|FALSE|BOOLEAN|0x00000065 >> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc >> index aa1da5d61f..ba3096672d 100644 >> --- a/Platform/Hisilicon/D03/D03.dsc >> +++ b/Platform/Hisilicon/D03/D03.dsc >> @@ -281,6 +281,11 @@ >> 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 1040466633..b8500cef87 100644 >> --- a/Platform/Hisilicon/D05/D05.dsc >> +++ b/Platform/Hisilicon/D05/D05.dsc >> @@ -422,6 +422,11 @@ >> 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 1a479c160e..b6ef9fedf0 100644 >> --- a/Platform/Hisilicon/D06/D06.dsc >> +++ b/Platform/Hisilicon/D06/D06.dsc >> @@ -243,6 +243,11 @@ >> >> 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 f8be4741ef..934c86c79b 100644 >> --- a/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf >> +++ b/Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf >> @@ -46,6 +46,7 @@ >> [Guids] >> gEfiSystemNvDataFvGuid >> gEfiVariableGuid >> + gEfiAuthenticatedVariableGuid > > Please move up two lines to insert sorted. > > / > Leif > >> >> [Protocols] >> gEfiBlockIoProtocolGuid >> @@ -62,6 +63,7 @@ >> 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 e18cc9e06e..309941d6fe 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; >> -- >> 2.18.0 >>