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.133.124]) by mx.groups.io with SMTP id smtpd.web10.17713.1677826291748354900 for ; Thu, 02 Mar 2023 22:51:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YiaDx60B; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677826290; 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=Kft3/Fjh/ZekGaJhDUNP30LZ5JnvIh3Zs1FamRWSkgA=; b=YiaDx60BuPNvqWgR8S2+bYqsjDPmyWjPh5VfMlVR+lYE5qnGS+FIAvkLGcgW47O5dp8loJ zot2NjCK3NXa1q0mYNxX5i2iJlmW/dH7zaHdZVFkzLDnejUVqSDglo0mFt/lLx2LWSofgS 9OVBTfWoyRAG6htv2UHJYyFXB44+Ao8= 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 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) 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) 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: [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 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 --- 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