From owner-freebsd-virtualization@freebsd.org Thu Apr 4 06:27:08 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 8E8921564851 for ; Thu, 4 Apr 2019 06:27:08 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70A0087F9A for ; Thu, 4 Apr 2019 06:27:07 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x346R0UT031283; Wed, 3 Apr 2019 23:27:00 -0700 (PDT) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: (from freebsd-rwg@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x346R09b031282; Wed, 3 Apr 2019 23:27:00 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201904040627.x346R09b031282@gndrsh.dnsmgr.net> Subject: Re: Bhyve with UEFI edk2-stable201903 and CSM support - debugging the crash In-Reply-To: <9927beac-92cd-1059-298d-b7ffd9f34a42@bluestop.org> To: Rebecca Cran Date: Wed, 3 Apr 2019 23:27:00 -0700 (PDT) CC: freebsd-virtualization@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 70A0087F9A X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [1.88 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(0.52)[0.521,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[dnsmgr.net]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.01)[0.006,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: gndrsh.dnsmgr.net]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(0.43)[0.431,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US]; MID_RHS_MATCH_FROM(0.00)[]; IP_SCORE(0.03)[ip: (0.13), ipnet: 69.59.192.0/19(0.06), asn: 13868(0.04), country: US(-0.06)] 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 06:27:08 -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. Since your building a bios there should be a table some place in some header or c file that builds the EBDA and puts a pointer to it at 0x40E. This should be someplace in the CSM legacy support stuff since the EBSA is a legacy bios thingy. You may want to look at the prior port of UEFI/CSM and see how this was done in that code, it may be a hard coded hack. > 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. Well I would think if the legacy memory region table is bogus that would be a good start point to fix. > > 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 ? I would firmcode it, if CC=cc then CC=gcc, this would allow a person to override CC with something else and still have all the other stuff work out, except for this specific point that does infact need gcc. > Rebecca Cran -- Rod Grimes rgrimes@freebsd.org