<p>Subrata Banik has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26275">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">arch/x86: Fix cpu_index wrong issue with STACK_SIZE=16K<br><br>As per c_start.S implementation logic, struct cpu_info pointer<br>will be present at 8 bytes below stack_top(_estack).<br><br>Getting stack_base and stack_end using checkstack(_estack, 0)<br>function and comparing struct cpu_info *ci pointer address with<br>different STACK_SIZE.<br><br>STACK_SIZE=8K (0x2000)<br><br>stack_base = 0x85ccc000<br>stack_top = 0x85cce000<br><br>(struct cpu_info) ci = 0x85ccdff8<br><br>STACK_SIZE=16K (0x4000)<br><br>stack_base = 0x85cca000<br>stack_top = 0x85cce000<br><br>(struct cpu_info) ci = 0x85ccfff8<br><br>Due to wrong alignment issue, cpu_index variable is getting random/wrong<br>value.<br><br>BUG=b:79562868<br>TEST=Verify cpu_index is returning correct cpu_index of BSP and AP<br>with different STACK_SIZE 4K/8K/16K/32K on KBL and CNL platform.<br><br>Change-Id: I3ef0590b50ceca36c25198beb6775ae51da6420b<br>Signed-off-by: Subrata Banik <subrata.banik@intel.com><br>---<br>M src/Kconfig<br>M src/arch/x86/c_start.S<br>M src/arch/x86/include/arch/cpu.h<br>3 files changed, 8 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/26275/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/Kconfig b/src/Kconfig</span><br><span>index 99a704d..73e6fcd 100644</span><br><span>--- a/src/Kconfig</span><br><span>+++ b/src/Kconfig</span><br><span>@@ -395,6 +395,11 @@</span><br><span>     default 0x1000 if ARCH_X86</span><br><span>   default 0x0</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+config STACK_ALIGNMENT_SIZE</span><br><span style="color: hsl(120, 100%, 40%);">+  hex</span><br><span style="color: hsl(120, 100%, 40%);">+   default 0x1000 if ARCH_X86</span><br><span style="color: hsl(120, 100%, 40%);">+    default 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> config MAX_CPUS</span><br><span>     int</span><br><span>  default 1</span><br><span>diff --git a/src/arch/x86/c_start.S b/src/arch/x86/c_start.S</span><br><span>index 6426ef3..b9573ba 100644</span><br><span>--- a/src/arch/x86/c_start.S</span><br><span>+++ b/src/arch/x86/c_start.S</span><br><span>@@ -19,7 +19,7 @@</span><br><span> .global _stack</span><br><span> .global _estack</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-.align CONFIG_STACK_SIZE</span><br><span style="color: hsl(120, 100%, 40%);">+.align CONFIG_STACK_ALIGNMENT_SIZE</span><br><span> _stack:</span><br><span> .space CONFIG_MAX_CPUS*CONFIG_STACK_SIZE</span><br><span> _estack:</span><br><span>diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h</span><br><span>index 5d44aae..7d0f182 100644</span><br><span>--- a/src/arch/x86/include/arch/cpu.h</span><br><span>+++ b/src/arch/x86/include/arch/cpu.h</span><br><span>@@ -206,8 +206,8 @@</span><br><span>            "orl  %2, %0 "</span><br><span> #endif</span><br><span>           : "=r" (ci)</span><br><span style="color: hsl(0, 100%, 40%);">-           : "0" (~(CONFIG_STACK_SIZE - 1)),</span><br><span style="color: hsl(0, 100%, 40%);">-             "r" (CONFIG_STACK_SIZE - sizeof(struct cpu_info))</span><br><span style="color: hsl(120, 100%, 40%);">+           : "0" (~(CONFIG_STACK_ALIGNMENT_SIZE - 1)),</span><br><span style="color: hsl(120, 100%, 40%);">+         "r" (CONFIG_STACK_ALIGNMENT_SIZE - sizeof(struct cpu_info))</span><br><span>        );</span><br><span>   return ci;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26275">change 26275</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26275"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3ef0590b50ceca36c25198beb6775ae51da6420b </div>
<div style="display:none"> Gerrit-Change-Number: 26275 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Subrata Banik <subrata.banik@intel.com> </div>