From owner-freebsd-emulation@freebsd.org Fri Dec 28 12:31:55 2018 Return-Path: Delivered-To: freebsd-emulation@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 56EE51437738; Fri, 28 Dec 2018 12:31:55 +0000 (UTC) (envelope-from fabian.freyer@physik.tu-berlin.de) Received: from mail.physik.tu-berlin.de (mail.physik-pool.tu-berlin.de [130.149.50.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 39F5688F8A; Fri, 28 Dec 2018 12:31:53 +0000 (UTC) (envelope-from fabian.freyer@physik.tu-berlin.de) Received: from [192.168.43.105] (x59cc8986.dyn.telefonica.de [89.204.137.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.physik.tu-berlin.de (Postfix) with ESMTPSA id EFD1A61F9D; Fri, 28 Dec 2018 11:53:06 +0000 (UTC) Subject: Re: core dumps running in bhyve To: Chuck Tuffli , freebsd-emulation@freebsd.org, FreeBSD Hackers References: Cc: freebsd-virtualization@freebsd.org From: Fabian Freyer Message-ID: <79b6eebd-2320-1888-1162-d3ca5492670c@physik.tu-berlin.de> Date: Fri, 28 Dec 2018 11:53:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 39F5688F8A X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [5.23 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; HFILTER_HOSTNAME_4(2.50)[mail.physik-pool.tu-berlin.de]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[tu-berlin.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.76)[0.761,0]; NEURAL_SPAM_SHORT(0.70)[0.704,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[25.50.149.130.list.dnswl.org : 127.0.11.2]; MX_GOOD(-0.01)[a1861.mx.srv.dfn.de,b1861.mx.srv.dfn.de,c1861.mx.srv.dfn.de]; NEURAL_SPAM_LONG(0.59)[0.586,0]; IP_SCORE(-0.02)[asn: 680(-0.06), country: DE(-0.01)]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:680, ipnet:130.149.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Dec 2018 12:31:55 -0000 CCing freebsd-virtualization@, because they might know more about this. Am 25.12.2018 um 02:24 schrieb Chuck Tuffli: > Using the latest bhyve, I'm seeing core dumps in the guest when running: > nvmecontrol identify nvme0 > against the emulated NVMe drive. The location of the core dump changes > from run to run, but I suspect the root cause is a memory corruption > caused by the transfer of the Identify data (4KB) back to the guest. > This transfer of data is actually a memcpy to an address returned from > vm_map_gpa() based on the physical address provided by the guest. > > Based on the signature of one of the core dumps, I modified > nvmecontrol to always pass a 4KB aligned buffer to the driver instead > of the (typically) unaligned address of the structure on the stack. > With this change, nvmecontrol in the guest no longer core dumps. What > I don't understand is why this changes the behavior. Do the addresses > passed to vm_map_gpa() need to be page aligned? AFAIK vm_map_gpa maps a page, so yes, it needs to be 4k-aligned. > Or did moving the > memory location from the stack to the heap merely mitigate what is > corrupted? > > Thoughts? > > --chuck > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >