From mboxrd@z Thu Jan 1 00:00:00 1970 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.36980.1679468587538061068 for ; Wed, 22 Mar 2023 00:03:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hR+ffzph; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679468586; 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=r3KS7n0uv2wVu3b2su+uzeeIQ0XppUL5J8zrclMs5bM=; b=hR+ffzphScrl0Pxqt2mb1m/iIotLxdf5SVRimB1SIA9CouE/8F9LNHxhKWb+CEDxBeJMTZ /+aRZuakvnnmRY9ZTOdU04bhZHii0eW8lfSYHoaIV03mj9A0w8+mpIiiDHVwoX1W5X8+OA GbBBUXn+DWhXH9ge8JavJKlnXxfwVfg= 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-627-rbN4KpLHPcKm4PaB94Q2MQ-1; Wed, 22 Mar 2023 03:02:59 -0400 X-MC-Unique: rbN4KpLHPcKm4PaB94Q2MQ-1 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 A68052808E66; Wed, 22 Mar 2023 07:02:58 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 692EE2166B29; Wed, 22 Mar 2023 07:02:58 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D029218003B3; Wed, 22 Mar 2023 08:02:43 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Michael D Kinney , Erdem Aktas , James Bottomley , Liming Gao , =?UTF-8?q?Marvin=20H=C3=A4user?= , Pawel Polawski , Michael Roth , Tom Lendacky , Gerd Hoffmann , Jiewen Yao , Jian J Wang , Ard Biesheuvel , Jordan Justen , Hao A Wu , Zhiguang Liu , Ray Ni , Min Xu , Oliver Steffen , Jiewen Yao Subject: [PATCH v2 5/6] OvmfPkg: Consume new alignment-related macros Date: Wed, 22 Mar 2023 08:02:42 +0100 Message-Id: <20230322070243.410903-6-kraxel@redhat.com> In-Reply-To: <20230322070243.410903-1-kraxel@redhat.com> References: <20230322070243.410903-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; 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 Reviewed-by: Michael D Kinney Reviewed-by: Jiewen Yao Acked-by: Tom Lendacky --- 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 = TRUE; STATIC EFI_EVENT mAcceptAllMemoryEvent = NULL; -#define IS_ALIGNED_(x, y) ((((x) & ((y) - 1)) == 0)) - STATIC EFI_STATUS EFIAPI @@ -60,8 +58,8 @@ AmdSevMemoryAccept ( // multiple of SIZE_4KB. Use an assert instead of returning an erros since // 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 != 0); MemEncryptSevSnpPreValidateSystemRam ( diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c index f35bba5deb46..7a8878b1a9c2 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -20,7 +20,6 @@ #include "SnpPageStateChange.h" -#define IS_ALIGNED_(x, y) ((((x) & (y - 1)) == 0)) #define PAGES_PER_LARGE_ENTRY 512 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) >= SIZE_2MB)) { RmpPageSize = PvalidatePageSize2MB; -- 2.39.2