From nobody Fri May 17 05:54:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100663+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100663+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677826285; cv=none; d=zohomail.com; s=zohoarc; b=McoYWr3PruZZBdGqKRb7HKgF5xdfpl9n17zIaelyiswbtjzraOXIqvlu4232/gvfEQLtaEzUb9Bx2vJpe85kgK8Do0EDQjxVCaniHevpQXA4vZZiM6v0k6CLC5U+19WVr8Gzawwcfaj87qkIqiuDp9ERIS79IP2mU0y9GcYieow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677826285; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Wyg0A1BJ11XbPMbSoPK10LzJxrfGiOUkC0feMQF3K8s=; b=faHuNqsZayAH8kEh+7kBwPgY251lo2/XLT4UXVg4VipSp0ZtYgJ6N/VZR0G9UsI+R8JOje7O//Wx2jfEqMCr4sIhLX6ES7/u076xTdIGyjAAYOiEzhmbXvr4gZhecyKvp4OPGgMI7ejyqgpSXzpW/3DWVjnnpDT29PLgNhIYhx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100663+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1677826285336826.0256410564828; Thu, 2 Mar 2023 22:51:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3MX1YY1788612xHM4MvSKUy7; Thu, 02 Mar 2023 22:51:24 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.17708.1677826283856256376 for ; Thu, 02 Mar 2023 22:51:24 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-_llwqDvWMGmKLTCDmzdZVA-1; Fri, 03 Mar 2023 01:51:19 -0500 X-MC-Unique: _llwqDvWMGmKLTCDmzdZVA-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05BC8811E9C; Fri, 3 Mar 2023 06:51:19 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7697440D8; Fri, 3 Mar 2023 06:51:17 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 02F711800991; Fri, 3 Mar 2023 07:51:16 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jian J Wang , Jiewen Yao , =?UTF-8?q?Marvin=20H=C3=A4user?= , James Bottomley , Michael Roth , Hao A Wu , Michael D Kinney , Oliver Steffen , Min Xu , Liming Gao , Ray Ni , Tom Lendacky , Erdem Aktas , Zhiguang Liu , Pawel Polawski , Jordan Justen Subject: [edk2-devel] [PATCH 1/5] MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions Date: Fri, 3 Mar 2023 07:51:11 +0100 Message-Id: <20230303065115.406020-2-kraxel@redhat.com> In-Reply-To: <20230303065115.406020-1-kraxel@redhat.com> References: <20230303065115.406020-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: wWNUIYqXVLQhg7XykJUALldDx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1677826284; bh=T+TDE6iMuMP1jO4T7MzCScC990pe9/q8lemKu2U4KTw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LpjI9I1S975I4LOtk2nJk74fbO0xJg0wRu98mMgl0SMKMFVfclUjc9iE+8sIqGsGrmW XabYKAoAWRh1pzZA1oi/dG44NdNKJ8/Ex+IZ6mhkoPe6kuRG0WAMqbqNu6Ax9zu04yrsy ++UX0EKuunzHUts4Vxw09vO0RsfXg9KgRLI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1677826286728100004 From: Marvin H=C3=A4user This patch is a preparation for the patches that follow. The subsequent patches will introduce and integrate new alignment-related macros, which collide with existing definitions in MdeModulePkg. Temporarily rename them to avoid build failure, till they can be substituted with the new, shared definitions. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Marvin H=C3=A4user Acked-by: Tom Lendacky Reviewed-by: Hao A Wu Reviewed-by: Michael D Kinney --- MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h | 4 +-- .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 2 +- MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h | 2 +- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 2 +- .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h | 2 +- .../Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 2 +- MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 4 +-- MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 2 +- .../Bus/Ata/AhciPei/AhciPeiPassThru.c | 6 ++-- .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 12 +++---- .../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 2 +- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 +-- .../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 ++-- MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 36 +++++++++---------- 14 files changed, 43 insertions(+), 43 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h b/MdeModulePkg/Bus/Ata/= AhciPei/AhciPei.h index 4aed1cb7ad8a..71d34c962ad1 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h @@ -146,8 +146,8 @@ typedef union { #define AHCI_PORT_SERR 0x0030 #define AHCI_PORT_CI 0x0038 =20 -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D= =3D 0) -#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000= 000) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) +#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 100= 00000) =20 #pragma pack(1) =20 diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/Mde= ModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h index 62ba6d6680dd..7937886614e1 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h @@ -148,7 +148,7 @@ struct _ATA_NONBLOCK_TASK { #define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3) #define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10) =20 -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D=3D 0) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 #define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ CR (a, \ diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata= /AtaBusDxe/AtaBus.h index 4428c484fd6c..47346e911d47 100644 --- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h +++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h @@ -76,7 +76,7 @@ #define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K') #define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D') #define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S') -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D=3D 0) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 // // ATA bus data structure for ATA controller diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bu= s/Scsi/ScsiDiskDxe/ScsiDisk.h index 5b4047e1dbdd..ed384ad52182 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h @@ -38,7 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0 =20 -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D=3D 0) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 #define UFS_WLUN_RPMB 0xC4 =20 diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h b/MdeModule= Pkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h index a0b615b7eab3..1adb382aa8c3 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h @@ -133,7 +133,7 @@ typedef struct _UFS_PEIM_HC_PRIVATE_DATA { =20 #define ROUNDUP8(x) (((x) % 8 =3D=3D 0) ? (x) : ((x) / 8 + 1) * 8) =20 -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D=3D 0) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_= HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG) #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_= HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index 2b4f5d32d901..0ec37e56652b 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -105,7 +105,7 @@ typedef struct { =20 #define ROUNDUP8(x) (((x) % 8 =3D=3D 0) ? (x) : ((x) / 8 + 1) * 8) =20 -#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) =3D=3D 0) +#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 #define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ CR (a, \ diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Univ= ersal/EbcDxe/EbcExecute.h index 32b8670c5b2a..6dc6730ab095 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h @@ -14,8 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // Macros to check and set alignment // -#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)= )) -#define IS_ALIGNED(addr, size) !((UINT32) (addr) & (size - 1)) +#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size= - 1))) +#define ADDRESS_IS_ALIGNED_(addr, size) !((UINT32) (addr) & (size - 1)) =20 // // Debug macro diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata= /AhciPei/AhciMode.c index 7b97887c5dbd..d93fa78c81f3 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c @@ -2126,7 +2126,7 @@ TrustTransferAtaDevice ( // ATA PassThru PPI. // if ((AtaPassThru->Mode->IoAlign > 1) && - !IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) + !ADDRESS_IS_ALIGNED_ (Buffer, AtaPassThru->Mode->IoAlign)) { NewBuffer =3D AllocateAlignedPages ( EFI_SIZE_TO_PAGES (TransferLength), diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c b/MdeModulePkg/= Bus/Ata/AhciPei/AhciPeiPassThru.c index d5ed93dc4f67..0c49059a00d5 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c @@ -194,15 +194,15 @@ AhciAtaPassThruPassThru ( } =20 IoAlign =3D This->Mode->IoAlign; - if ((IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, IoAlign)) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, IoAlign= )) { return EFI_INVALID_PARAMETER; } =20 - if ((IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, IoAlign)) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, IoAlig= n)) { return EFI_INVALID_PARAMETER; } =20 - if ((IoAlign > 1) && !IS_ALIGNED (Packet->Asb, IoAlign)) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/Mde= ModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 1070516b358a..324abadd02dd 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -1299,15 +1299,15 @@ AtaPassThruPassThru ( =20 Instance =3D ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This); =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This= ->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, Thi= s->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->Asb, This->Mode->I= oAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, This= ->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 @@ -2039,15 +2039,15 @@ ExtScsiPassThruPassThru ( return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This= ->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, Thi= s->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->M= ode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData= , This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModul= ePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c index 4334169d256a..18aa4f9bb666 100644 --- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c +++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c @@ -1040,7 +1040,7 @@ TrustTransferAtaDevice ( // Check the alignment of the incoming buffer prior to invoking underl= ying ATA PassThru // AtaPassThru =3D AtaDevice->AtaBusDriverData->AtaPassThru; - if ((AtaPassThru->Mode->IoAlign > 1) && !IS_ALIGNED (Buffer, AtaPassTh= ru->Mode->IoAlign)) { + if ((AtaPassThru->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Buffer, = AtaPassThru->Mode->IoAlign)) { NewBuffer =3D AllocateAlignedBuffer (AtaDevice, TransferLength); if (NewBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bu= s/Scsi/ScsiDiskDxe/ScsiDisk.c index fbc236cb465e..faf4ae332e46 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c @@ -2029,7 +2029,7 @@ ScsiDiskReceiveData ( goto Done; } =20 - if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !IS_ALIGNED (PayloadBuffe= r, ScsiDiskDevice->ScsiIo->IoAlign)) { + if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Pay= loadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { AlignedBuffer =3D AllocateAlignedBuffer (ScsiDiskDevice, PayloadBuff= erSize); if (AlignedBuffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; @@ -2249,7 +2249,7 @@ ScsiDiskSendData ( goto Done; } =20 - if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !IS_ALIGNED (PayloadBuffe= r, ScsiDiskDevice->ScsiIo->IoAlign)) { + if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Pay= loadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { AlignedBuffer =3D AllocateAlignedBuffer (ScsiDiskDevice, PayloadBuff= erSize); if (AlignedBuffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index ae593ff03a0d..392a295caf04 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -171,15 +171,15 @@ UfsPassThruPassThru ( return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This= ->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, Thi= s->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->M= ode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData= , This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Univ= ersal/EbcDxe/EbcExecute.c index 82a7782fb99a..28f108c44873 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -2015,7 +2015,7 @@ ExecuteJMP ( // check for alignment, and jump absolute. // Data64 =3D (UINT64)VmReadImmed64 (VmPtr, 2); - if (!IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED_ ((UINTN)Data64, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -2074,7 +2074,7 @@ ExecuteJMP ( // Form: JMP32 @Rx {Index32} // Addr =3D VmReadMemN (VmPtr, (UINTN)Data64 + Index32); - if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -2097,7 +2097,7 @@ ExecuteJMP ( // Form: JMP32 Rx {Immed32} // Addr =3D (UINTN)(Data64 + Index32); - if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -3158,7 +3158,7 @@ ExecuteRET ( // Pull the return address off the VM app's stack and set the IP // to it // - if (!IS_ALIGNED ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -4733,7 +4733,7 @@ VmWriteMem16 ( // // Do a simple write if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) { *(UINT16 *)Addr =3D Data; } else { // @@ -4795,7 +4795,7 @@ VmWriteMem32 ( // // Do a simple write if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) { *(UINT32 *)Addr =3D Data; } else { // @@ -4857,7 +4857,7 @@ VmWriteMem64 ( // // Do a simple write if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) { *(UINT64 *)Addr =3D Data; } else { // @@ -4922,7 +4922,7 @@ VmWriteMemN ( // // Do a simple write if aligned // - if (IS_ALIGNED (Addr, sizeof (UINTN))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) { *(UINTN *)Addr =3D Data; } else { for (Index =3D 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) { @@ -4985,7 +4985,7 @@ VmReadImmed16 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) { return *(INT16 *)(VmPtr->Ip + Offset); } else { // @@ -5029,7 +5029,7 @@ VmReadImmed32 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { return *(INT32 *)(VmPtr->Ip + Offset); } =20 @@ -5068,7 +5068,7 @@ VmReadImmed64 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { return *(UINT64 *)(VmPtr->Ip + Offset); } =20 @@ -5105,7 +5105,7 @@ VmReadCode16 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) { return *(UINT16 *)(VmPtr->Ip + Offset); } else { // @@ -5147,7 +5147,7 @@ VmReadCode32 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { return *(UINT32 *)(VmPtr->Ip + Offset); } =20 @@ -5184,7 +5184,7 @@ VmReadCode64 ( // // Read direct if aligned // - if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { return *(UINT64 *)(VmPtr->Ip + Offset); } =20 @@ -5247,7 +5247,7 @@ VmReadMem16 ( // // Read direct if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) { return *(UINT16 *)Addr; } =20 @@ -5281,7 +5281,7 @@ VmReadMem32 ( // // Read direct if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) { return *(UINT32 *)Addr; } =20 @@ -5319,7 +5319,7 @@ VmReadMem64 ( // // Read direct if aligned // - if (IS_ALIGNED (Addr, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) { return *(UINT64 *)Addr; } =20 @@ -5388,7 +5388,7 @@ VmReadMemN ( // // Read direct if aligned // - if (IS_ALIGNED (Addr, sizeof (UINTN))) { + if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) { return *(UINTN *)Addr; } =20 --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100663): https://edk2.groups.io/g/devel/message/100663 Mute This Topic: https://groups.io/mt/97357265/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 05:54:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100665+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100665+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677826290; cv=none; d=zohomail.com; s=zohoarc; b=DbFx2tcERq1wWmWyQOGXhMa3N2AvgTRR2WUU5jWV2FDs101cgiOVoEG36995MZz0vKjZd7gFAEg5oj7/sctAopkOovyc3+hDQKmOI7gP53tg9uuWjUgni/xg3Rt74+TF9HAHUDqPFrqU/68nbLm4F/kq+lT688nCxqzSFnqsiKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677826290; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=lMrykFpH7m09J3QU1I1Io4s93OWjHS7tqiU8G7jMmsU=; b=Ar2Sa8z9NHdBzhnJFvgSsrIrM+IMh3roB8K+Bh2dGFaGoVSapteTdXJo/J5oqejIJd4CQtW5hB+5enkXGIGuSxS53eQSgMmhsViYxrebkD+2yT5s9O1rFQBEEdlUBTMTNKP5i/SJMy8wdXyWM6AnnVdKtsLe1zJzYcYrAc8RQ/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100665+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1677826290002520.1399567921763; Thu, 2 Mar 2023 22:51:30 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8qMgYY1788612xvNKfLD3vex; Thu, 02 Mar 2023 22:51:29 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.17712.1677826288365160765 for ; Thu, 02 Mar 2023 22:51:28 -0800 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-157-f2yIYlcmMfOjOeyPBoloKw-1; Fri, 03 Mar 2023 01:51:21 -0500 X-MC-Unique: f2yIYlcmMfOjOeyPBoloKw-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 860233806108; Fri, 3 Mar 2023 06:51:20 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37D662166B26; Fri, 3 Mar 2023 06:51:20 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 07EAD18009B1; Fri, 3 Mar 2023 07:51:16 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jian J Wang , Jiewen Yao , =?UTF-8?q?Marvin=20H=C3=A4user?= , James Bottomley , Michael Roth , Hao A Wu , Michael D Kinney , Oliver Steffen , Min Xu , Liming Gao , Ray Ni , Tom Lendacky , Erdem Aktas , Zhiguang Liu , Pawel Polawski , Jordan Justen Subject: [edk2-devel] [PATCH 2/5] OvmfPkg: Rename IS_ALIGNED macros to avoid name collisions Date: Fri, 3 Mar 2023 07:51:12 +0100 Message-Id: <20230303065115.406020-3-kraxel@redhat.com> In-Reply-To: <20230303065115.406020-1-kraxel@redhat.com> References: <20230303065115.406020-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: ZcHJwkoCBoC9PcJYSm7qzx2xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1677826289; bh=w8gvAGW4hRaGCd5K/wMiR+6wCQie6WueQcXZ400kqRU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=uuw5qtqDykExFQjEtTw9mNC5SwkOqjX2CKUcfyZDQ9xFftUOW+hgLOEkm4ePSCN36E/ XreXq5D67k87QwSDPmHdK/0LzlN/h5XsqZjHo1WDbB/DqmV7ew36ADKRlWGHG1vj3SNwa YTPJeVsgFOTaED34FcB0UOhULKyd1Lr1s5I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1677826290707100002 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch is a preparation for the patches that follow. The subsequent patches will introduce and integrate new alignment-related macros, which collide with existing definitions in OvmfPkg. Temporarily rename them to avoid build failure, till they can be substituted with the new, shared definitions. Signed-off-by: Gerd Hoffmann Acked-by: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Michael D Kinney --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 6 +++--- .../BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index a726498e2792..71a1eaaf0a1d 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -44,7 +44,7 @@ STATIC BOOLEAN mAcceptAllMemoryAtEBS =3D TRUE; =20 STATIC EFI_EVENT mAcceptAllMemoryEvent =3D NULL; =20 -#define IS_ALIGNED(x, y) ((((x) & ((y) - 1)) =3D=3D 0)) +#define IS_ALIGNED_(x, y) ((((x) & ((y) - 1)) =3D=3D 0)) =20 STATIC EFI_STATUS @@ -60,8 +60,8 @@ AmdSevMemoryAccept ( // multiple of SIZE_4KB. Use an assert instead of returning an erros sin= ce // this is an EDK2-internal protocol. // - ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB)); - ASSERT (IS_ALIGNED (Size, SIZE_4KB)); + ASSERT (IS_ALIGNED_ (StartAddress, SIZE_4KB)); + ASSERT (IS_ALIGNED_ (Size, SIZE_4KB)); ASSERT (Size !=3D 0); =20 MemEncryptSevSnpPreValidateSystemRam ( diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInt= ernal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeIntern= al.c index 4d684964d838..f35bba5deb46 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -20,7 +20,7 @@ =20 #include "SnpPageStateChange.h" =20 -#define IS_ALIGNED(x, y) ((((x) & (y - 1)) =3D=3D 0)) +#define IS_ALIGNED_(x, y) ((((x) & (y - 1)) =3D=3D 0)) #define PAGES_PER_LARGE_ENTRY 512 =20 STATIC @@ -150,7 +150,7 @@ BuildPageStateBuffer ( // // Is this a 2MB aligned page? Check if we can use the Large RMP entry. // - if (UseLargeEntry && IS_ALIGNED (BaseAddress, SIZE_2MB) && + if (UseLargeEntry && IS_ALIGNED_ (BaseAddress, SIZE_2MB) && ((EndAddress - BaseAddress) >=3D SIZE_2MB)) { RmpPageSize =3D PvalidatePageSize2MB; --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100665): https://edk2.groups.io/g/devel/message/100665 Mute This Topic: https://groups.io/mt/97357269/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 05:54:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100664+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100664+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677826289; cv=none; d=zohomail.com; s=zohoarc; b=cde4s+V/sFNjVyvwQTjVWGXftPqTQi0UTmVhVQEk0nOCARcDrryM98ttBzyZ3R7syFjUA807KdTGUfEEmpNjuv6Weo7Z+qXYmo8nVMJx4xM0pISmlhHE/zDH25I9kqbjONUgKIWyeGD9hVak8O3K8Fx0uReFJO43UBz5e8CF0GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677826289; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8hIQ0w67ekAZMPHgf518NgHE3OaQOG8J9wdrBd7q8wA=; b=Al5aXnInW+cmGiSLBmotOq+v3X9ZSqqVmUZZTu9nxSTWppV923Im4ox6CF8pGyZE1YI2MhpRCxczSTI9FKdovlh4+IWPcidqSqHXrlS7YIeLNIy1QfJvCch29AYTL9cHghCQvXRzOnTMe0IjqeCAERGHsp3ls/HmPKP1wchCzgM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100664+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167782628914228.91908649898062; Thu, 2 Mar 2023 22:51:29 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wKZrYY1788612xBAltCN6jrl; Thu, 02 Mar 2023 22:51:28 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.17738.1677826288059300063 for ; Thu, 02 Mar 2023 22:51:28 -0800 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-dR3hsUS2POWVO2w2ZM6d-Q-1; Fri, 03 Mar 2023 01:51:22 -0500 X-MC-Unique: dR3hsUS2POWVO2w2ZM6d-Q-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2773B29ABA23; Fri, 3 Mar 2023 06:51:21 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 840441121315; Fri, 3 Mar 2023 06:51:20 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0D24D180101D; Fri, 3 Mar 2023 07:51:16 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jian J Wang , Jiewen Yao , =?UTF-8?q?Marvin=20H=C3=A4user?= , James Bottomley , Michael Roth , Hao A Wu , Michael D Kinney , Oliver Steffen , Min Xu , Liming Gao , Ray Ni , Tom Lendacky , Erdem Aktas , Zhiguang Liu , Pawel Polawski , Jordan Justen , Vitaly Cheptsov Subject: [edk2-devel] [PATCH 3/5] MdePkg/Base.h: Introduce various alignment-related macros Date: Fri, 3 Mar 2023 07:51:13 +0100 Message-Id: <20230303065115.406020-4-kraxel@redhat.com> In-Reply-To: <20230303065115.406020-1-kraxel@redhat.com> References: <20230303065115.406020-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: H1B76p2ASOaGWfeU9yyromAmx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1677826288; bh=xQ7e/RZt/WGQ/7CBTry7C1yJ2eiz3cbuJD2ucFuxNpo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=EHTKIfhSvuQd0ORBcEAFSIX6iqdgWvHV2uRmD4LGMveXMlh3uF7GQyyDtBIjBA2qBxK vSTLJsRLq/I7BOBm3Qa+w9+htcKZC2dDpC2lGDFIBe8EE+Yh3a5LADB9RMw3dMC/5GVDj fxB2HmM+cctj22SijPaNudTNzS7wJhVVRJY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1677826290740100004 From: Marvin H=C3=A4user ALIGNOF: Determining the alignment requirement of data types is crucial to ensure safe memory accesses when parsing untrusted data. IS_POW2: Determining whether a value is a power of two is important to verify whether untrusted values are valid alignment values. IS_ALIGNED: In combination with ALIGNOF data offsets can be verified. A more general version of the IS_ALIGNED macro previously defined by severa= l modules. ADDRESS_IS_ALIGNED: Variant of IS_ALIGNED for pointers and addresses. Replaces module-specific definitions throughout the codebase. ALIGN_VALUE_ADDEND: The addend to align up can be used to directly determine the required offset for data alignment. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user Acked-by: Tom Lendacky --- MdePkg/Include/Base.h | 95 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index d209e6de280a..2053314b50d1 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -758,6 +758,40 @@ typedef UINTN *BASE_LIST; #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) #endif =20 +/** + Returns the alignment requirement of a type. + + @param TYPE The name of the type to retrieve the alignment requiremen= t of. + + @return Alignment requirement, in Bytes, of TYPE. +**/ +#if defined (__cplusplus) +// +// Standard C++ operator. +// +#define ALIGNOF(TYPE) alignof (TYPE) +#elif defined (__GNUC__) || defined (__clang__) || (defined (_MSC_VER) && = _MSC_VER >=3D 1900) +// +// All supported versions of GCC and Clang, as well as MSVC 2015 and later, +// support the standard operator _Alignof. +// +#define ALIGNOF(TYPE) _Alignof (TYPE) +#elif defined (_MSC_EXTENSIONS) +// +// Earlier versions of MSVC, at least MSVC 2008 and later, support the ven= dor +// extension __alignof. +// +#define ALIGNOF(TYPE) __alignof (TYPE) +#else +// +// For compilers that do not support inbuilt alignof operators, use OFFSET= _OF. +// CHAR8 is known to have both a size and an alignment requirement of 1 By= te. +// As such, A must be located exactly at the offset equal to its alignment +// requirement. +// +#define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A) +#endif + /** Portable definition for compile time assertions. Equivalent to C11 static_assert macro from assert.h. @@ -793,6 +827,21 @@ STATIC_ASSERT (sizeof (CHAR16) =3D=3D 2, "sizeof (CHA= R16) does not meet UEFI Specif STATIC_ASSERT (sizeof (L'A') =3D=3D 2, "sizeof (L'A') does not meet UEF= I Specification Data Type requirements"); STATIC_ASSERT (sizeof (L"A") =3D=3D 4, "sizeof (L\"A\") does not meet U= EFI Specification Data Type requirements"); =20 +STATIC_ASSERT (ALIGNOF (BOOLEAN) =3D=3D sizeof (BOOLEAN), "Alignment of BO= OLEAN does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (INT8) =3D=3D sizeof (INT8), "Alignment of INT8 = does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (UINT8) =3D=3D sizeof (UINT8), "Alignment of INT1= 6 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (INT16) =3D=3D sizeof (INT16), "Alignment of INT1= 6 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (UINT16) =3D=3D sizeof (UINT16), "Alignment of UIN= T16 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (INT32) =3D=3D sizeof (INT32), "Alignment of INT3= 2 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (UINT32) =3D=3D sizeof (UINT32), "Alignment of UIN= T32 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (INT64) =3D=3D sizeof (INT64), "Alignment of INT6= 4 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (UINT64) =3D=3D sizeof (UINT64), "Alignment of UIN= T64 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (CHAR8) =3D=3D sizeof (CHAR8), "Alignment of CHAR= 8 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (CHAR16) =3D=3D sizeof (CHAR16), "Alignment of CHA= R16 does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (INTN) =3D=3D sizeof (INTN), "Alignment of INTN = does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (UINTN) =3D=3D sizeof (UINTN), "Alignment of UINT= N does not meet UEFI Specification Data Type requirements"); +STATIC_ASSERT (ALIGNOF (VOID *) =3D=3D sizeof (VOID *), "Alignment of VOI= D * does not meet UEFI Specification Data Type requirements"); + // // The following three enum types are used to verify that the compiler // configuration for enum types is compliant with Section 2.3.1 of the @@ -816,6 +865,10 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) =3D= =3D 4, "Size of enum does not me STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) =3D=3D 4, "Size of enum = does not meet UEFI Specification Data Type requirements"); STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) =3D=3D 4, "Size of enum = does not meet UEFI Specification Data Type requirements"); =20 +STATIC_ASSERT (ALIGNOF (__VERIFY_UINT8_ENUM_SIZE) =3D=3D sizeof (__VERIFY= _UINT8_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data= Type requirements"); +STATIC_ASSERT (ALIGNOF (__VERIFY_UINT16_ENUM_SIZE) =3D=3D sizeof (__VERIFY= _UINT16_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Dat= a Type requirements"); +STATIC_ASSERT (ALIGNOF (__VERIFY_UINT32_ENUM_SIZE) =3D=3D sizeof (__VERIFY= _UINT32_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Dat= a Type requirements"); + /** Macro that returns a pointer to the data structure that contains a speci= fied field of that data structure. This is a lightweight method to hide information b= y placing a @@ -837,6 +890,46 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) =3D= =3D 4, "Size of enum does not m **/ #define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFS= ET_OF (TYPE, Field))) =20 +/** + Checks whether a value is a power of two. + + @param Value The value to check. + + @return Whether Value is a power of two. +**/ +#define IS_POW2(Value) ((Value) !=3D 0U && ((Value) & ((Value) - 1U)) =3D= =3D 0U) + +/** + Checks whether a value is aligned by a specified alignment. + + @param Value The value to check. + @param Alignment The alignment boundary used to check against. + + @return Whether Value is aligned by Alignment. +**/ +#define IS_ALIGNED(Value, Alignment) (((Value) & ((Alignment) - 1U)) =3D= =3D 0U) + +/** + Checks whether a pointer or address is aligned by a specified alignment. + + @param Address The pointer or address to check. + @param Alignment The alignment boundary used to check against. + + @return Whether Address is aligned by Alignment. +**/ +#define ADDRESS_IS_ALIGNED(Address, Alignment) IS_ALIGNED ((UINTN) (Addre= ss), Alignment) + +/** + Determines the addend to add to a value to round it up to the next bound= ary of + a specified alignment. + + @param Value The value to round up. + @param Alignment The alignment boundary used to return the addend. + + @return Addend to round Value up to alignment boundary Alignment. +**/ +#define ALIGN_VALUE_ADDEND(Value, Alignment) (((Alignment) - (Value)) & (= (Alignment) - 1U)) + /** Rounds a value up to the next boundary using a specified alignment. =20 @@ -849,7 +942,7 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) =3D= =3D 4, "Size of enum does not m @return A value up to the next boundary. =20 **/ -#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value))= & ((Alignment) - 1))) +#define ALIGN_VALUE(Value, Alignment) ((Value) + ALIGN_VALUE_ADDEND (Valu= e, Alignment)) =20 /** Adjust a pointer by adding the minimum offset required for it to be alig= ned on --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100664): https://edk2.groups.io/g/devel/message/100664 Mute This Topic: https://groups.io/mt/97357268/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 05:54:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100666+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100666+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677826289; cv=none; d=zohomail.com; s=zohoarc; b=HCUYrUG5nMs+dsRyesL80g/bX4Kn9Xb6ZdT23P8grMhaDHWigcinSnm2PtPWszFrK8mr4AVvm+l26OQy5KohX0ZcHDdZGnFwJFKYWVe4fc2POWWMxaRCd1DOZMKitH08HwjShJLYrxxBDhaJNRIB/HBOxoio8z3A1XqAFBP+cHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677826289; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nJ7PjVPfu90Mk7n/LM0nHtBLNbqr5aL/k32JPrhK4h0=; b=CXfRmS3Lk3qeERRup9Lr9M6JguqPsvow0XFXI6TzXA7stO6DlH/Kn8N1LYfbtX3a/K1Lrj+rWrzAG1C9xmYsHWg/x1P13B2EZSe4ApS0wttlzo3Uaam/16WykL7gX2Ognbb1/UqqxoZ/N5/yksfPPlzqDB5l1RJk9Fq/5fbjTUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100666+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1677826289663160.14039805785637; Thu, 2 Mar 2023 22:51:29 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id IhXlYY1788612xxKx7i4B0ia; Thu, 02 Mar 2023 22:51:29 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.17739.1677826288464580336 for ; Thu, 02 Mar 2023 22:51:28 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-IT1hR0DdPlqIU6L5vvGwgQ-1; Fri, 03 Mar 2023 01:51:24 -0500 X-MC-Unique: IT1hR0DdPlqIU6L5vvGwgQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA6A918A64E0; Fri, 3 Mar 2023 06:51:23 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17E51492C3E; Fri, 3 Mar 2023 06:51:23 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 11C061801020; Fri, 3 Mar 2023 07:51:16 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jian J Wang , Jiewen Yao , =?UTF-8?q?Marvin=20H=C3=A4user?= , James Bottomley , Michael Roth , Hao A Wu , Michael D Kinney , Oliver Steffen , Min Xu , Liming Gao , Ray Ni , Tom Lendacky , Erdem Aktas , Zhiguang Liu , Pawel Polawski , Jordan Justen , Vitaly Cheptsov Subject: [edk2-devel] [PATCH 4/5] MdeModulePkg: Consume new alignment-related macros Date: Fri, 3 Mar 2023 07:51:14 +0100 Message-Id: <20230303065115.406020-5-kraxel@redhat.com> In-Reply-To: <20230303065115.406020-1-kraxel@redhat.com> References: <20230303065115.406020-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: GtpC5VMIigVWy3eCmq2D89Ejx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1677826289; bh=zNW1OYWInPm3sY/FggabBFxYbPj4e6hXW5Y7BeMyq64=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=qIDILaJRE+HdTyiuiUnAvqvfa91iTgELY3zJncYe0UNadVDkv/B/Hdquge6MyDafpa7 vUWI8sI6u5TUCVOBYNEM2nzoh4Nk3IgjYptJpsFO9OgtgyheU60lkne7X72c/IqXOIkhG HZliTCqO0OAu2i4wZtsr2f9SI7yz3VULw7E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1677826290766100006 From: Marvin H=C3=A4user This patch substitutes the macros that were renamed in the first patch with the new, shared alignment macros. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user Acked-by: Tom Lendacky Reviewed-by: Hao A Wu Reviewed-by: Michael D Kinney >michael.d.kinney@intel.com> --- MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h | 3 +- .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 2 -- MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h | 1 - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 2 -- .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h | 2 -- .../Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 2 -- MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 3 +- MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 2 +- .../Bus/Ata/AhciPei/AhciPeiPassThru.c | 6 ++-- .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 12 +++---- .../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 2 +- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 +-- .../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 ++-- MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 36 +++++++++---------- 14 files changed, 36 insertions(+), 47 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h b/MdeModulePkg/Bus/Ata/= AhciPei/AhciPei.h index 71d34c962ad1..e2e4ba43e7c4 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h @@ -146,8 +146,7 @@ typedef union { #define AHCI_PORT_SERR 0x0030 #define AHCI_PORT_CI 0x0038 =20 -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) -#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 100= 00000) +#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000= 000) =20 #pragma pack(1) =20 diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/Mde= ModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h index 7937886614e1..016fc6890ae9 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h @@ -148,8 +148,6 @@ struct _ATA_NONBLOCK_TASK { #define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3) #define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10) =20 -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) - #define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ CR (a, \ ATA_ATAPI_PASS_THRU_INSTANCE, \ diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata= /AtaBusDxe/AtaBus.h index 47346e911d47..6bc345f7e777 100644 --- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h +++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h @@ -76,7 +76,6 @@ #define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K') #define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D') #define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S') -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) =20 // // ATA bus data structure for ATA controller diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bu= s/Scsi/ScsiDiskDxe/ScsiDisk.h index ed384ad52182..5a25b55c4952 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h @@ -38,8 +38,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0 =20 -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) - #define UFS_WLUN_RPMB 0xC4 =20 typedef struct { diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h b/MdeModule= Pkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h index 1adb382aa8c3..ed4776f548e0 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h @@ -133,8 +133,6 @@ typedef struct _UFS_PEIM_HC_PRIVATE_DATA { =20 #define ROUNDUP8(x) (((x) % 8 =3D=3D 0) ? (x) : ((x) / 8 + 1) * 8) =20 -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) - #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_= HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG) #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_= HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG) #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, UFS_PEIM_= HC_PRIVATE_DATA, EndOfPeiNotifyList, UFS_PEIM_HC_SIG) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index 0ec37e56652b..bc1139da6e3b 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -105,8 +105,6 @@ typedef struct { =20 #define ROUNDUP8(x) (((x) % 8 =3D=3D 0) ? (x) : ((x) / 8 + 1) * 8) =20 -#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) = =3D=3D 0) - #define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ CR (a, \ UFS_PASS_THRU_PRIVATE_DATA, \ diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Univ= ersal/EbcDxe/EbcExecute.h index 6dc6730ab095..f3768e79528e 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h @@ -14,8 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // Macros to check and set alignment // -#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size= - 1))) -#define ADDRESS_IS_ALIGNED_(addr, size) !((UINT32) (addr) & (size - 1)) +#define ASSERT_ALIGNED(addr, size) ASSERT (ADDRESS_IS_ALIGNED (addr, size= )) =20 // // Debug macro diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata= /AhciPei/AhciMode.c index d93fa78c81f3..0f0198d3085b 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c @@ -2126,7 +2126,7 @@ TrustTransferAtaDevice ( // ATA PassThru PPI. // if ((AtaPassThru->Mode->IoAlign > 1) && - !ADDRESS_IS_ALIGNED_ (Buffer, AtaPassThru->Mode->IoAlign)) + !ADDRESS_IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) { NewBuffer =3D AllocateAlignedPages ( EFI_SIZE_TO_PAGES (TransferLength), diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c b/MdeModulePkg/= Bus/Ata/AhciPei/AhciPeiPassThru.c index 0c49059a00d5..cd55272c96cd 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c @@ -194,15 +194,15 @@ AhciAtaPassThruPassThru ( } =20 IoAlign =3D This->Mode->IoAlign; - if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, IoAlign= )) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->InDataBuffer, IoAlign)= ) { return EFI_INVALID_PARAMETER; } =20 - if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, IoAlig= n)) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->OutDataBuffer, IoAlign= )) { return EFI_INVALID_PARAMETER; } =20 - if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, IoAlign)) { + if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->Asb, IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/Mde= ModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 324abadd02dd..50406fe0270d 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -1299,15 +1299,15 @@ AtaPassThruPassThru ( =20 Instance =3D ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This); =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->InDataBuff= er, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->OutDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, This= ->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->Asb, This-= >Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 @@ -2039,15 +2039,15 @@ ExtScsiPassThruPassThru ( return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->InDataBuff= er, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->OutDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData= , This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->SenseData,= This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModul= ePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c index 18aa4f9bb666..a77852bae054 100644 --- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c +++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c @@ -1040,7 +1040,7 @@ TrustTransferAtaDevice ( // Check the alignment of the incoming buffer prior to invoking underl= ying ATA PassThru // AtaPassThru =3D AtaDevice->AtaBusDriverData->AtaPassThru; - if ((AtaPassThru->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Buffer, = AtaPassThru->Mode->IoAlign)) { + if ((AtaPassThru->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Buffer, A= taPassThru->Mode->IoAlign)) { NewBuffer =3D AllocateAlignedBuffer (AtaDevice, TransferLength); if (NewBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bu= s/Scsi/ScsiDiskDxe/ScsiDisk.c index faf4ae332e46..873581d817ce 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c @@ -2029,7 +2029,7 @@ ScsiDiskReceiveData ( goto Done; } =20 - if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Pay= loadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { + if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Payl= oadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { AlignedBuffer =3D AllocateAlignedBuffer (ScsiDiskDevice, PayloadBuff= erSize); if (AlignedBuffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; @@ -2249,7 +2249,7 @@ ScsiDiskSendData ( goto Done; } =20 - if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Pay= loadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { + if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Payl= oadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) { AlignedBuffer =3D AllocateAlignedBuffer (ScsiDiskDevice, PayloadBuff= erSize); if (AlignedBuffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 392a295caf04..880e7d85114e 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -171,15 +171,15 @@ UfsPassThruPassThru ( return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuf= fer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->InDataBuff= er, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBu= ffer, This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->OutDataBuf= fer, This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 - if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData= , This->Mode->IoAlign)) { + if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->SenseData,= This->Mode->IoAlign)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Univ= ersal/EbcDxe/EbcExecute.c index 28f108c44873..3221f95a739f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -2015,7 +2015,7 @@ ExecuteJMP ( // check for alignment, and jump absolute. // Data64 =3D (UINT64)VmReadImmed64 (VmPtr, 2); - if (!ADDRESS_IS_ALIGNED_ ((UINTN)Data64, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -2074,7 +2074,7 @@ ExecuteJMP ( // Form: JMP32 @Rx {Index32} // Addr =3D VmReadMemN (VmPtr, (UINTN)Data64 + Index32); - if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -2097,7 +2097,7 @@ ExecuteJMP ( // Form: JMP32 Rx {Immed32} // Addr =3D (UINTN)(Data64 + Index32); - if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -3158,7 +3158,7 @@ ExecuteRET ( // Pull the return address off the VM app's stack and set the IP // to it // - if (!ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) { + if (!ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) { EbcDebugSignalException ( EXCEPT_EBC_ALIGNMENT_CHECK, EXCEPTION_FLAG_FATAL, @@ -4733,7 +4733,7 @@ VmWriteMem16 ( // // Do a simple write if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT16))) { *(UINT16 *)Addr =3D Data; } else { // @@ -4795,7 +4795,7 @@ VmWriteMem32 ( // // Do a simple write if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT32))) { *(UINT32 *)Addr =3D Data; } else { // @@ -4857,7 +4857,7 @@ VmWriteMem64 ( // // Do a simple write if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT64))) { *(UINT64 *)Addr =3D Data; } else { // @@ -4922,7 +4922,7 @@ VmWriteMemN ( // // Do a simple write if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINTN))) { *(UINTN *)Addr =3D Data; } else { for (Index =3D 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) { @@ -4985,7 +4985,7 @@ VmReadImmed16 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) { return *(INT16 *)(VmPtr->Ip + Offset); } else { // @@ -5029,7 +5029,7 @@ VmReadImmed32 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { return *(INT32 *)(VmPtr->Ip + Offset); } =20 @@ -5068,7 +5068,7 @@ VmReadImmed64 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { return *(UINT64 *)(VmPtr->Ip + Offset); } =20 @@ -5105,7 +5105,7 @@ VmReadCode16 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) { return *(UINT16 *)(VmPtr->Ip + Offset); } else { // @@ -5147,7 +5147,7 @@ VmReadCode32 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) { return *(UINT32 *)(VmPtr->Ip + Offset); } =20 @@ -5184,7 +5184,7 @@ VmReadCode64 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) { return *(UINT64 *)(VmPtr->Ip + Offset); } =20 @@ -5247,7 +5247,7 @@ VmReadMem16 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT16))) { return *(UINT16 *)Addr; } =20 @@ -5281,7 +5281,7 @@ VmReadMem32 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT32))) { return *(UINT32 *)Addr; } =20 @@ -5319,7 +5319,7 @@ VmReadMem64 ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT64))) { return *(UINT64 *)Addr; } =20 @@ -5388,7 +5388,7 @@ VmReadMemN ( // // Read direct if aligned // - if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) { + if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINTN))) { return *(UINTN *)Addr; } =20 --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100666): https://edk2.groups.io/g/devel/message/100666 Mute This Topic: https://groups.io/mt/97357270/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 05:54:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100667+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100667+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677826292; cv=none; d=zohomail.com; s=zohoarc; b=cOnznOkUpGd7857Ev3Iwih6/B38Azz9CA6FmVHl502UwZzj/BmK6dmv86FyWPQ2QVNZ514yODeB5KfsgwjPmD3jHsgXYgCjHp2GtcNOIh+h2eYf848QF25q17mYkM1aPMsd6+GrtYNVhqUhtJOd9nrg7i44Seghy/S9Dj4s7QzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677826292; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Z0hN38f4i1DkGV6px5VJiXZpdOca5/T2Z2VGqDePjJ8=; b=Vukb/ttri13exYaqsGmXkzrV7qCXmgr90O44zVP9OBpBJUipJtSTvGmPs1kao3LYHROlIgs3jS5SqpJVtgKDO23i+N78x95ducyz/pMJGTzXDw3v01kdYTaz1V/RK6Zv9WakXmfNJ+gv75/dPEebpC3udqtNMumTSdQUS1psaW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100667+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1677826292711114.88772891293479; Thu, 2 Mar 2023 22:51:32 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id AtUyYY1788612xtOB0TbWpqE; Thu, 02 Mar 2023 22:51:32 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.17713.1677826291748354900 for ; Thu, 02 Mar 2023 22:51:31 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-Pm0LZdnePtqaEcr2blXQIQ-1; Fri, 03 Mar 2023 01:51:23 -0500 X-MC-Unique: Pm0LZdnePtqaEcr2blXQIQ-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11DF3800B23; Fri, 3 Mar 2023 06:51:23 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B95512026D4B; Fri, 3 Mar 2023 06:51:22 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 162FB180108D; Fri, 3 Mar 2023 07:51:16 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jian J Wang , Jiewen Yao , =?UTF-8?q?Marvin=20H=C3=A4user?= , James Bottomley , Michael Roth , Hao A Wu , Michael D Kinney , Oliver Steffen , Min Xu , Liming Gao , Ray Ni , Tom Lendacky , Erdem Aktas , Zhiguang Liu , Pawel Polawski , Jordan Justen Subject: [edk2-devel] [PATCH 5/5] OvmfPkg: Consume new alignment-related macros Date: Fri, 3 Mar 2023 07:51:15 +0100 Message-Id: <20230303065115.406020-6-kraxel@redhat.com> In-Reply-To: <20230303065115.406020-1-kraxel@redhat.com> References: <20230303065115.406020-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: Fn01zhyYx01itn6BqGXPrPLNx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1677826292; bh=cxuWd44kcYBJLSHxRypWLa4sMX9EOPqvhysWzPH8XpY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=xCkhO36bddqVcHLz8AH1Sn+Ln/xySAi8puSObJCOhtuwUGtMcZ0auRr/zbnLCTeIZn2 kWpnkaUx770BNe7KeiGavrVYG2ngF6bFm7uaDHbUpkAl36GIsMBdcyiQCaOFVgNH0TPJp WOPn5sWg8bDwCf1dFWsJUaigSBC557QzOAs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1677826294670100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch substitutes the macros that were renamed in the second patch with the new, shared alignment macros. Signed-off-by: Gerd Hoffmann Acked-by: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Michael D Kinney --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 6 ++---- .../BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 71a1eaaf0a1d..9b0d0e92b6f7 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -44,8 +44,6 @@ STATIC BOOLEAN mAcceptAllMemoryAtEBS =3D TRUE; =20 STATIC EFI_EVENT mAcceptAllMemoryEvent =3D NULL; =20 -#define IS_ALIGNED_(x, y) ((((x) & ((y) - 1)) =3D=3D 0)) - STATIC EFI_STATUS EFIAPI @@ -60,8 +58,8 @@ AmdSevMemoryAccept ( // multiple of SIZE_4KB. Use an assert instead of returning an erros sin= ce // this is an EDK2-internal protocol. // - ASSERT (IS_ALIGNED_ (StartAddress, SIZE_4KB)); - ASSERT (IS_ALIGNED_ (Size, SIZE_4KB)); + ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB)); + ASSERT (IS_ALIGNED (Size, SIZE_4KB)); ASSERT (Size !=3D 0); =20 MemEncryptSevSnpPreValidateSystemRam ( diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInt= ernal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeIntern= al.c index f35bba5deb46..7a8878b1a9c2 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -20,7 +20,6 @@ =20 #include "SnpPageStateChange.h" =20 -#define IS_ALIGNED_(x, y) ((((x) & (y - 1)) =3D=3D 0)) #define PAGES_PER_LARGE_ENTRY 512 =20 STATIC @@ -150,7 +149,7 @@ BuildPageStateBuffer ( // // Is this a 2MB aligned page? Check if we can use the Large RMP entry. // - if (UseLargeEntry && IS_ALIGNED_ (BaseAddress, SIZE_2MB) && + if (UseLargeEntry && IS_ALIGNED (BaseAddress, SIZE_2MB) && ((EndAddress - BaseAddress) >=3D SIZE_2MB)) { RmpPageSize =3D PvalidatePageSize2MB; --=20 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100667): https://edk2.groups.io/g/devel/message/100667 Mute This Topic: https://groups.io/mt/97357272/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-