From owner-freebsd-virtualization@freebsd.org Sun Mar 31 13: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 74CB9155E0E4 for ; Sun, 31 Mar 2019 13:26:02 +0000 (UTC) (envelope-from chuck@tuffli.net) Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 756E681993 for ; Sun, 31 Mar 2019 13:26:00 +0000 (UTC) (envelope-from chuck@tuffli.net) Received: by mail-io1-xd44.google.com with SMTP id c4so5424112ioh.9 for ; Sun, 31 Mar 2019 06:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuffli-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Aeptdwul5hqEmJjO1UUdnj2fLR9Me6KWd97xXQhgalc=; b=L0EB8MsxECLNxSqnkdjUEDPpMbsBz8LRAzbZIwPeTjy9gqzoNUtIdtNEqVkkn31FtS qfVS7Y5NUJcw5A/B/A0w1HyhAIqEGthuDwWE7MMQUjFcbEuOHqDrWu7+YUG9clKZCfQ1 qAaMawXteq/bzZhYK0WEpx7Ptz5V8C7YR0weoXwvhpTGUmvoBgEJvXL6d2ZXwqlgdTXQ xSUOFEegYZLlsymH5jzWGPQqPYkCukai00A/Ow9k8uLyeCuc63XqVhPzS9leztxj9mC6 DYDa5LfUtYyand0USd+s/VXRHUXn/EdKHMO8saWrO0Lhg3kplLYK54o4JL+5VN07KEMD 5G5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Aeptdwul5hqEmJjO1UUdnj2fLR9Me6KWd97xXQhgalc=; b=CR15ESUAZEjwd3M6bKVrToCB3bwJnwkHFUJgzWdBoLb8Nc2OpW1tNi+rZb+MiKAAoY ZGYisIqFciBeoz6+51owwE+l7IRiKkh6VKgf3glXaQsxIBFgxwDiKagaGfbCPLd5ZZ63 KXQwXz3rRv6dxMZvJ+i+6noYTK6Xz0t8doc4jP/WpYWHHaXPfeRFLJms1xeALCikeXR2 k1y3vaCNYa1uJCH7Y3CB2z665RADc7PjQEo5UjQIABK/PYI90nNISKVpmbhIfknd624Z Hh61lEgMMSiqIwGU5X10cHNthTIHkoxsyL83uk9/WBydol1gcWBnJoZRVbXatuOErtzF 9L2w== X-Gm-Message-State: APjAAAXugmkZIBWpBRD3xUX61sa0SwFdoltjzJk5h5x667fNBZACKuEI sG+5sDIsvhaD323ydQCtN+n0WPdVcZlopzIbxBVwaA== X-Google-Smtp-Source: APXvYqxwvXbLLYwyWu5i/Ybv0fEvL3KxWiz4FJoUEz8oVwNFBc8bK5ZVpgKP9MDLUMyeV85XYZ5Ej/prddJjHSgkmRY= X-Received: by 2002:a5d:855a:: with SMTP id b26mr25715297ios.151.1554038759414; Sun, 31 Mar 2019 06:25:59 -0700 (PDT) MIME-Version: 1.0 References: <79b6eebd-2320-1888-1162-d3ca5492670c@physik.tu-berlin.de> In-Reply-To: <79b6eebd-2320-1888-1162-d3ca5492670c@physik.tu-berlin.de> From: Chuck Tuffli Date: Sun, 31 Mar 2019 06:25:48 -0700 Message-ID: Subject: Re: core dumps running in bhyve To: Fabian Freyer Cc: freebsd-emulation@freebsd.org, FreeBSD Hackers , freebsd-virtualization@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 756E681993 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=tuffli-net.20150623.gappssmtp.com header.s=20150623 header.b=L0EB8Msx; spf=permerror (mx1.freebsd.org: domain of chuck@tuffli.net uses mechanism not recognized by this client) smtp.mailfrom=chuck@tuffli.net X-Spamd-Result: default: False [-3.84 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; R_DKIM_ALLOW(-0.20)[tuffli-net.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; DMARC_NA(0.00)[tuffli.net]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[tuffli-net.20150623.gappssmtp.com:+]; R_SPF_PERMFAIL(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[4.4.d.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; MX_GOOD(-0.01)[alt1.aspmx.l.google.com,aspmx.l.google.com,aspmx2.googlemail.com,aspmx3.googlemail.com,aspmx4.googlemail.com,alt2.aspmx.l.google.com,aspmx5.googlemail.com]; IP_SCORE(-0.70)[ip: (1.60), ipnet: 2607:f8b0::/32(-2.89), asn: 15169(-2.15), country: US(-0.07)]; NEURAL_HAM_SHORT(-0.84)[-0.836,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2] 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: Sun, 31 Mar 2019 13:26:02 -0000 On Fri, Dec 28, 2018 at 3:53 AM Fabian Freyer wrote: > > 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? Thanks Fabian for the redirect to a better list. FWIW, the issue is with bhyve's NVMe emulation code and not anything to do with vm_map_gpa() per se. See https://reviews.freebsd.org/D19695 for those who are curious. --chuck