From nobody Sat Apr 20 13:56:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47045+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47045+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568054457; cv=none; d=zoho.com; s=zohoarc; b=Tt3GnnOGUKGEHbB9cEbwWoBLnt/76xm2tQGlSphWxHqsVSF1Iokigsz5PJA/I6adZH3FAldXEEywU4I1FljAJ4wLMbVrUyr5JmZfYEFvPfAFhqVYmJ35PNyzW6j/MTuXq7L6xuOvewl441zcUvn1shOSPd+HuXnuiaOyoWVex5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568054457; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=VmTzJ+Dur3O+bMZQrkDu+0qVi8MQrpaOAAk/QOI8Oxo=; b=fvpVTzrFQc1LuXH+/OItXVt25WbkpmMG9WjfL1onb/0bvwJy0CERz0smiG2Fe58tbCqO9bAidZ7zAkd3E3Y9mnF+xGMZAQBkYoVjTZjAOX2gcFs1J/QEhgKLh0XpW66PzR8QN7UysunTF2Bd9vH2XqUZP5GaKXZjOOLU97kcpAU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47045+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568054457017844.3530477182928; Mon, 9 Sep 2019 11:40:57 -0700 (PDT) Return-Path: X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Mon, 09 Sep 2019 11:40:55 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Sep 2019 11:40:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,486,1559545200"; d="scan'208";a="178435771" X-Received: from jelofgre-desk.amr.corp.intel.com ([10.78.26.249]) by orsmga008.jf.intel.com with ESMTP; 09 Sep 2019 11:40:54 -0700 From: "John E Lofgren" To: devel@edk2.groups.io Subject: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Fix #AC split lock Date: Mon, 9 Sep 2019 11:40:39 -0700 Message-Id: <20190909184039.1648-1-john.e.lofgren@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,john.e.lofgren@intel.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568054456; bh=nthty8bx4f0oanWdRxVWJQ5iguZF+ap7QTcjM8jZoQo=; h=Content-Type:Date:From:Reply-To:Subject:To; b=PaaR3VqvOqRXDzzg44lS8TlPXerClichupKIOqJZJ+/lQMtiZsvRJzJUKOcvC19YoWN 56k4dENgVXc4vxrN1TYI5zpn5CYL1clJj7wKYvIUaYRstPrT0FdAFxRyPE7vfraoGNz/e E8pddlinSobCd1gmfP9IEXHMPcT/LZW3Wwo= X-ZohoMail-DKIM: pass (identity @groups.io) REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2150 V2 changes: Add xchg 16 bit instructions to handle sgdt and sidt base 63:48 bits and 47:32 bits. Add comment to explain why xchg 64bit isnt being used Fix #AC split lock's caused by seperating base and limit from sgdt and sidt by changing xchg operands to 32-bit to stop from crossing cacheline. Signed-off-by: John E Lofgren Reviewed-by: Eric Dong --- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 2= 0 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandler= Asm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAs= m.nasm index 4db1a09f28..7b7642b290 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm @@ -180,21 +180,29 @@ HasErrorCode: push qword [rbp + 24] =20 ;; UINT64 Gdtr[2], Idtr[2]; + ; sidt and sgdt saves 10 bytes to memory, 8 bytes =3D base and 2 bytes= =3D limit. + ; To avoid #AC split lock when separating base and limit into their + ; own separate 64 bit memory, we can=E2=80=99t use 64 bit xchg since b= ase [63:48] bits + ; may cross the cache line. xor rax, rax push rax push rax sidt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] + xchg eax, [rsp + 2] + xchg eax, [rsp] + xchg eax, [rsp + 8] + xchg ax, [rsp + 6] + xchg ax, [rsp + 4] =20 xor rax, rax push rax push rax sgdt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] + xchg eax, [rsp + 2] + xchg eax, [rsp] + xchg eax, [rsp + 8] + xchg ax, [rsp + 6] + xchg ax, [rsp + 4] =20 ;; UINT64 Ldtr, Tr; xor rax, rax --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47045): https://edk2.groups.io/g/devel/message/47045 Mute This Topic: https://groups.io/mt/34083544/1787277 Mute #ac: https://groups.io/mk?hashtag=3Dac&subid=3D3901457 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-