From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.11550.1610039586175177633 for ; Thu, 07 Jan 2021 09:13:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZnD+UQAt; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610039585; 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=V/Rjw6YWlkpfYQ19r5AMOwkRecV0/jhATQenVz3bDL4=; b=ZnD+UQAtjaXeOTSJ6Pf4hx65cNFBxd1x+L1PhpqyBApf/paBgxN1GJocOTfG8zzPBko6QN gnkg/xGfAdWE63xcW7nmeVmU1rYQ2aH9c1odFVpYGSHcgaxMN+JGySgT2irN2nrCTUGjky AnnOod8idwya5fjEcPah8GYRmiJsumw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-Ry-3TB9KPK6vAU5cYoVNlA-1; Thu, 07 Jan 2021 12:13:01 -0500 X-MC-Unique: Ry-3TB9KPK6vAU5cYoVNlA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4492100C603; Thu, 7 Jan 2021 17:12:59 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-164.ams2.redhat.com [10.36.112.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C49C10013BD; Thu, 7 Jan 2021 17:12:58 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 10/15] OvmfPkg/MemEncryptSevLib: Coding style fixes in prep for SEC library To: devel@edk2.groups.io, thomas.lendacky@amd.com Cc: Brijesh Singh , James Bottomley , Jordan Justen , Ard Biesheuvel References: <47e8a4edf59761c1052631487276d4ac04bea561.1609968101.git.thomas.lendacky@amd.com> From: "Laszlo Ersek" Message-ID: <1eaff1e8-3d3a-a8d5-865f-2c6f4d158209@redhat.com> Date: Thu, 7 Jan 2021 18:12:57 +0100 MIME-Version: 1.0 In-Reply-To: <47e8a4edf59761c1052631487276d4ac04bea561.1609968101.git.thomas.lendacky@amd.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 01/06/21 22:21, Lendacky, Thomas wrote: > From: Tom Lendacky > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108 > > Creating an SEC version of the library requires renaming an existing file > which will result in the existing code failing ECC. Prior to renaming the > existing file, fix the coding style to avoid the ECC failure. > > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Brijesh Singh > Signed-off-by: Tom Lendacky > --- > OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c > index 6422bc53bd5d..3a5bab657bd7 100644 > --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c > +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c > @@ -192,7 +192,8 @@ Split2MPageTo4K ( > { > PHYSICAL_ADDRESS PhysicalAddress4K; > UINTN IndexOfPageTableEntries; > - PAGE_TABLE_4K_ENTRY *PageTableEntry, *PageTableEntry1; > + PAGE_TABLE_4K_ENTRY *PageTableEntry; > + PAGE_TABLE_4K_ENTRY *PageTableEntry1; > UINT64 AddressEncMask; > > PageTableEntry = AllocatePageTableMemory(1); > @@ -472,7 +473,7 @@ Split1GPageTo2M ( > /** > Set or Clear the memory encryption bit > > - @param[in] PagetablePoint Page table entry pointer (PTE). > + @param[in, out] PageTablePointer Page table entry pointer (PTE). > @param[in] Mode Set or Clear encryption bit > > **/ > @@ -562,7 +563,6 @@ EnableReadOnlyPageWriteProtect ( > @retval RETURN_UNSUPPORTED Setting the memory encyrption attribute > is not supported > **/ > - > STATIC > RETURN_STATUS > EFIAPI > @@ -635,7 +635,7 @@ SetMemoryEncDec ( > > Status = EFI_SUCCESS; > > - while (Length) > + while (Length != 0) > { > // > // If Cr3BaseAddress is not specified then read the current CR3 > @@ -683,7 +683,7 @@ SetMemoryEncDec ( > // Valid 1GB page > // If we have at least 1GB to go, we can just update this entry > // > - if (!(PhysicalAddress & (BIT30 - 1)) && Length >= BIT30) { > + if ((PhysicalAddress & (BIT30 - 1)) == 0 && Length >= BIT30) { > SetOrClearCBit(&PageDirectory1GEntry->Uint64, Mode); > DEBUG (( > DEBUG_VERBOSE, > @@ -744,7 +744,7 @@ SetMemoryEncDec ( > // Valid 2MB page > // If we have at least 2MB left to go, we can just update this entry > // > - if (!(PhysicalAddress & (BIT21-1)) && Length >= BIT21) { > + if ((PhysicalAddress & (BIT21-1)) == 0 && Length >= BIT21) { > SetOrClearCBit (&PageDirectory2MEntry->Uint64, Mode); > PhysicalAddress += BIT21; > Length -= BIT21; > Reviewed-by: Laszlo Ersek