coreboot-kgpe-d16/src
Zheng Bao abd119d28f AMD IMC AGESA: Access the data in stack by correct length
The bug is hard to find. We were adding the feature of fan control. We
met some strange things which could not be explained. Like, sometimes
adding printk let the error disappear. Then we traced the code by hardware
debug tool (HDT). It turned out the data in stack was overwritten.

The values of AccessWidthxx are
{ AccessWidth8 = 1,
  AccessWidth16,
  AccessWidth32,}
For the case of AccessWidth8, we only need to access the index/data
once. But ReadECmsg and WriteECmsg did the loop twice, 1 more time
than they are supposed to do. The data in stack next to "Value" would
be overwritten.

For all the cases, the code should be
 OpFlag = OpFlag & 0x7f;
 switch (OpFlag) {
    case 1:              /* AccessWidth8 */
         OpFlag = 0;break;
    case 2:              /* AccessWidth16 */
         OpFlag = 1;break;
    case 3:              /* AccessWidth32 */
         OpFlag = 3;break;
    case 4:              /* AccessWidth64 */
         OpFlag = 7;break;
    default:
         error;
 }

Actually, the caller only takes AccessWidth8 as the parameter. We can ignore other
cases for now.

That is an AGESA bug. AMD's AGESA team own this code. They have given the
response that they are going to update this in next release. I presume let them
decide the proper way to fix that. Before that, I change the code as little
as possible to make it run without crash.

Change-Id: I566f74c242ce93f4569eedf69ca07d2fb7fb368d
Signed-off-by: Zheng Bao <zheng.bao@amd.com>
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: http://review.coreboot.org/4297
Reviewed-by: Bruce Griffith <Bruce.Griffith@se-eng.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
2013-12-05 03:52:24 +01:00
..
arch Makefile: Drop obsolete rules 2013-12-02 19:41:53 +01:00
console Drop obsolete CONSOLE_LOGBUF 2013-12-03 02:36:02 +01:00
cpu cpu: Remove BOARD_MICROCODE_CBFS_GENERATE Kconfig option 2013-12-05 03:33:40 +01:00
device Clean up POST codes for Boot State machine 2013-11-26 19:10:38 +01:00
drivers elog: Get rid of the descriptor type and some unnecessary wrappers 2013-12-02 15:18:06 +01:00
ec Introduce a config whether dock is inited in romstage or not 2013-12-02 22:16:18 +01:00
include Add Intel FSP northbridge support Sandybridge and Ivybridge 2013-12-04 18:45:13 +01:00
lib Drop obsolete CONSOLE_LOGBUF 2013-12-03 02:36:02 +01:00
mainboard lenovo/x60: Drop global oprom_is_loaded 2013-12-04 20:14:03 +01:00
northbridge Add Intel FSP northbridge support Sandybridge and Ivybridge 2013-12-04 18:45:13 +01:00
southbridge intel/fsp_bd82x6x: Use correct type pointer for mainboard_smi_gpi 2013-12-05 03:21:08 +01:00
superio sio1007: Properly build '.c' files 2013-11-10 14:19:28 +01:00
vendorcode AMD IMC AGESA: Access the data in stack by correct length 2013-12-05 03:52:24 +01:00
Kconfig Add GRUB2 payload to build system 2013-11-19 01:07:25 +01:00