From nobody Mon Feb 9 22:20:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+67846+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+67846+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1606179465; cv=none; d=zohomail.com; s=zohoarc; b=Qd6fXc7g58LLV1xXnmHHapVMGE/zTh4sS6SzWdvrQMcTivZtaz0paNtBtEN7An1hM6B6lBL9g44o9l9EtkQpAyMXK9Uo15WUkwhA8CjaSL5evn8GtqfXtYkI/53cf1CIdAG4vbzb67qriW5++ky/DbaD0C2FfOQsxRfq4NegFgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606179465; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=mGk2Qhm3PnLUCRVvkHu/W8H7yK8oOaf+RZPduAbp/wY=; b=TUWoYY5zb9iszHowXREmtZvmFm7hF85imGR/2lAs5hcz5K5h8IrH1Vdgcj5MRa9l4lH5GnWaslYESPM4JOcy/QX7bbx09fFeYHoj2Lr9WtER1lUnzLa8eLxQKU25LjfKo+LVO74ByiOFkvNeL43FseUPMOslUAJaMCLfT8XkKqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+67846+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1606179465278608.9301567892011; Mon, 23 Nov 2020 16:57:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SKS3YY1788612x280dtkYA9U; Mon, 23 Nov 2020 16:57:44 -0800 X-Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by mx.groups.io with SMTP id smtpd.web10.45352.1606179464523074528 for ; Mon, 23 Nov 2020 16:57:44 -0800 X-Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1khMeN-007APJ-Kg; Mon, 23 Nov 2020 17:57:43 -0700 X-Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1khMeM-003zFX-IV; Mon, 23 Nov 2020 17:57:43 -0700 X-Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id 5B571500667; Mon, 23 Nov 2020 17:57:42 -0700 (MST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com X-Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id M6LGED9HVcLx; Mon, 23 Nov 2020 17:57:42 -0700 (MST) X-Received: from smic.int.bluestop.org (c-174-52-16-57.hsd1.ut.comcast.net [174.52.16.57]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id 95685500668; Mon, 23 Nov 2020 17:57:41 -0700 (MST) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Peter Grehan Date: Mon, 23 Nov 2020 17:57:33 -0700 Message-Id: <20201124005733.18107-4-rebecca@bsdio.com> In-Reply-To: <20201124005733.18107-1-rebecca@bsdio.com> References: <20201124005733.18107-1-rebecca@bsdio.com> MIME-Version: 1.0 X-XM-SPF: eid=1khMeM-003zFX-IV;;;mid=<20201124005733.18107-4-rebecca@bsdio.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=rebecca@bsdio.com;;;spf=none X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: rebecca@bsdio.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMSubLong,XM_B_SpammyWords, XM_B_SpammyWords2 autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; IP=ok Body=1 Fuz1=1] [Fuz2=1] * 0.8 XM_B_SpammyWords2 Two or more commony used spammy words * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.2 XM_B_SpammyWords One or more commonly used spammy words X-Spam-DCC: XMission; sa07 1397; IP=ok Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;devel@edk2.groups.io X-Spam-Relay-Country: X-Spam-Timing: total 590 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 11 (1.8%), b_tie_ro: 9 (1.6%), parse: 1.14 (0.2%), extract_message_metadata: 14 (2.4%), get_uri_detail_list: 2.9 (0.5%), tests_pri_-1000: 14 (2.5%), tests_pri_-950: 1.20 (0.2%), tests_pri_-900: 0.98 (0.2%), tests_pri_-90: 77 (13.0%), check_bayes: 75 (12.7%), b_tokenize: 20 (3.4%), b_tok_get_all: 9 (1.6%), b_comp_prob: 4.4 (0.8%), b_tok_touch_all: 37 (6.2%), b_finish: 0.98 (0.2%), tests_pri_0: 459 (77.8%), check_dkim_signature: 0.95 (0.2%), check_dkim_adsp: 3.0 (0.5%), poll_dns_idle: 0.86 (0.1%), tests_pri_10: 2.1 (0.4%), tests_pri_500: 7 (1.1%), rewrite_mail: 0.00 (0.0%) Subject: [edk2-devel] [PATCH v2 3/3] OvmfPkg/Bhyve: Copy Real16ToFlat32.asm and enable cache in CR0 X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.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,rebecca@bsdio.com X-Gm-Message-State: 0GikJZmmJgdsrz3FFIkaK6PLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1606179464; bh=/LhYQn3KYLlj4vjM7yNy3HrtssEe61rNgp0nVQVVvZw=; h=Cc:Date:From:Reply-To:Subject:To; b=wb1Pg+b8pukfKkyTW4i82i1Mai75UDyle0shgXLglLNDgt09sg9LEcQ+287CkYIfPYP T4ixcyskphMr4mLbKiFhYWPbUQi8RjYipfEUdMBSOwYMXjligRptAbSdEflwrOCEPEIDu S2f/TUOsW/qTT5GK+4i3xZ7g8FaBWw363IA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Copy UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm to OvmfPkg/Bhyve/ResetVector/Ia16, with one change, as has also been made in XenResetVector: - SEC_DEFAULT_CR0: enable cache (bit 30 or CD set to 0) With the CD bit set to 1, this has the downside on AMD systems of actually running with the cache disabled, which slows the entire system to a crawl. There's no need for this bit to be set in virtualized environments. This patch reapplies the change from the freebsd uefi-edk2 repo at https://github.com/freebsd/uefi-edk2/commit/08c00f4e8d9e3e469bdc2ce92d3aa83= 9cae7cf17 Signed-off-by: Rebecca Cran Reviewed-by: Peter Grehan Acked-by: Laszlo Ersek --- .../Bhyve/ResetVector/Ia16/Real16ToFlat32.asm | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 OvmfPkg/Bhyve/ResetVector/Ia16/Real16ToFlat32.asm diff --git a/OvmfPkg/Bhyve/ResetVector/Ia16/Real16ToFlat32.asm b/OvmfPkg/Bh= yve/ResetVector/Ia16/Real16ToFlat32.asm new file mode 100644 index 000000000000..580fe068e7e1 --- /dev/null +++ b/OvmfPkg/Bhyve/ResetVector/Ia16/Real16ToFlat32.asm @@ -0,0 +1,143 @@ +;-------------------------------------------------------------------------= ----- +; @file +; Transition from 16 bit real mode into 32 bit flat protected mode +; +; Copyright (c) 2020, Rebecca Cran . All rights reserve= d.
+; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +;-------------------------------------------------------------------------= ----- + +%define SEC_DEFAULT_CR0 0x00000023 +%define SEC_DEFAULT_CR4 0x640 + +BITS 16 + +; +; Modified: EAX, EBX +; +; @param[out] DS Selector allowing flat access to all addresses +; @param[out] ES Selector allowing flat access to all addresses +; @param[out] FS Selector allowing flat access to all addresses +; @param[out] GS Selector allowing flat access to all addresses +; @param[out] SS Selector allowing flat access to all addresses +; +TransitionFromReal16To32BitFlat: + + debugShowPostCode POSTCODE_16BIT_MODE + + cli + + mov bx, 0xf000 + mov ds, bx + + mov bx, ADDR16_OF(gdtr) + +o32 lgdt [cs:bx] + + mov eax, SEC_DEFAULT_CR0 + mov cr0, eax + + jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere) +BITS 32 +jumpTo32BitAndLandHere: + + mov eax, SEC_DEFAULT_CR4 + mov cr4, eax + + debugShowPostCode POSTCODE_32BIT_MODE + + mov ax, LINEAR_SEL + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + OneTimeCallRet TransitionFromReal16To32BitFlat + +ALIGN 2 + +gdtr: + dw GDT_END - GDT_BASE - 1 ; GDT limit + dd ADDR_OF(GDT_BASE) + +ALIGN 16 + +; +; Macros for GDT entries +; + +%define PRESENT_FLAG(p) (p << 7) +%define DPL(dpl) (dpl << 5) +%define SYSTEM_FLAG(s) (s << 4) +%define DESC_TYPE(t) (t) + +; Type: data, expand-up, writable, accessed +%define DATA32_TYPE 3 + +; Type: execute, readable, expand-up, accessed +%define CODE32_TYPE 0xb + +; Type: execute, readable, expand-up, accessed +%define CODE64_TYPE 0xb + +%define GRANULARITY_FLAG(g) (g << 7) +%define DEFAULT_SIZE32(d) (d << 6) +%define CODE64_FLAG(l) (l << 5) +%define UPPER_LIMIT(l) (l) + +; +; The Global Descriptor Table (GDT) +; + +GDT_BASE: +; null descriptor +NULL_SEL equ $-GDT_BASE + DW 0 ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB 0 ; sys flag, dpl, type + DB 0 ; limit 19:16, flags + DB 0 ; base 31:24 + +; linear data segment descriptor +LINEAR_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(DATA32_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIM= IT(0xf) + DB 0 ; base 31:24 + +; linear code segment descriptor +LINEAR_CODE_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIM= IT(0xf) + DB 0 ; base 31:24 + +%ifdef ARCH_X64 +; linear code (64-bit) segment descriptor +LINEAR_CODE64_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE64_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(1)|UPPER_LIM= IT(0xf) + DB 0 ; base 31:24 +%endif + +; linear code segment descriptor +LINEAR_CODE16_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(0)|UPPER_LIM= IT(0xf) + DB 0 ; base 31:24 + +GDT_END: + --=20 2.29.2 -=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 (#67846): https://edk2.groups.io/g/devel/message/67846 Mute This Topic: https://groups.io/mt/78468100/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-