]> git.proxmox.com Git - mirror_edk2.git/commitdiff
QuarkSocPkg/QncSmmDispatcher: Fix context passed to SMI handlers
authorMichael Kinney <michael.d.kinney@intel.com>
Wed, 5 Oct 2016 03:03:24 +0000 (20:03 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Fri, 7 Oct 2016 21:56:29 +0000 (14:56 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=136

1) Add CallbackContext field to the DATABASE_RECORD structure that
   is set to the RegisterContent value passed to QNCSmmCoreRegister().
   This is the content that must be passed to the SMI handler when
   its source is triggered.

2) Update usage of ChildContext field in the DATABASE_RECOD to use
   CopyMem() instead of structure assignments to avoid compiler
   use of memcpy() intrinsics

This issue was reproduced using the unit test at:

https://github.com/mdkinney/edk2/tree/Bug51/Reproduce

An ASSERT() is generated the first time the periodic SMI
handler is triggered.  After applying this patch, the
DEBUG() messages from the periodic SMI handler in this
unit test are generated.

Cc: Kelly Steele <kelly.steele@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Kelly Steele <kelly.steele@intel.com>
QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c
QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h
QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c

index 1d1030c0ae42d1dcf9215920bbc1e52726d96ed2..670ca91c5c95a67bdefa39f100e271609c2221fe 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 File to contain all the hardware specific stuff for the Periodical Timer dispatch protocol.\r
 \r
-Copyright (c) 2013-2015 Intel Corporation.\r
+Copyright (c) 2013-2016 Intel Corporation.\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -177,7 +177,7 @@ PeriodicTimerGetContext (
     // Update the elapsed time w/ the data from our tables\r
     //\r
     Record->CommBuffer.PeriodicTimer.ElapsedTime += TimerInterval->Interval;\r
-    *HwContext = Record->ChildContext;\r
+    CopyMem (HwContext, &Record->ChildContext, sizeof (QNC_SMM_CONTEXT));\r
   }\r
 }\r
 \r
index 892294fa71f5d062e8f01a7b4c2654cfa2eb7a15..797be16f79cd35bbad6ca269a82ceca795bacbc6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Prototypes and defines for the QNC SMM Dispatcher.\r
 \r
-Copyright (c) 2013-2015 Intel Corporation.\r
+Copyright (c) 2013-2016 Intel Corporation.\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -396,8 +396,9 @@ struct _DATABASE_RECORD {
   // Callback function\r
   //\r
   EFI_SMM_HANDLER_ENTRY_POINT2      Callback;\r
-  QNC_SMM_CONTEXT       ChildContext;\r
-  QNC_SMM_BUFFER                     CommBuffer;\r
+  QNC_SMM_CONTEXT                   ChildContext;\r
+  VOID                              *CallbackContext;\r
+  QNC_SMM_BUFFER                    CommBuffer;\r
   UINTN                             BufferSize;\r
 \r
   //\r
index ba8c72177361af77cc9c08ac11c503109ef853c6..47834064ffc121f9e86499792981fbd47904db9a 100644 (file)
@@ -2,7 +2,7 @@
 This driver is responsible for the registration of child drivers\r
 and the abstraction of the QNC SMI sources.\r
 \r
-Copyright (c) 2013-2015 Intel Corporation.\r
+Copyright (c) 2013-2016 Intel Corporation.\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -351,7 +351,8 @@ Returns:
   // Gather information about the registration request\r
   //\r
   Record->Callback          = DispatchFunction;\r
-  Record->ChildContext      = *RegisterContext;\r
+  Record->CallbackContext   = RegisterContext;\r
+  CopyMem (&Record->ChildContext, RegisterContext, sizeof (QNC_SMM_CONTEXT));\r
 \r
   Qualified                 = QUALIFIED_PROTOCOL_FROM_GENERIC (This);\r
 \r
@@ -407,7 +408,7 @@ Returns:
       //\r
       // Update ChildContext again as SwSmiInputValue has been changed\r
       //\r
-      Record->ChildContext = *RegisterContext;\r
+      CopyMem (&Record->ChildContext, RegisterContext, sizeof (QNC_SMM_CONTEXT));\r
     }\r
 \r
     //\r
@@ -688,7 +689,6 @@ QNCSmmCoreDispatcher (
                 // it supplied in registration.  Simply pass back what it gave us.\r
                 //\r
                 ASSERT (RecordToExhaust->Callback != NULL);\r
-                Context       = RecordToExhaust->ChildContext;\r
                 ContextsMatch = TRUE;\r
               }\r
 \r
@@ -710,7 +710,7 @@ QNCSmmCoreDispatcher (
 \r
                 RecordToExhaust->Callback (\r
                                    (EFI_HANDLE) & RecordToExhaust->Link,\r
-                                   &Context,\r
+                                   RecordToExhaust->CallbackContext,\r
                                    CommunicationBuffer,\r
                                    &BufferSize\r
                                    );\r