Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-08 Thread Laszlo Ersek
On 07/08/20 15:07, Tom Lendacky wrote:
> On 7/7/20 12:11 PM, Tom Lendacky wrote:
>> On 7/7/20 10:50 AM, Tom Lendacky wrote:
>>> On 7/7/20 10:36 AM, Laszlo Ersek wrote:
 On 07/06/20 22:03, Tom Lendacky wrote:
> On 7/2/20 2:04 AM, Dong, Eric wrote:
>> Hi Tom,
>
> Hi Eric,
>
>>
>> We have root cause this Mac file format issue. The patch mail from your 
>> side include extra two "=0D=0D" , and our test tool convert them to 
>> "\r\r". This is Mac file line ending format. So this issue been 
>> reported. We have updated our tool to handle this special case.
>
> Good to know, thanks!
>
>>
>> With that change, now I met below error when use VS2015 tool chain. Can 
>> you help to fix it?
>>
>> Building ... 
>> g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
>>  [X64]
>> PeCoffLoaderEx.c
>> g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386):
>>  warning C4334: '<<': result of 32-bit shift implicitly converted to 64 
>> bits (was 64-bit shift intended?)
>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
>> Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'

 This is for the line

   Displacement *= (1 << Ext->Sib.Scale);

 from

   [edk2-devel] [PATCH v9 17/46]
   OvmfPkg/VmgExitLib: Add support for NPF NAE events (MMIO)

>
> Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
> I have verified that fixes the issue.

 I disagree.

 At that point, Displacement is of type INT64, and it may well be a
 negative value. We definitely want to multiply it by a signed int
 (values 1, 2, 4, 8).

 I commented on this before. Please see:

 (i) my comment block (10) here -- especially comment (10c):

   
 https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60144data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=g%2BGooY1Sv0G7ydr11Jh%2BTXxo4Wy6ZWcT5Mq9VmWddi8%3Dreserved=0

 (alternative link:
 )

 (ii) and my comment here:

   
 https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60146data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=iNIBJCIlfEEsY37cdwUbH27tx5HvXVs3PZiOQfaGeLQ%3Dreserved=0

 (alternative link:
 ).


 The compiler warning is well-meaning, but unnecessary. A 64-bit shift is
 *NOT* intended. We want to end up with one of the signed int (aka INT32)
 values 1, 2, 4 or 8. And then multiply the INT64 Displacement with that
 value. For the multiplication, the INT32 value 1, 2, 4 or 8 will be
 implicitly converted to INT64. That's entirely intentional.

 If we want to suppress the warning, while keeping the logic intact, we
 should employ an explicit cast:

   Displacement *= (INT64)(1 << Ext->Sib.Scale);
>>>
>>> Ok, that makes sense. I'll use the explicit cast.
>>>

>
> One thing I noticed is that the 32-bit builds
> (PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
> Platform_CI OVMF_IA32X64_NOOPT) encounter an error:
>
> ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved 
> external symbol __allshl
> ERROR - Linker #1120 from 
> d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll
>  : fatal   1 unresolved externals
> ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files 
> (x86)\Microsoft Visual 
> Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"'
>  : return code '0x460'
>
> Any idea what is causing this error?

 A left-shift operator (<<) applied to a 64-bit operand is somehow
 finding its way into the 32-bit SEC build.

 That is indeed wrong (for such cases, we're supposed to use LShiftU64()
 from BaseLib).

 What I don't understand however is that all of 

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-08 Thread Lendacky, Thomas
On 7/7/20 12:11 PM, Tom Lendacky wrote:
> On 7/7/20 10:50 AM, Tom Lendacky wrote:
>> On 7/7/20 10:36 AM, Laszlo Ersek wrote:
>>> On 07/06/20 22:03, Tom Lendacky wrote:
 On 7/2/20 2:04 AM, Dong, Eric wrote:
> Hi Tom,

 Hi Eric,

>
> We have root cause this Mac file format issue. The patch mail from your 
> side include extra two "=0D=0D" , and our test tool convert them to 
> "\r\r". This is Mac file line ending format. So this issue been reported. 
> We have updated our tool to handle this special case.

 Good to know, thanks!

>
> With that change, now I met below error when use VS2015 tool chain. Can 
> you help to fix it?
>
> Building ... 
> g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
>  [X64]
> PeCoffLoaderEx.c
> g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386):
>  warning C4334: '<<': result of 32-bit shift implicitly converted to 64 
> bits (was 64-bit shift intended?)
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
> Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
>>>
>>> This is for the line
>>>
>>>   Displacement *= (1 << Ext->Sib.Scale);
>>>
>>> from
>>>
>>>   [edk2-devel] [PATCH v9 17/46]
>>>   OvmfPkg/VmgExitLib: Add support for NPF NAE events (MMIO)
>>>

 Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
 I have verified that fixes the issue.
>>>
>>> I disagree.
>>>
>>> At that point, Displacement is of type INT64, and it may well be a
>>> negative value. We definitely want to multiply it by a signed int
>>> (values 1, 2, 4, 8).
>>>
>>> I commented on this before. Please see:
>>>
>>> (i) my comment block (10) here -- especially comment (10c):
>>>
>>>   
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60144data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=g%2BGooY1Sv0G7ydr11Jh%2BTXxo4Wy6ZWcT5Mq9VmWddi8%3Dreserved=0
>>>
>>> (alternative link:
>>> )
>>>
>>> (ii) and my comment here:
>>>
>>>   
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60146data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=iNIBJCIlfEEsY37cdwUbH27tx5HvXVs3PZiOQfaGeLQ%3Dreserved=0
>>>
>>> (alternative link:
>>> ).
>>>
>>>
>>> The compiler warning is well-meaning, but unnecessary. A 64-bit shift is
>>> *NOT* intended. We want to end up with one of the signed int (aka INT32)
>>> values 1, 2, 4 or 8. And then multiply the INT64 Displacement with that
>>> value. For the multiplication, the INT32 value 1, 2, 4 or 8 will be
>>> implicitly converted to INT64. That's entirely intentional.
>>>
>>> If we want to suppress the warning, while keeping the logic intact, we
>>> should employ an explicit cast:
>>>
>>>   Displacement *= (INT64)(1 << Ext->Sib.Scale);
>>
>> Ok, that makes sense. I'll use the explicit cast.
>>
>>>

 One thing I noticed is that the 32-bit builds
 (PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
 Platform_CI OVMF_IA32X64_NOOPT) encounter an error:

 ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved external 
 symbol __allshl
 ERROR - Linker #1120 from 
 d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll
  : fatal   1 unresolved externals
 ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files 
 (x86)\Microsoft Visual 
 Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"'
  : return code '0x460'

 Any idea what is causing this error?
>>>
>>> A left-shift operator (<<) applied to a 64-bit operand is somehow
>>> finding its way into the 32-bit SEC build.
>>>
>>> That is indeed wrong (for such cases, we're supposed to use LShiftU64()
>>> from BaseLib).
>>>
>>> What I don't understand however is that all of the "<<" operator uses,
>>> on 64-bit operands, should already be limited to code that is *only*
>>> built for X64!
>>>
>>> For example, with this 

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-07 Thread Lendacky, Thomas
On 7/7/20 10:50 AM, Tom Lendacky wrote:
> On 7/7/20 10:36 AM, Laszlo Ersek wrote:
>> On 07/06/20 22:03, Tom Lendacky wrote:
>>> On 7/2/20 2:04 AM, Dong, Eric wrote:
 Hi Tom,
>>>
>>> Hi Eric,
>>>

 We have root cause this Mac file format issue. The patch mail from your 
 side include extra two "=0D=0D" , and our test tool convert them to 
 "\r\r". This is Mac file line ending format. So this issue been reported. 
 We have updated our tool to handle this special case.
>>>
>>> Good to know, thanks!
>>>

 With that change, now I met below error when use VS2015 tool chain. Can 
 you help to fix it?

 Building ... 
 g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
  [X64]
 PeCoffLoaderEx.c
 g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386):
  warning C4334: '<<': result of 32-bit shift implicitly converted to 64 
 bits (was 64-bit shift intended?)
 NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
 Studio 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
>>
>> This is for the line
>>
>>   Displacement *= (1 << Ext->Sib.Scale);
>>
>> from
>>
>>   [edk2-devel] [PATCH v9 17/46]
>>   OvmfPkg/VmgExitLib: Add support for NPF NAE events (MMIO)
>>
>>>
>>> Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
>>> I have verified that fixes the issue.
>>
>> I disagree.
>>
>> At that point, Displacement is of type INT64, and it may well be a
>> negative value. We definitely want to multiply it by a signed int
>> (values 1, 2, 4, 8).
>>
>> I commented on this before. Please see:
>>
>> (i) my comment block (10) here -- especially comment (10c):
>>
>>   
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60144data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=g%2BGooY1Sv0G7ydr11Jh%2BTXxo4Wy6ZWcT5Mq9VmWddi8%3Dreserved=0
>>
>> (alternative link:
>> )
>>
>> (ii) and my comment here:
>>
>>   
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60146data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=iNIBJCIlfEEsY37cdwUbH27tx5HvXVs3PZiOQfaGeLQ%3Dreserved=0
>>
>> (alternative link:
>> ).
>>
>>
>> The compiler warning is well-meaning, but unnecessary. A 64-bit shift is
>> *NOT* intended. We want to end up with one of the signed int (aka INT32)
>> values 1, 2, 4 or 8. And then multiply the INT64 Displacement with that
>> value. For the multiplication, the INT32 value 1, 2, 4 or 8 will be
>> implicitly converted to INT64. That's entirely intentional.
>>
>> If we want to suppress the warning, while keeping the logic intact, we
>> should employ an explicit cast:
>>
>>   Displacement *= (INT64)(1 << Ext->Sib.Scale);
> 
> Ok, that makes sense. I'll use the explicit cast.
> 
>>
>>>
>>> One thing I noticed is that the 32-bit builds
>>> (PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
>>> Platform_CI OVMF_IA32X64_NOOPT) encounter an error:
>>>
>>> ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved external 
>>> symbol __allshl
>>> ERROR - Linker #1120 from 
>>> d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll
>>>  : fatal   1 unresolved externals
>>> ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files 
>>> (x86)\Microsoft Visual 
>>> Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"' 
>>> : return code '0x460'
>>>
>>> Any idea what is causing this error?
>>
>> A left-shift operator (<<) applied to a 64-bit operand is somehow
>> finding its way into the 32-bit SEC build.
>>
>> That is indeed wrong (for such cases, we're supposed to use LShiftU64()
>> from BaseLib).
>>
>> What I don't understand however is that all of the "<<" operator uses,
>> on 64-bit operands, should already be limited to code that is *only*
>> built for X64!
>>
>> For example, with this series applied, SecMain in OVMF consumes
>> "UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf".
>> And the latter consumes 

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-07 Thread Lendacky, Thomas
On 7/7/20 10:36 AM, Laszlo Ersek wrote:
> On 07/06/20 22:03, Tom Lendacky wrote:
>> On 7/2/20 2:04 AM, Dong, Eric wrote:
>>> Hi Tom,
>>
>> Hi Eric,
>>
>>>
>>> We have root cause this Mac file format issue. The patch mail from your 
>>> side include extra two "=0D=0D" , and our test tool convert them to "\r\r". 
>>> This is Mac file line ending format. So this issue been reported. We have 
>>> updated our tool to handle this special case.
>>
>> Good to know, thanks!
>>
>>>
>>> With that change, now I met below error when use VS2015 tool chain. Can you 
>>> help to fix it?
>>>
>>> Building ... 
>>> g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
>>>  [X64]
>>> PeCoffLoaderEx.c
>>> g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386):
>>>  warning C4334: '<<': result of 32-bit shift implicitly converted to 64 
>>> bits (was 64-bit shift intended?)
>>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
>>> 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'
> 
> This is for the line
> 
>   Displacement *= (1 << Ext->Sib.Scale);
> 
> from
> 
>   [edk2-devel] [PATCH v9 17/46]
>   OvmfPkg/VmgExitLib: Add support for NPF NAE events (MMIO)
> 
>>
>> Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
>> I have verified that fixes the issue.
> 
> I disagree.
> 
> At that point, Displacement is of type INT64, and it may well be a
> negative value. We definitely want to multiply it by a signed int
> (values 1, 2, 4, 8).
> 
> I commented on this before. Please see:
> 
> (i) my comment block (10) here -- especially comment (10c):
> 
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60144data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=g%2BGooY1Sv0G7ydr11Jh%2BTXxo4Wy6ZWcT5Mq9VmWddi8%3Dreserved=0
> 
> (alternative link:
> )
> 
> (ii) and my comment here:
> 
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F60146data=02%7C01%7Cthomas.lendacky%40amd.com%7Cec0cb2ad96694b66d8ff08d8228b7c8e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637297329772337705sdata=iNIBJCIlfEEsY37cdwUbH27tx5HvXVs3PZiOQfaGeLQ%3Dreserved=0
> 
> (alternative link:
> ).
> 
> 
> The compiler warning is well-meaning, but unnecessary. A 64-bit shift is
> *NOT* intended. We want to end up with one of the signed int (aka INT32)
> values 1, 2, 4 or 8. And then multiply the INT64 Displacement with that
> value. For the multiplication, the INT32 value 1, 2, 4 or 8 will be
> implicitly converted to INT64. That's entirely intentional.
> 
> If we want to suppress the warning, while keeping the logic intact, we
> should employ an explicit cast:
> 
>   Displacement *= (INT64)(1 << Ext->Sib.Scale);

Ok, that makes sense. I'll use the explicit cast.

> 
>>
>> One thing I noticed is that the 32-bit builds
>> (PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
>> Platform_CI OVMF_IA32X64_NOOPT) encounter an error:
>>
>> ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved external 
>> symbol __allshl
>> ERROR - Linker #1120 from 
>> d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll
>>  : fatal   1 unresolved externals
>> ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files 
>> (x86)\Microsoft Visual 
>> Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"' 
>> : return code '0x460'
>>
>> Any idea what is causing this error?
> 
> A left-shift operator (<<) applied to a 64-bit operand is somehow
> finding its way into the 32-bit SEC build.
> 
> That is indeed wrong (for such cases, we're supposed to use LShiftU64()
> from BaseLib).
> 
> What I don't understand however is that all of the "<<" operator uses,
> on 64-bit operands, should already be limited to code that is *only*
> built for X64!
> 
> For example, with this series applied, SecMain in OVMF consumes
> "UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf".
> And the latter consumes VmgExitLib.
> 
> But VmgExitLib is resolved to
> "UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf", in the IA32 and
> IA32X64 DSC 

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-07 Thread Laszlo Ersek
On 07/06/20 22:03, Tom Lendacky wrote:
> On 7/2/20 2:04 AM, Dong, Eric wrote:
>> Hi Tom,
> 
> Hi Eric,
> 
>>
>> We have root cause this Mac file format issue. The patch mail from your side 
>> include extra two "=0D=0D" , and our test tool convert them to "\r\r". This 
>> is Mac file line ending format. So this issue been reported. We have updated 
>> our tool to handle this special case.
> 
> Good to know, thanks!
> 
>>
>> With that change, now I met below error when use VS2015 tool chain. Can you 
>> help to fix it?
>>
>> Building ... 
>> g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
>>  [X64]
>> PeCoffLoaderEx.c
>> g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386): 
>> warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits 
>> (was 64-bit shift intended?)
>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
>> 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'

This is for the line

  Displacement *= (1 << Ext->Sib.Scale);

from

  [edk2-devel] [PATCH v9 17/46]
  OvmfPkg/VmgExitLib: Add support for NPF NAE events (MMIO)

> 
> Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
> I have verified that fixes the issue.

I disagree.

At that point, Displacement is of type INT64, and it may well be a
negative value. We definitely want to multiply it by a signed int
(values 1, 2, 4, 8).

I commented on this before. Please see:

(i) my comment block (10) here -- especially comment (10c):

  https://edk2.groups.io/g/devel/message/60144

(alternative link:
<169e44cb-2c1c-6d9a-342a-2a1f618e3753@redhat.com">http://mid.mail-archive.com/169e44cb-2c1c-6d9a-342a-2a1f618e3753@redhat.com>)

(ii) and my comment here:

  https://edk2.groups.io/g/devel/message/60146

(alternative link:
<139ce789-b938-c8b9-030e-c1b6c67e47ea@redhat.com">http://mid.mail-archive.com/139ce789-b938-c8b9-030e-c1b6c67e47ea@redhat.com>).


The compiler warning is well-meaning, but unnecessary. A 64-bit shift is
*NOT* intended. We want to end up with one of the signed int (aka INT32)
values 1, 2, 4 or 8. And then multiply the INT64 Displacement with that
value. For the multiplication, the INT32 value 1, 2, 4 or 8 will be
implicitly converted to INT64. That's entirely intentional.

If we want to suppress the warning, while keeping the logic intact, we
should employ an explicit cast:

  Displacement *= (INT64)(1 << Ext->Sib.Scale);

> 
> One thing I noticed is that the 32-bit builds
> (PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
> Platform_CI OVMF_IA32X64_NOOPT) encounter an error:
> 
> ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved external 
> symbol __allshl
> ERROR - Linker #1120 from 
> d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll
>  : fatal   1 unresolved externals
> ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files 
> (x86)\Microsoft Visual 
> Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"' : 
> return code '0x460'
> 
> Any idea what is causing this error?

A left-shift operator (<<) applied to a 64-bit operand is somehow
finding its way into the 32-bit SEC build.

That is indeed wrong (for such cases, we're supposed to use LShiftU64()
from BaseLib).

What I don't understand however is that all of the "<<" operator uses,
on 64-bit operands, should already be limited to code that is *only*
built for X64!

For example, with this series applied, SecMain in OVMF consumes
"UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf".
And the latter consumes VmgExitLib.

But VmgExitLib is resolved to
"UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf", in the IA32 and
IA32X64 DSC files. This Null instance contains no left-shifts.

Therefore any << operators, applied to 64-bit operands, present in
"OvmfPkg/Library/VmgExitLib", should never be compiled for IA32 and IA32X64.

So I don't know where the problematic "<<" comes from. It does not come
from VmgExitLib, as far as I can tell.

Thanks,
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62166): https://edk2.groups.io/g/devel/message/62166
Mute This Topic: https://groups.io/mt/74692413/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-06 Thread Lendacky, Thomas
On 7/2/20 2:04 AM, Dong, Eric wrote:
> Hi Tom,

Hi Eric,

> 
> We have root cause this Mac file format issue. The patch mail from your side 
> include extra two "=0D=0D" , and our test tool convert them to "\r\r". This 
> is Mac file line ending format. So this issue been reported. We have updated 
> our tool to handle this special case.

Good to know, thanks!

> 
> With that change, now I met below error when use VS2015 tool chain. Can you 
> help to fix it?
> 
> Building ... 
> g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf
>  [X64]
> PeCoffLoaderEx.c
> g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386): 
> warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits 
> (was 64-bit shift intended?)
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
> 14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'

Yup, looks like that needs to be a "1ULL <<" instead of "1 <<".
I have verified that fixes the issue.

One thing I noticed is that the 32-bit builds
(PlatformCI_OvmfPkg_Windows_VS2019_PR, Platform_CI OVMF_IA32_NOOPT and
Platform_CI OVMF_IA32X64_NOOPT) encounter an error:

ERROR - Linker #2001 from SecMain.lib(SecMain.obj) :   unresolved external 
symbol __allshl
ERROR - Linker #1120 from 
d:\a\1\s\Build\Ovmf3264\NOOPT_VS2019\IA32\OvmfPkg\Sec\SecMain\DEBUG\SecMain.dll 
: fatal   1 unresolved externals
ERROR - Compiler #1077 from NMAKE : fatal   '"C:\Program Files (x86)\Microsoft 
Visual 
Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x86\link.exe"' : 
return code '0x460'

Any idea what is causing this error?

Thanks,
Tom

> 
> Thanks,
> Eric
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of
>> Lendacky, Thomas
>> Sent: Tuesday, June 23, 2020 8:58 PM
>> To: devel@edk2.groups.io; Dong, Eric ;
>> ler...@redhat.com
>> Cc: Brijesh Singh ; Ard Biesheuvel
>> ; Justen, Jordan L ;
>> Gao, Liming ; Kinney, Michael D
>> ; Ni, Ray 
>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
>> support for VMGEXIT
>>
>> On 6/22/20 8:16 PM, Dong, Eric via groups.io wrote:
>>>
>>>
>>>> -Original Message-
>>>> From: devel@edk2.groups.io  On Behalf Of
>> Laszlo
>>>> Ersek
>>>> Sent: Friday, June 19, 2020 11:39 PM
>>>> To: Tom Lendacky ; devel@edk2.groups.io;
>>>> Dong, Eric 
>>>> Cc: Brijesh Singh ; Ard Biesheuvel
>>>> ; Justen, Jordan L
>>>> ; Gao, Liming ;
>>>> Kinney, Michael D ; Ni, Ray
>>>> 
>>>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
>>>> library support for VMGEXIT
>>>>
>>>> On 06/19/20 15:50, Tom Lendacky wrote:
>>>>> On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
>>>>>>
>>>>>>
>>>>>>> -Original Message-
>>>>>>> From: devel@edk2.groups.io  On Behalf Of
>>>>>>> Lendacky, Thomas
>>>>>>> Sent: Thursday, June 18, 2020 10:09 PM
>>>>>>> To: Dong, Eric ; devel@edk2.groups.io
>>>>>>> Cc: Brijesh Singh ; Ard Biesheuvel
>>>>>>> ; Justen, Jordan L
>>>> ;
>>>>>>> Laszlo Ersek ; Gao, Liming
>>>>>>> ; Kinney, Michael D
>>>>>>> ; Ni, Ray 
>>>>>>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
>>>> library
>>>>>>> support for VMGEXIT
>>>>>>>
>>>>>>> On 6/18/20 2:23 AM, Dong, Eric wrote:
>>>>>>>> Hi Tom,
>>>>>>>>
>>>>>>>> When use VS2015 to build this code, it reports below error.
>>>>>>>> Please help to
>>>>>>> fix it.
>>>>>>>>
>>>>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220:
>>>> warning
>>>>>>>> treated as error - no 'object' file generated
>>>>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335:
>>>> Mac
>>>>>>>> file format detected: please convert the source file to either
>>>>>>>> DOS or UNIX format
>>>>>>>
>>>>>>> That is strange...  I didn't see this when I ran through the CI.
>>>>>>> When I do a file command against the file it r

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-07-02 Thread Dong, Eric
Hi Tom,

We have root cause this Mac file format issue. The patch mail from your side 
include extra two "=0D=0D" , and our test tool convert them to "\r\r". This is 
Mac file line ending format. So this issue been reported. We have updated our 
tool to handle this special case.

With that change, now I met below error when use VS2015 tool chain. Can you 
help to fix it?

Building ... 
g:\edk2-open-source\edk2\MdePkg\Library\PeiCoreEntryPoint\PeiCoreEntryPoint.inf 
[X64]
PeCoffLoaderEx.c
g:\edk2-open-source\edk2\OvmfPkg\Library\VmgExitLib\VmgExitVcHandler.c(386): 
warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits 
(was 64-bit shift intended?)
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 
14.0\Vc\bin\x86_amd64\cl.exe"' : return code '0x2'

Thanks,
Eric
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> Lendacky, Thomas
> Sent: Tuesday, June 23, 2020 8:58 PM
> To: devel@edk2.groups.io; Dong, Eric ;
> ler...@redhat.com
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Justen, Jordan L ;
> Gao, Liming ; Kinney, Michael D
> ; Ni, Ray 
> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
> support for VMGEXIT
> 
> On 6/22/20 8:16 PM, Dong, Eric via groups.io wrote:
> >
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io  On Behalf Of
> Laszlo
> >> Ersek
> >> Sent: Friday, June 19, 2020 11:39 PM
> >> To: Tom Lendacky ; devel@edk2.groups.io;
> >> Dong, Eric 
> >> Cc: Brijesh Singh ; Ard Biesheuvel
> >> ; Justen, Jordan L
> >> ; Gao, Liming ;
> >> Kinney, Michael D ; Ni, Ray
> >> 
> >> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
> >> library support for VMGEXIT
> >>
> >> On 06/19/20 15:50, Tom Lendacky wrote:
> >>> On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
> >>>>
> >>>>
> >>>>> -Original Message-
> >>>>> From: devel@edk2.groups.io  On Behalf Of
> >>>>> Lendacky, Thomas
> >>>>> Sent: Thursday, June 18, 2020 10:09 PM
> >>>>> To: Dong, Eric ; devel@edk2.groups.io
> >>>>> Cc: Brijesh Singh ; Ard Biesheuvel
> >>>>> ; Justen, Jordan L
> >> ;
> >>>>> Laszlo Ersek ; Gao, Liming
> >>>>> ; Kinney, Michael D
> >>>>> ; Ni, Ray 
> >>>>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
> >> library
> >>>>> support for VMGEXIT
> >>>>>
> >>>>> On 6/18/20 2:23 AM, Dong, Eric wrote:
> >>>>>> Hi Tom,
> >>>>>>
> >>>>>> When use VS2015 to build this code, it reports below error.
> >>>>>> Please help to
> >>>>> fix it.
> >>>>>>
> >>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220:
> >> warning
> >>>>>> treated as error - no 'object' file generated
> >>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335:
> >> Mac
> >>>>>> file format detected: please convert the source file to either
> >>>>>> DOS or UNIX format
> >>>>>
> >>>>> That is strange...  I didn't see this when I ran through the CI.
> >>>>> When I do a file command against the file it reports:
> >>>>>
> >>>>> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text,
> >>>>> with
> >> CRLF
> >>>>> line terminators
> >>>>>
> >>>>> I'll investigate this and try and figure out what's going on, but
> >>>>> if anyone else has some ideas, please let me know.
> >>>>
> >>>> Hi Tom,
> >>>>
> >>>> I met this error again when I trig below patch from AMD again for
> >>>> CPU change.
> >>>> "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to
> >> BaseUefiCpuLib"
> >>>
> >>> Hmmm... I think we could be running into issues with sending patches
> >>> through our mail servers. Let me send you the patch series directly
> >>> using some changes I made to my git config file to see if that helps.
> >>> Would that be ok?
> >>
> >> both sender and recipient git clones should have
> >>
> >> [core]
> >> whitespace = cr-at-eol

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-23 Thread Lendacky, Thomas
On 6/22/20 8:16 PM, Dong, Eric via groups.io wrote:
> 
> 
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Laszlo
>> Ersek
>> Sent: Friday, June 19, 2020 11:39 PM
>> To: Tom Lendacky ; devel@edk2.groups.io;
>> Dong, Eric 
>> Cc: Brijesh Singh ; Ard Biesheuvel
>> ; Justen, Jordan L ;
>> Gao, Liming ; Kinney, Michael D
>> ; Ni, Ray 
>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
>> support for VMGEXIT
>>
>> On 06/19/20 15:50, Tom Lendacky wrote:
>>> On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
>>>>
>>>>
>>>>> -Original Message-
>>>>> From: devel@edk2.groups.io  On Behalf Of
>>>>> Lendacky, Thomas
>>>>> Sent: Thursday, June 18, 2020 10:09 PM
>>>>> To: Dong, Eric ; devel@edk2.groups.io
>>>>> Cc: Brijesh Singh ; Ard Biesheuvel
>>>>> ; Justen, Jordan L
>> ;
>>>>> Laszlo Ersek ; Gao, Liming ;
>>>>> Kinney, Michael D ; Ni, Ray
>>>>> 
>>>>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
>> library
>>>>> support for VMGEXIT
>>>>>
>>>>> On 6/18/20 2:23 AM, Dong, Eric wrote:
>>>>>> Hi Tom,
>>>>>>
>>>>>> When use VS2015 to build this code, it reports below error. Please
>>>>>> help to
>>>>> fix it.
>>>>>>
>>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220:
>> warning
>>>>>> treated as error - no 'object' file generated
>>>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335:
>> Mac
>>>>>> file format detected: please convert the source file to either DOS or
>>>>>> UNIX format
>>>>>
>>>>> That is strange...  I didn't see this when I ran through the CI. When
>>>>> I do a file
>>>>> command against the file it reports:
>>>>>
>>>>> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with
>> CRLF
>>>>> line terminators
>>>>>
>>>>> I'll investigate this and try and figure out what's going on, but if
>>>>> anyone else
>>>>> has some ideas, please let me know.
>>>>
>>>> Hi Tom,
>>>>
>>>> I met this error again when I trig below patch from AMD again for CPU
>>>> change.
>>>> "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to
>> BaseUefiCpuLib"
>>>
>>> Hmmm... I think we could be running into issues with sending patches
>>> through our mail servers. Let me send you the patch series directly
>>> using some changes I made to my git config file to see if that helps.
>>> Would that be ok?
>>
>> both sender and recipient git clones should have
>>
>> [core]
>> whitespace = cr-at-eol
>>
>> and the recipient clone should have
>>
>> [am]
>> keepcr = true
>>
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FLaszlo%27s-unkempt-git-data=02%7C01%7Cthomas.lendacky%40amd.com%7Cd461956236264e4a6d3a08d81713205d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637284718210751789sdata=ftFiRZkC3n2n2MZyL6t9HKnp1fYgzUQV4FRBvVNQ4%2FA%3Dreserved=0
>> guide-for-edk2-contributors-and-maintainers#contrib-05
>>
>> These are also set by "BaseTools/Scripts/SetupGit.py".
>>
> 
> Hi Tom,
> 
> I see below context in another mail thread and base on the latest status, 
> this solution works and that patch has fixed the issue. Can you follow below 
> suggest fixing your issue?
> 
>   Hi Garrett,
> 
>   I encounter below error when build
>   UefiCpuPkg\Library\BaseUefiCpuLib\BaseUefiCpuLib.c: warning C4335: Mac 
> file format detected: please convert the source file to either DOS or UNIX 
> format'
> 
>   I encounter the issue ever, it result by mail encoding.
>   To resolve this issue, you can run [BaseTools\ Scripts\SetupGit.py] 
> first, and then send the patch again.
> 
>   Could you try it and send the patch again?

Hi Eric,

I already had those settings in my git config file, so I'm thinking it was
still something else. I sent you a direct set of patches with some other
setting tweaks. Let me know how those work out for you.

Thanks,
Tom

> 
> Thanks,
> Eric
> 
>> Thanks
>> Laszlo
>>
>>
>>
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61599): https://edk2.groups.io/g/devel/message/61599
Mute This Topic: https://groups.io/mt/74692413/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-22 Thread Dong, Eric


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Laszlo
> Ersek
> Sent: Friday, June 19, 2020 11:39 PM
> To: Tom Lendacky ; devel@edk2.groups.io;
> Dong, Eric 
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Justen, Jordan L ;
> Gao, Liming ; Kinney, Michael D
> ; Ni, Ray 
> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
> support for VMGEXIT
> 
> On 06/19/20 15:50, Tom Lendacky wrote:
> > On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
> >>
> >>
> >>> -Original Message-
> >>> From: devel@edk2.groups.io  On Behalf Of
> >>> Lendacky, Thomas
> >>> Sent: Thursday, June 18, 2020 10:09 PM
> >>> To: Dong, Eric ; devel@edk2.groups.io
> >>> Cc: Brijesh Singh ; Ard Biesheuvel
> >>> ; Justen, Jordan L
> ;
> >>> Laszlo Ersek ; Gao, Liming ;
> >>> Kinney, Michael D ; Ni, Ray
> >>> 
> >>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
> library
> >>> support for VMGEXIT
> >>>
> >>> On 6/18/20 2:23 AM, Dong, Eric wrote:
> >>>> Hi Tom,
> >>>>
> >>>> When use VS2015 to build this code, it reports below error. Please
> >>>> help to
> >>> fix it.
> >>>>
> >>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220:
> warning
> >>>> treated as error - no 'object' file generated
> >>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335:
> Mac
> >>>> file format detected: please convert the source file to either DOS or
> >>>> UNIX format
> >>>
> >>> That is strange...  I didn't see this when I ran through the CI. When
> >>> I do a file
> >>> command against the file it reports:
> >>>
> >>> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with
> CRLF
> >>> line terminators
> >>>
> >>> I'll investigate this and try and figure out what's going on, but if
> >>> anyone else
> >>> has some ideas, please let me know.
> >>
> >> Hi Tom,
> >>
> >> I met this error again when I trig below patch from AMD again for CPU
> >> change.
> >> "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to
> BaseUefiCpuLib"
> >
> > Hmmm... I think we could be running into issues with sending patches
> > through our mail servers. Let me send you the patch series directly
> > using some changes I made to my git config file to see if that helps.
> > Would that be ok?
> 
> both sender and recipient git clones should have
> 
> [core]
> whitespace = cr-at-eol
> 
> and the recipient clone should have
> 
> [am]
> keepcr = true
> 
> https://github.com/tianocore/tianocore.github.io/wiki/Laszlo's-unkempt-git-
> guide-for-edk2-contributors-and-maintainers#contrib-05
> 
> These are also set by "BaseTools/Scripts/SetupGit.py".
> 

Hi Tom,

I see below context in another mail thread and base on the latest status, this 
solution works and that patch has fixed the issue. Can you follow below suggest 
fixing your issue?

Hi Garrett,

I encounter below error when build
UefiCpuPkg\Library\BaseUefiCpuLib\BaseUefiCpuLib.c: warning C4335: Mac 
file format detected: please convert the source file to either DOS or UNIX 
format'

I encounter the issue ever, it result by mail encoding.
To resolve this issue, you can run [BaseTools\ Scripts\SetupGit.py] 
first, and then send the patch again.

Could you try it and send the patch again?

Thanks,
Eric

> Thanks
> Laszlo
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61572): https://edk2.groups.io/g/devel/message/61572
Mute This Topic: https://groups.io/mt/74692413/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-19 Thread Laszlo Ersek
On 06/19/20 15:50, Tom Lendacky wrote:
> On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
>>
>>
>>> -Original Message-
>>> From: devel@edk2.groups.io  On Behalf Of
>>> Lendacky, Thomas
>>> Sent: Thursday, June 18, 2020 10:09 PM
>>> To: Dong, Eric ; devel@edk2.groups.io
>>> Cc: Brijesh Singh ; Ard Biesheuvel
>>> ; Justen, Jordan L ;
>>> Laszlo Ersek ; Gao, Liming ;
>>> Kinney, Michael D ; Ni, Ray
>>> 
>>> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
>>> support for VMGEXIT
>>>
>>> On 6/18/20 2:23 AM, Dong, Eric wrote:
>>>> Hi Tom,
>>>>
>>>> When use VS2015 to build this code, it reports below error. Please
>>>> help to
>>> fix it.
>>>>
>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning
>>>> treated as error - no 'object' file generated
>>>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac
>>>> file format detected: please convert the source file to either DOS or
>>>> UNIX format
>>>
>>> That is strange...  I didn't see this when I ran through the CI. When
>>> I do a file
>>> command against the file it reports:
>>>
>>> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with CRLF
>>> line terminators
>>>
>>> I'll investigate this and try and figure out what's going on, but if
>>> anyone else
>>> has some ideas, please let me know.
>>
>> Hi Tom,
>>
>> I met this error again when I trig below patch from AMD again for CPU
>> change.
>> "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib"
> 
> Hmmm... I think we could be running into issues with sending patches
> through our mail servers. Let me send you the patch series directly
> using some changes I made to my git config file to see if that helps.
> Would that be ok?

both sender and recipient git clones should have

[core]
whitespace = cr-at-eol

and the recipient clone should have

[am]
keepcr = true

https://github.com/tianocore/tianocore.github.io/wiki/Laszlo's-unkempt-git-guide-for-edk2-contributors-and-maintainers#contrib-05

These are also set by "BaseTools/Scripts/SetupGit.py".

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61527): https://edk2.groups.io/g/devel/message/61527
Mute This Topic: https://groups.io/mt/74692413/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-19 Thread Dong, Eric


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> Lendacky, Thomas
> Sent: Friday, June 19, 2020 9:51 PM
> To: devel@edk2.groups.io; Dong, Eric 
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Justen, Jordan L ;
> Laszlo Ersek ; Gao, Liming ;
> Kinney, Michael D ; Ni, Ray 
> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
> support for VMGEXIT
> 
> On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:
> >
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io  On Behalf Of
> >> Lendacky, Thomas
> >> Sent: Thursday, June 18, 2020 10:09 PM
> >> To: Dong, Eric ; devel@edk2.groups.io
> >> Cc: Brijesh Singh ; Ard Biesheuvel
> >> ; Justen, Jordan L
> >> ; Laszlo Ersek ; Gao,
> >> Liming ; Kinney, Michael D
> >> ; Ni, Ray 
> >> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement
> >> library support for VMGEXIT
> >>
> >> On 6/18/20 2:23 AM, Dong, Eric wrote:
> >>> Hi Tom,
> >>>
> >>> When use VS2015 to build this code, it reports below error. Please
> >>> help to
> >> fix it.
> >>>
> >>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220:
> >>> warning treated as error - no 'object' file generated
> >>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac
> >>> file format detected: please convert the source file to either DOS
> >>> or UNIX format
> >>
> >> That is strange...  I didn't see this when I ran through the CI. When
> >> I do a file command against the file it reports:
> >>
> >> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with
> >> CRLF line terminators
> >>
> >> I'll investigate this and try and figure out what's going on, but if
> >> anyone else has some ideas, please let me know.
> >
> > Hi Tom,
> >
> > I met this error again when I trig below patch from AMD again for CPU
> change.
> > "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib"
> 
> Hmmm... I think we could be running into issues with sending patches
> through our mail servers. Let me send you the patch series directly using
> some changes I made to my git config file to see if that helps. Would that be
> ok?

Yes, please do it.

Thanks,
Eric
> 
> Thanks,
> Tom
> 
> >
> > I'm not sure whether this is patch issue, or our internal test sever issue. 
> > I
> have reported this error to our internal team to check also.
> > Please check it from your side and make sure no error from your side. I will
> update the status from my side when I get the update.
> >
> > Thanks,
> > Eric
> >
> >>
> >> Thanks,
> >> Tom
> >>
> >>>
> >>> Thanks,
> >>> Eric
> >>>
> >>>> -Original Message-
> >>>> From: Tom Lendacky 
> >>>> Sent: Friday, June 5, 2020 9:27 PM
> >>>> To: devel@edk2.groups.io
> >>>> Cc: Brijesh Singh ; Ard Biesheuvel
> >>>> ; Dong, Eric ; Justen,
> >>>> Jordan L ; Laszlo Ersek
> >>>> ; Gao, Liming ; Kinney,
> >>>> Michael D ; Ni, Ray 
> >>>> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
> >>>> VMGEXIT
> >>>>
> >>>> BZ:
> >>>>
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbug
> >>>>
> >>
> zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Ct
> >> ho
> >>>>
> >>
> mas.lendacky%40amd.com%7Cd75554da4959407c967608d8135877be%7C3dd
> >> 8961fe
> >>>>
> >>
> 4884e608e11a82d994e183d%7C0%7C0%7C637280617975250842sdata=
> >> fBlK2B
> >>>>
> FkRdAS5EWcM8YShf1ZswfRN%2F41L7XeUsb4ZCs%3Dreserved=0
> >>>>
> >>>> To support handling #VC exceptions and issuing VMGEXIT
> >>>> instructions, create a library with functions that can be used to
> >>>> perform these #VC/VMGEXIT related operations. This includes
> functions for:
> >>>> - Handling #VC exceptions
> >>>> - Preparing for and issuing a VMGEXIT
> >>>> - Performing MMIO-related write operations to support flash
> emulation
> >>>> - Performing AP related boot opeations
> >>>>
> >>>> The base functions in thi

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-19 Thread Lendacky, Thomas

On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote:




-Original Message-
From: devel@edk2.groups.io  On Behalf Of
Lendacky, Thomas
Sent: Thursday, June 18, 2020 10:09 PM
To: Dong, Eric ; devel@edk2.groups.io
Cc: Brijesh Singh ; Ard Biesheuvel
; Justen, Jordan L ;
Laszlo Ersek ; Gao, Liming ;
Kinney, Michael D ; Ni, Ray 
Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
support for VMGEXIT

On 6/18/20 2:23 AM, Dong, Eric wrote:

Hi Tom,

When use VS2015 to build this code, it reports below error. Please help to

fix it.


k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning
treated as error - no 'object' file generated
k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac
file format detected: please convert the source file to either DOS or
UNIX format


That is strange...  I didn't see this when I ran through the CI. When I do a 
file
command against the file it reports:

UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with CRLF
line terminators

I'll investigate this and try and figure out what's going on, but if anyone else
has some ideas, please let me know.


Hi Tom,

I met this error again when I trig below patch from AMD again for CPU change.
"UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib"


Hmmm... I think we could be running into issues with sending patches 
through our mail servers. Let me send you the patch series directly using 
some changes I made to my git config file to see if that helps. Would that 
be ok?


Thanks,
Tom



I'm not sure whether this is patch issue, or our internal test sever issue. I 
have reported this error to our internal team to check also.
Please check it from your side and make sure no error from your side. I will 
update the status from my side when I get the update.

Thanks,
Eric



Thanks,
Tom



Thanks,
Eric


-Original Message-
From: Tom Lendacky 
Sent: Friday, June 5, 2020 9:27 PM
To: devel@edk2.groups.io
Cc: Brijesh Singh ; Ard Biesheuvel
; Dong, Eric ; Justen,
Jordan L ; Laszlo Ersek
; Gao, Liming ; Kinney,
Michael D ; Ni, Ray 
Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
VMGEXIT

BZ:


https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbug



zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Ct
ho



mas.lendacky%40amd.com%7Cd75554da4959407c967608d8135877be%7C3dd
8961fe



4884e608e11a82d994e183d%7C0%7C0%7C637280617975250842sdata=
fBlK2B

FkRdAS5EWcM8YShf1ZswfRN%2F41L7XeUsb4ZCs%3Dreserved=0

To support handling #VC exceptions and issuing VMGEXIT instructions,
create a library with functions that can be used to perform these
#VC/VMGEXIT related operations. This includes functions for:
- Handling #VC exceptions
- Preparing for and issuing a VMGEXIT
- Performing MMIO-related write operations to support flash emulation
- Performing AP related boot opeations

The base functions in this driver will not do anything and will
return an error if a return value is required. It is expected that
other packages (like OvmfPkg) will create a version of the library to
fully support an SEV-ES guest.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Signed-off-by: Tom Lendacky 
---
   UefiCpuPkg/UefiCpuPkg.dec|   3 +
   UefiCpuPkg/UefiCpuPkg.dsc|   2 +
   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
   UefiCpuPkg/Include/Library/VmgExitLib.h  | 103

+

   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121

   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
   6 files changed, 271 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index df5d02bae6b4..cb92f34b6f55 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
 ##

 MpInitLib|Include/Library/MpInitLib.h



+  ##  @libraryclass  Provides function to support VMGEXIT processing.

+  VmgExitLib|Include/Library/VmgExitLib.h

+

   [Guids]

 gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,
0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}

 gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 
0x30,
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index afa304128221..f0e58b90ff0a 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -56,6 +56,7 @@ [LibraryClasses]



PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base

PeCoffGetEntryPointLib.inf




PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/Base

PeCoffExtraActionLib|P
eCoffExtraActionLibNull.inf




TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp

mMeasurementLibNull.inf

+  VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf



   [LibraryClasses.

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-19 Thread Dong, Eric


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> Lendacky, Thomas
> Sent: Thursday, June 18, 2020 10:09 PM
> To: Dong, Eric ; devel@edk2.groups.io
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Justen, Jordan L ;
> Laszlo Ersek ; Gao, Liming ;
> Kinney, Michael D ; Ni, Ray 
> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library
> support for VMGEXIT
> 
> On 6/18/20 2:23 AM, Dong, Eric wrote:
> > Hi Tom,
> >
> > When use VS2015 to build this code, it reports below error. Please help to
> fix it.
> >
> > k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning
> > treated as error - no 'object' file generated
> > k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac
> > file format detected: please convert the source file to either DOS or
> > UNIX format
> 
> That is strange...  I didn't see this when I ran through the CI. When I do a 
> file
> command against the file it reports:
> 
> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with CRLF
> line terminators
> 
> I'll investigate this and try and figure out what's going on, but if anyone 
> else
> has some ideas, please let me know.

Hi Tom,

I met this error again when I trig below patch from AMD again for CPU change.
"UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib"

I'm not sure whether this is patch issue, or our internal test sever issue. I 
have reported this error to our internal team to check also.
Please check it from your side and make sure no error from your side. I will 
update the status from my side when I get the update.

Thanks,
Eric

> 
> Thanks,
> Tom
> 
> >
> > Thanks,
> > Eric
> >
> >> -Original Message-
> >> From: Tom Lendacky 
> >> Sent: Friday, June 5, 2020 9:27 PM
> >> To: devel@edk2.groups.io
> >> Cc: Brijesh Singh ; Ard Biesheuvel
> >> ; Dong, Eric ; Justen,
> >> Jordan L ; Laszlo Ersek
> >> ; Gao, Liming ; Kinney,
> >> Michael D ; Ni, Ray 
> >> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
> >> VMGEXIT
> >>
> >> BZ:
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbug
> >>
> zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Ct
> ho
> >>
> mas.lendacky%40amd.com%7Cd75554da4959407c967608d8135877be%7C3dd
> 8961fe
> >>
> 4884e608e11a82d994e183d%7C0%7C0%7C637280617975250842sdata=
> fBlK2B
> >> FkRdAS5EWcM8YShf1ZswfRN%2F41L7XeUsb4ZCs%3Dreserved=0
> >>
> >> To support handling #VC exceptions and issuing VMGEXIT instructions,
> >> create a library with functions that can be used to perform these
> >> #VC/VMGEXIT related operations. This includes functions for:
> >>- Handling #VC exceptions
> >>- Preparing for and issuing a VMGEXIT
> >>- Performing MMIO-related write operations to support flash emulation
> >>- Performing AP related boot opeations
> >>
> >> The base functions in this driver will not do anything and will
> >> return an error if a return value is required. It is expected that
> >> other packages (like OvmfPkg) will create a version of the library to
> >> fully support an SEV-ES guest.
> >>
> >> Cc: Eric Dong 
> >> Cc: Ray Ni 
> >> Cc: Laszlo Ersek 
> >> Signed-off-by: Tom Lendacky 
> >> ---
> >>   UefiCpuPkg/UefiCpuPkg.dec|   3 +
> >>   UefiCpuPkg/UefiCpuPkg.dsc|   2 +
> >>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
> >>   UefiCpuPkg/Include/Library/VmgExitLib.h  | 103
> +
> >>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121
> >> 
> >>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
> >>   6 files changed, 271 insertions(+)
> >>
> >> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> >> index df5d02bae6b4..cb92f34b6f55 100644
> >> --- a/UefiCpuPkg/UefiCpuPkg.dec
> >> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> >> @@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
> >> ##
> >>
> >> MpInitLib|Include/Library/MpInitLib.h
> >>
> >>
> >>
> >> +  ##  @libraryclass  Provides function to support VMGEXIT processing.
> >>
> >> +  VmgExitLib|Include/Library/VmgExitLib.h
> >>
> >> +
> >>
> >>   [Gu

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-18 Thread Lendacky, Thomas
On 6/18/20 2:23 AM, Dong, Eric wrote:
> Hi Tom,
> 
> When use VS2015 to build this code, it reports below error. Please help to 
> fix it.
> 
> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning treated 
> as error - no 'object' file generated
> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac file 
> format detected: please convert the source file to either DOS or UNIX format

That is strange...  I didn't see this when I ran through the CI. When I do
a file command against the file it reports:

UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with CRLF line 
terminators

I'll investigate this and try and figure out what's going on, but if
anyone else has some ideas, please let me know.

Thanks,
Tom

> 
> Thanks,
> Eric
> 
>> -Original Message-
>> From: Tom Lendacky 
>> Sent: Friday, June 5, 2020 9:27 PM
>> To: devel@edk2.groups.io
>> Cc: Brijesh Singh ; Ard Biesheuvel
>> ; Dong, Eric ; Justen,
>> Jordan L ; Laszlo Ersek ;
>> Gao, Liming ; Kinney, Michael D
>> ; Ni, Ray 
>> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
>> VMGEXIT
>>
>> BZ: 
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Cthomas.lendacky%40amd.com%7Cd75554da4959407c967608d8135877be%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637280617975250842sdata=fBlK2BFkRdAS5EWcM8YShf1ZswfRN%2F41L7XeUsb4ZCs%3Dreserved=0
>>
>> To support handling #VC exceptions and issuing VMGEXIT instructions,
>> create a library with functions that can be used to perform these
>> #VC/VMGEXIT related operations. This includes functions for:
>>- Handling #VC exceptions
>>- Preparing for and issuing a VMGEXIT
>>- Performing MMIO-related write operations to support flash emulation
>>- Performing AP related boot opeations
>>
>> The base functions in this driver will not do anything and will return
>> an error if a return value is required. It is expected that other packages
>> (like OvmfPkg) will create a version of the library to fully support an
>> SEV-ES guest.
>>
>> Cc: Eric Dong 
>> Cc: Ray Ni 
>> Cc: Laszlo Ersek 
>> Signed-off-by: Tom Lendacky 
>> ---
>>   UefiCpuPkg/UefiCpuPkg.dec|   3 +
>>   UefiCpuPkg/UefiCpuPkg.dsc|   2 +
>>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
>>   UefiCpuPkg/Include/Library/VmgExitLib.h  | 103 
>> +
>>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121
>> 
>>   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
>>   6 files changed, 271 insertions(+)
>>
>> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
>> index df5d02bae6b4..cb92f34b6f55 100644
>> --- a/UefiCpuPkg/UefiCpuPkg.dec
>> +++ b/UefiCpuPkg/UefiCpuPkg.dec
>> @@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
>> ##
>>
>> MpInitLib|Include/Library/MpInitLib.h
>>
>>
>>
>> +  ##  @libraryclass  Provides function to support VMGEXIT processing.
>>
>> +  VmgExitLib|Include/Library/VmgExitLib.h
>>
>> +
>>
>>   [Guids]
>>
>> gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,
>> 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
>>
>> gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 
>> 0x30,
>> 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
>>
>> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
>> index afa304128221..f0e58b90ff0a 100644
>> --- a/UefiCpuPkg/UefiCpuPkg.dsc
>> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
>> @@ -56,6 +56,7 @@ [LibraryClasses]
>>
>> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
>> PeCoffGetEntryPointLib.inf
>>
>>
>> PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BaseP
>> eCoffExtraActionLibNull.inf
>>
>>
>> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
>> mMeasurementLibNull.inf
>>
>> +  VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
>>
>>
>>
>>   [LibraryClasses.common.SEC]
>>
>>
>> PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.i
>> nf
>>
>> @@ -143,6 +144,7 @@ [Components.IA32, Components.X64]
>>
>> UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLib
>> Null.inf
>>
>> UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
>>
>> UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
>>
>> +  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
>>
>> UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
>>
>> UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
>>
>> UefiCpuPkg/SecCore/SecCore.inf
>>
>> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
>> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
>> new file mode 100644
>> index ..d8770a21c355
>> --- /dev/null
>> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
>> @@ -0,0 +1,27 @@
>> +## @file
>>
>> +#  

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-18 Thread Dong, Eric
Hi Tom,

When use VS2015 to build this code, it reports below error. Please help to fix 
it.

k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning treated 
as error - no 'object' file generated
k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac file format 
detected: please convert the source file to either DOS or UNIX format

Thanks,
Eric

> -Original Message-
> From: Tom Lendacky 
> Sent: Friday, June 5, 2020 9:27 PM
> To: devel@edk2.groups.io
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Dong, Eric ; Justen,
> Jordan L ; Laszlo Ersek ;
> Gao, Liming ; Kinney, Michael D
> ; Ni, Ray 
> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
> VMGEXIT
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
> 
> To support handling #VC exceptions and issuing VMGEXIT instructions,
> create a library with functions that can be used to perform these
> #VC/VMGEXIT related operations. This includes functions for:
>   - Handling #VC exceptions
>   - Preparing for and issuing a VMGEXIT
>   - Performing MMIO-related write operations to support flash emulation
>   - Performing AP related boot opeations
> 
> The base functions in this driver will not do anything and will return
> an error if a return value is required. It is expected that other packages
> (like OvmfPkg) will create a version of the library to fully support an
> SEV-ES guest.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Signed-off-by: Tom Lendacky 
> ---
>  UefiCpuPkg/UefiCpuPkg.dec|   3 +
>  UefiCpuPkg/UefiCpuPkg.dsc|   2 +
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
>  UefiCpuPkg/Include/Library/VmgExitLib.h  | 103 +
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121
> 
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
>  6 files changed, 271 insertions(+)
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index df5d02bae6b4..cb92f34b6f55 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
>##
> 
>MpInitLib|Include/Library/MpInitLib.h
> 
> 
> 
> +  ##  @libraryclass  Provides function to support VMGEXIT processing.
> 
> +  VmgExitLib|Include/Library/VmgExitLib.h
> 
> +
> 
>  [Guids]
> 
>gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,
> 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
> 
>gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 
> 0x30,
> 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
> index afa304128221..f0e58b90ff0a 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dsc
> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
> @@ -56,6 +56,7 @@ [LibraryClasses]
> 
> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
> PeCoffGetEntryPointLib.inf
> 
> 
> PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BaseP
> eCoffExtraActionLibNull.inf
> 
> 
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
> mMeasurementLibNull.inf
> 
> +  VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> 
> 
> 
>  [LibraryClasses.common.SEC]
> 
> 
> PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.i
> nf
> 
> @@ -143,6 +144,7 @@ [Components.IA32, Components.X64]
> 
> UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLib
> Null.inf
> 
>UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
> 
>UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
> 
> +  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> 
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
> 
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
> 
>UefiCpuPkg/SecCore/SecCore.inf
> 
> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> new file mode 100644
> index ..d8770a21c355
> --- /dev/null
> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> @@ -0,0 +1,27 @@
> +## @file
> 
> +#  VMGEXIT Support Library.
> 
> +#
> 
> +#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
> 
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +#
> 
> +##
> 
> +
> 
> +[Defines]
> 
> +  INF_VERSION= 0x00010005
> 
> +  BASE_NAME  = VmgExitLibNull
> 
> +  MODULE_UNI_FILE= VmgExitLibNull.uni
> 
> +  FILE_GUID  = 3cd7368f-ef9b-4a9b-9571-2ed93813677e
> 
> +  MODULE_TYPE= BASE
> 
> +  VERSION_STRING = 1.0
> 
> +  LIBRARY_CLASS  = VmgExitLib
> 
> +
> 
> +[Sources.common]
> 
> +  VmgExitLibNull.c
> 
> +
> 
> +[Packages]
> 
> +  MdePkg/MdePkg.dec
> 
> +  UefiCpuPkg/UefiCpuPkg.dec
> 
> +
> 
> +[LibraryClasses]
> 
> +  BaseLib
> 
> +
> 
> 

Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-11 Thread Dong, Eric
Reviewed-by: Eric Dong 

Thanks,
Eric
> -Original Message-
> From: Tom Lendacky 
> Sent: Friday, June 5, 2020 9:27 PM
> To: devel@edk2.groups.io
> Cc: Brijesh Singh ; Ard Biesheuvel
> ; Dong, Eric ; Justen,
> Jordan L ; Laszlo Ersek ;
> Gao, Liming ; Kinney, Michael D
> ; Ni, Ray 
> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for
> VMGEXIT
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
> 
> To support handling #VC exceptions and issuing VMGEXIT instructions,
> create a library with functions that can be used to perform these
> #VC/VMGEXIT related operations. This includes functions for:
>   - Handling #VC exceptions
>   - Preparing for and issuing a VMGEXIT
>   - Performing MMIO-related write operations to support flash emulation
>   - Performing AP related boot opeations
> 
> The base functions in this driver will not do anything and will return
> an error if a return value is required. It is expected that other packages
> (like OvmfPkg) will create a version of the library to fully support an
> SEV-ES guest.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Signed-off-by: Tom Lendacky 
> ---
>  UefiCpuPkg/UefiCpuPkg.dec|   3 +
>  UefiCpuPkg/UefiCpuPkg.dsc|   2 +
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
>  UefiCpuPkg/Include/Library/VmgExitLib.h  | 103 +
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121
> 
>  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
>  6 files changed, 271 insertions(+)
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index df5d02bae6b4..cb92f34b6f55 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
>##
> 
>MpInitLib|Include/Library/MpInitLib.h
> 
> 
> 
> +  ##  @libraryclass  Provides function to support VMGEXIT processing.
> 
> +  VmgExitLib|Include/Library/VmgExitLib.h
> 
> +
> 
>  [Guids]
> 
>gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,
> 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
> 
>gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 
> 0x30,
> 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
> index afa304128221..f0e58b90ff0a 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dsc
> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
> @@ -56,6 +56,7 @@ [LibraryClasses]
> 
> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
> PeCoffGetEntryPointLib.inf
> 
> 
> PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BaseP
> eCoffExtraActionLibNull.inf
> 
> 
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
> mMeasurementLibNull.inf
> 
> +  VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> 
> 
> 
>  [LibraryClasses.common.SEC]
> 
> 
> PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.i
> nf
> 
> @@ -143,6 +144,7 @@ [Components.IA32, Components.X64]
> 
> UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLib
> Null.inf
> 
>UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
> 
>UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
> 
> +  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> 
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
> 
>UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
> 
>UefiCpuPkg/SecCore/SecCore.inf
> 
> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> new file mode 100644
> index ..d8770a21c355
> --- /dev/null
> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
> @@ -0,0 +1,27 @@
> +## @file
> 
> +#  VMGEXIT Support Library.
> 
> +#
> 
> +#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
> 
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +#
> 
> +##
> 
> +
> 
> +[Defines]
> 
> +  INF_VERSION= 0x00010005
> 
> +  BASE_NAME  = VmgExitLibNull
> 
> +  MODULE_UNI_FILE= VmgExitLibNull.uni
> 
> +  FILE_GUID  = 3cd7368f-ef9b-4a9b-9571-2ed93813677e
> 
> +  MODULE_TYPE= BASE
> 
> +  VERSION_STRING = 1.0
> 
> +  LIBRARY_CLASS  = VmgExitLib
> 
> +
> 
> +[Sources.common]
> 
> +  VmgExitLibNull.c
> 
> +
> 
> +[Packages]
> 
> +  MdePkg/MdePkg.dec
> 
> +  UefiCpuPkg/UefiCpuPkg.dec
> 
> +
> 
> +[LibraryClasses]
> 
> +  BaseLib
> 
> +
> 
> diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h
> b/UefiCpuPkg/Include/Library/VmgExitLib.h
> new file mode 100644
> index ..0b2f39026a4a
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Library/VmgExitLib.h
> @@ -0,0 +1,103 @@
> +/** @file
> 
> +  Public header file for the VMGEXIT Support library class.
> 
> +
> 
> +  This 

[edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT

2020-06-05 Thread Lendacky, Thomas
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198

To support handling #VC exceptions and issuing VMGEXIT instructions,
create a library with functions that can be used to perform these
#VC/VMGEXIT related operations. This includes functions for:
  - Handling #VC exceptions
  - Preparing for and issuing a VMGEXIT
  - Performing MMIO-related write operations to support flash emulation
  - Performing AP related boot opeations

The base functions in this driver will not do anything and will return
an error if a return value is required. It is expected that other packages
(like OvmfPkg) will create a version of the library to fully support an
SEV-ES guest.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Signed-off-by: Tom Lendacky 
---
 UefiCpuPkg/UefiCpuPkg.dec|   3 +
 UefiCpuPkg/UefiCpuPkg.dsc|   2 +
 UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf |  27 +
 UefiCpuPkg/Include/Library/VmgExitLib.h  | 103 +
 UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c   | 121 
 UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni |  15 +++
 6 files changed, 271 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index df5d02bae6b4..cb92f34b6f55 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
   ##

   MpInitLib|Include/Library/MpInitLib.h

 

+  ##  @libraryclass  Provides function to support VMGEXIT processing.

+  VmgExitLib|Include/Library/VmgExitLib.h

+

 [Guids]

   gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 
0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}

   gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 0x30, 
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index afa304128221..f0e58b90ff0a 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -56,6 +56,7 @@ [LibraryClasses]
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf

   
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf

   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf

+  VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf

 

 [LibraryClasses.common.SEC]

   PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf

@@ -143,6 +144,7 @@ [Components.IA32, Components.X64]
   UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf

   UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf

   UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf

+  UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf

   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf

   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf

   UefiCpuPkg/SecCore/SecCore.inf

diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf 
b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
new file mode 100644
index ..d8770a21c355
--- /dev/null
+++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
@@ -0,0 +1,27 @@
+## @file

+#  VMGEXIT Support Library.

+#

+#  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+##

+

+[Defines]

+  INF_VERSION= 0x00010005

+  BASE_NAME  = VmgExitLibNull

+  MODULE_UNI_FILE= VmgExitLibNull.uni

+  FILE_GUID  = 3cd7368f-ef9b-4a9b-9571-2ed93813677e

+  MODULE_TYPE= BASE

+  VERSION_STRING = 1.0

+  LIBRARY_CLASS  = VmgExitLib

+

+[Sources.common]

+  VmgExitLibNull.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  UefiCpuPkg/UefiCpuPkg.dec

+

+[LibraryClasses]

+  BaseLib

+

diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h 
b/UefiCpuPkg/Include/Library/VmgExitLib.h
new file mode 100644
index ..0b2f39026a4a
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/VmgExitLib.h
@@ -0,0 +1,103 @@
+/** @file

+  Public header file for the VMGEXIT Support library class.

+

+  This library class defines some routines used when invoking the VMGEXIT

+  instruction in support of SEV-ES and to handle #VC exceptions.

+

+  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef __VMG_EXIT_LIB_H__

+#define __VMG_EXIT_LIB_H__

+

+#include 

+#include 

+

+

+/**

+  Perform VMGEXIT.

+

+  Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and

+  then handles the return actions.

+

+  @param[in, out]  Ghcb   A pointer to the GHCB

+  @param[in]   ExitCode   VMGEXIT code to be assigned to the SwExitCode

+  field of the GHCB.

+  @param[in]