From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C246620349DAC for ; Fri, 17 Nov 2017 09:32:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E1B646E; Fri, 17 Nov 2017 17:37:04 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-124-49.rdu2.redhat.com [10.10.124.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEC628B13D; Fri, 17 Nov 2017 17:37:02 +0000 (UTC) To: Paolo Bonzini , edk2-devel@lists.01.org Cc: Jordan Justen , Ard Biesheuvel References: <20171116203100.28085-1-pbonzini@redhat.com> <20171116203100.28085-4-pbonzini@redhat.com> From: Laszlo Ersek Message-ID: <068f9ac6-2fd2-d412-2eae-b84bb1a545c2@redhat.com> Date: Fri, 17 Nov 2017 18:37:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171116203100.28085-4-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 17 Nov 2017 17:37:04 +0000 (UTC) Subject: Re: [PATCH v3 3/3] OvmfPkg: save on I/O port accesses when the debug port is not in use X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2017 17:32:53 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/16/17 21:31, Paolo Bonzini wrote: > When SEV is enabled, every debug message printed by OVMF to the > QEMU debug port traps from the guest to QEMU character by character > because "REP OUTSB" cannot be used by IoWriteFifo8. Furthermore, > when OVMF is built with the DEBUG_VERBOSE bit (value 0x00400000) > enabled in "gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel", then the > OvmfPkg/IoMmuDxe driver, and the OvmfPkg/Library/BaseMemEncryptSevLib > library instance that is built into it, produce a huge amount of > log messages. Therefore, in SEV guests, the boot time impact is huge > (about 45 seconds _additional_ time spent writing to the debug port). > > While these messages are very useful for analyzing guest behavior, > most of the time the user won't be capturing the OVMF debug log. > In fact libvirt does not provide a method for configuring log capture; > users that wish to do this (or are instructed to do this) have to resort > to . > > The debug console device provides a handy detection mechanism; when read, > it returns 0xE9 (which is very much unlike the 0xFF that is returned by > an unused port). Use it to skip the possibly expensive OUT instructions > when the debug I/O port isn't plugged anywhere. > > For SEC, the debug port has to be read before each full message. > However: > > - if the debug port is available, then reading one byte before writing > a full message isn't tragic, especially because SEC doesn't print many > messages > > - if the debug port is not available, then reading one byte instead of > writing a full message is still a win. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Jordan Justen (Intel address) > Signed-off-by: Paolo Bonzini > --- > .../PlatformDebugLibIoPort/DebugLibDetect.h | 57 ++++++++++++++++++++++ > OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 28 +++++++++-- > .../PlatformDebugLibIoPort/DebugLibDetect.c | 30 ++++++++++-- > .../PlatformDebugLibIoPort/DebugLibDetectRom.c | 21 +++++++- > 4 files changed, 127 insertions(+), 9 deletions(-) > create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h (looks like you didn't pick up my T-b from the v2 review for this patch; I'm adding that back in)