From owner-freebsd-current@freebsd.org Sat Oct 15 13:21:43 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31DBEC13B76 for ; Sat, 15 Oct 2016 13:21:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAB66BDB for ; Sat, 15 Oct 2016 13:21:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u9FDLbSo081692 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 15 Oct 2016 16:21:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u9FDLbSo081692 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u9FDLbtb081691; Sat, 15 Oct 2016 16:21:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 15 Oct 2016 16:21:37 +0300 From: Konstantin Belousov To: "Hartmann, O." Cc: FreeBSD CURRENT Subject: Re: options EFIRT: immediate crash of CURRENT Message-ID: <20161015132137.GH2404@kib.kiev.ua> References: <20161015140059.06f60244@hermann> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161015140059.06f60244@hermann> User-Agent: Mutt/1.7.0 (2016-08-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 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, 15 Oct 2016 13:21:43 -0000 On Sat, Oct 15, 2016 at 02:00:59PM +0200, Hartmann, O. wrote: > > Playing around with some EFI related options and putting > > options EFIRT > > into the kernel config, results in an immediate crash after booting, > see screenshot attached. > > This happens on non-EFI booting systems as well as EFI capable systems. > The screenshot is taken from a box with UEFI firmware, but disabled and > used via CSM/BIOS, but with option enabled. There is no screenshot. Anyway, I have a guess, possibly similar issue was reported already, you might try this patch. diff --git a/sys/amd64/amd64/efirt.c b/sys/amd64/amd64/efirt.c index 4c0454c..4540625 100644 --- a/sys/amd64/amd64/efirt.c +++ b/sys/amd64/amd64/efirt.c @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); static struct efi_systbl *efi_systbl; static struct efi_cfgtbl *efi_cfgtbl; static struct efi_rt *efi_runtime; -static struct cdev *efi_cdev; static int efi_status2err[25] = { 0, /* EFI_SUCCESS */ @@ -403,15 +402,13 @@ efi_init(void) return (ENXIO); } - return (efidev_init(&efi_cdev)); + return (0); } static void efi_uninit(void) { - efidev_uninit(efi_cdev); - efi_destroy_1t1_map(); efi_systbl = NULL; @@ -566,7 +563,6 @@ efirt_modevents(module_t m, int event, void *arg __unused) switch (event) { case MOD_LOAD: return (efi_init()); - break; case MOD_UNLOAD: efi_uninit(); diff --git a/sys/dev/efidev/efidev.c b/sys/dev/efidev/efidev.c index abceec8..d6e0e06 100644 --- a/sys/dev/efidev/efidev.c +++ b/sys/dev/efidev/efidev.c @@ -47,7 +47,6 @@ static struct cdevsw efi_cdevsw = { .d_ioctl = efidev_ioctl, }; -/* ARGSUSED */ static int efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, int flags __unused, struct thread *td __unused) @@ -173,21 +172,45 @@ vs_out: return (error); } -int -efidev_init(struct cdev **cdev) +static struct cdev *efidev; + +static int +efidev_modevents(module_t m, int event, void *arg __unused) { - - *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, - "efi"); + struct make_dev_args mda; + int error; + + switch (event) { + case MOD_LOAD: + make_dev_args_init(&mda); + mda.mda_flags = MAKEDEV_WAITOK | MAKEDEV_CHECKNAME; + mda.mda_devsw = &efi_cdevsw; + mda.mda_uid = UID_ROOT; + mda.mda_gid = GID_WHEEL; + mda.mda_mode = 0700; + error = make_dev_s(&mda, &efidev, "efi"); + return (error); + + case MOD_UNLOAD: + if (efidev != NULL) + destroy_dev(efidev); + efidev = NULL; + return (0); + + case MOD_SHUTDOWN: + return (0); - return (0); + default: + return (EOPNOTSUPP); + } } -int -efidev_uninit(struct cdev *cdev) -{ - - destroy_dev(cdev); +static moduledata_t efidev_moddata = { + .name = "efidev", + .evhand = efidev_modevents, + .priv = NULL, +}; - return (0); -} +DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DEVFS, SI_ORDER_ANY); +MODULE_VERSION(efidev, 1); +MODULE_DEPEND(efidev, efirt, 1, 1, 1); diff --git a/sys/sys/efi.h b/sys/sys/efi.h index 81c6fd3..68fc281 100644 --- a/sys/sys/efi.h +++ b/sys/sys/efi.h @@ -165,9 +165,6 @@ struct efi_systbl { #ifdef _KERNEL extern vm_paddr_t efi_systbl_phys; -struct cdev; -int efidev_init(struct cdev **); -int efidev_uninit(struct cdev *); #endif /* _KERNEL */ #endif /* _SYS_EFI_H_ */