On 01/31/18 23:11, Kinney, Michael D wrote:
> Laszlo,
> 
> I agree the Unaligned functions have issues.
> We should see if we could change the param type.
> It should be a backwards compatible change to
> go from a type specific pointer to VOID *.  But
> need to check with all supported compilers.
> 
> We can have arch specific functions and macros.
> There are many in BaseLib.h.  This way, if a macro
> or function is used by an unsupported arch, the
> build will fail.  I also like some of the name
> change suggestions.  Maybe PatchInstructionX86()
> and change the parameter name to InstructionEnd.
> 
> BaseLib.h
> ==========
> #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
> 
> VOID
> EFIAPI
> PatchInstructionX86 (
>   VOID    *InstructionEnd,
>   UINT64  PatchValue,
>   UINTN   ValueSize
>   );
> 
> #endif
> 
> BaseLib Instance
> ==========
> VOID
> EFIAPI
> PatchInstructionX86 (
>   VOID    *InstructionEnd,
>   UINT64  PatchValue,
>   UINTN   ValueSize
>   )
> {
>   ASSERT ((UINTN)InstructionEnd > ValueSize);
>   switch (ValueSize) {
>   case 1:
>     ASSERT (PatchValue <= MAX_UINT8);
>     *((UINT8 *)InstructionEnd - 1) = (UINT8)PatchValue;
>   case 2:
>     ASSERT (PatchValue <= MAX_UINT16);
>     WriteUnaligned16 ((UINT16 *)(InstructionEnd) - 1, (UINT16)PatchValue));
>     break;
>   case 4:
>     ASSERT (PatchValue <= MAX_UINT32);
>     WriteUnaligned32 ((UINT32 *)(InstructionEnd) - 1, (UINT32)PatchValue));
>     break;
>   case 8:
>     WriteUnaligned64 ((UINT64 *)(InstructionEnd) - 1, PatchValue));
>     break;
>   default:
>     ASSERT (FALSE);
>   }
> }

I managed to remove all instruction DBs from PiSmmCpuDxeSmm. I plan to
post the patches this week or the next.

Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to