From owner-freebsd-current@freebsd.org Sat May 18 18:57:44 2019 Return-Path: Delivered-To: freebsd-current@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 6317B1595220 for ; Sat, 18 May 2019 18:57:44 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B46CB8CC20 for ; Sat, 18 May 2019 18:57:42 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x844.google.com with SMTP id a17so11867752qth.3 for ; Sat, 18 May 2019 11:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XVfpj6282A4Iyvhg3szQWwgpmeseDQnUcbEtqlrgAmU=; b=HiTLUVNRNAgKFNStv9m1Mamlks9AuXue0y/dQUN2dwbj1G63tA9xAeXUFDFQt07PpK 5B66FecC3My7QsSAbyo0cDOSeHHyq22qnnS1Tq7WeTzuYaTuJ/22etCmsBkiNh/4DYHf Ru9a+ZoGiQRg70ihY/RWSW7FvvIcjl0dR5oPfP7pofB2iH5B/Reqf2J9GWuDwHUDyQa0 97mwwn14FM7IbYvAPM6ctmYxpXCZ7+svpA6PxfJA/qFNnC9BftCr+bMeZPnoBoOZZLH1 q3BEsY6Vx4mRrhF6LG0TXea2CH1NQWHNEc+Nfqv7rd9tq4Imr4XJnlTkPHEHHV67Vex4 6Zow== 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=XVfpj6282A4Iyvhg3szQWwgpmeseDQnUcbEtqlrgAmU=; b=btuH6Xi/qB8RruWy6CjNnDbtqlGt1VS00KbMh9C75uCF3C3Ngxg/ETfz1DvqRA704m MeWLoLFJIgpcApAIk3FEVjHVVLQezucv6GAsEYVhp9kvADp/gSvaXfNvseMCXVNwo561 Qz4ApA4ovv8hXzBH1UvAkiUJI1PLUn9gVF9afHTlYrr5VqivlX7VFD1rrgszxZwbI6G3 3SEqgGgmiNdjlTayRUhETDcMTArAfK2Izitvw26sB/zQpLAgK+DBNnZEUNiPYqGgpkVq H2zCDX+VU/nEVhx5SqRA2xSx3mmrkOeZPpqaO4AqZfsEKFg9Hchq6wLUW0oJCuJOif+O ArUQ== X-Gm-Message-State: APjAAAX6BE041SMNJLGeBF8Zd9nPJum3jXcJcb2AIRFyyzuuyANw7Edf +H+CdqilUX7EWMIt8YfXCGXKvKHp0/Ljhy9G4uL73qtP X-Google-Smtp-Source: APXvYqy96HhCctcUdzcyb1QBQOodtEthbbQR4J742JY1VlOPJTpfGohKg+Ya2D4zzc8v08X5awysix1sHOmmZ2DekQ0= X-Received: by 2002:a0c:8a6c:: with SMTP id 41mr50151222qvu.236.1558205862019; Sat, 18 May 2019 11:57:42 -0700 (PDT) MIME-Version: 1.0 References: <105ad083-ea95-21a7-35be-de01e32578c4@bluestop.org> <20190518053328.GA7370@raichu> <20190518085546.GY2748@kib.kiev.ua> <20190518142436.GB7370@raichu> <20190518143815.GD2748@kib.kiev.ua> <20190518144547.GE2748@kib.kiev.ua> <20190518154653.GD7370@raichu> In-Reply-To: <20190518154653.GD7370@raichu> From: Warner Losh Date: Sat, 18 May 2019 12:57:29 -0600 Message-ID: Subject: Re: panic booting with if_tap_load="YES" in loader.conf To: Mark Johnston Cc: Konstantin Belousov , Rebecca Cran , freebsd-current@freebsd.org X-Rspamd-Queue-Id: B46CB8CC20 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=HiTLUVNR X-Spamd-Result: default: False [-2.48 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; RCVD_COUNT_TWO(0.00)[2]; URI_COUNT_ODD(1.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; MX_GOOD(-0.01)[ALT1.aspmx.l.google.com,aspmx.l.google.com,ALT2.aspmx.l.google.com]; RCVD_IN_DNSWL_NONE(0.00)[4.4.8.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]; NEURAL_HAM_SHORT(-0.80)[-0.803,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; IP_SCORE(-0.67)[ip: (2.24), ipnet: 2607:f8b0::/32(-3.27), asn: 15169(-2.27), country: US(-0.06)]; FREEMAIL_CC(0.00)[gmail.com] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 May 2019 18:57:44 -0000 On Sat, May 18, 2019, 9:48 AM Mark Johnston wrote: > On Sat, May 18, 2019 at 05:45:47PM +0300, Konstantin Belousov wrote: > > On Sat, May 18, 2019 at 05:38:15PM +0300, Konstantin Belousov wrote: > > > On Sat, May 18, 2019 at 10:24:36AM -0400, Mark Johnston wrote: > > > > On Sat, May 18, 2019 at 11:55:46AM +0300, Konstantin Belousov wrote: > > > > > On Sat, May 18, 2019 at 01:33:28AM -0400, Mark Johnston wrote: > > > > > > On Fri, May 17, 2019 at 10:18:57PM -0600, Rebecca Cran wrote: > > > > > > > I just updated from r346856 to r347950 and ran into a new > panic, caused > > > > > > > by having if_tap_load="YES" in /boot/loader.conf - because > it's already > > > > > > > built-in to the kernel: > > > > > > > > > > > > I think this patch should fix the panic, but I only > compile-tested it. > > > > > > I considered having the logic live in preload_delete_name() > instead, but > > > > > > the boot-time ucode code must still defer the deletion somewhat. > > > > > > > > > > Try this instead. I will revert r347931 after this landed, or > could keep > > > > > it alone. > > > > > > > > I have no strong feeling either way. > > > > > > > > > diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c > > > > > index 1cf09dc5cb7..03fe8a5d096 100644 > > > > > --- a/sys/amd64/amd64/machdep.c > > > > > +++ b/sys/amd64/amd64/machdep.c > > > > > @@ -1616,6 +1616,13 @@ hammer_time(u_int64_t modulep, u_int64_t > physfree) > > > > > bzero((void *)thread0.td_kstack, kstack0_sz); > > > > > physfree += kstack0_sz; > > > > > > > > > > + /* > > > > > + * Initialize enough of thread0 for delayed invalidation to > > > > > + * work very early. Rely on thread0.td_base_pri > > > > > + * zero-initialization, it is reset to PVM at proc0_init(). > > > > > + */ > > > > > + pmap_thread_init_invl_gen(&thread0); > > > > > + > > > > > > > > I think pmap_thread_init_invl_gen() also needs to initialize > > > > invl_gen->saved_pri to 0. > > > It is zero-initialized, same as td_base_pri. The call to > > > pmap_thread_init_invl_gen() is needed because _INVALID bit must be set, > > > which is cleared by default. > > I now think that you mean something else, that invl_gen.saved_pri must > > be set on each entry to invl_start_u(). Otherwise invl_finish_u() might > > act on the priority from the previous DI block. > > That is not what I was thinking about, but I agree. thread0's saved_pri > should be zero-initialized, but I don't see how any other thread's > saved_pri is initialized - td_md is not in the zero or copy region of > the thread structure. Your patch should address this as well, but maybe > I am still missing something about how saved_pri gets initialized. The > patch looks right to me. > Could this crash on other architectures? Do we need fixes there as well... Warner > diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c > > index 1cf09dc5cb7..03fe8a5d096 100644 > > --- a/sys/amd64/amd64/machdep.c > > +++ b/sys/amd64/amd64/machdep.c > > @@ -1616,6 +1616,13 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) > > bzero((void *)thread0.td_kstack, kstack0_sz); > > physfree += kstack0_sz; > > > > + /* > > + * Initialize enough of thread0 for delayed invalidation to > > + * work very early. Rely on thread0.td_base_pri > > + * zero-initialization, it is reset to PVM at proc0_init(). > > + */ > > + pmap_thread_init_invl_gen(&thread0); > > + > > /* > > * make gdt memory segments > > */ > > diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c > > index 7997a9f65dc..89ba9da19d8 100644 > > --- a/sys/amd64/amd64/pmap.c > > +++ b/sys/amd64/amd64/pmap.c > > @@ -700,16 +700,17 @@ pmap_delayed_invl_start_u(void) > > invl_gen = &td->td_md.md_invl_gen; > > PMAP_ASSERT_NOT_IN_DI(); > > lock_delay_arg_init(&lda, &di_delay); > > - thread_lock(td); > > + invl_gen->saved_pri = 0; > > pri = td->td_base_pri; > > - if (pri < PVM) { > > - invl_gen->saved_pri = 0; > > - } else { > > - invl_gen->saved_pri = pri; > > - sched_prio(td, PVM); > > + if (pri > PVM) { > > + thread_lock(td); > > + pri = td->td_base_pri; > > + if (pri > PVM) { > > + invl_gen->saved_pri = pri; > > + sched_prio(td, PVM); > > + } > > + thread_unlock(td); > > } > > - thread_unlock(td); > > - > > again: > > PV_STAT(i = 0); > > for (p = &pmap_invl_gen_head;; p = prev.next) { > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >