From owner-freebsd-virtualization@freebsd.org Thu Apr 4 03:26:02 2019 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E76AF155FADF for ; Thu, 4 Apr 2019 03:26:01 +0000 (UTC) (envelope-from rebecca@bluestop.org) Received: from muon.bluestop.org (muon.bluestop.org [65.103.231.193]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC931822F0 for ; Thu, 4 Apr 2019 03:26:00 +0000 (UTC) (envelope-from rebecca@bluestop.org) Received: from muon.bluestop.org (localhost [127.0.0.1]) by muon.bluestop.org (Postfix) with ESMTP id 87B7FCC312 for ; Wed, 3 Apr 2019 21:26:37 -0600 (MDT) Received: from muon.bluestop.org ([127.0.0.1]) by muon.bluestop.org (muon.bluestop.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r4kuo0pSpBW1 for ; Wed, 3 Apr 2019 21:26:37 -0600 (MDT) Received: from photon.int.bluestop.org (unknown [65.103.231.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by muon.bluestop.org (Postfix) with ESMTPSA for ; Wed, 3 Apr 2019 21:26:37 -0600 (MDT) To: freebsd-virtualization@freebsd.org From: Rebecca Cran Subject: Bhyve with UEFI edk2-stable201903 and CSM support - debugging the crash Message-ID: <9927beac-92cd-1059-298d-b7ffd9f34a42@bluestop.org> Date: Wed, 3 Apr 2019 21:25:52 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Rspamd-Queue-Id: DC931822F0 X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.95 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[bluestop.org:s=mail]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[4]; IP_SCORE(-2.99)[ip: (-9.88), ipnet: 65.100.0.0/14(-4.91), asn: 209(-0.09), country: US(-0.06)]; DKIM_TRACE(0.00)[bluestop.org:+]; DMARC_POLICY_ALLOW(-0.50)[bluestop.org,quarantine]; MX_GOOD(-0.01)[mail.bluestop.org]; NEURAL_HAM_SHORT(-0.95)[-0.947,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:209, ipnet:65.100.0.0/14, country:US]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 03:26:02 -0000 I've spent some time trying to figure out where and why the UEFI 2.70 firmware is crashing when built with CSM support under Bhyve. The first thing I noticed is that the code that builds the E820 table doesn't appear to be finding the location of the EBDA at 0x40E: the first entry should be something like 0x0 to 0x4cf00, but is 0-0 instead. E820[ 0]: 0x               0 ---- 0x               0, Type = 0x1 E820[ 1]: 0x               0 ---- 0x           A0000, Type = 0x2 E820[ 2]: 0x           E0000 ---- 0x          100000, Type = 0x2 E820[ 3]: 0x          100000 ---- 0x          406000, Type = 0x1 ... As an aside, I'm working on a patch to submit upstream to fix the output so it pads with zeros instead of spaces. I've also found that as was probably pretty obvious the system is crashing when trying to call into the CSM to initialize it. It gets as far as calling AsmThunk16 (AsmThunk.nasm), but never appears to reach CsmMain in BhyveCsm16.c. I'll see if I can work on it some more to narrow down the error. Another thing: the GNUmakefile in OvmfPkg/Csm/BhyveCsm16 has "CC ?= gcc", but it appears the build system already sets CC to "cc", which uses the system's clang compiler, which can't compile the assembly code. I don't know if we might want to either hard-code CC to "gcc" for now, or have users create a 'cc' symlinks in BaseTools/Bin/FreeBSD-amd64 ? -- Rebecca Cran