Index: AcpiPlatform/AcpiPlatform.c
===================================================================
--- AcpiPlatform/AcpiPlatform.c	(revision 17583)
+++ AcpiPlatform/AcpiPlatform.c	(working copy)
@@ -697,7 +697,18 @@
                   &VariableSize,
                   &SetupVarBuffer
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VariableSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &mSystemConfigurationGuid,
+              NULL,
+              &VariableSize,
+              &SetupVarBuffer
+              );
+    ASSERT_EFI_ERROR (Status);
+  }    
 
   //
   // Find the AcpiSupport protocol.
@@ -817,7 +828,18 @@
                   &VarSize,
                   &mSystemConfiguration
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &mSystemConfigurationGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
 
   //
   // Find the AcpiSupport protocol.
@@ -842,7 +864,20 @@
                   &SysCfgSize,
                   &mSystemConfig
                   );
+  if (EFI_ERROR (Status) || SysCfgSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    SysCfgSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &SysCfgSize,
+              &mSystemConfig
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
 
+
   Status    = EFI_SUCCESS;
   Instance  = 0;
 
Index: Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
===================================================================
--- Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c	(revision 17583)
+++ Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c	(working copy)
@@ -355,7 +355,18 @@
                                    NULL,
                                    &VariableSize,
                                    &SystemConfiguration);
-
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VariableSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = Variable->GetVariable(Variable,
+              L"SetupRecovery",
+              &gEfiSetupVariableGuid,
+              NULL,
+              &VariableSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
   if(!EFI_ERROR (Status)){
     EnableSpreadSpectrum = SystemConfiguration.EnableClockSpreadSpec;
   }
Index: Library/PlatformBdsLib/BdsPlatform.c
===================================================================
--- Library/PlatformBdsLib/BdsPlatform.c	(revision 17583)
+++ Library/PlatformBdsLib/BdsPlatform.c	(working copy)
@@ -331,7 +331,18 @@
                   &VarSize,
                   &mSystemConfiguration
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }    
 
   if(mSystemConfiguration.BootDisplayDevice != 0x0)
   {
@@ -633,7 +644,18 @@
                   &VarSize,
                   &mSystemConfiguration
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }    
 
 
   if ((PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath != NULL) ) {
@@ -689,7 +711,18 @@
                   &VarSize,
                   &SystemConfiguration
                   );
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
 
   switch (SystemConfiguration.IgdFlatPanel) {
 
@@ -1593,10 +1626,20 @@
                   &VarSize,
                   &SystemConfiguration
                   );
-  if (EFI_ERROR (Status)) {
-    return;
-  }
 
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
+
   //
   // Load the driver option as the driver option list
   //
Index: PciPlatform/PciPlatform.c
===================================================================
--- PciPlatform/PciPlatform.c	(revision 17583)
+++ PciPlatform/PciPlatform.c	(working copy)
@@ -352,7 +352,18 @@
                   &VarSize,
                   &mSystemConfiguration
                   );
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
 
   //
   // Install on a new handle
Index: PlatformDxe/ExI.c
===================================================================
--- PlatformDxe/ExI.c	(revision 17583)
+++ PlatformDxe/ExI.c	(working copy)
@@ -82,7 +82,18 @@
                   &SystemConfiguration
                   );
 
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
 
   if (SystemConfiguration.ExISupport == 1) {
 	  MmioOr32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), (UINT32) BIT0+BIT1+BIT2);
Index: PlatformDxe/Platform.c
===================================================================
--- PlatformDxe/Platform.c	(revision 17583)
+++ PlatformDxe/Platform.c	(working copy)
@@ -49,7 +49,9 @@
 #include <Protocol/GlobalNvsArea.h>
 #include <Protocol/IgdOpRegion.h>
 #include <Library/PcdLib.h>
+#include <Protocol/VariableLock.h>
 
+
 //
 // VLV2 GPIO GROUP OFFSET
 //
@@ -200,6 +202,82 @@
   );
 
 
+EFI_STATUS
+EFIAPI
+SaveSetupRecoveryVar(
+  VOID
+  )
+{
+  EFI_STATUS                   Status = EFI_SUCCESS;
+  UINTN                        SizeOfNvStore = 0;
+  UINTN                        SizeOfSetupVar = 0;
+  SYSTEM_CONFIGURATION         *SetupData = NULL;
+  SYSTEM_CONFIGURATION         *RecoveryNvData = NULL;
+  EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock = NULL;
+
+
+  DEBUG ((EFI_D_INFO, "SaveSetupRecoveryVar() Entry \n"));
+  SizeOfNvStore = sizeof(SYSTEM_CONFIGURATION);
+  RecoveryNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));
+  if (NULL == RecoveryNvData) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Exit; 
+  }
+  
+  Status = gRT->GetVariable(
+                L"SetupRecovery",
+                &gEfiNormalSetupGuid,
+                NULL,
+                &SizeOfNvStore,
+                RecoveryNvData
+                );
+  
+  if (EFI_ERROR (Status)) {
+    // Don't find the "SetupRecovery" variable.
+    // have to copy "Setup" variable to "SetupRecovery" variable.
+    SetupData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));
+    if (NULL == SetupData) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto Exit;      
+    }
+    SizeOfSetupVar = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+                    NORMAL_SETUP_NAME,
+                    &gEfiNormalSetupGuid,
+                    NULL,
+                    &SizeOfSetupVar,
+                    SetupData
+                    );
+    ASSERT_EFI_ERROR (Status);
+    
+    Status = gRT->SetVariable (
+                    L"SetupRecovery",
+                    &gEfiNormalSetupGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof(SYSTEM_CONFIGURATION),
+                    SetupData
+                    );
+    ASSERT_EFI_ERROR (Status);
+
+    Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
+      if (!EFI_ERROR (Status)) {
+        Status = VariableLock->RequestToLock (VariableLock, L"SetupRecovery", &gEfiNormalSetupGuid);
+        ASSERT_EFI_ERROR (Status);
+    }
+    
+  }
+
+Exit:
+  if (RecoveryNvData)
+    FreePool (RecoveryNvData);
+  if (SetupData)
+    FreePool (SetupData);
+  
+  return Status;
+    
+}
+
+
 VOID
 TristateLpcGpioConfig (
   IN UINT32             Gpio_Mmio_Offset,
@@ -662,6 +740,10 @@
   //
   InitializeObservableProtocol();
 
+  Status = SaveSetupRecoveryVar();
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "InitializePlatform() Save SetupRecovery variable failed \n"));
+  }
 
   VarSize = sizeof(SYSTEM_CONFIGURATION);
   Status = gRT->GetVariable(
@@ -671,8 +753,26 @@
                   &VarSize,
                   &mSystemConfiguration
                   );
-
-
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+    Status = gRT->SetVariable (
+                    NORMAL_SETUP_NAME,
+                    &gEfiNormalSetupGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof(SYSTEM_CONFIGURATION),
+                    &mSystemConfiguration
+                    );    
+  }
+    
   Status = EfiCreateEventReadyToBootEx (
              TPL_CALLBACK,
              ReadyToBootFunction,
@@ -1545,6 +1645,19 @@
                   &SystemConfiguration
                   );
 
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
+
   if((SystemConfiguration.GraphicsDriverMemorySize < 4) && !EFI_ERROR(Status) ) {
     switch (SystemConfiguration.GraphicsDriverMemorySize){
       case 1:
Index: PlatformDxe/PlatformDxe.inf
===================================================================
--- PlatformDxe/PlatformDxe.inf	(revision 17583)
+++ PlatformDxe/PlatformDxe.inf	(working copy)
@@ -127,6 +127,7 @@
   gEfiCpuIo2ProtocolGuid
   gIgdOpRegionProtocolGuid
   gExitPmAuthProtocolGuid
+  gEdkiiVariableLockProtocolGuid
 
 [Pcd.common]
   gPlatformModuleTokenSpaceGuid.PcdPBTNDisableInterval
Index: PlatformGopPolicy/PlatformGopPolicy.c
===================================================================
--- PlatformGopPolicy/PlatformGopPolicy.c	(revision 17583)
+++ PlatformGopPolicy/PlatformGopPolicy.c	(working copy)
@@ -190,7 +190,19 @@
                   &VarSize,
                   &SystemConfiguration
                   );
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
+  
   if (SystemConfiguration.GOPEnable == 1)
   {
   Status = gBS->InstallMultipleProtocolInterfaces (
Index: PlatformInfoDxe/PlatformInfoDxe.c
===================================================================
--- PlatformInfoDxe/PlatformInfoDxe.c	(revision 17583)
+++ PlatformInfoDxe/PlatformInfoDxe.c	(working copy)
@@ -71,6 +71,19 @@
                   &VarSize,
                   &SystemConfiguration
                   );
+  
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }    
 
   VarSize = sizeof(Selection);
   Status = gRT->GetVariable(
Index: PlatformInitPei/BootMode.c
===================================================================
--- PlatformInitPei/BootMode.c	(revision 17583)
+++ PlatformInitPei/BootMode.c	(working copy)
@@ -211,6 +211,19 @@
                            &VarSize,
                            &SystemConfiguration
                            );
+      if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+        //The setup variable is corrupted
+        VarSize = sizeof(SYSTEM_CONFIGURATION);
+        Status = Variable->GetVariable(
+                  Variable,
+                  L"SetupRecovery",
+                  &gEfiSetupVariableGuid,
+                  NULL,
+                  &VarSize,
+                  &SystemConfiguration
+                  );
+        ASSERT_EFI_ERROR (Status);
+      }      
 
       if (SystemConfiguration.FastBoot == 1) {
             BootMode = BOOT_WITH_MINIMAL_CONFIGURATION;
Index: PlatformInitPei/PlatformEarlyInit.c
===================================================================
--- PlatformInitPei/PlatformEarlyInit.c	(revision 17583)
+++ PlatformInitPei/PlatformEarlyInit.c	(working copy)
@@ -205,7 +205,19 @@
                        &VariableSize,
                        SystemConfiguration
                        );
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VariableSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = Variable->GetVariable(
+              Variable,
+              L"SetupRecovery",
+              &gEfiSetupVariableGuid,
+              NULL,
+              &VariableSize,
+              SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
   return Status;
 }
 
Index: PlatformPei/Platform.c
===================================================================
--- PlatformPei/Platform.c	(revision 17583)
+++ PlatformPei/Platform.c	(working copy)
@@ -725,7 +725,20 @@
                        &VariableSize,
                        &SystemConfiguration
 					   );
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VariableSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = Variable->GetVariable(
+              Variable,
+              L"SetupRecovery",
+              &gEfiSetupVariableGuid,
+              NULL,
+              &VariableSize,
+              &SystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
+  
   if (EFI_ERROR (Status)) {
     GGC = ((2 << 3) | 0x200);
     PciCfg16Write(EC_BASE, 0, 2, 0, 0x50, GGC);
Index: PlatformSetupDxe/SetupInfoRecords.c
===================================================================
--- PlatformSetupDxe/SetupInfoRecords.c	(revision 17583)
+++ PlatformSetupDxe/SetupInfoRecords.c	(working copy)
@@ -1759,7 +1759,18 @@
                   &mSystemConfiguration
 				  );
 
-  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = gRT->GetVariable(
+              L"SetupRecovery",
+              &gEfiNormalSetupGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
 
   //
   // Update HOB variable for PCI resource information
Index: PlatformSmm/Platform.c
===================================================================
--- PlatformSmm/Platform.c	(revision 17583)
+++ PlatformSmm/Platform.c	(working copy)
@@ -179,6 +179,18 @@
                           &VarSize,
                           &mSystemConfiguration
                           );
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = SystemTable->RuntimeServices->GetVariable(
+              L"SetupRecovery",
+              &gEfiSetupVariableGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }  
   if (!EFI_ERROR(Status)) {
     mAcLossVariable = mSystemConfiguration.StateAfterG3;
 
@@ -857,7 +869,20 @@
                            &VarSize,
                            &mSystemConfiguration
                            );
-  if (EFI_ERROR(Status) || (!mSystemConfiguration.WakeOnRtcS5)) {
+  if (EFI_ERROR(Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+    //The setup variable is corrupted
+    VarSize = sizeof(SYSTEM_CONFIGURATION);
+    Status = mSmmVariable->SmmGetVariable(
+              L"SetupRecovery",
+              &gEfiSetupVariableGuid,
+              NULL,
+              &VarSize,
+              &mSystemConfiguration
+              );
+    ASSERT_EFI_ERROR (Status);
+  }
+
+  if (!mSystemConfiguration.WakeOnRtcS5) {
     return;
   }
   mWakeupDay = HexToBcd((UINT8)mSystemConfiguration.RTCWakeupDate);
