From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=Kh4g19h1; spf=pass (domain: apple.com, ip: 17.151.62.66, mailfrom: afish@apple.com) Received: from nwk-aaemail-lapp01.apple.com (nwk-aaemail-lapp01.apple.com [17.151.62.66]) by groups.io with SMTP; Sun, 11 Aug 2019 16:57:55 -0700 Received: from pps.filterd (nwk-aaemail-lapp01.apple.com [127.0.0.1]) by nwk-aaemail-lapp01.apple.com (8.16.0.27/8.16.0.27) with SMTP id x7BNv8tM017484 for ; Sun, 11 Aug 2019 16:57:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=sender : from : content-type : mime-version : subject : message-id : date : to; s=20180706; bh=3dsW45PlzTxb3EVcHSerD8tWClE8UPZBiSsnX2pKoL8=; b=Kh4g19h1XfoFhWj4fsdB453QMjL1z8vqOPLciTs9JSoCrdhTz2RMZ3wB8l4TkDib91ux rsnrM13aPdTtgB5/PH49O0Y5tDjfBEMqCFl3mcwD5QqZR0VJ9yWICfYSoXKDNdL85hS4 Ryypbrqxfx3A8yymEdFcQ1oi07ieeqQ+MaNm1RrDK3S2/v+TiW45qeI8d8pNObsINK9A i/5t42CDcxySDZKQrREjvxjzZ1h0gXxHk5DK3NNRzL8LJSxZ1CCBxzjUALpsyu6OHuoI UU2spzqh/FlrO32uixGKqAnBsyOL43q5wfiB4Dchqlsx281/tNKkzKCdfImdMcp8M7mo Lw== Received: from ma1-mtap-s03.corp.apple.com (ma1-mtap-s03.corp.apple.com [17.40.76.7]) by nwk-aaemail-lapp01.apple.com with ESMTP id 2u9vv00tqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Sun, 11 Aug 2019 16:57:53 -0700 Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by ma1-mtap-s03.corp.apple.com (Oracle Communications Messaging Server 8.0.2.4.20190507 64bit (built May 7 2019)) with ESMTPS id <0PW300IA8JWFOZ80@ma1-mtap-s03.corp.apple.com> for devel@edk2.groups.io; Sun, 11 Aug 2019 16:57:52 -0700 (PDT) Received: from process_milters-daemon.nwk-mmpp-sz13.apple.com by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.4.20190507 64bit (built May 7 2019)) id <0PW300400J5ED800@nwk-mmpp-sz13.apple.com> for devel@edk2.groups.io; Sun, 11 Aug 2019 16:57:51 -0700 (PDT) X-Va-A: X-Va-T-CD: af33feddfb7fcbdf4ba2524fa1b83a2c X-Va-E-CD: c8473f97292c1bb40b7288ad3a2f7f73 X-Va-R-CD: 55e0602a123750aaa2d5ad69e28ce984 X-Va-CD: 0 X-Va-ID: 9cbfd80a-7229-4a91-b77e-6175f78f93ca X-V-A: X-V-T-CD: af33feddfb7fcbdf4ba2524fa1b83a2c X-V-E-CD: c8473f97292c1bb40b7288ad3a2f7f73 X-V-R-CD: 55e0602a123750aaa2d5ad69e28ce984 X-V-CD: 0 X-V-ID: 2ecd97d2-9f48-436f-b8cd-abef0f078926 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-11_12:,, signatures=0 Received: from [17.235.50.16] (unknown [17.235.50.16]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.4.20190507 64bit (built May 7 2019)) with ESMTPSA id <0PW300HJ5JWEBH70@nwk-mmpp-sz13.apple.com> for devel@edk2.groups.io; Sun, 11 Aug 2019 16:57:51 -0700 (PDT) Sender: afish@apple.com From: "Andrew Fish" MIME-version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate definition confusion? Message-id: Date: Sun, 11 Aug 2019 16:57:49 -0700 To: "devel@edk2.groups.io" X-Mailer: Apple Mail (2.3445.104.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-11_12:,, signatures=0 Content-type: multipart/alternative; boundary="Apple-Mail=_181D40B8-C006-4707-A977-871A8369AC30" --Apple-Mail=_181D40B8-C006-4707-A977-871A8369AC30 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I was tracking down a Platform C state bug and I noticed the platform = code was using this definition [1] for PcdCpuApTargetCstate and wrote = that actual value used for Mwait. But the MpInitLIb seems to assume that = PcdCpuApTargetCstate is eax[7:4] and it shifts the data left. This ends = up with the value being 0 which means C1 for all calculated values.=20 So my question is which definition is correct? As far as I can tell = eax[3:0] are sub C states and thus being able to pass that value would = be useful?=20 There is other code in the MpLib [3] that is also doing the shift so it = seems intestinal. But given the PCD definition I can see how the = platform code set the wrong value.=20 [1] PCD Definition https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/UefiCpuPkg.dec = ## Specifies the AP target C-state for Mwait during POST phase. # The default value 0 means C1 state. # The value is defined as below.

# @Prompt The specified AP target C-state for Mwait. gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate|0|UINT8|0x00000007 [2] UefiCpuPkg code = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib= /X64/MpFuncs.nasm = MwaitLoop: cli mov eax, esp ; Set Monitor Address xor ecx, ecx ; ecx =3D 0 xor edx, edx ; edx =3D 0 monitor mov eax, ebx ; Mwait Cx, Target C-State per = eax[7:4] shl eax, 4 mwait jmp MwaitLoop = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib= /DxeMpLib.c = AsmRelocateApLoopFunc ( MwaitSupport, CpuMpData->ApTargetCState, CpuMpData->PmCodeSegment, mReservedTopOfApStack - ProcessorNumber * AP_SAFE_STACK_SIZE, (UINTN) &mNumberToFinish ); [3] ApTargetCState shifting = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib= /MpLib.c = // // Check AP start-up signal again. // If AP start-up signal is not set, place AP into // the specified C-state // AsmMwait (CpuMpData->ApTargetCState << 4, 0); Thanks, Andrew Fish= --Apple-Mail=_181D40B8-C006-4707-A977-871A8369AC30 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
I = was tracking down a Platform C state bug and I noticed the platform code = was using this definition [1] for PcdCpuApTargetCstate and wrote = that actual value used for Mwait. But the MpInitLIb seems to assume that = PcdCpuApTargetCstate is eax[7:4] and it shifts the data left. This = ends up with the value being 0 which means C1 for all calculated = values. 

So my question = is which definition is correct? As far as I can tell eax[3:0] are = sub C states and thus being able to pass that value would be = useful? 

There is other = code in the MpLib [3] that is also doing the shift so it seems = intestinal. But given the PCD definition I can see how the platform code = set the wrong value. 

[1] PCD = Definition

## = Specifies the AP target C-state for Mwait during POST phase.
# The = default value 0 means C1 state.
# The = value is defined as below.<BR><BR>
# = @Prompt The specified AP target C-state for Mwait.
= gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate|0|UINT8|0x00000007

[2] UefiCpuPkg = code
MwaitLoop:
cli
mov eax, esp ; Set Monitor = Address
xor ecx, ecx ; ecx =3D 0
xor = edx, edx ; edx =3D 0
monitor
mov = eax, ebx ; Mwait Cx, Target C-State per = eax[7:4]
shl eax, 4
mwait
jmp = MwaitLoop


AsmRelocateApLoopFunc (
= MwaitSupport,
CpuMpData->ApTargetCState,
= CpuMpData->PmCodeSegment,
= mReservedTopOfApStack - ProcessorNumber * = AP_SAFE_STACK_SIZE,
(UINTN) &mNumberToFinish
= );
[3] ApTargetCState shifting
= //
// Check AP start-up signal = again.
// If AP start-up signal is not = set, place AP into
// the specified = C-state
//
= AsmMwait (CpuMpData->ApTargetCState << 4, 0);

Thanks,

Andrew = Fish
= --Apple-Mail=_181D40B8-C006-4707-A977-871A8369AC30--