From owner-svn-src-all@freebsd.org Thu Oct 13 03:22:09 2016 Return-Path: Delivered-To: svn-src-all@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 A2F23C0E885 for ; Thu, 13 Oct 2016 03:22:09 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x232.google.com (mail-it0-x232.google.com [IPv6:2607:f8b0:4001:c0b::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6AAE17A for ; Thu, 13 Oct 2016 03:22:09 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x232.google.com with SMTP id k64so29247021itb.0 for ; Wed, 12 Oct 2016 20:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=kaGP9Vycd+ebFXtEJ4m+IdRISWdg7vnsKPEs/Dzvr5o=; b=LPczsdQXycZy1LM+zO8pdlEG815kR6j31gR1u3O4P5IbS7P01jrzXSZudS7AREapBA dkGNzVuCUBOUTYYNMfW+iwtgzWNJkdQ+PRYel5sMbqwv1T3oXOsWjEsY4Z+LEEQO4UuF txbrVlXtIHmZDLnItSJYTqktCl/pWL5wTCxCfy2LA/3/WRhx3nPbdQ5aTseuMU3DpZz2 TYiuFifvdMzbRoptXwAYBsoiWG6gBA8gOa0ZQTl+4K2Fvj5tqfvZizKCA5k/3BOKyh7f 4H+MZyy8/UgXKP0vVOm39Y2McmvNeU25Lje4/BRzoXI6NZkWpJBMPS0A543ofCoMmNFl wdmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=kaGP9Vycd+ebFXtEJ4m+IdRISWdg7vnsKPEs/Dzvr5o=; b=cPEJgnITiipVDscADlLMNaIs7ei2IQplhFk9Ld2rzFBwHa/wTkczLD7RQls4K0/Ucp e/SlPWsGzflvoA5l43fdPNq5LcYI48SKvBK57GGYQVxAAIXKmFNsCNZVYHr/pvtEstET 7n/DbfVM3yI70SZMNNuhZz1NwOIHOU4wLijG8HN84b6Glb8yweS0s8GlOrUDI8Ujxgk0 NtGLABfWXtfSol07ae49y/FFOaDcQFdcjfnNDKbLK9Cm4UMeIz3eOtwgz4xTMRB+4ded 6zzQCX22Gz/us9JwsZu72Db19lBaX/pL5HtvMHgDVDum2p7dg64e6imp0RgyHbOSKVFI HyPg== X-Gm-Message-State: AA6/9RkTmAVRppf/7/4Up9h3A08XqoLNvFM4DL6OYrGbtrms0P8A82LutHmhDs3b0kmY/eZtHIAsfl1TWjfaKA== X-Received: by 10.36.19.147 with SMTP id 141mr5567929itz.85.1476328928778; Wed, 12 Oct 2016 20:22:08 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Wed, 12 Oct 2016 20:22:08 -0700 (PDT) X-Originating-IP: [50.253.99.174] In-Reply-To: <20161012114920.GU68202@kib.kiev.ua> References: <201610112224.u9BMOUlp053188@repo.freebsd.org> <20161012114920.GU68202@kib.kiev.ua> From: Warner Losh Date: Wed, 12 Oct 2016 21:22:08 -0600 X-Google-Sender-Auth: u6LAcOIQOUGx52tmafsOfAYTQMI Message-ID: Subject: Re: svn commit: r307070 - in head/sys: amd64/amd64 conf dev/efidev i386/include modules/efirt sys To: Konstantin Belousov , "svn-src-all@freebsd.org" Cc: Warner Losh , src-committers , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:22:09 -0000 Yea, I'd made most of those changes in git and lost them :( Warner On Wed, Oct 12, 2016 at 5:49 AM, Konstantin Belousov wrote: > On Tue, Oct 11, 2016 at 10:24:30PM +0000, Warner Losh wrote: > >> Added: head/sys/dev/efidev/efidev.c >> ============================================================================== >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >> +++ head/sys/dev/efidev/efidev.c Tue Oct 11 22:24:30 2016 (r307070) >> @@ -0,0 +1,199 @@ >> +/*- >> + * Copyright (c) 2016 Netflix, Inc. >> + * All rights reserved. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer >> + * in this position and unchanged. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in the >> + * documentation and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR >> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. >> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, >> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT >> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#include >> +__FBSDID("$FreeBSD$"); >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include > As I asked in review, please use , not > >> +#include >> + >> +static d_ioctl_t efidev_ioctl; >> + >> +static struct cdevsw efi_cdevsw = { >> + .d_name = "efi", >> + .d_version = D_VERSION, >> + .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) >> +{ >> + int error; >> + >> + switch (cmd) { >> + case EFIIOC_GET_TABLE: >> + { >> + struct efi_get_table_ioc *egtioc = >> + (struct efi_get_table_ioc *)addr; >> + >> + error = efi_get_table(&egtioc->uuid, &egtioc->ptr); >> + break; >> + } >> + case EFIIOC_GET_TIME: >> + { >> + struct efi_tm *tm = (struct efi_tm *)addr; >> + >> + error = efi_get_time(tm); >> + break; >> + } >> + case EFIIOC_SET_TIME: >> + { >> + struct efi_tm *tm = (struct efi_tm *)addr; >> + >> + error = efi_set_time(tm); >> + break; >> + } >> + case EFIIOC_VAR_GET: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + void *data; >> + efi_char *name; >> + >> + data = malloc(ev->datasize, M_TEMP, M_WAITOK); >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vg_out; >> + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { >> + error = EINVAL; >> + goto vg_out; >> + } >> + >> + error = efi_var_get(name, &ev->vendor, &ev->attrib, >> + &ev->datasize, data); >> + >> + if (error == 0) { >> + error = copyout(data, ev->data, ev->datasize); >> + } else if (error == EOVERFLOW) { >> + /* >> + * Pass back the size we really need, but >> + * convert the error to 0 so the copyout >> + * happens. datasize was updated in the >> + * efi_var_get call. >> + */ >> + ev->data = NULL; >> + error = 0; >> + } >> +vg_out: >> + free(data, M_TEMP); >> + free(name, M_TEMP); >> + break; >> + } >> + case EFIIOC_VAR_NEXT: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + efi_char *name; >> + >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + if (name == NULL) { > The check is for impossible condition. > >> + error = ENOMEM; >> + goto vn_out; >> + } >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vn_out; >> + /* Note: namesize is the buffer size, not the string lenght */ >> + >> + error = efi_var_nextname(&ev->namesize, name, &ev->vendor); >> + if (error == 0) { >> + error = copyout(name, ev->name, ev->namesize); >> + } else if (error == EOVERFLOW) { >> + ev->name = NULL; >> + error = 0; >> + } >> + vn_out: >> + if (name != NULL) > The check is redundand. > >> + free(name, M_TEMP); >> + break; >> + } >> + case EFIIOC_VAR_SET: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + void *data = NULL; >> + efi_char *name; >> + >> + /* datasize == 0 -> delete (more or less) */ >> + if (ev->datasize > 0) >> + data = malloc(ev->datasize, M_TEMP, M_WAITOK); >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + if (ev->datasize) { >> + error = copyin(ev->data, data, ev->datasize); >> + if (error) >> + goto vs_out; >> + } >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vs_out; >> + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { >> + error = EINVAL; >> + goto vs_out; >> + } >> + >> + error = efi_var_set(name, &ev->vendor, ev->attrib, ev->datasize, >> + data); >> +vs_out: >> + if (data != NULL) > The check is redundand. > >> + free(data, M_TEMP); >> + free(name, M_TEMP); >> + break; >> + } >> + default: >> + error = ENOTTY; >> + break; >> + } >> + >> + return (error); >> +} >> + >> +int >> +efidev_init(struct cdev **cdev) >> +{ >> + >> + *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, >> + "efidev"); > It is still "/dev/efidev". Please rename as discussed. > >> + >> + return (0); >> +} >> + >> +int >> +efidev_uninit(struct cdev *cdev) >> +{ >> + >> + destroy_dev(cdev); >> + >> + return (0); >> +} >> >> Added: head/sys/i386/include/efi.h >> ============================================================================== >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >> +++ head/sys/i386/include/efi.h Tue Oct 11 22:24:30 2016 (r307070) >> @@ -0,0 +1,39 @@ >> +/*- >> + * Copyright (c) 2016 The FreeBSD Foundation >> + * All rights reserved. >> + * >> + * This software was developed by Konstantin Belousov >> + * under sponsorship from the FreeBSD Foundation. > It was not. > >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in the >> + * documentation and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> + * SUCH DAMAGE. >> + * >> + * $FreeBSD$ >> + */ >> + >> +#ifndef __I386_INCLUDE_EFI_H_ >> +#define __I386_INCLUDE_EFI_H_ >> + >> +#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ >> + >> +/* Note: we don't actually support this on i386 yet */ >> + >> +#endif /* __I386_INCLUDE_EFI_H_ */