From nobody Sun Apr 28 22:29:12 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+47484+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+47484+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568821411; cv=none; d=zoho.com; s=zohoarc; b=D5TL/9wcDAO19jIA9QkAGS+LYJBQqm2fyzH1Rg0qdqaNkUVkS3uOPDJl3i6eztp0iBA+xJO3kOMhAGVbeQX4v9yKR/g1M+OIg+GjszVdy7S9qqHW9Nmt87BHH5TrDif85XEgQFhorULdwgsAfbZA+bV/OgkR+e1D/tgOrkDzrQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568821411; h=Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=rt0xF9x/jT5I8MclOf91CtgAXC/sbYd94ZvLv/Z0lKY=; b=FX5el1nrr47tAlyThmrtMzTlqUw9jUwFPWWzwib84QSbrzzJ2dpN/evcULuqsNb4I1mL/2O7xtNcWevTHJYKyJosntdhAWw3ZSh2pC9Ym0OmKjVNAtfVYyTEBkVdKn6lEyrbmLxT9mtr8uEEqmnxJ3uInZFkiut7nF0+xtTnJ4Y= 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+47484+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 156882141167672.1822060213998; Wed, 18 Sep 2019 08:43:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7vA5YY1788612xbbCvodjaD5; Wed, 18 Sep 2019 08:43:30 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 18 Sep 2019 08:43:30 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2019 08:43:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,521,1559545200"; d="scan'208";a="186499990" X-Received: from jelofgre-desk.amr.corp.intel.com ([10.78.26.249]) by fmsmga008.fm.intel.com with ESMTP; 18 Sep 2019 08:43:29 -0700 From: "John E Lofgren" To: devel@edk2.groups.io Subject: [edk2-devel] [Patch V3] UefiCpuPkg/CpuExceptionHandlerLib: Fix split lock Date: Wed, 18 Sep 2019 08:43:23 -0700 Message-Id: <20190918154323.20804-1-john.e.lofgren@intel.com> 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 X-Gm-Message-State: SMeq4mjQ3ekmSyIdziGPcX6Yx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568821410; bh=m2hhEuEWfdIsUJ+/t03vNld+ifnJbWZumGdpg0IIMBQ=; h=Date:From:Reply-To:Subject:To; b=IildPmRraarWjlBvEq5j7vFgfMtE/3ujeRu5sHkpEsNnAqDND7UJrs/wVxEpt/LaGhe P2QfBuCLpIQRS0VYpFC9poCPyEq1KeLkH99nvrgyj9Jm/3a3rpOhal52ED1K1lhbZKu9U PJ7CRFOAQRh3Oyo8hzxRsJr2lQ4ZRpc/cw8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2150 V3 changes: change to mov instruction (non locking instuction) instead of xchg to simplify design. 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 Split lock happens when a locking instruction is used on mis-aligned data that crosses two cachelines. If close source platform enables Alignment Che= ck Exception(#AC), They can hit a double fault due to split lock being in CpuExceptionHandlerLib. sigt and sgdt saves 10 bytes to memory, 8 bytes is base and 2 bytes is limi= t. The data is mis-aligned, can cross two cacheline, and a xchg instruction(locking instuction) is being utilize. Signed-off-by: John E Lofgren Reviewed-by: Eric Dong Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 1= 4 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandler= Asm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAs= m.nasm index 4db1a09f28..19198f2731 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm @@ -184,17 +184,19 @@ HasErrorCode: push rax push rax sidt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] + mov bx, word [rsp] + mov rax, qword [rsp + 2] + mov qword [rsp], rax + mov word [rsp + 8], bx =20 xor rax, rax push rax push rax sgdt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] + mov bx, word [rsp] + mov rax, qword [rsp + 2] + mov qword [rsp], rax + mov word [rsp + 8], bx =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 (#47484): https://edk2.groups.io/g/devel/message/47484 Mute This Topic: https://groups.io/mt/34181976/1787277 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-