From owner-freebsd-virtualization@freebsd.org Wed Feb 6 14:46:52 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 09C7F14D5B11 for ; Wed, 6 Feb 2019 14:46:52 +0000 (UTC) (envelope-from sc.dying@gmail.com) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D905B7023C for ; Wed, 6 Feb 2019 14:46:50 +0000 (UTC) (envelope-from sc.dying@gmail.com) Received: by mail-ed1-x536.google.com with SMTP id f9so6061292eds.10 for ; Wed, 06 Feb 2019 06:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VMLvFBqhhABrmc6Mued3AQtxhTb+pXtHlrWt7gPgitg=; b=ZN7uOonoinXRf+De/AiPNucngQjk1T8vyPGdPpLt9sC5xVScpRT351LIomllElLUMP A4dBPKVDIyn08ak9gESleIIWXTBeLL4Z8NRH+WCe2T+OSwKbQxsFDDwVY29eRp9eqVmE YxWv2InLr1YauzgB3Wf1o7qW9OLlaEEpMek9D6XyY5rJ4SKQ2nkSS8VtfWDiGEJxMx+0 Sl/UghOyr1E9az9kltU/LenL+ZkxArEQ43jebKTvR8RTMrHcH5DPm369Xsee48pYalv6 FTYT/bAUUgKA+F6/9Y0DmI3R6tFW0sWg9pc+lc0GJ5lwyE5gDogi46NOWSdA7p3zxGMu c9zg== 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=VMLvFBqhhABrmc6Mued3AQtxhTb+pXtHlrWt7gPgitg=; b=pQBS1TQ0kYZSvA4+6oqSy3h0IfS5JQLRSSHtav4e9V9YIRq/gZdhwRFKPI3AfNJBxM SauISt/2iahOSptoVQiROXEdCYVmf7cnEGJizdAAGwjdj22+99ARxTuSf/DJyYLLYr7e JH8MLIKQanglsPqf07aRDxFu6ObgXCosXY1UZl4uUva1CfdZ42N2cD5s23FqUmMXRD3C IYmCYmsIUamRs3ll0V4PBc5ddLuEYUV3yDTARUw+Swijv50NdPcAyeIGAwzYkRmOhbd/ mnlpJWlicZKOWxJ57iFClJ80MrjQF1m+IDpUG+nvkqembo22aEuWc1gXW+c2Ba/K6dNS ViCw== X-Gm-Message-State: AHQUAuavT+rXst1qYZ6/4YspejMRO/mVZ8uj7oaBkHt0Fi2TPxkQGxLC MCtEw/8D4sJ9GTqcrOjsKYhKWI6VCZWtVxglt3k= X-Google-Smtp-Source: AHgI3IY4fCyZllZD15zy5zzQLvFzbzcbwIp6rtjUH2FalPCyRq2AWKWK53UvPg8BJccPOZD+ET4iJDXqBzoMTnSbl8A= X-Received: by 2002:a17:906:3b8c:: with SMTP id u12mr7746492ejf.54.1549464409703; Wed, 06 Feb 2019 06:46:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: sc dying Date: Wed, 6 Feb 2019 14:46:34 +0000 Message-ID: Subject: Re: NetBSD 8.0/amd64+ bhyve (FreeBSD 12)+xhci = SIGSEGV To: Oleg Ginzburg Cc: freebsd-virtualization@freebsd.org, tech-kern@netbsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: D905B7023C X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=ZN7uOono; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of scdying@gmail.com designates 2a00:1450:4864:20::536 as permitted sender) smtp.mailfrom=scdying@gmail.com X-Spamd-Result: default: False [-6.63 / 15.00]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.94)[-0.936,0]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[6.3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; IP_SCORE(-2.68)[ip: (-9.07), ipnet: 2a00:1450::/32(-2.30), asn: 15169(-1.96), country: US(-0.07)]; 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: Wed, 06 Feb 2019 14:46:52 -0000 On Tue, Sep 25, 2018 at 11:02 PM Oleg Ginzburg wrote: > > Hello. NetBSD works fine in bhyve, except for the case when the bhyve > emulates eXtensible Host Controller Interface (xHCI) USB controller. ( > -s 30,xhci,tablet ) > Perhaps SIGSEGV of bhyve is caused by the abnormal behavior of xhci on > the NetBSD guest, so I decided to write both mailing lists. > > LLDB output upon bhyve crash (guest screen: https://pasteboard.co/HFAqTOk.png ): > > https://github.com/freebsd/freebsd/blob/ebeb3285f598d6c1214c49598c951493d09e1067/usr.sbin/bhyve/pci_xhci.c#L735 > > Process 57083 stopped > * thread #20, name = 'vcpu 0', stop reason = signal SIGSEGV: invalid > address (fault address: 0x0) > frame #0: 0x00000000002587d8 > bhyve`pci_xhci_insert_event(sc=0x00000008010a5100, > evtrb=0x00007fffddbeba78, do_intr=0) at pci_xhci.c:735 > 732 rts = &sc->rtsregs; > 733 > 734 erdp = rts->intrreg.erdp & ~0xF; > -> 735 erdp_idx = (erdp - > rts->erstba_p[rts->er_deq_seg].qwEvrsTablePtr) / > 736 sizeof(struct xhci_trb); > 737 > 738 DPRINTF(("pci_xhci: insert event 0[%lx] 2[%x] 3[%x]\r\n" > (lldb) frame variable erdp_idx > (int) erdp_idx = 0 > > > in all likelihood, the problem in the rts->erstba_p structure because > when I commenting 735 line ( erdp_idx is used only in DPRINTF debug > output ) the next stop when working with this structure again, e.g: > > Process 58354 stopped > * thread #20, name = 'vcpu 0', stop reason = signal SIGSEGV: invalid > address (fault address: 0x8) > frame #0: 0x0000000000258881 > bhyve`pci_xhci_insert_event(sc=0x00000008010a5100, > evtrb=0x00007fffddbeba78, do_intr=0) at pci_xhci.c:750 > 747 evtrbptr = &rts->erst_p[rts->er_enq_idx]; > 748 > 749 /* TODO: multi-segment table */ > -> 750 if (rts->er_events_cnt >= rts->erstba_p->dwEvrsTableSize) { > 751 DPRINTF(("pci_xhci[%d] cannot insert event; > ring full\r\n", > 752 __LINE__)); > 753 err = XHCI_TRB_ERROR_EV_RING_FULL; > > > What can I do to find out the reasons for this behavior? Thanks! The bhyve initializes rts->erstba_p in pci_xhci_rtsregs_write() of bhyve/pci_xhci.c only when higher 32 bits of ERSTBA (ERSTBA_HI) is written. The NetBSD writes only lower 32 bit of ERSTBA because the AC64 bit of hccparams1 is not set on the bhyve. I think rts->erstba_p of the bhyve is uninitialised for the NetBSD guest. The bhyve should initialize rts->erstba_p when lower 32 bits of ERSTBA is written, too.