From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1298B1A1EE3 for ; Wed, 5 Oct 2016 11:28:56 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 05 Oct 2016 11:28:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,302,1473145200"; d="scan'208";a="1060913931" Received: from mdkinney-mobl.amr.corp.intel.com ([10.232.96.21]) by orsmga002.jf.intel.com with ESMTP; 05 Oct 2016 11:28:55 -0700 From: Michael Kinney To: edk2-devel@lists.01.org Date: Wed, 5 Oct 2016 11:28:49 -0700 Message-Id: <1475692130-20756-2-git-send-email-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1475692130-20756-1-git-send-email-michael.d.kinney@intel.com> References: <1475692130-20756-1-git-send-email-michael.d.kinney@intel.com> Subject: [Patch 1/2] QuarkSocPkg/QncSmmDispatcher: Fix context passed to SMI handlers X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 18:28:56 -0000 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney --- .../Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c | 4 ++-- .../QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h | 7 ++++--- .../QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c index 1d1030c..670ca91 100644 --- a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c +++ b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmPeriodicTimer.c @@ -1,7 +1,7 @@ /** @file File to contain all the hardware specific stuff for the Periodical Timer dispatch protocol. -Copyright (c) 2013-2015 Intel Corporation. +Copyright (c) 2013-2016 Intel Corporation. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -177,7 +177,7 @@ PeriodicTimerGetContext ( // Update the elapsed time w/ the data from our tables // Record->CommBuffer.PeriodicTimer.ElapsedTime += TimerInterval->Interval; - *HwContext = Record->ChildContext; + CopyMem (HwContext, &Record->ChildContext, sizeof (QNC_SMM_CONTEXT)); } } diff --git a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h index 892294f..797be16 100644 --- a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h +++ b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmm.h @@ -1,7 +1,7 @@ /** @file Prototypes and defines for the QNC SMM Dispatcher. -Copyright (c) 2013-2015 Intel Corporation. +Copyright (c) 2013-2016 Intel Corporation. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -396,8 +396,9 @@ struct _DATABASE_RECORD { // Callback function // EFI_SMM_HANDLER_ENTRY_POINT2 Callback; - QNC_SMM_CONTEXT ChildContext; - QNC_SMM_BUFFER CommBuffer; + QNC_SMM_CONTEXT ChildContext; + VOID *CallbackContext; + QNC_SMM_BUFFER CommBuffer; UINTN BufferSize; // diff --git a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c index ba8c721..4783406 100644 --- a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c +++ b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c @@ -2,7 +2,7 @@ This driver is responsible for the registration of child drivers and the abstraction of the QNC SMI sources. -Copyright (c) 2013-2015 Intel Corporation. +Copyright (c) 2013-2016 Intel Corporation. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -351,7 +351,8 @@ Returns: // Gather information about the registration request // Record->Callback = DispatchFunction; - Record->ChildContext = *RegisterContext; + Record->CallbackContext = RegisterContext; + CopyMem (&Record->ChildContext, RegisterContext, sizeof (QNC_SMM_CONTEXT)); Qualified = QUALIFIED_PROTOCOL_FROM_GENERIC (This); @@ -407,7 +408,7 @@ Returns: // // Update ChildContext again as SwSmiInputValue has been changed // - Record->ChildContext = *RegisterContext; + CopyMem (&Record->ChildContext, RegisterContext, sizeof (QNC_SMM_CONTEXT)); } // @@ -688,7 +689,6 @@ QNCSmmCoreDispatcher ( // it supplied in registration. Simply pass back what it gave us. // ASSERT (RecordToExhaust->Callback != NULL); - Context = RecordToExhaust->ChildContext; ContextsMatch = TRUE; } @@ -710,7 +710,7 @@ QNCSmmCoreDispatcher ( RecordToExhaust->Callback ( (EFI_HANDLE) & RecordToExhaust->Link, - &Context, + RecordToExhaust->CallbackContext, CommunicationBuffer, &BufferSize ); -- 2.6.3.windows.1