From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.14260.1583156948366580397 for ; Mon, 02 Mar 2020 05:49:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=anHQUc20; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583156947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4k1BdUJ6kqNz7RWINw5VjAu0yKvZb9zyo2RrsJ7mYnA=; b=anHQUc20m6Oi5q3v+kUhmk7ZdpVvDtCziCajoPum+/C6NW1lwun2AeSKc/emhwRd2PRlDs E6QEpEmM7LuVJG4nIBwJ5LpbXzqU73LI0Zq/m9h0/eS+PsuDTw7Nr4galriBY4Z5YdeZy0 1WfJFz+c9WUOOPpevNbwkVfqDRYncGk= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-CMgWlwI1N9O1QYmFdmgQGA-1; Mon, 02 Mar 2020 08:49:05 -0500 X-MC-Unique: CMgWlwI1N9O1QYmFdmgQGA-1 Received: by mail-wm1-f71.google.com with SMTP id v21so1731365wml.5 for ; Mon, 02 Mar 2020 05:49:05 -0800 (PST) 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=3xu9sl+CcT1nP31FjePQBzSTwkgmbOeMwHE0JlnUwuQ=; b=gfkm9R4+9sQUPE7uElrojltl4/gzLuuVoaLhbD+FRIA5xzJFagLQ0OvlsGePckAimN ubod8Zmpd1EGsSN+BYCcxRpE4qBL+XqMecvEOrl4GUZslGimJ78tzHPTLytBb/KzAuzq u88Nnf/hNlqsUup8pFWhoIGvNAij/9zn8/ntHpwWxe6j2tzyD2bZR1eSxDM4tX2VWEns csGHsuUpvnJmZfTrf0W1lTk2JwKVzZi3sKUPBRrZcSKOSNfeNuBHP7L7maG8da04nrIg 5sZWoQuhKczHX0o9f0G2OHAKCJx6F3/4UGQ72Pmy93HrUPZhR/zvLU4hmzNVgoDvOS6n FVcA== X-Gm-Message-State: APjAAAX+KFfMoxv4bNrOvh1IvIZtwOnorQYTglXxXORBKSgvc+cb82Sn 3NmUuYQXiXjZNyGrDVwZoxEVyejVyKfxJfRTnkQSPlmdoxUghvO8uA2KZbeNszHyyKWpwVfcWpj gc+W4w5h528AqZA== X-Received: by 2002:adf:dccb:: with SMTP id x11mr22161932wrm.214.1583156944517; Mon, 02 Mar 2020 05:49:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwrwlS9/lDiFObG0+GKXnJo5NBFj/0b+yq3+05svPPzMMUfQpxUeYmhSyEpLfbuHjCj/JMqig== X-Received: by 2002:adf:dccb:: with SMTP id x11mr22161906wrm.214.1583156944221; Mon, 02 Mar 2020 05:49:04 -0800 (PST) Return-Path: Received: from ?IPv6:2a01:e35:2fb0:49e0:3f7b:4b69:b9c:cdc0? ([2a01:e35:2fb0:49e0:3f7b:4b69:b9c:cdc0]) by smtp.gmail.com with ESMTPSA id j16sm27954090wru.68.2020.03.02.05.49.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Mar 2020 05:49:03 -0800 (PST) Subject: Re: [PATCH v2 03/16] OvmfPkg: clone SmmCpuPlatformHookLib from UefiCpuPkg To: Laszlo Ersek , edk2-devel-groups-io Cc: Ard Biesheuvel , Igor Mammedov , Jiewen Yao , Jordan Justen , Michael Kinney References: <20200226221156.29589-1-lersek@redhat.com> <20200226221156.29589-4-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Mon, 2 Mar 2020 14:49:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200226221156.29589-4-lersek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 2/26/20 11:11 PM, Laszlo Ersek wrote: > Clone the Null instance of SmmCpuPlatformHookLib from UefiCpuPkg to > OvmfPkg. In this patch, customize the lib instance only with the followin= g > no-op steps: >=20 > - Replace Null/NULL references in filenames and comments with Qemu/QEMU > references. > - Update copyright notices. > - Clean up and rewrap comment blocks. > - Update INF_VERSION to the latest INF spec version (1.29). > - Update FILE_GUID. > - Drop the UNI file. >=20 > This patch is best reviewed with: >=20 > $ git show --find-copies=3D43 --find-copies-harder >=20 > Cc: Ard Biesheuvel > Cc: Igor Mammedov > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Michael Kinney > Cc: Philippe Mathieu-Daud=C3=A9 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 > Signed-off-by: Laszlo Ersek > Acked-by: Ard Biesheuvel > --- >=20 > Notes: > v2: > =20 > - Pick up Ard's Acked-by, which is conditional on approval from Inte= l > reviewers on Cc. (I'd like to save Ard the churn of re-acking > unmodified patches.) >=20 > OvmfPkg/OvmfPkgIa32.dsc = = | 2 +- > OvmfPkg/OvmfPkgIa32X64.dsc = = | 2 +- > OvmfPkg/OvmfPkgX64.dsc = = | 2 +- > UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.= inf =3D> OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQem= u.inf | 21 +++++------- > UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.= c =3D> OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.= c | 36 ++++++++++++-------- > 5 files changed, 32 insertions(+), 31 deletions(-) >=20 > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc > index 19728f20b34e..813995fefad8 100644 > --- a/OvmfPkg/OvmfPkgIa32.dsc > +++ b/OvmfPkg/OvmfPkgIa32.dsc > @@ -858,45 +858,45 @@ [Components] > UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > =20 > # > # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) > # > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > =20 > # > # SMM_CORE > # > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > =20 > # > # Privileged drivers (DXE_SMM_DRIVER modules) > # > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { > > LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.in= f > } > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { > > - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull= /SmmCpuPlatformHookLibNull.inf > + SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/Sm= mCpuPlatformHookLibQemu.inf > SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature= sLib.inf > } > =20 > # > # Variable driver stack (SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.in= f > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { > > NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf > } > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf > =20 > !else > =20 > # > # Variable driver stack (non-SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf > OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { > > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc > index 3c0c229e3a72..a256c7084a7e 100644 > --- a/OvmfPkg/OvmfPkgIa32X64.dsc > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc > @@ -872,45 +872,45 @@ [Components.X64] > UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > =20 > # > # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) > # > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > =20 > # > # SMM_CORE > # > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > =20 > # > # Privileged drivers (DXE_SMM_DRIVER modules) > # > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { > > LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.in= f > } > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { > > - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull= /SmmCpuPlatformHookLibNull.inf > + SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/Sm= mCpuPlatformHookLibQemu.inf > SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature= sLib.inf > } > =20 > # > # Variable driver stack (SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.in= f > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { > > NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf > } > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf > =20 > !else > =20 > # > # Variable driver stack (non-SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf > OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { > > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc > index f6c1d8d228c6..78079b9f8e13 100644 > --- a/OvmfPkg/OvmfPkgX64.dsc > +++ b/OvmfPkg/OvmfPkgX64.dsc > @@ -870,45 +870,45 @@ [Components] > UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > =20 > # > # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) > # > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf > =20 > # > # SMM_CORE > # > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > =20 > # > # Privileged drivers (DXE_SMM_DRIVER modules) > # > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { > > LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.in= f > } > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { > > - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull= /SmmCpuPlatformHookLibNull.inf > + SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/Sm= mCpuPlatformHookLibQemu.inf > SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature= sLib.inf > } > =20 > # > # Variable driver stack (SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.in= f > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { > > NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf > } > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf > =20 > !else > =20 > # > # Variable driver stack (non-SMM) > # > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf > OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { > > diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformH= ookLibNull.inf b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHo= okLibQemu.inf > similarity index 43% > copy from UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHook= LibNull.inf > copy to OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQe= mu.inf > index fab6b30b7a3f..82edeca3d12d 100644 > --- a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibN= ull.inf > +++ b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu= .inf > @@ -1,34 +1,29 @@ > ## @file > -# SMM CPU Platform Hook NULL library instance. > +# SMM CPU Platform Hook library instance for QEMU. > # > +# Copyright (c) 2020, Red Hat, Inc. > # Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent > -# > ## > =20 > -########################################################################= ######## > -# > -# Defines Section - statements that will be processed to create a Makefi= le. > -# > -########################################################################= ######## > [Defines] > - INF_VERSION =3D 0x00010005 > - BASE_NAME =3D SmmCpuPlatformHookLibNull > - MODULE_UNI_FILE =3D SmmCpuPlatformHookLibNull.uni > - FILE_GUID =3D D6494E1B-E06F-4ab5-B64D-48B25AA9EB3= 3 > + INF_VERSION =3D 1.29 > + BASE_NAME =3D SmmCpuPlatformHookLibQemu > + FILE_GUID =3D 154D6D26-54B8-45BC-BA3A-CBAA20C02A6= A > MODULE_TYPE =3D DXE_DRIVER > VERSION_STRING =3D 1.0 > LIBRARY_CLASS =3D SmmCpuPlatformHookLib > =20 > # > -# The following information is for reference only and not required by th= e build tools. > +# The following information is for reference only and not required by th= e build > +# tools. > # > # VALID_ARCHITECTURES =3D IA32 X64 > # > =20 > [Sources] > - SmmCpuPlatformHookLibNull.c > + SmmCpuPlatformHookLibQemu.c > =20 > [Packages] > MdePkg/MdePkg.dec > UefiCpuPkg/UefiCpuPkg.dec > diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformH= ookLibNull.c b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHook= LibQemu.c > similarity index 67% > copy from UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHook= LibNull.c > copy to OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQe= mu.c > index 6c2010dc0a67..257e1d399cc6 100644 > --- a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibN= ull.c > +++ b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu= .c > @@ -1,102 +1,108 @@ > /** @file > -SMM CPU Platform Hook NULL library instance. > +SMM CPU Platform Hook library instance for QEMU. > =20 > +Copyright (c) 2020, Red Hat, Inc. > Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > =20 > **/ > #include > #include > =20 > /** > Checks if platform produces a valid SMI. > =20 > This function checks if platform produces a valid SMI. This function = is > called at SMM entry to detect if this is a spurious SMI. This functio= n > must be implemented in an MP safe way because it is called by multipl= e CPU > threads. > =20 > @retval TRUE There is a valid SMI > @retval FALSE There is no valid SMI > =20 > **/ > BOOLEAN > EFIAPI > PlatformValidSmi ( > VOID > ) > { > return TRUE; > } > =20 > /** > Clears platform top level SMI status bit. > =20 > This function clears platform top level SMI status bit. > =20 > @retval TRUE The platform top level SMI status is cleare= d. > - @retval FALSE The platform top level SMI status cannot be = cleared. > + @retval FALSE The platform top level SMI status cannot be > + cleared. > =20 > **/ > BOOLEAN > EFIAPI > ClearTopLevelSmiStatus ( > VOID > ) > { > return TRUE; > } > =20 > /** > Performs platform specific way of SMM BSP election. > =20 > This function performs platform specific way of SMM BSP election. > =20 > - @param IsBsp Output parameter. TRUE: the CPU this functio= n executes > - on is elected to be the SMM BSP. FALSE: the = CPU this > - function executes on is to be SMM AP. > + @param IsBsp Output parameter. TRUE: the CPU this functio= n > + executes on is elected to be the SMM BSP. FA= LSE: > + the CPU this function executes on is to be S= MM AP. > =20 > @retval EFI_SUCCESS The function executes successfully. > - @retval EFI_NOT_READY The function does not determine whether this= CPU should be > - BSP or AP. This may occur if hardware init s= equence to > - enable the determination is yet to be done, = or the function > - chooses not to do BSP election and will let = SMM CPU driver to > - use its default BSP election process. > - @retval EFI_DEVICE_ERROR The function cannot determine whether this C= PU should be > - BSP or AP due to hardware error. > + @retval EFI_NOT_READY The function does not determine whether this= CPU > + should be BSP or AP. This may occur if hardw= are > + init sequence to enable the determination is= yet to > + be done, or the function chooses not to do B= SP > + election and will let SMM CPU driver to use = its > + default BSP election process. > + @retval EFI_DEVICE_ERROR The function cannot determine whether this C= PU > + should be BSP or AP due to hardware error. > =20 > **/ > EFI_STATUS > EFIAPI > PlatformSmmBspElection ( > OUT BOOLEAN *IsBsp > ) > { > return EFI_NOT_READY; > } > =20 > /** > Get platform page table attribute. > =20 > This function gets page table attribute of platform. > =20 > - @param Address Input parameter. Obtain the page table entries = attribute on this address. > + @param Address Input parameter. Obtain the page table entries > + attribute on this address. > @param PageSize Output parameter. The size of the page. > @param NumOfPages Output parameter. Number of page. > @param PageAttribute Output parameter. Paging Attributes (WB, UC, e= tc). > =20 > - @retval EFI_SUCCESS The platform page table attribute from the ad= dress is determined. > - @retval EFI_UNSUPPORTED The platform does not support getting page ta= ble attribute for the address. > + @retval EFI_SUCCESS The platform page table attribute from the ad= dress > + is determined. > + @retval EFI_UNSUPPORTED The platform does not support getting page ta= ble > + attribute for the address. > =20 > **/ > EFI_STATUS > EFIAPI > GetPlatformPageTableAttribute ( > IN UINT64 Address, > IN OUT SMM_PAGE_SIZE_TYPE *PageSize, > IN OUT UINTN *NumOfPages, > IN OUT UINTN *PageAttribute > ) > { > return EFI_UNSUPPORTED; > } >=20 Reviewed-by: Philippe Mathieu-Daude