From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web10.14806.1595949550982078213 for ; Tue, 28 Jul 2020 08:19:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YC1CWAZL; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595949550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TOGf9vRI1S11cCXdzEaoNTRsZauRKrJQwXqnzF6dT5I=; b=YC1CWAZLQMAGqkrnwgv3kiaVchLyLurMbvV06BvFMmLNcQ0iMCI1n5Wpx1lE6foKeHsDFE C58DZnZY+qm1JTPzltUhknaz9GeDFhpnhcCOEIqihPzxkKALmUuXQgERb32TT3ZYQgVVhG N1Zd5IsIcuTcnSzRF8koxCb2RlcZgWM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-86-qDRunjKRMyKm-kK8EwHTzA-1; Tue, 28 Jul 2020 11:19:07 -0400 X-MC-Unique: qDRunjKRMyKm-kK8EwHTzA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 128B4102C84A; Tue, 28 Jul 2020 15:19:06 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-229.ams2.redhat.com [10.36.113.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81FF090E77; Tue, 28 Jul 2020 15:19:03 +0000 (UTC) Subject: Re: [PATCH v12 07/46] MdePkg/BaseLib: Add support for the VMGEXIT instruction To: Tom Lendacky , "Gao, Liming" , "devel@edk2.groups.io" Cc: Brijesh Singh , Ard Biesheuvel , "Dong, Eric" , "Justen, Jordan L" , "Kinney, Michael D" , "Ni, Ray" References: <57cfa8bb-f683-08c4-7262-5762a9e0a4c1@amd.com> <1d539df5-142e-7ab1-faa6-0d0f6eea1608@redhat.com> <674ee9db-7295-cbab-19a3-495c1bcc0487@amd.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 28 Jul 2020 17:19:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <674ee9db-7295-cbab-19a3-495c1bcc0487@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 07/28/20 16:13, Tom Lendacky wrote: > IIUC, create a VmgExit.c file in MdePkg/Library/BaseLib/Ia32/ that > doesn't actually encode the VMGEXIT instruction, just calls > CpuBreakpoint(), e.g.: > > VOID > EFIAPI > AsmVmgExit ( > VOID > ) > { > CpuBreakpoint(); > } > Yes -- either that, or even just open-code (copy) what we have in MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.nasm now: global ASM_PFX(AsmVmgExit) ASM_PFX(AsmVmgExit): ; ; VMGEXIT makes no sense on IA32, and NASM versions before 2.12 cannot ; translate the 64-bit "rep vmmcall" instruction into elf32 format. So ; provide a stub implementation that is identical to CpuBreakpoint(). In ; practice, AsmVmgExit() should never be called on IA32. ; int 3 ret Because this assembly-language implementation might be more "true" to the name "AsmVmgExit". Liming, would you be OK with this approach? In other words, the set of files changed/introduced in this patch would not change, just the implementation of IA32 AsmVmgExit(). > The other alternative is to use a DB-encoded instruction, though I > know that isn't the most popular approach. Right, I've been quite on a quest to eliminate DBs that encode instructions. > The BITS 64 method to generate the instruction bytes is also used in > OvmfPkg/ResetVector/Ia32/PageTables64.asm, but that file is only > included when ARCH_X64 is defined, so there shouldn't be an issue > there, plus the nasm file format is bin (-f bin). I confirm that; the following commands all work on RHEL7, with this series applied: $ build -b NOOPT -t GCC48 -m OvmfPkg/ResetVector/ResetVector.inf -a IA32 -p OvmfPkg/OvmfPkgIa32.dsc $ build -b NOOPT -t GCC48 -m OvmfPkg/ResetVector/ResetVector.inf -a IA32 -a X64 -p OvmfPkg/OvmfPkgIa32X64.dsc $ build -b NOOPT -t GCC48 -m OvmfPkg/ResetVector/ResetVector.inf -a X64 -p OvmfPkg/OvmfPkgX64.dsc Thanks! Laszlo