From owner-svn-src-all@freebsd.org Sun May 12 01:31:14 2019 Return-Path: Delivered-To: svn-src-all@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 B3E2D15ACEC6; Sun, 12 May 2019 01:31:14 +0000 (UTC) (envelope-from unkadoug@gmail.com) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 33C5982C3B; Sun, 12 May 2019 01:31:14 +0000 (UTC) (envelope-from unkadoug@gmail.com) Received: by mail-ot1-x32a.google.com with SMTP id l17so8836267otq.1; Sat, 11 May 2019 18:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=bX2ERCFQLjJxYJRcj9FxHJiT4h4EnFjXkttzqyEKAbE=; b=j3HLkcii1GUDREkiAuPyhBlius/D0b6LW9wYlTKRv1p+n2phMjUUac14nkCTmKo6qq lWwuaVK7iaOC5BNOhUqnzC3JlGCHapdewVLBFv5E6Gt0HKXu7MgZf1WVQQklDI844i8R hu9H+2tG/NBwbyxPqiIfqbI1g1jJQ3Y93Q0YIjlvdPNvbQpkGZimUqNzUZQF2qg3cujS +GbhM+9KcoQgbnNIoiLn1kIFiic+ne+hIsaDi5IFjVVQiw7mAHzpQwlNlCJEovnCLOlw hyz08iHfXMHdwpa8pqOz6BjMXZa6YFKVPoU7O55ZdZyr3ccJlnxUj5Wp93Q8g/tuqL/A OIPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=bX2ERCFQLjJxYJRcj9FxHJiT4h4EnFjXkttzqyEKAbE=; b=gACU0V9bicRmIlZu2dIGigTwg3IMs83HXIIrAwexom3pyYE/M8nPzSJsdJnoE7u2+X AtwM3+82unhuxz5IRh7O3obsjqhwI5I3TbUvQ/GWMCBNQjn9IqAoN+jw+7cQWrLIyA0g 06w3rL9+8An0Odrx15h3SdVha34lIhfyuXJ4JRYl9lF/S1zp/2fmsqdgqQmJvMK6vz+n Ls0MSmIFIV8ufRHBLFtVZpaL2HREF9i9Aj2MS6pscA+uzi9puMZBArfMZ0/DRuU49QCh U5TaFOxV9WAPo/wPC9u74nMiuDGv9XRzJQW94MzJy0LycflPB7u5JSU75jp06FZMoavh fcRQ== X-Gm-Message-State: APjAAAWtvzsWct6lazAJSh3m24vLPoKbWawjDg3UXrxyVLFpXJzbe54r 5Caet6HQzYjEOwxy416iAZfeh0APg6NAmQ== X-Google-Smtp-Source: APXvYqzcjUWZuI8v+1tm9tI8SKhzSnBx9e3HY8vTF8rIawNaUkm4Eurw99LbWWhx0NdxSDVci11CxA== X-Received: by 2002:a9d:3f05:: with SMTP id m5mr12459812otc.59.1557624673477; Sat, 11 May 2019 18:31:13 -0700 (PDT) Received: from 108-254-203-202.lightspeed.hstntx.sbcglobal.net (108-254-203-202.lightspeed.hstntx.sbcglobal.net. [108.254.203.202]) by smtp.gmail.com with ESMTPSA id 33sm3694172ott.23.2019.05.11.18.31.12 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 11 May 2019 18:31:12 -0700 (PDT) Subject: Re: svn commit: r347484 - head/sys/kern To: Bruce Evans , Doug Moore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201905110909.x4B99A5L006389@repo.freebsd.org> <20190511202741.H1251@besplex.bde.org> From: Doug Moore Openpgp: preference=signencrypt Autocrypt: addr=unkadoug@gmail.com; keydata= mQENBFy53VQBCAD2UiGSouAAMcSIax5Sp9JtRSd9dYVuAmSraY7x5yOylq8yJ5IDvHZy5q3a FamaCHMpXxieiD/8yTnHIeHP4bg02oDD3ALs0hMAEz00pZlLdxeXRfDzAlMTqFF6USPjDUI8 J/WH+pciNT68bFVXFYVg+bgp4GIdi2Md8X8zQQnHY0xLyKE9FjVN1MlCk+62B6fFhMQIEvd5 RQdbGd+ljuoORD1ajljwP1waXKBfAN5RnIbAXppokgQvnwNRf1eZ7GnqSiwu0eaTHGBatPgr y2v5N19R5WxP2kiN95xdlJEwdUikAhWO1UncDxvXQoM1e68L/J85JSLLIgzuywKpBBtdABEB AAG0MERvdWcgTW9vcmUgKHd3dy5mcmVlYnNkLm9yZykgPGRvdWdtQGZyZWVic2Qub3JnPokB UgQTAQoAPBYhBHleNTGSVgOuQpfeg+iPIVPTudVuBQJcyljBAhsDBQkFo5qAAwsJCAUVCgkI CwUWAwIBAAIeAQIXgAAKCRDojyFT07nVbs4lB/49oHwi3YR7SQr43+59tBudmf3WdQ1SRi3G vJDufsrtsB7E9bIFXwFGvVDOMn/cfhNlzors3aM6UQr1N3TPqMAK4TaS12qGL3EvFQ0eVAF1 J+vhQCIjZtgFaCIjoPeQVbi2tVsHaCttBRJeHRIPruWlxngSGZ7eMfjlOY9Oupi809QjFO/3 7FHv+/Bw9HvzlUciY3wH6vLe4zE3Bhqz4lrQAAKey4XPwKwUgs7QK0qhHrlxy+mD0r8LYvwE +Y7WVu5bbDPbyWYZeI8rnCCKnoJ7VFxQd2/g3Jxc1alDg5LoHCssP7z8g9OG8GBXk1T5dRrA Vxlc8Rs3gSxg6b3+lt+CuQENBFy53VQBCADbHDoIQCMsyFFaNjzqZbrd8ntaMwpQ6hBL7Rnb LJSHa8jehZYyAdtWWbbttyVf66J3EAF6HyBXExw9fryuLU+yZfANI0D3cmmb51jCG6Bu8Nnk QTOf3N7cw1sYQSHH2PQlhWYc55Jbu/aJrwfVnEchLdbN8p2y4WXRLfhK32iOaQzMM2xHNk28 sXnAV5DRxQjvXY7IG7cT5Pfr2uAhXqPDDCZsMj9ghZ3aQyvr7q7jS1uzvSPsimOW4Hf9fJqi VxF2kMRH1hQNe1I4v79SaFtDXRSuYivEPV6epifWATwY66/U/jO55TqqDyFz/Bg+2CCpHyyZ GM9A+f86VxLEGc7hABEBAAGJATwEGAEIACYWIQR5XjUxklYDrkKX3oPojyFT07nVbgUCXLnd VAIbDAUJBaOagAAKCRDojyFT07nVbkhiB/0SVq6YcYwrz1j1lBUk7DCUPVALoNSiW4iNia52 7pWQdHGtsTVVCiEcB65qZo0DSrMsAvtGCRSzUebIQ6omDSDnWmbveXykr3vO0+pcRqsJPQKc ATRq2XjcBjZMKOD4A2XOS2t3hAM+oY4F9htQIY9gnvK6RdTtyafJonHpeeNkMC7KEwPGS6hz FU0lrfZxXQ1ipj0QOOgZ8ZomMXbSV5f8GwYSULMPOVmB9ak0ZCOoa451h0o3Hjcnrngw7ofF JFPbmPT2zbpXOm9PqshzTA10ngIETm2x4j5iVvCHEbOJCH8UQydNKrGFa3UBzqj1OoxAggqh CFx6S9PsRfm6+86cuQENBFy6y/MBCAC+ULdDmJZVs7GFnpBdKJnSnVIbX1dkGju1jkvg+7pA 82yX+0hZvIOh0x3Py8asbfqxFleVws59mGEAe5YpRyg+kn0fd14ethlIrsf0sG82b7QLyf9p xGuQBlhyHvgDgdeUGlz6kybVJ9e59ebtNYgjuEC/Glf/b55pmmkSXx5F/4l82Er7fhpiOg42 n7CLonP+AxLsR8L6AjCODedyKidSopcdH8dH6RTN9CmIYSPQq8vRiARrDLNvVQH4PQlv3s4C KqP6zSN3hMdLlLtvgd6UMdyuWKxRk0y0WhGa4bZ8oKPCo5Dr6o12OSEvx+Ue2QBQ67nVY5H6 SoCoopHHomeRABEBAAGJAtIEGAEKACYWIQR5XjUxklYDrkKX3oPojyFT07nVbgUCXLrL8wIb AgUJBaOagAGgCRDojyFT07nVbsDUIAQZAQoAfRYhBH6QdtAAogUD++RrUKO0e1Y/oUusBQJc usvzXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9wZW5wZ3AuZmlmdGhob3JzZW1h bi5uZXQ3RTkwNzZEMDAwQTIwNTAzRkJFNDZCNTBBM0I0N0I1NjNGQTE0QkFDAAoJEKO0e1Y/ oUusp/AH/0kmG5bylgh6Crg307jXoCQgZvtThaB9LGmf57ypUvnfrwt1n0Ex7cKcQnvSA+12 809K12QmR5D61AdU8HBaQdoLFj0rDi34raxgAY554+YiGuj9XagPEKMeb+iuvqvhetC6v7K8 eXqpaWIozIpFJCmElxGMSngAj/V6nOnm6XDSyfgaOCmnjOQRqe49uU+6R67gb7UB4J+XJHgP Wla91BTqsv3NLcwXINqP+iiHtgMLmrH1j0eNhxOk9+RLNf0YbZcGZHf7eWjcJbWcB13e0gF6 mR0RcQxClm89EVv2p+CPITpXTALrIb1/EX9O4bz9OuzdZk5FrWAUNHStBE6+McJz9Qf9Hs+Z vDizuv8NOX2YZeKRdBpWSsKRL32DkPrup6vMDVL1LIft3SJXLc+oWvy82fAm0HuGMXHq47Zc bvmHUJfnSrdhjHSB35R3BwzYZ4/lINDR90WgKw+NJNErmiIP3oPzlVNtLsQmAXXjAdysFuq6 VSW0TclJVIiBjLgnKvh0XzakzxdZ5pVpgCHzKggO+53lRhEkQIgLTRU0bVb/BQkqa8iGwUhB dGd4Sgy9sykO8/1C8ApYrsT51iG7956YWG14NOBuHXoBsdynCTAVYwSR7+7f3enNKzEpUKtg ALG/tpjXzp8gsOtBSlComvjQjZHfWe9+fLy2wJ98wi8q0n3xHA== Message-ID: Date: Sat, 11 May 2019 20:31:11 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190511202741.H1251@besplex.bde.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Rspamd-Queue-Id: 33C5982C3B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 01:31:14 -0000 On 5/11/19 5:52 AM, Bruce Evans wrote: > On Sat, 11 May 2019, Doug Moore wrote: >> +#ifdef HAVE_INLINE_FFS >> +    case sizeof(int): >> +        return (ffs(mask) - 1); >> +#endif > > This is unreachable, since sizeof(int) is 4 on all supported arches, and > sizeof(mask) is 8 on all arches. > Another FreeBSD developer has expressed to me that sizeof(mask) ought to become 4 on some 32-bit arches before too long, and I added this case in anticipation of that.  I see now that I should have waited. Doug Moore From owner-svn-src-all@freebsd.org Sun May 12 06:32:47 2019 Return-Path: Delivered-To: svn-src-all@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 B567D158DF6A; Sun, 12 May 2019 06:32:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5680C8A233; Sun, 12 May 2019 06:32:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B74F26E54; Sun, 12 May 2019 06:32:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6WkBF093872; Sun, 12 May 2019 06:32:46 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6Wkmr093871; Sun, 12 May 2019 06:32:46 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120632.x4C6Wkmr093871@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:32:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347500 - head/sys/libkern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/libkern X-SVN-Commit-Revision: 347500 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5680C8A233 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:32:47 -0000 Author: mjg Date: Sun May 12 06:32:46 2019 New Revision: 347500 URL: https://svnweb.freebsd.org/changeset/base/347500 Log: random(4): depessimize arc4random - __predict_false reseeding on entry as it is almost never true. - don't blindly atomic_cmpset as on x86 it ends up dirtying the cacheline. it almost ever succeeds per above - fetch the timestamp prior to getting the cpu number Reviewed by: cem Approved by: secteam (delphij) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20242 Modified: head/sys/libkern/arc4random.c Modified: head/sys/libkern/arc4random.c ============================================================================== --- head/sys/libkern/arc4random.c Sat May 11 22:58:25 2019 (r347499) +++ head/sys/libkern/arc4random.c Sun May 12 06:32:46 2019 (r347500) @@ -173,18 +173,20 @@ arc4rand(void *ptr, u_int len, int reseed) u_int length; u_int8_t *p; - if (reseed || atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE, ARC4_ENTR_SEED)) + if (__predict_false(reseed || + (arc4rand_iniseed_state == ARC4_ENTR_HAVE && + atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE, ARC4_ENTR_SEED)))) CHACHA20_FOREACH(chacha20) chacha20_randomstir(chacha20); - chacha20 = &chacha20inst[curcpu]; getmicrouptime(&tv); + chacha20 = &chacha20inst[curcpu]; /* We may get unlucky and be migrated off this CPU, but that is expected to be infrequent */ if ((chacha20->numbytes > CHACHA20_RESEED_BYTES) || (tv.tv_sec > chacha20->t_reseed)) chacha20_randomstir(chacha20); - mtx_lock(&chacha20->mtx); p = ptr; + mtx_lock(&chacha20->mtx); while (len) { length = MIN(CHACHA20_BUFFER_SIZE, len); chacha_encrypt_bytes(&chacha20->ctx, chacha20->m_buffer, p, length); From owner-svn-src-all@freebsd.org Sun May 12 06:34:59 2019 Return-Path: Delivered-To: svn-src-all@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 C0199158E015; Sun, 12 May 2019 06:34:59 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 647518A3CF; Sun, 12 May 2019 06:34:59 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 532DF26E60; Sun, 12 May 2019 06:34:59 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6Yxo4094024; Sun, 12 May 2019 06:34:59 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6YxFx094023; Sun, 12 May 2019 06:34:59 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120634.x4C6YxFx094023@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:34:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347501 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 347501 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 647518A3CF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:34:59 -0000 Author: mjg Date: Sun May 12 06:34:58 2019 New Revision: 347501 URL: https://svnweb.freebsd.org/changeset/base/347501 Log: amd64: stop re-reading curpc in suword Plugs re-reads missed in r341719 Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/support.S Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Sun May 12 06:32:46 2019 (r347500) +++ head/sys/amd64/amd64/support.S Sun May 12 06:34:58 2019 (r347501) @@ -1083,7 +1083,6 @@ ENTRY(suword_nosmap) movq %rsi,(%rdi) xorl %eax,%eax - movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) POP_FRAME_POINTER ret @@ -1102,7 +1101,6 @@ ENTRY(suword_smap) movq %rsi,(%rdi) clac xorl %eax,%eax - movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) POP_FRAME_POINTER ret @@ -1119,7 +1117,6 @@ ENTRY(suword32_nosmap) movl %esi,(%rdi) xorl %eax,%eax - movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) POP_FRAME_POINTER ret @@ -1138,7 +1135,6 @@ ENTRY(suword32_smap) movl %esi,(%rdi) clac xorl %eax,%eax - movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) POP_FRAME_POINTER ret From owner-svn-src-all@freebsd.org Sun May 12 06:36:56 2019 Return-Path: Delivered-To: svn-src-all@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 47D6C158E139; Sun, 12 May 2019 06:36:56 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E1F608A68A; Sun, 12 May 2019 06:36:55 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE02826E63; Sun, 12 May 2019 06:36:55 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6atqa094486; Sun, 12 May 2019 06:36:55 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6asUq094481; Sun, 12 May 2019 06:36:54 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120636.x4C6asUq094481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:36:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347502 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/include x86/x86 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 347502 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E1F608A68A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:36:56 -0000 Author: mjg Date: Sun May 12 06:36:54 2019 New Revision: 347502 URL: https://svnweb.freebsd.org/changeset/base/347502 Log: x86: store pending bitmapped IPIs in per-cpu areas This gets rid of the global cpu_ipi_pending array. While replace cmpset with fcmpset in the delivery code and opportunistically check if given IPI is already pending. Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/pcpu.h head/sys/i386/i386/mp_machdep.c head/sys/i386/include/pcpu.h head/sys/x86/include/x86_smp.h head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Sun May 12 06:34:58 2019 (r347501) +++ head/sys/amd64/amd64/mp_machdep.c Sun May 12 06:36:54 2019 (r347502) @@ -193,7 +193,6 @@ cpu_mp_start(void) /* Initialize the logical ID to APIC ID table. */ for (i = 0; i < MAXCPU; i++) { cpu_apic_ids[i] = -1; - cpu_ipi_pending[i] = 0; } /* Install an inter-CPU IPI for TLB invalidation */ Modified: head/sys/amd64/include/pcpu.h ============================================================================== --- head/sys/amd64/include/pcpu.h Sun May 12 06:34:58 2019 (r347501) +++ head/sys/amd64/include/pcpu.h Sun May 12 06:36:54 2019 (r347502) @@ -84,7 +84,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c uint32_t pc_pcid_gen; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[3288] /* pad to UMA_PCPU_ALLOC_SIZE */ + u_int pc_ipi_bitmap; \ + char __pad[3284] /* pad to UMA_PCPU_ALLOC_SIZE */ #define PC_DBREG_CMD_NONE 0 #define PC_DBREG_CMD_LOAD 1 Modified: head/sys/i386/i386/mp_machdep.c ============================================================================== --- head/sys/i386/i386/mp_machdep.c Sun May 12 06:34:58 2019 (r347501) +++ head/sys/i386/i386/mp_machdep.c Sun May 12 06:36:54 2019 (r347502) @@ -153,7 +153,6 @@ cpu_mp_start(void) /* Initialize the logical ID to APIC ID table. */ for (i = 0; i < MAXCPU; i++) { cpu_apic_ids[i] = -1; - cpu_ipi_pending[i] = 0; } /* Install an inter-CPU IPI for TLB invalidation */ Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Sun May 12 06:34:58 2019 (r347501) +++ head/sys/i386/include/pcpu.h Sun May 12 06:36:54 2019 (r347502) @@ -87,7 +87,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c caddr_t pc_pmap_eh_ptep; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[3610] + u_int pc_ipi_bitmap; \ + char __pad[3606] #ifdef _KERNEL Modified: head/sys/x86/include/x86_smp.h ============================================================================== --- head/sys/x86/include/x86_smp.h Sun May 12 06:34:58 2019 (r347501) +++ head/sys/x86/include/x86_smp.h Sun May 12 06:36:54 2019 (r347502) @@ -34,7 +34,6 @@ extern char *bootSTK; extern void *bootstacks[]; extern unsigned int boot_address; extern unsigned int bootMP_size; -extern volatile u_int cpu_ipi_pending[]; extern volatile int aps_ready; extern struct mtx ap_boot_mtx; extern int cpu_logical; Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Sun May 12 06:34:58 2019 (r347501) +++ head/sys/x86/x86/mp_x86.c Sun May 12 06:36:54 2019 (r347502) @@ -137,9 +137,6 @@ _Static_assert(MAXCPU <= MAX_APIC_ID, _Static_assert(xAPIC_MAX_APIC_ID <= MAX_APIC_ID, "xAPIC_MAX_APIC_ID cannot be larger that MAX_APIC_ID"); -/* Holds pending bitmap based IPIs per CPU */ -volatile u_int cpu_ipi_pending[MAXCPU]; - static void release_aps(void *dummy); static void cpustop_handler_post(u_int cpu); @@ -1224,19 +1221,24 @@ ipi_startup(int apic_id, int vector) void ipi_send_cpu(int cpu, u_int ipi) { - u_int bitmap, old_pending, new_pending; + u_int bitmap, old, new; + u_int *cpu_bitmap; KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); if (IPI_IS_BITMAPED(ipi)) { bitmap = 1 << ipi; ipi = IPI_BITMAP_VECTOR; - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) + cpu_bitmap = &cpuid_to_pcpu[cpu]->pc_ipi_bitmap; + old = *cpu_bitmap; + for (;;) { + if ((old & bitmap) == bitmap) + break; + new = old | bitmap; + if (atomic_fcmpset_int(cpu_bitmap, &old, new)) + break; + } + if (old) return; } lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); @@ -1255,7 +1257,7 @@ ipi_bitmap_handler(struct trapframe frame) td->td_intr_nesting_level++; oldframe = td->td_intr_frame; td->td_intr_frame = &frame; - ipi_bitmap = atomic_readandclear_int(&cpu_ipi_pending[cpu]); + ipi_bitmap = atomic_readandclear_int(&cpuid_to_pcpu[cpu]->pc_ipi_bitmap); if (ipi_bitmap & (1 << IPI_PREEMPT)) { #ifdef COUNT_IPIS (*ipi_preempt_counts[cpu])++; From owner-svn-src-all@freebsd.org Sun May 12 06:39:31 2019 Return-Path: Delivered-To: svn-src-all@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 7BB7D158E2AC; Sun, 12 May 2019 06:39:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 211258A89E; Sun, 12 May 2019 06:39:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F093526E66; Sun, 12 May 2019 06:39:30 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6dUeU094626; Sun, 12 May 2019 06:39:30 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6dU31094625; Sun, 12 May 2019 06:39:30 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120639.x4C6dU31094625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:39:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347503 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 347503 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 211258A89E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:39:31 -0000 Author: mjg Date: Sun May 12 06:39:30 2019 New Revision: 347503 URL: https://svnweb.freebsd.org/changeset/base/347503 Log: cache: push sdt probes in cache_zap_locked to code doing the work Avoids branching to check which probe to evaluate. Very same check was being done later to do the actual work. Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Sun May 12 06:36:54 2019 (r347502) +++ head/sys/kern/vfs_cache.c Sun May 12 06:39:30 2019 (r347503) @@ -851,19 +851,16 @@ cache_zap_locked(struct namecache *ncp, bool neg_locke CTR2(KTR_VFS, "cache_zap(%p) vp %p", ncp, (ncp->nc_flag & NCF_NEGATIVE) ? NULL : ncp->nc_vp); + LIST_REMOVE(ncp, nc_hash); if (!(ncp->nc_flag & NCF_NEGATIVE)) { SDT_PROBE3(vfs, namecache, zap, done, ncp->nc_dvp, ncp->nc_name, ncp->nc_vp); - } else { - SDT_PROBE3(vfs, namecache, zap_negative, done, ncp->nc_dvp, - ncp->nc_name, ncp->nc_neghits); - } - LIST_REMOVE(ncp, nc_hash); - if (!(ncp->nc_flag & NCF_NEGATIVE)) { TAILQ_REMOVE(&ncp->nc_vp->v_cache_dst, ncp, nc_dst); if (ncp == ncp->nc_vp->v_cache_dd) ncp->nc_vp->v_cache_dd = NULL; } else { + SDT_PROBE3(vfs, namecache, zap_negative, done, ncp->nc_dvp, + ncp->nc_name, ncp->nc_neghits); cache_negative_remove(ncp, neg_locked); } if (ncp->nc_flag & NCF_ISDOTDOT) { From owner-svn-src-all@freebsd.org Sun May 12 06:42:18 2019 Return-Path: Delivered-To: svn-src-all@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 86980158E599; Sun, 12 May 2019 06:42:18 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2DA978AC94; Sun, 12 May 2019 06:42:18 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0914E2700A; Sun, 12 May 2019 06:42:18 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6gH6T098797; Sun, 12 May 2019 06:42:17 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6gH30098796; Sun, 12 May 2019 06:42:17 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120642.x4C6gH30098796@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:42:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347504 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 347504 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2DA978AC94 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:42:18 -0000 Author: mjg Date: Sun May 12 06:42:17 2019 New Revision: 347504 URL: https://svnweb.freebsd.org/changeset/base/347504 Log: amd64: fixup MEMMOVE comment (10 -> r10) Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/support.S Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Sun May 12 06:39:30 2019 (r347503) +++ head/sys/amd64/amd64/support.S Sun May 12 06:42:17 2019 (r347504) @@ -205,7 +205,7 @@ END(memcmp) * rsi - source * rdx - count * - * The macro possibly clobbers the above and: rcx, r8, r9, 10 + * The macro possibly clobbers the above and: rcx, r8, r9, r10 * It does not clobber rax nor r11. */ .macro MEMMOVE erms overlap begin end From owner-svn-src-all@freebsd.org Sun May 12 06:59:23 2019 Return-Path: Delivered-To: svn-src-all@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 CBFC4158EF9D; Sun, 12 May 2019 06:59:23 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 71EC08B819; Sun, 12 May 2019 06:59:23 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4D2B6271C7; Sun, 12 May 2019 06:59:23 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C6xNJb005163; Sun, 12 May 2019 06:59:23 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C6xNXS005162; Sun, 12 May 2019 06:59:23 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120659.x4C6xNXS005162@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 06:59:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347505 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 347505 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 71EC08B819 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 06:59:24 -0000 Author: mjg Date: Sun May 12 06:59:22 2019 New Revision: 347505 URL: https://svnweb.freebsd.org/changeset/base/347505 Log: cache: bump numcache on entry, while here fix lnumcache type Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Sun May 12 06:42:17 2019 (r347504) +++ head/sys/kern/vfs_cache.c Sun May 12 06:59:22 2019 (r347505) @@ -1632,7 +1632,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, int flag; int len; bool neg_locked; - int lnumcache; + u_long lnumcache; CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr); VNASSERT(vp == NULL || (vp->v_iflag & VI_DOOMED) == 0, vp, @@ -1646,7 +1646,8 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, /* * Avoid blowout in namecache entries. */ - if (__predict_false(numcache >= desiredvnodes * ncsizefactor)) + lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; + if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor)) return; cache_celockstate_init(&cel); @@ -1825,7 +1826,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, ncp->nc_name); } cache_enter_unlock(&cel); - lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; if (numneg * ncnegfactor > lnumcache) cache_negative_zap_one(); cache_free(ndd); From owner-svn-src-all@freebsd.org Sun May 12 07:11:45 2019 Return-Path: Delivered-To: svn-src-all@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 A8A3C158F458; Sun, 12 May 2019 07:11:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4520D8BE68; Sun, 12 May 2019 07:11:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AE60274E4; Sun, 12 May 2019 07:11:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C7Bi0D012104; Sun, 12 May 2019 07:11:44 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C7Bifm012103; Sun, 12 May 2019 07:11:44 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120711.x4C7Bifm012103@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 07:11:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347506 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 347506 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4520D8BE68 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 07:11:45 -0000 Author: mjg Date: Sun May 12 07:11:44 2019 New Revision: 347506 URL: https://svnweb.freebsd.org/changeset/base/347506 Log: amd64: tidy up pagezero*/pagecopy (movq -> movl) Sponsored by: The FreeBSD Foundation Modified: head/sys/amd64/amd64/support.S Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Sun May 12 06:59:22 2019 (r347505) +++ head/sys/amd64/amd64/support.S Sun May 12 07:11:44 2019 (r347506) @@ -43,7 +43,7 @@ /* Address: %rdi */ ENTRY(pagezero_std) PUSH_FRAME_POINTER - movq $PAGE_SIZE/8,%rcx + movl $PAGE_SIZE/8,%ecx xorl %eax,%eax rep stosq @@ -53,7 +53,7 @@ END(pagezero_std) ENTRY(pagezero_erms) PUSH_FRAME_POINTER - movq $PAGE_SIZE,%rcx + movl $PAGE_SIZE,%ecx xorl %eax,%eax rep stosb @@ -66,7 +66,7 @@ END(pagezero_erms) */ ENTRY(pagecopy) PUSH_FRAME_POINTER - movq $PAGE_SIZE/8,%rcx + movl $PAGE_SIZE/8,%ecx movq %rdi,%r9 movq %rsi,%rdi movq %r9,%rsi From owner-svn-src-all@freebsd.org Sun May 12 07:13:27 2019 Return-Path: Delivered-To: svn-src-all@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 E6B8D158F4F8; Sun, 12 May 2019 07:13:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8797D8C02C; Sun, 12 May 2019 07:13:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5CD1027520; Sun, 12 May 2019 07:13:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C7DQFo015479; Sun, 12 May 2019 07:13:26 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C7DQkW015478; Sun, 12 May 2019 07:13:26 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120713.x4C7DQkW015478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 07:13:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347507 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 347507 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8797D8C02C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 07:13:27 -0000 Author: mjg Date: Sun May 12 07:13:25 2019 New Revision: 347507 URL: https://svnweb.freebsd.org/changeset/base/347507 Log: seqc: fix sed-introduced typos (seqcuence -> sequence) Sponsored by: The FreeBSD Foundation Modified: head/sys/sys/seqc.h Modified: head/sys/sys/seqc.h ============================================================================== --- head/sys/sys/seqc.h Sun May 12 07:11:44 2019 (r347506) +++ head/sys/sys/seqc.h Sun May 12 07:13:25 2019 (r347507) @@ -44,9 +44,9 @@ typedef uint32_t seqc_t; * seqc allows readers and writers to work with a consistent snapshot. Modifying * operations must be enclosed within a transaction delineated by * seqc_write_beg/seqc_write_end. The trick works by having the writer increment - * the seqcuence number twice, at the beginning and end of the transaction. - * The reader detects that the seqcuence number has not changed between its start - * and end, and that the seqcuence number is even, to validate consistency. + * the sequence number twice, at the beginning and end of the transaction. + * The reader detects that the sequence number has not changed between its start + * and end, and that the sequence number is even, to validate consistency. * * Some fencing (both hard fencing and compiler barriers) may be needed, * depending on the cpu. Modern AMD cpus provide strong enough guarantees to not From owner-svn-src-all@freebsd.org Sun May 12 07:53:25 2019 Return-Path: Delivered-To: svn-src-all@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 25B8615900A7; Sun, 12 May 2019 07:53:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BE2268CFEE; Sun, 12 May 2019 07:53:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9870127BC5; Sun, 12 May 2019 07:53:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C7rOWN036323; Sun, 12 May 2019 07:53:24 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C7rOXO036322; Sun, 12 May 2019 07:53:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905120753.x4C7rOXO036322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 12 May 2019 07:53:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347508 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 347508 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BE2268CFEE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.955,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 07:53:25 -0000 Author: kib Date: Sun May 12 07:53:24 2019 New Revision: 347508 URL: https://svnweb.freebsd.org/changeset/base/347508 Log: MFC r347150, r347180: Do not collapse objects with OBJ_NOSPLIT backing swap or default object. Modified: stable/12/sys/vm/vm_object.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_object.c ============================================================================== --- stable/12/sys/vm/vm_object.c Sun May 12 07:13:25 2019 (r347507) +++ stable/12/sys/vm/vm_object.c Sun May 12 07:53:24 2019 (r347508) @@ -1748,8 +1748,8 @@ vm_object_collapse(vm_object_t object) VM_OBJECT_WLOCK(backing_object); if (backing_object->handle != NULL || (backing_object->type != OBJT_DEFAULT && - backing_object->type != OBJT_SWAP) || - (backing_object->flags & OBJ_DEAD) || + backing_object->type != OBJT_SWAP) || + (backing_object->flags & (OBJ_DEAD | OBJ_NOSPLIT)) != 0 || object->handle != NULL || (object->type != OBJT_DEFAULT && object->type != OBJT_SWAP) || From owner-svn-src-all@freebsd.org Sun May 12 07:55:26 2019 Return-Path: Delivered-To: svn-src-all@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 BE09F15902B7; Sun, 12 May 2019 07:55:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 645608D24D; Sun, 12 May 2019 07:55:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2E18727BC6; Sun, 12 May 2019 07:55:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C7tQe2036487; Sun, 12 May 2019 07:55:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C7tQ4u036486; Sun, 12 May 2019 07:55:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905120755.x4C7tQ4u036486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 12 May 2019 07:55:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347509 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 347509 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 645608D24D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.955,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 07:55:26 -0000 Author: kib Date: Sun May 12 07:55:25 2019 New Revision: 347509 URL: https://svnweb.freebsd.org/changeset/base/347509 Log: MFC r347150, r347180: Do not collapse objects with OBJ_NOSPLIT backing swap or default object. Modified: stable/11/sys/vm/vm_object.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_object.c ============================================================================== --- stable/11/sys/vm/vm_object.c Sun May 12 07:53:24 2019 (r347508) +++ stable/11/sys/vm/vm_object.c Sun May 12 07:55:25 2019 (r347509) @@ -1777,8 +1777,8 @@ vm_object_collapse(vm_object_t object) VM_OBJECT_WLOCK(backing_object); if (backing_object->handle != NULL || (backing_object->type != OBJT_DEFAULT && - backing_object->type != OBJT_SWAP) || - (backing_object->flags & OBJ_DEAD) || + backing_object->type != OBJT_SWAP) || + (backing_object->flags & (OBJ_DEAD | OBJ_NOSPLIT)) != 0 || object->handle != NULL || (object->type != OBJT_DEFAULT && object->type != OBJT_SWAP) || From owner-svn-src-all@freebsd.org Sun May 12 07:56:02 2019 Return-Path: Delivered-To: svn-src-all@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 743E81590334; Sun, 12 May 2019 07:56:02 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 177E88D368; Sun, 12 May 2019 07:56:02 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E530927BC7; Sun, 12 May 2019 07:56:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4C7u1RR036562; Sun, 12 May 2019 07:56:01 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4C7u1eL036561; Sun, 12 May 2019 07:56:01 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201905120756.x4C7u1eL036561@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 12 May 2019 07:56:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347510 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 347510 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 177E88D368 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 07:56:02 -0000 Author: mjg Date: Sun May 12 07:56:01 2019 New Revision: 347510 URL: https://svnweb.freebsd.org/changeset/base/347510 Log: cache: fix a brainfart in r347505 If bumping over the counter goes over the limit we have to decrement it back. Previous code would only bump the counter after adding the entry (thus allowing the cache to go over the limit). Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Sun May 12 07:55:25 2019 (r347509) +++ head/sys/kern/vfs_cache.c Sun May 12 07:56:01 2019 (r347510) @@ -1647,8 +1647,10 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, * Avoid blowout in namecache entries. */ lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; - if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor)) + if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor)) { + atomic_add_long(&numcache, -1); return; + } cache_celockstate_init(&cel); ndd = NULL; From owner-svn-src-all@freebsd.org Sun May 12 11:45:21 2019 Return-Path: Delivered-To: svn-src-all@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 9421F1595024; Sun, 12 May 2019 11:45:21 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 115D16CD81; Sun, 12 May 2019 11:45:20 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id E5AB5105E529; Sun, 12 May 2019 21:45:08 +1000 (AEST) Date: Sun, 12 May 2019 21:45:07 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Doug Moore cc: Bruce Evans , Doug Moore , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r347484 - head/sys/kern In-Reply-To: Message-ID: <20190512212143.M868@besplex.bde.org> References: <201905110909.x4B99A5L006389@repo.freebsd.org> <20190511202741.H1251@besplex.bde.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=P6RKvmIu c=1 sm=1 tr=0 cx=a_idp_d a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=nlC_4_pT8q9DhB4Ho9EA:9 a=dJQolKwh0MkX_D4bUnwA:9 a=45ClL6m2LaAA:10 X-Rspamd-Queue-Id: 115D16CD81 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.98)[-0.980,0] Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 11:45:21 -0000 On Sat, 11 May 2019, Doug Moore wrote: > On 5/11/19 5:52 AM, Bruce Evans wrote: >> On Sat, 11 May 2019, Doug Moore wrote: >>> +#ifdef HAVE_INLINE_FFS >>> +=C2=A0=C2=A0=C2=A0 case sizeof(int): >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (ffs(mask) - 1); >>> +#endif >> >> This is unreachable, since sizeof(int) is 4 on all supported arches, and >> sizeof(mask) is 8 on all arches. >> > Another FreeBSD developer has expressed to me that sizeof(mask) ought to > become 4 on some 32-bit arches before too long, and I added this case in > anticipation of that.=C2=A0 I see now that I should have waited. I also don't like the use of unsigned long for __fd_mask and bitstr_t. This asks for a a pessimal type that is twice as wide as a machine register, but is not so pessimal in practice since longs are rarely implemented correctly except on systems with 16-bit machine registers. The mask type u_daddr_t is both logically wrong (masks have nothing to do with daddr_t's) and gives a pessimal bitstring type more often in practice: - in FreeBSD-4, [u_]daddr_t was 32 bits, so misusing it for bitstrings was pessimal on 64-bit arches - expanding [u_]daddr_t to 64 bits in FreeBSD-5 (r96572-96851 only 17 years ago) made it pessimal for bitstrings on 32-bit arches. The pessimization would be smaller if ffs64() exists and is inlined to 32-bit ffs()'s. Using the long long abomination asks for double the pessimizations and machine dependencies as using long. In practice, expanding long long to larger than 64 bits would break ABIs so it is not much worse than a spelling error for int64_t. Bruce From owner-svn-src-all@freebsd.org Sun May 12 12:30:47 2019 Return-Path: Delivered-To: svn-src-all@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 E4F1215965FD; Sun, 12 May 2019 12:30:46 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 881926E208; Sun, 12 May 2019 12:30:46 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 647A52A8C3; Sun, 12 May 2019 12:30:46 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4CCUkRb078350; Sun, 12 May 2019 12:30:46 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4CCUjp9078347; Sun, 12 May 2019 12:30:45 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201905121230.x4CCUjp9078347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 12 May 2019 12:30:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347511 - in stable: 11/sys/dev/iwi 11/sys/dev/otus 11/sys/dev/usb/wlan 12/sys/dev/iwi 12/sys/dev/otus 12/sys/dev/usb/wlan X-SVN-Group: stable-11 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in stable: 11/sys/dev/iwi 11/sys/dev/otus 11/sys/dev/usb/wlan 12/sys/dev/iwi 12/sys/dev/otus 12/sys/dev/usb/wlan X-SVN-Commit-Revision: 347511 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 881926E208 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.92)[-0.918,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 12:30:47 -0000 Author: avos Date: Sun May 12 12:30:45 2019 New Revision: 347511 URL: https://svnweb.freebsd.org/changeset/base/347511 Log: MFC r346073: urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8) Was tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode. Modified: stable/11/sys/dev/iwi/if_iwi.c stable/11/sys/dev/otus/if_otus.c stable/11/sys/dev/usb/wlan/if_urtw.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/dev/iwi/if_iwi.c stable/12/sys/dev/otus/if_otus.c stable/12/sys/dev/usb/wlan/if_urtw.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/dev/iwi/if_iwi.c ============================================================================== --- stable/11/sys/dev/iwi/if_iwi.c Sun May 12 07:56:01 2019 (r347510) +++ stable/11/sys/dev/iwi/if_iwi.c Sun May 12 12:30:45 2019 (r347511) @@ -2549,16 +2549,19 @@ static int iwi_config(struct iwi_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); struct iwi_configuration config; struct iwi_rateset rs; struct iwi_txpower power; + uint8_t *macaddr; uint32_t data; int error, i; IWI_LOCK_ASSERT(sc); - DPRINTF(("Setting MAC address to %6D\n", ic->ic_macaddr, ":")); - error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, ic->ic_macaddr, + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + DPRINTF(("Setting MAC address to %6D\n", macaddr, ":")); + error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, macaddr, IEEE80211_ADDR_LEN); if (error != 0) return error; Modified: stable/11/sys/dev/otus/if_otus.c ============================================================================== --- stable/11/sys/dev/otus/if_otus.c Sun May 12 07:56:01 2019 (r347510) +++ stable/11/sys/dev/otus/if_otus.c Sun May 12 12:30:45 2019 (r347511) @@ -3095,7 +3095,7 @@ otus_set_operating_mode(struct otus_softc *sc) */ IEEE80211_ADDR_COPY(bssid, zero_macaddr); vap = TAILQ_FIRST(&ic->ic_vaps); - macaddr = ic->ic_macaddr; + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; switch (ic->ic_opmode) { case IEEE80211_M_STA: Modified: stable/11/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- stable/11/sys/dev/usb/wlan/if_urtw.c Sun May 12 07:56:01 2019 (r347510) +++ stable/11/sys/dev/usb/wlan/if_urtw.c Sun May 12 12:30:45 2019 (r347511) @@ -744,6 +744,7 @@ static void urtw_free_tx_data_list(struct urtw_softc static void urtw_free_rx_data_list(struct urtw_softc *); static void urtw_free_data_list(struct urtw_softc *, struct urtw_data data[], int, int); +static usb_error_t urtw_set_macaddr(struct urtw_softc *, const uint8_t *); static usb_error_t urtw_adapter_start(struct urtw_softc *); static usb_error_t urtw_adapter_start_b(struct urtw_softc *); static usb_error_t urtw_set_mode(struct urtw_softc *, uint32_t); @@ -1179,9 +1180,23 @@ fail: } static usb_error_t +urtw_set_macaddr(struct urtw_softc *sc, const uint8_t *macaddr) +{ + usb_error_t error; + + urtw_write32_m(sc, URTW_MAC0, ((const uint32_t *)macaddr)[0]); + urtw_write16_m(sc, URTW_MAC4, ((const uint32_t *)macaddr)[1] & 0xffff); + +fail: + return (error); +} + +static usb_error_t urtw_adapter_start(struct urtw_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + const uint8_t *macaddr; usb_error_t error; error = urtw_reset(sc); @@ -1201,8 +1216,11 @@ urtw_adapter_start(struct urtw_softc *sc) if (error) goto fail; /* applying MAC address again. */ - urtw_write32_m(sc, URTW_MAC0, ((uint32_t *)ic->ic_macaddr)[0]); - urtw_write16_m(sc, URTW_MAC4, ((uint32_t *)ic->ic_macaddr)[1] & 0xffff); + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + urtw_set_macaddr(sc, macaddr); + if (error) + goto fail; + error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); if (error) goto fail; @@ -3185,6 +3203,8 @@ static usb_error_t urtw_8225v2b_rf_init(struct urtw_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + const uint8_t *macaddr; unsigned int i; uint8_t data8; usb_error_t error; @@ -3232,8 +3252,10 @@ urtw_8225v2b_rf_init(struct urtw_softc *sc) urtw_write8_m(sc, URTW_CONFIG1, data8); /* applying MAC address again. */ - urtw_write32_m(sc, URTW_MAC0, ((uint32_t *)ic->ic_macaddr)[0]); - urtw_write16_m(sc, URTW_MAC4, ((uint32_t *)ic->ic_macaddr)[1] & 0xffff); + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + error = urtw_set_macaddr(sc, macaddr); + if (error) + goto fail; error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); if (error) From owner-svn-src-all@freebsd.org Sun May 12 12:30:47 2019 Return-Path: Delivered-To: svn-src-all@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 AA0671596603; Sun, 12 May 2019 12:30:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CECB6E20D; Sun, 12 May 2019 12:30:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28A312A8C5; Sun, 12 May 2019 12:30:47 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4CCUlD9078358; Sun, 12 May 2019 12:30:47 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4CCUkGs078355; Sun, 12 May 2019 12:30:46 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201905121230.x4CCUkGs078355@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 12 May 2019 12:30:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347511 - in stable: 11/sys/dev/iwi 11/sys/dev/otus 11/sys/dev/usb/wlan 12/sys/dev/iwi 12/sys/dev/otus 12/sys/dev/usb/wlan X-SVN-Group: stable-12 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in stable: 11/sys/dev/iwi 11/sys/dev/otus 11/sys/dev/usb/wlan 12/sys/dev/iwi 12/sys/dev/otus 12/sys/dev/usb/wlan X-SVN-Commit-Revision: 347511 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4CECB6E20D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.92)[-0.918,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 12:30:47 -0000 Author: avos Date: Sun May 12 12:30:45 2019 New Revision: 347511 URL: https://svnweb.freebsd.org/changeset/base/347511 Log: MFC r346073: urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8) Was tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode. Modified: stable/12/sys/dev/iwi/if_iwi.c stable/12/sys/dev/otus/if_otus.c stable/12/sys/dev/usb/wlan/if_urtw.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/iwi/if_iwi.c stable/11/sys/dev/otus/if_otus.c stable/11/sys/dev/usb/wlan/if_urtw.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/iwi/if_iwi.c ============================================================================== --- stable/12/sys/dev/iwi/if_iwi.c Sun May 12 07:56:01 2019 (r347510) +++ stable/12/sys/dev/iwi/if_iwi.c Sun May 12 12:30:45 2019 (r347511) @@ -2576,15 +2576,18 @@ static int iwi_config(struct iwi_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); struct iwi_configuration config; struct iwi_txpower power; + uint8_t *macaddr; uint32_t data; int error, i; IWI_LOCK_ASSERT(sc); - DPRINTF(("Setting MAC address to %6D\n", ic->ic_macaddr, ":")); - error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, ic->ic_macaddr, + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + DPRINTF(("Setting MAC address to %6D\n", macaddr, ":")); + error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, macaddr, IEEE80211_ADDR_LEN); if (error != 0) return error; Modified: stable/12/sys/dev/otus/if_otus.c ============================================================================== --- stable/12/sys/dev/otus/if_otus.c Sun May 12 07:56:01 2019 (r347510) +++ stable/12/sys/dev/otus/if_otus.c Sun May 12 12:30:45 2019 (r347511) @@ -3108,7 +3108,7 @@ otus_set_operating_mode(struct otus_softc *sc) */ IEEE80211_ADDR_COPY(bssid, zero_macaddr); vap = TAILQ_FIRST(&ic->ic_vaps); - macaddr = ic->ic_macaddr; + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; switch (ic->ic_opmode) { case IEEE80211_M_STA: Modified: stable/12/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- stable/12/sys/dev/usb/wlan/if_urtw.c Sun May 12 07:56:01 2019 (r347510) +++ stable/12/sys/dev/usb/wlan/if_urtw.c Sun May 12 12:30:45 2019 (r347511) @@ -752,6 +752,7 @@ static void urtw_free_tx_data_list(struct urtw_softc static void urtw_free_rx_data_list(struct urtw_softc *); static void urtw_free_data_list(struct urtw_softc *, struct urtw_data data[], int, int); +static usb_error_t urtw_set_macaddr(struct urtw_softc *, const uint8_t *); static usb_error_t urtw_adapter_start(struct urtw_softc *); static usb_error_t urtw_adapter_start_b(struct urtw_softc *); static usb_error_t urtw_set_mode(struct urtw_softc *, uint32_t); @@ -1187,9 +1188,23 @@ fail: } static usb_error_t +urtw_set_macaddr(struct urtw_softc *sc, const uint8_t *macaddr) +{ + usb_error_t error; + + urtw_write32_m(sc, URTW_MAC0, ((const uint32_t *)macaddr)[0]); + urtw_write16_m(sc, URTW_MAC4, ((const uint32_t *)macaddr)[1] & 0xffff); + +fail: + return (error); +} + +static usb_error_t urtw_adapter_start(struct urtw_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + const uint8_t *macaddr; usb_error_t error; error = urtw_reset(sc); @@ -1209,8 +1224,11 @@ urtw_adapter_start(struct urtw_softc *sc) if (error) goto fail; /* applying MAC address again. */ - urtw_write32_m(sc, URTW_MAC0, ((uint32_t *)ic->ic_macaddr)[0]); - urtw_write16_m(sc, URTW_MAC4, ((uint32_t *)ic->ic_macaddr)[1] & 0xffff); + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + urtw_set_macaddr(sc, macaddr); + if (error) + goto fail; + error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); if (error) goto fail; @@ -3180,6 +3198,8 @@ static usb_error_t urtw_8225v2b_rf_init(struct urtw_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + const uint8_t *macaddr; unsigned int i; uint8_t data8; usb_error_t error; @@ -3227,8 +3247,10 @@ urtw_8225v2b_rf_init(struct urtw_softc *sc) urtw_write8_m(sc, URTW_CONFIG1, data8); /* applying MAC address again. */ - urtw_write32_m(sc, URTW_MAC0, ((uint32_t *)ic->ic_macaddr)[0]); - urtw_write16_m(sc, URTW_MAC4, ((uint32_t *)ic->ic_macaddr)[1] & 0xffff); + macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; + error = urtw_set_macaddr(sc, macaddr); + if (error) + goto fail; error = urtw_set_mode(sc, URTW_EPROM_CMD_NORMAL); if (error) From owner-svn-src-all@freebsd.org Sun May 12 15:27:02 2019 Return-Path: Delivered-To: svn-src-all@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 2A16E15999F4; Sun, 12 May 2019 15:27:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C270B72DC9; Sun, 12 May 2019 15:27:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8FDF92C68F; Sun, 12 May 2019 15:27:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4CFR1w1071629; Sun, 12 May 2019 15:27:01 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4CFR1eO071628; Sun, 12 May 2019 15:27:01 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201905121527.x4CFR1eO071628@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sun, 12 May 2019 15:27:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347512 - head/sys/arm/allwinner/clkng X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner/clkng X-SVN-Commit-Revision: 347512 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C270B72DC9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.94)[-0.939,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 15:27:02 -0000 Author: manu Date: Sun May 12 15:27:01 2019 New Revision: 347512 URL: https://svnweb.freebsd.org/changeset/base/347512 Log: arm: allwinner: aw_clk_nm: Don't reparent the clock if we didn't ask When looking for the best frequency don't change the clock parent if the clock wasn't configured to do that. Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c ============================================================================== --- head/sys/arm/allwinner/clkng/aw_clk_nm.c Sun May 12 12:30:45 2019 (r347511) +++ head/sys/arm/allwinner/clkng/aw_clk_nm.c Sun May 12 15:27:01 2019 (r347512) @@ -236,7 +236,7 @@ aw_clk_nm_set_freq(struct clknode *clk, uint64_t fpare return (ERANGE); } - if (p_idx != best_parent) + if ((sc->flags & AW_CLK_REPARENT) != 0 && p_idx != best_parent) clknode_set_parent_by_idx(clk, best_parent); DEVICE_LOCK(clk); From owner-svn-src-all@freebsd.org Sun May 12 16:17:07 2019 Return-Path: Delivered-To: svn-src-all@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 37D11159AA4A; Sun, 12 May 2019 16:17:07 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BFC8C745D4; Sun, 12 May 2019 16:17:06 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94AAA2CEEA; Sun, 12 May 2019 16:17:06 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4CGH6Lg097226; Sun, 12 May 2019 16:17:06 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4CGH5CU097220; Sun, 12 May 2019 16:17:05 GMT (envelope-from br@FreeBSD.org) Message-Id: <201905121617.x4CGH5CU097220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Sun, 12 May 2019 16:17:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347514 - in head/sys/riscv: include riscv X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys/riscv: include riscv X-SVN-Commit-Revision: 347514 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BFC8C745D4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 12 May 2019 16:17:07 -0000 Author: br Date: Sun May 12 16:17:05 2019 New Revision: 347514 URL: https://svnweb.freebsd.org/changeset/base/347514 Log: Add support for HiFive Unleashed -- the board with a multi-core RISC-V SoC from SiFive, Inc. The first core on this SoC (hart 0) is a 64-bit microcontroller. o Pick a hart to run boot process using hart lottery. This allows to exclude hart 0 from running the boot process. (BBL releases hart 0 after the main harts, so it never wins the lottery). o Renumber CPUs early on boot. Exclude non-MMU cores. Store the original hart ID in struct pcpu. This allows to find out the correct destination for IPIs and remote sfence calls. Thanks to SiFive, Inc for the board provided. Reviewed by: markj Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20225 Modified: head/sys/riscv/include/pcpu.h head/sys/riscv/riscv/intr_machdep.c head/sys/riscv/riscv/locore.S head/sys/riscv/riscv/machdep.c head/sys/riscv/riscv/mp_machdep.c head/sys/riscv/riscv/pmap.c Modified: head/sys/riscv/include/pcpu.h ============================================================================== --- head/sys/riscv/include/pcpu.h Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/include/pcpu.h Sun May 12 16:17:05 2019 (r347514) @@ -47,7 +47,8 @@ #define PCPU_MD_FIELDS \ struct pmap *pc_curpmap; /* Currently active pmap */ \ uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \ - char __pad[61] + uint32_t pc_hart; /* Hart ID */ \ + char __pad[57] #ifdef _KERNEL Modified: head/sys/riscv/riscv/intr_machdep.c ============================================================================== --- head/sys/riscv/riscv/intr_machdep.c Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/riscv/intr_machdep.c Sun May 12 16:17:05 2019 (r347514) @@ -207,7 +207,7 @@ ipi_send(struct pcpu *pc, int ipi) CTR3(KTR_SMP, "%s: cpu=%d, ipi=%x", __func__, pc->pc_cpuid, ipi); atomic_set_32(&pc->pc_pending_ipis, ipi); - mask = (1 << (pc->pc_cpuid)); + mask = (1 << pc->pc_hart); sbi_send_ipi(&mask); @@ -252,7 +252,7 @@ ipi_selected(cpuset_t cpus, u_int ipi) CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc, ipi); atomic_set_32(&pc->pc_pending_ipis, ipi); - mask |= (1 << (pc->pc_cpuid)); + mask |= (1 << pc->pc_hart); } } sbi_send_ipi(&mask); Modified: head/sys/riscv/riscv/locore.S ============================================================================== --- head/sys/riscv/riscv/locore.S Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/riscv/locore.S Sun May 12 16:17:05 2019 (r347514) @@ -59,12 +59,18 @@ _start: sub t1, t1, t0 li t2, KERNBASE sub s9, t2, t1 /* s9 = physmem base */ - mv s10, a0 /* s10 = hart id */ - mv s11, a1 /* s11 = dtbp */ - /* Direct secondary cores to mpentry */ - bnez s10, mpentry + /* + * a0 = hart id + * a1 = dtbp + */ + /* Pick a hart to run the boot process. */ + la t0, hart_lottery + li t1, 1 + amoadd.w t0, t1, 0(t0) + bnez t0, mpentry + /* * Page tables */ @@ -123,7 +129,7 @@ _start: /* Create an L2 page superpage for DTB */ la s1, pagetable_l2_devmap - mv s2, s11 + mv s2, a1 srli s2, s2, PAGE_SHIFT li t0, (PTE_KERN) @@ -171,13 +177,19 @@ va: addi sp, sp, -PCB_SIZE /* Clear BSS */ - la a0, _C_LABEL(__bss_start) + la s0, _C_LABEL(__bss_start) la s1, _C_LABEL(_end) 1: - sd zero, 0(a0) - addi a0, a0, 8 - bltu a0, s1, 1b + sd zero, 0(s0) + addi s0, s0, 8 + bltu s0, s1, 1b +#ifdef SMP + /* Store boot hart id. */ + la t0, boot_hart + sw a0, 0(t0) +#endif + /* Fill riscv_bootparams */ addi sp, sp, -40 @@ -190,7 +202,7 @@ va: li t0, (VM_MAX_KERNEL_ADDRESS - 2 * L2_SIZE) sd t0, 24(sp) /* dtbp_virt */ - sd s11, 32(sp) /* dtbp_phys */ + sd a1, 32(sp) /* dtbp_phys */ mv a0, sp call _C_LABEL(initriscv) /* Off we go */ @@ -233,9 +245,11 @@ pagetable_l2: pagetable_l2_devmap: .space PAGE_SIZE - .align 3 + .align 3 virt_map: - .quad virt_map + .quad virt_map +hart_lottery: + .space 4 /* Not in use, but required for linking. */ .align 3 @@ -278,7 +292,8 @@ ENTRY(mpentry) /* Setup stack pointer */ la t0, secondary_stacks li t1, (PAGE_SIZE * KSTACK_PAGES) - mulw t1, t1, s10 + mulw t2, t1, a0 + add t0, t0, t2 add t0, t0, t1 sub t0, t0, s9 li t1, KERNBASE Modified: head/sys/riscv/riscv/machdep.c ============================================================================== --- head/sys/riscv/riscv/machdep.c Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/riscv/machdep.c Sun May 12 16:17:05 2019 (r347514) @@ -117,6 +117,9 @@ int64_t dcache_line_size; /* The minimum D cache line int64_t icache_line_size; /* The minimum I cache line size */ int64_t idcache_line_size; /* The minimum cache line size */ +uint32_t boot_hart; /* The hart we booted on. */ +cpuset_t all_harts; + extern int *end; extern int *initstack_end; @@ -815,6 +818,7 @@ initriscv(struct riscv_bootparams *rvbp) /* Set the pcpu data, this is needed by pmap_bootstrap */ pcpup = &__pcpu[0]; pcpu_init(pcpup, 0, sizeof(struct pcpu)); + pcpup->pc_hart = boot_hart; /* Set the pcpu pointer */ __asm __volatile("mv gp, %0" :: "r"(pcpup)); Modified: head/sys/riscv/riscv/mp_machdep.c ============================================================================== --- head/sys/riscv/riscv/mp_machdep.c Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/riscv/mp_machdep.c Sun May 12 16:17:05 2019 (r347514) @@ -91,6 +91,9 @@ static int ipi_handler(void *); struct mtx ap_boot_mtx; struct pcb stoppcbs[MAXCPU]; +extern uint32_t boot_hart; +extern cpuset_t all_harts; + #ifdef INVARIANTS static uint32_t cpu_reg[MAXCPU][2]; #endif @@ -99,7 +102,7 @@ static device_t cpu_list[MAXCPU]; void mpentry(unsigned long cpuid); void init_secondary(uint64_t); -uint8_t secondary_stacks[MAXCPU - 1][PAGE_SIZE * KSTACK_PAGES] __aligned(16); +uint8_t secondary_stacks[MAXCPU][PAGE_SIZE * KSTACK_PAGES] __aligned(16); /* Set to 1 once we're ready to let the APs out of the pen. */ volatile int aps_ready = 0; @@ -182,7 +185,7 @@ riscv64_cpu_attach(device_t dev) static void release_aps(void *dummy __unused) { - u_long mask; + cpuset_t mask; int cpu, i; if (mp_ncpus == 1) @@ -194,15 +197,13 @@ release_aps(void *dummy __unused) atomic_store_rel_int(&aps_ready, 1); /* Wake up the other CPUs */ - mask = 0; + mask = all_harts; + CPU_CLR(boot_hart, &mask); - for (i = 1; i < mp_ncpus; i++) - mask |= (1 << i); - - sbi_send_ipi(&mask); - printf("Release APs\n"); + sbi_send_ipi(mask.__bits); + for (i = 0; i < 2000; i++) { if (smp_started) { for (cpu = 0; cpu <= mp_maxid; cpu++) { @@ -219,12 +220,19 @@ release_aps(void *dummy __unused) SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); void -init_secondary(uint64_t cpu) +init_secondary(uint64_t hart) { struct pcpu *pcpup; + u_int cpuid; + /* Renumber this cpu */ + cpuid = hart; + if (cpuid < boot_hart) + cpuid += mp_maxid + 1; + cpuid -= boot_hart; + /* Setup the pcpu pointer */ - pcpup = &__pcpu[cpu]; + pcpup = &__pcpu[cpuid]; __asm __volatile("mv gp, %0" :: "r"(pcpup)); /* Workaround: make sure wfi doesn't halt the hart */ @@ -366,11 +374,12 @@ cpu_mp_probe(void) static boolean_t cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) { - uint64_t target_cpu; struct pcpu *pcpup; + uint64_t hart; + u_int cpuid; - /* Check we are able to start this cpu */ - if (id > mp_maxid) + /* Check if this hart supports MMU. */ + if (OF_getproplen(node, "mmu-type") < 0) return (0); KASSERT(id < MAXCPU, ("Too many CPUs")); @@ -382,29 +391,44 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size cpu_reg[id][1] = reg[1]; #endif - target_cpu = reg[0]; + hart = reg[0]; if (addr_size == 2) { - target_cpu <<= 32; - target_cpu |= reg[1]; + hart <<= 32; + hart |= reg[1]; } - pcpup = &__pcpu[id]; + KASSERT(hart < MAXCPU, ("Too many harts.")); - /* We are already running on cpu 0 */ - if (id == 0) { + /* We are already running on this cpu */ + if (hart == boot_hart) return (1); - } - pcpu_init(pcpup, id, sizeof(struct pcpu)); + /* + * Rotate the CPU IDs to put the boot CPU as CPU 0. + * We keep the other CPUs ordered. + */ + cpuid = hart; + if (cpuid < boot_hart) + cpuid += mp_maxid + 1; + cpuid -= boot_hart; - dpcpu[id - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); - dpcpu_init(dpcpu[id - 1], id); + /* Check if we are able to start this cpu */ + if (cpuid > mp_maxid) + return (0); - printf("Starting CPU %u (%lx)\n", id, target_cpu); - __riscv_boot_ap[id] = 1; + pcpup = &__pcpu[cpuid]; + pcpu_init(pcpup, cpuid, sizeof(struct pcpu)); + pcpup->pc_hart = hart; - CPU_SET(id, &all_cpus); + dpcpu[cpuid - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); + dpcpu_init(dpcpu[cpuid - 1], cpuid); + printf("Starting CPU %u (hart %lx)\n", cpuid, hart); + __riscv_boot_ap[hart] = 1; + + CPU_SET(cpuid, &all_cpus); + CPU_SET(hart, &all_harts); + return (1); } #endif @@ -417,6 +441,7 @@ cpu_mp_start(void) mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); CPU_SET(0, &all_cpus); + CPU_SET(boot_hart, &all_harts); switch(cpu_enum_method) { #ifdef FDT @@ -435,13 +460,24 @@ cpu_mp_announce(void) { } +static boolean_t +cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) +{ + + /* Check if this hart supports MMU. */ + if (OF_getproplen(node, "mmu-type") < 0) + return (0); + + return (1); +} + void cpu_mp_setmaxid(void) { #ifdef FDT int cores; - cores = ofw_cpu_early_foreach(NULL, false); + cores = ofw_cpu_early_foreach(cpu_check_mmu, true); if (cores > 0) { cores = MIN(cores, MAXCPU); if (bootverbose) Modified: head/sys/riscv/riscv/pmap.c ============================================================================== --- head/sys/riscv/riscv/pmap.c Sun May 12 15:27:18 2019 (r347513) +++ head/sys/riscv/riscv/pmap.c Sun May 12 16:17:05 2019 (r347514) @@ -273,6 +273,8 @@ static struct rwlock pv_list_locks[NPV_LIST_LOCKS]; static struct md_page *pv_table; static struct md_page pv_dummy; +extern cpuset_t all_harts; + /* * Internal flags for pmap_enter()'s helper functions. */ @@ -737,7 +739,7 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_sfence_vma(mask.__bits, va, 1); @@ -752,7 +754,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_sfence_vma(mask.__bits, sva, eva - sva + 1); @@ -772,7 +774,7 @@ pmap_invalidate_all(pmap_t pmap) sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); /* * XXX: The SBI doc doesn't detail how to specify x0 as the @@ -4255,7 +4257,7 @@ void pmap_activate_sw(struct thread *td) { pmap_t oldpmap, pmap; - u_int cpu; + u_int hart; oldpmap = PCPU_GET(curpmap); pmap = vmspace_pmap(td->td_proc->p_vmspace); @@ -4263,13 +4265,13 @@ pmap_activate_sw(struct thread *td) return; load_satp(pmap->pm_satp); - cpu = PCPU_GET(cpuid); + hart = PCPU_GET(hart); #ifdef SMP - CPU_SET_ATOMIC(cpu, &pmap->pm_active); - CPU_CLR_ATOMIC(cpu, &oldpmap->pm_active); + CPU_SET_ATOMIC(hart, &pmap->pm_active); + CPU_CLR_ATOMIC(hart, &oldpmap->pm_active); #else - CPU_SET(cpu, &pmap->pm_active); - CPU_CLR(cpu, &oldpmap->pm_active); + CPU_SET(hart, &pmap->pm_active); + CPU_CLR(hart, &oldpmap->pm_active); #endif PCPU_SET(curpmap, pmap); @@ -4288,13 +4290,13 @@ pmap_activate(struct thread *td) void pmap_activate_boot(pmap_t pmap) { - u_int cpu; + u_int hart; - cpu = PCPU_GET(cpuid); + hart = PCPU_GET(hart); #ifdef SMP - CPU_SET_ATOMIC(cpu, &pmap->pm_active); + CPU_SET_ATOMIC(hart, &pmap->pm_active); #else - CPU_SET(cpu, &pmap->pm_active); + CPU_SET(hart, &pmap->pm_active); #endif PCPU_SET(curpmap, pmap); } @@ -4313,8 +4315,8 @@ pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_ * FENCE.I." */ sched_pin(); - mask = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &mask); + mask = all_harts; + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_fence_i(mask.__bits); From owner-svn-src-all@freebsd.org Mon May 13 01:18:19 2019 Return-Path: Delivered-To: svn-src-all@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 E2C5915A7684; Mon, 13 May 2019 01:18:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 865D091948; Mon, 13 May 2019 01:18:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60C5B2A1D; Mon, 13 May 2019 01:18:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4D1IIeC092844; Mon, 13 May 2019 01:18:18 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4D1IIvV092843; Mon, 13 May 2019 01:18:18 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905130118.x4D1IIvV092843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 01:18:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347515 - head/sys/mips/conf X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/mips/conf X-SVN-Commit-Revision: 347515 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 865D091948 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 01:18:19 -0000 Author: markj Date: Mon May 13 01:18:17 2019 New Revision: 347515 URL: https://svnweb.freebsd.org/changeset/base/347515 Log: Catch up with r347241. MFC with: r347241 Modified: head/sys/mips/conf/std.AR_MIPS_BASE Modified: head/sys/mips/conf/std.AR_MIPS_BASE ============================================================================== --- head/sys/mips/conf/std.AR_MIPS_BASE Sun May 12 16:17:05 2019 (r347514) +++ head/sys/mips/conf/std.AR_MIPS_BASE Mon May 13 01:18:17 2019 (r347515) @@ -21,8 +21,8 @@ options SCSI_NO_OP_STRINGS # .. And no sysctl strings options NO_SYSCTL_DESCR -makeoptions MODULES_OVERRIDE+="gpio ar71xx if_gif if_vlan if_gre if_tap" -makeoptions MODULES_OVERRIDE+="if_tun if_bridge bridgestp usb" +makeoptions MODULES_OVERRIDE+="gpio ar71xx if_gif if_vlan if_gre if_tuntap" +makeoptions MODULES_OVERRIDE+="if_bridge bridgestp usb" makeoptions MODULES_OVERRIDE+="alq" # Random - required during early boot! From owner-svn-src-all@freebsd.org Mon May 13 05:06:37 2019 Return-Path: Delivered-To: svn-src-all@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 1AEE115ABC5D; Mon, 13 May 2019 05:06:37 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 AB21E9730A; Mon, 13 May 2019 05:06:35 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x62d.google.com with SMTP id y3so5829767plp.0; Sun, 12 May 2019 22:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=z6Fe+PBu/NDgbfuVAU9z7dmfMq0/Db7z5jSVUeEa8zM=; b=SNAVrMrvzdIa/6Fp8pLon8azE0gYdlLPY04oAHOm8GK4MXDw+UBq2JioRGNA5lMNS2 pOJ24AXTUZmhbsly1YscLRVKPRa5sYDiPivTCkyQCliGmw2lPCScDRTXCBivyWfza7Rr nLjamc5hM0I+fKpv7zFEN9ipm0XMmET38yqSpLm7R+6BR219/G5V0WHanI5Tr6aw5EJv RS30c3h++zSQdjWzI5adN7+PxStCz+ZRPI6eK7GmYiUsQbFKRQ4w12cEDbZhJOcpofIi FESmGdEviCtvKQK9e1BjaTRm4EmgGdv0yuqMJemGnn66wZRW7kMGXJD4aurHfJOUy+gm xrLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=z6Fe+PBu/NDgbfuVAU9z7dmfMq0/Db7z5jSVUeEa8zM=; b=lmtDfihtYH/xj7KMu1pLGJnzjfxa7unhFtug9FgvmotKNeqMubP0MhYg8LzWQIsx24 mdNUdjE8grb6tbhR0Vo8M+qgw14Csal/erfgt0QAa4ay5dH+vwUoe6v8oT9OyCcgRZRN b8ZcLCVvqMfFcrucZ5qnwo3H88HEMs6yd9O3h4qKtwWQd78C5umQC4eTN9hH09vemV5k UNAVGeDCZi8kMQ4NqAZmSDv21UdQOjRZFeLG0ITkYUlUH2f7VJ4z0/n/EUjjaNI4SlvU w9fFYv/I20ewot6hRS1CFsxbc3v5KXu2NIOznBwyaiAreuWTY4R7IMdpi5ZTokuUYTNd jNxw== X-Gm-Message-State: APjAAAUvI20K/uy/oOP9Jh90J99G9ekSxHHnnCA0TzAG2oS0KPe2agbQ yWL1V4zMLkTN9pfSNIe9qA+wxFdtYmo= X-Google-Smtp-Source: APXvYqxX6fG4vG2gXNxNfYo44QFmTYJBas000stlaDnJZxOWRf0eZsoiJzr2neF1nFdipS6bEbR/Lw== X-Received: by 2002:a17:902:e183:: with SMTP id cd3mr28387364plb.233.1557723994143; Sun, 12 May 2019 22:06:34 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id s18sm1438334pgg.64.2019.05.12.22.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 22:06:33 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: svn commit: r347477 - head/sys/kern From: Enji Cooper In-Reply-To: <201905110213.x4B2Dq9U088622@repo.freebsd.org> Date: Sun, 12 May 2019 22:06:31 -0700 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <201905110213.x4B2Dq9U088622@repo.freebsd.org> To: Doug Moore X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: AB21E9730A X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=SNAVrMrv; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of yaneurabeya@gmail.com designates 2607:f8b0:4864:20::62d as permitted sender) smtp.mailfrom=yaneurabeya@gmail.com X-Spamd-Result: default: False [-6.16 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MV_CASE(0.50)[]; RCVD_COUNT_THREE(0.00)[3]; 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.97)[-0.970,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:2607:f8b0::/32, country:US]; MID_RHS_MATCH_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)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(-2.68)[ip: (-7.82), ipnet: 2607:f8b0::/32(-3.25), asn: 15169(-2.26), country: US(-0.06)]; RCVD_IN_DNSWL_NONE(0.00)[d.2.6.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] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 05:06:37 -0000 Hi Doug, > On May 10, 2019, at 7:13 PM, Doug Moore wrote: > > Author: dougm > Date: Sat May 11 02:13:52 2019 > New Revision: 347477 > URL: https://svnweb.freebsd.org/changeset/base/347477 > > Log: > Revert r347469. Why was the commit reverted? Thank you! -Enji From owner-svn-src-all@freebsd.org Mon May 13 05:11:15 2019 Return-Path: Delivered-To: svn-src-all@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 6197F15AC134; Mon, 13 May 2019 05:11:15 +0000 (UTC) (envelope-from unkadoug@gmail.com) Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) (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 E961E97724; Mon, 13 May 2019 05:11:14 +0000 (UTC) (envelope-from unkadoug@gmail.com) Received: by mail-ot1-x343.google.com with SMTP id 66so10598311otq.0; Sun, 12 May 2019 22:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=c99cS9K0ASsMUrDeSjZ8+oF5s4LM/gBhmNK1B9sakpU=; b=KqC/qtOq09wFSmS6Tz0Ba+y65RjkKr7YpXueNaiH6NF7skgQeS3al65J1sqQttflLY mlMaapsAMvA0XxL53Z+DD9sCxpJb1hvXN+x/PgRu0oOCXbc+Cv6DoTJTfrlBIcU343d7 y8zU763FWfL6HMcVfI9GXTNHEv0fPPpIs/l4mB7bC8U9zfcKcBVNBTcixuq0QVtNlAKy Tj1gUgZOSSKfsOrNcwm1/jHnqwmOvzZOrAq87INuVXGFNWcH31EOtidOajMk+lDpRyhz eSnLH10E1Dtf/SisIbHUAb/EKiu9VXKJnnB2hgRnrdPvsmNIT8pJxWsRvXeo5eK55w07 gTzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=c99cS9K0ASsMUrDeSjZ8+oF5s4LM/gBhmNK1B9sakpU=; b=tl7g7+Ehopt8kIUTR+MZVhE/G4JKNbrWNo+PwdRYctSkF0S3PpqsZyEpa5iH2vNFfn VCvaMtYTuhf/OZEeFiJOOztEjDJskxIxoIEnoVRjsk8DZNiJUgCSdILBIb1FQH3AaBTM kOjBNF/6LXzobxAxHtzzbXlPoEU/0faaWhLUnl8wNwgPk5ViKFsXYuMFGozEM7wybnhs G8HYCCSnA6KThZGqny9K221D1ASifkpzS5Me1iujzmBSLt3H4jCLg0ZIPRy3l7fbGjVK yyDez7adTmbwm5yZ4RLgrv1n7zMANj8D2I7QxdQMUMvvUtIh9bfyCmuYd0FhnwxH/WvF C8uw== X-Gm-Message-State: APjAAAWtVVn0TlHW7xOEViBYWCVCVk1rbUQJ35SkLvrEHcpuIyF5pKOY +guwuo88e+aktu6ILiLx2qDCyv6oy2xkZQ== X-Google-Smtp-Source: APXvYqy9te05Ld6MLt/jWybwS6k6QAYsNHCG2faa0x6px8NYm/CkXKDdxvRFhBMZOKYWZg2xeERDyg== X-Received: by 2002:a9d:6313:: with SMTP id q19mr737201otk.90.1557724274111; Sun, 12 May 2019 22:11:14 -0700 (PDT) Received: from 108-254-203-202.lightspeed.hstntx.sbcglobal.net (108-254-203-202.lightspeed.hstntx.sbcglobal.net. [108.254.203.202]) by smtp.gmail.com with ESMTPSA id b186sm1013326oia.51.2019.05.12.22.11.13 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 22:11:13 -0700 (PDT) From: Doug Moore X-Google-Original-From: Doug Moore Subject: Re: svn commit: r347477 - head/sys/kern To: Enji Cooper Cc: src-committers , svn-src-all , svn-src-head@freebsd.org References: <201905110213.x4B2Dq9U088622@repo.freebsd.org> Message-ID: <87a91545-01a1-dd96-881f-d5adde0896bd@freebsd.org> Date: Mon, 13 May 2019 00:11:12 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: E961E97724 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 05:11:15 -0000 I refer you to the discussion that began with that question from Cy Schubert on Friday night. I apologize again for the brevity of my commit message. Doug Moore On 5/13/19 12:06 AM, Enji Cooper wrote: > Hi Doug, > >> On May 10, 2019, at 7:13 PM, Doug Moore wrote: >> >> Author: dougm >> Date: Sat May 11 02:13:52 2019 >> New Revision: 347477 >> URL: https://svnweb.freebsd.org/changeset/base/347477 >> >> Log: >> Revert r347469. > Why was the commit reverted? > > Thank you! > -Enji From owner-svn-src-all@freebsd.org Mon May 13 05:12:57 2019 Return-Path: Delivered-To: svn-src-all@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 AA47015AC2D2; Mon, 13 May 2019 05:12:57 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 286D097939; Mon, 13 May 2019 05:12:57 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x629.google.com with SMTP id p15so5833193pll.4; Sun, 12 May 2019 22:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=yA7ZDMCh0RQLoEQ6oxO/DqiR0bB80jhTieS+Oi78u/8=; b=jOjJQk7r88mQg8FsXHQb2+B8hn430ZnQFafTCQkmk3XdOQq163ku+8CNLjN4JPrGu/ Zpopa05h5pu12rsmQdpCyW+PSN4X8kwWeYHDQlmW5UY8j4Gp37HWCkVjGQk3bq+hNxSg 2FSOX/fxDCdLARb1MDWWyiM+PVMLe6TffmYdQ7NeuVEb00mb0U3mtVsCTM66EmWoF/sM xHE8BVGPmm/8k91qviWjLkW+qzgxyVnKpR3xjOCdv1+NonIqgqghAM2fdmuBwOspmzjz 7sgJxCypPl00JGQT9rZ2rQWMA2NycIWKY4xAJ3vsSN/ZwSrumHw4yGzV/38feDoCN5HG 4qfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=yA7ZDMCh0RQLoEQ6oxO/DqiR0bB80jhTieS+Oi78u/8=; b=XwhPFrziuOwRb1T5mLRz9uyHSxVAsR0NPLDCz0Gwky8aXYxUpt0oUUj9uH2Eo1sr3b RweqHn0YCisXZNNfJLdN5rZs3qv7AlIHiVZjMs9MGMgJhM1PJoSKNZiVKVaShez5RfxO GZo502s138J8iyaVBmCxtDVbxD3zoKwYPFO9bajcOQd0b/8dWcUUviaQGUiGyvBQtf99 sDpmea3pPqoyMHCPUTGVEPzCtGYCJiqZXq0vsergzZaPfrWiT5zyNg864GI13E+A3pxG v359ujPCw+0FPjuOFFW8pDdiQl4F6Q+CT9oOBGeCgUsRmoEX2x0luAmfL7CB4j/s1wYp aQLg== X-Gm-Message-State: APjAAAUirvfP2Bm3g1g2lmv7nbPQ8StbC12j050QUVDuBRJAnY/UpBIL 4F582Ti/KDa6uVZDv7AeqZo= X-Google-Smtp-Source: APXvYqxuEobokhMz1HHWrci4YOW0xGkVv9loitjeQqib05M6oI79QUJ5tgnPBikt3TpV//vUduMk7Q== X-Received: by 2002:a17:902:102a:: with SMTP id b39mr28452813pla.188.1557724375833; Sun, 12 May 2019 22:12:55 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id w125sm16814578pfw.69.2019.05.12.22.12.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 22:12:54 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: svn commit: r347477 - head/sys/kern From: Enji Cooper In-Reply-To: <87a91545-01a1-dd96-881f-d5adde0896bd@freebsd.org> Date: Sun, 12 May 2019 22:12:53 -0700 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <41948E9C-4B2F-4211-B814-9D5BF5E8163C@gmail.com> References: <201905110213.x4B2Dq9U088622@repo.freebsd.org> <87a91545-01a1-dd96-881f-d5adde0896bd@freebsd.org> To: Doug Moore X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: 286D097939 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 05:12:57 -0000 > On May 12, 2019, at 10:11 PM, Doug Moore wrote: >=20 > I refer you to the discussion that began with that question from Cy > Schubert on Friday night. >=20 > I apologize again for the brevity of my commit message. It=E2=80=99s quite all right. Unfortunately Cy=E2=80=99s mail client = reads threading, so it=E2=80=99s sometimes difficult for me to track a = conversation. I appreciate your reaching out and for answering the question there. Thank you! -Enji From owner-svn-src-all@freebsd.org Mon May 13 05:13:34 2019 Return-Path: Delivered-To: svn-src-all@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 1795215AC33D; Mon, 13 May 2019 05:13:34 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (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 8B2DF97A5B; Mon, 13 May 2019 05:13:33 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x629.google.com with SMTP id n8so5827208plp.10; Sun, 12 May 2019 22:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rskH74Eleu6dT4fsiFboxt7CC+svvZbo5ABAtorBJy8=; b=U1vLVNPNmyU8vq0QbHktuCxIDm0fvPKwK6ett7wnQ1DNCUWXdeEaeuTDrR4EBs/giR 21nMNav38ajp5WhIbgrp/nR5Yb09qlT6sA1wKGVS/+XLg3QmaZoHsJm7V0JJGmTVJD9e QtT1POaoKRuLMgi9E8RIMw8K0HdF3jPgAIQeh1xOqqmjUjQvAxKKlrlgOWlWxKsxpCl/ ZRad2jazP+caATgbuE7vlINksD5rYj0wlh1yBySgySbFO7QNOshCbh+4pzGZEbo830Cc SqB7WWORt+c3YeTpYtZE4dsRJEbVAR1aIH48YQbeBxTHTb9lnzZc5iMvxEkqZMTJTE+W RFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rskH74Eleu6dT4fsiFboxt7CC+svvZbo5ABAtorBJy8=; b=ZreG9v9+maseN0f+V9yDFvn88nHAAOPJItTgzGC8KE+vkjyddy7jNt0fGgQGnEgztx /veHB/PImS5DA5PSV4zefkaPS5NbaFxunsOAaXK3YWuqLkTVdDoaFUvrxdn6L8Tr3JfI tE6fU1ZJMyYtlqLPzFib2UWxKLfHJkVCD4tC5yl4TOsWWjApZKxowLnlAEz0B/o+G++b wB10KFb+8LFBBAh8UaJoi1dVXCfhM/M8Dduvs7kR/ObjdaW3vRhTOWEoWxACPI/2OH1d lZ5E9uuC2461NQUYEBbUNUSFHwYX5TxSZrL+1ioqlmmmpAXWkmCM0MNlAcUe3Xyu2wNR I8EA== X-Gm-Message-State: APjAAAVh8MNlS04TblYBpgSImwD23keiA5oIurr5uJAnrTvbwDaSz2Et Zh6/Ds3bfCbX5CbIPl659K4= X-Google-Smtp-Source: APXvYqwiHZwIXaa/d1bGUJtvd3NsBLjeCriCWbMSqPr9LPkFHd4Kv5Gfs5LdsptzSyMUO97YRS+lgw== X-Received: by 2002:a17:902:e48d:: with SMTP id cj13mr28518719plb.156.1557724412605; Sun, 12 May 2019 22:13:32 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id w125sm16814578pfw.69.2019.05.12.22.13.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 22:13:32 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: svn commit: r347477 - head/sys/kern From: Enji Cooper In-Reply-To: <41948E9C-4B2F-4211-B814-9D5BF5E8163C@gmail.com> Date: Sun, 12 May 2019 22:13:31 -0700 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <563A6E6A-514C-4CDE-A522-7A3E329C0B8E@gmail.com> References: <201905110213.x4B2Dq9U088622@repo.freebsd.org> <87a91545-01a1-dd96-881f-d5adde0896bd@freebsd.org> <41948E9C-4B2F-4211-B814-9D5BF5E8163C@gmail.com> To: Doug Moore X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: 8B2DF97A5B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 05:13:34 -0000 > On May 12, 2019, at 10:12 PM, Enji Cooper = wrote: >=20 >=20 >> On May 12, 2019, at 10:11 PM, Doug Moore wrote: >>=20 >> I refer you to the discussion that began with that question from Cy >> Schubert on Friday night. >>=20 >> I apologize again for the brevity of my commit message. >=20 > It=E2=80=99s quite all right. Unfortunately Cy=E2=80=99s mail client = reads threading, so it=E2=80=99s sometimes difficult for me to track a = conversation. *reads -> breaks I need to get some sleep. -Enji= From owner-svn-src-all@freebsd.org Mon May 13 08:26:22 2019 Return-Path: Delivered-To: svn-src-all@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 D673C1584DED; Mon, 13 May 2019 08:26:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7A4546E806; Mon, 13 May 2019 08:26:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E90C744D; Mon, 13 May 2019 08:26:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4D8QMRb019274; Mon, 13 May 2019 08:26:22 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4D8QMSt019273; Mon, 13 May 2019 08:26:22 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905130826.x4D8QMSt019273@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 08:26:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347516 - stable/12/sbin/ipfw X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sbin/ipfw X-SVN-Commit-Revision: 347516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7A4546E806 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 08:26:23 -0000 Author: ae Date: Mon May 13 08:26:21 2019 New Revision: 347516 URL: https://svnweb.freebsd.org/changeset/base/347516 Log: MFC r346885: Handle HAVE_PROTO flag and print "proto" keyword for O_IP4 and O_IP6 opcodes when it is needed. This should fix the problem, when printed by `ipfw show` rule can not be added due to missing "proto" keyword. Modified: stable/12/sbin/ipfw/ipfw2.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ipfw/ipfw2.c ============================================================================== --- stable/12/sbin/ipfw/ipfw2.c Mon May 13 01:18:17 2019 (r347515) +++ stable/12/sbin/ipfw/ipfw2.c Mon May 13 08:26:21 2019 (r347516) @@ -1701,9 +1701,13 @@ print_instruction(struct buf_pr *bp, const struct form IPFW_TLV_STATE_NAME)); break; case O_IP6: + if (state->flags & HAVE_PROTO) + bprintf(bp, " proto"); bprintf(bp, " ip6"); break; case O_IP4: + if (state->flags & HAVE_PROTO) + bprintf(bp, " proto"); bprintf(bp, " ip4"); break; case O_ICMP6TYPE: From owner-svn-src-all@freebsd.org Mon May 13 08:27:53 2019 Return-Path: Delivered-To: svn-src-all@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 E09291584E97; Mon, 13 May 2019 08:27:53 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 842B36E96F; Mon, 13 May 2019 08:27:53 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5BBD7745F; Mon, 13 May 2019 08:27:53 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4D8RrNY019389; Mon, 13 May 2019 08:27:53 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4D8Rr2B019388; Mon, 13 May 2019 08:27:53 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905130827.x4D8Rr2B019388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 08:27:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347517 - stable/11/sbin/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sbin/ipfw X-SVN-Commit-Revision: 347517 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 842B36E96F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 08:27:54 -0000 Author: ae Date: Mon May 13 08:27:52 2019 New Revision: 347517 URL: https://svnweb.freebsd.org/changeset/base/347517 Log: MFC r346885: Handle HAVE_PROTO flag and print "proto" keyword for O_IP4 and O_IP6 opcodes when it is needed. This should fix the problem, when printed by `ipfw show` rule can not be added due to missing "proto" keyword. Modified: stable/11/sbin/ipfw/ipfw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ipfw/ipfw2.c ============================================================================== --- stable/11/sbin/ipfw/ipfw2.c Mon May 13 08:26:21 2019 (r347516) +++ stable/11/sbin/ipfw/ipfw2.c Mon May 13 08:27:52 2019 (r347517) @@ -1701,9 +1701,13 @@ print_instruction(struct buf_pr *bp, const struct form IPFW_TLV_STATE_NAME)); break; case O_IP6: + if (state->flags & HAVE_PROTO) + bprintf(bp, " proto"); bprintf(bp, " ip6"); break; case O_IP4: + if (state->flags & HAVE_PROTO) + bprintf(bp, " proto"); bprintf(bp, " ip4"); break; case O_ICMP6TYPE: From owner-svn-src-all@freebsd.org Mon May 13 08:29:29 2019 Return-Path: Delivered-To: svn-src-all@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 39DDC1584F4D; Mon, 13 May 2019 08:29:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D4D5C6EAC7; Mon, 13 May 2019 08:29:28 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AD6C17461; Mon, 13 May 2019 08:29:28 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4D8TSY9019512; Mon, 13 May 2019 08:29:28 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4D8TSQE019511; Mon, 13 May 2019 08:29:28 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905130829.x4D8TSQE019511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 08:29:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347518 - stable/12/libexec/rc/rc.d X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/libexec/rc/rc.d X-SVN-Commit-Revision: 347518 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D4D5C6EAC7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 08:29:29 -0000 Author: ae Date: Mon May 13 08:29:28 2019 New Revision: 347518 URL: https://svnweb.freebsd.org/changeset/base/347518 Log: MFC r347178: Add ipsec.ko to required_modules for rc.d/ipsec script. Thus it can be automatically loaded if ipsec_enable="YES" and option IPSEC is not in the kernel config. Modified: stable/12/libexec/rc/rc.d/ipsec Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.d/ipsec ============================================================================== --- stable/12/libexec/rc/rc.d/ipsec Mon May 13 08:27:52 2019 (r347517) +++ stable/12/libexec/rc/rc.d/ipsec Mon May 13 08:29:28 2019 (r347518) @@ -20,6 +20,7 @@ stop_cmd="ipsec_stop" reload_cmd="ipsec_reload" extra_commands="reload" ipsec_program="/sbin/setkey" +required_modules="ipsec" # ipsec_file is set by rc.conf ipsec_prestart() From owner-svn-src-all@freebsd.org Mon May 13 08:34:14 2019 Return-Path: Delivered-To: svn-src-all@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 300351585221; Mon, 13 May 2019 08:34:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA1326EFC2; Mon, 13 May 2019 08:34:13 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A26DB7613; Mon, 13 May 2019 08:34:13 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4D8YDTK024638; Mon, 13 May 2019 08:34:13 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4D8YDBw024637; Mon, 13 May 2019 08:34:13 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905130834.x4D8YDBw024637@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 08:34:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347519 - head/sys/modules/ipsec X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/modules/ipsec X-SVN-Commit-Revision: 347519 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CA1326EFC2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 08:34:14 -0000 Author: ae Date: Mon May 13 08:34:13 2019 New Revision: 347519 URL: https://svnweb.freebsd.org/changeset/base/347519 Log: Revert r347402. After r347429 symlink is no longer needed. Modified: head/sys/modules/ipsec/Makefile Modified: head/sys/modules/ipsec/Makefile ============================================================================== --- head/sys/modules/ipsec/Makefile Mon May 13 08:29:28 2019 (r347518) +++ head/sys/modules/ipsec/Makefile Mon May 13 08:34:13 2019 (r347519) @@ -7,7 +7,6 @@ SRCS= if_ipsec.c ipsec.c ipsec_input.c ipsec_mbuf.c ip ipsec_output.c xform_ah.c xform_esp.c xform_ipcomp.c \ opt_inet.h opt_inet6.h opt_ipsec.h opt_sctp.h SRCS.INET= udpencap.c -SYMLINKS= ${KMOD}.ko ${KMODDIR}/if_${KMOD}.ko opt_ipsec.h: @echo "#define IPSEC_SUPPORT 1" > ${.TARGET} From owner-svn-src-all@freebsd.org Mon May 13 10:43:19 2019 Return-Path: Delivered-To: svn-src-all@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 B8933158A6B4; Mon, 13 May 2019 10:43:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A8897361E; Mon, 13 May 2019 10:43:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 32D438BB7; Mon, 13 May 2019 10:43:19 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DAhJQv096626; Mon, 13 May 2019 10:43:19 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DAhIj1096624; Mon, 13 May 2019 10:43:18 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131043.x4DAhIj1096624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 10:43:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347520 - stable/12/sys/compat/linux X-SVN-Group: stable-12 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: stable/12/sys/compat/linux X-SVN-Commit-Revision: 347520 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5A8897361E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 10:43:20 -0000 Author: dchagin Date: Mon May 13 10:43:18 2019 New Revision: 347520 URL: https://svnweb.freebsd.org/changeset/base/347520 Log: MFC r346965: Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. It was first introduced in r163734 and missied by me in r283383. Modified: stable/12/sys/compat/linux/linux_emul.c stable/12/sys/compat/linux/linux_emul.h stable/12/sys/compat/linux/linux_misc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linux/linux_emul.c ============================================================================== --- stable/12/sys/compat/linux/linux_emul.c Mon May 13 08:34:13 2019 (r347519) +++ stable/12/sys/compat/linux/linux_emul.c Mon May 13 10:43:18 2019 (r347520) @@ -127,7 +127,6 @@ linux_proc_init(struct thread *td, struct thread *newt em->em_tid = p->p_pid; em->flags = 0; - em->pdeath_signal = 0; em->robust_futexes = NULL; em->child_clear_tid = NULL; em->child_set_tid = NULL; Modified: stable/12/sys/compat/linux/linux_emul.h ============================================================================== --- stable/12/sys/compat/linux/linux_emul.h Mon May 13 08:34:13 2019 (r347519) +++ stable/12/sys/compat/linux/linux_emul.h Mon May 13 10:43:18 2019 (r347520) @@ -40,7 +40,6 @@ struct linux_emuldata { int *child_set_tid; /* in clone(): Child's TID to set on clone */ int *child_clear_tid;/* in clone(): Child's TID to clear on exit */ - int pdeath_signal; /* parent death signal */ int flags; /* thread emuldata flags */ int em_tid; /* thread id */ Modified: stable/12/sys/compat/linux/linux_misc.c ============================================================================== --- stable/12/sys/compat/linux/linux_misc.c Mon May 13 08:34:13 2019 (r347519) +++ stable/12/sys/compat/linux/linux_misc.c Mon May 13 10:43:18 2019 (r347520) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1993,7 +1994,6 @@ linux_prctl(struct thread *td, struct linux_prctl_args int error = 0, max_size; struct proc *p = td->td_proc; char comm[LINUX_MAX_COMM_LEN]; - struct linux_emuldata *em; int pdeath_signal; #ifdef DEBUG @@ -2007,17 +2007,18 @@ linux_prctl(struct thread *td, struct linux_prctl_args case LINUX_PR_SET_PDEATHSIG: if (!LINUX_SIG_VALID(args->arg2)) return (EINVAL); - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - em->pdeath_signal = args->arg2; - break; + pdeath_signal = linux_to_bsd_signal(args->arg2); + return (kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_CTL, + &pdeath_signal)); case LINUX_PR_GET_PDEATHSIG: - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - pdeath_signal = em->pdeath_signal; - error = copyout(&pdeath_signal, + error = kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_STATUS, + &pdeath_signal); + if (error != 0) + return (error); + pdeath_signal = bsd_to_linux_signal(pdeath_signal); + return (copyout(&pdeath_signal, (void *)(register_t)args->arg2, - sizeof(pdeath_signal)); + sizeof(pdeath_signal))); break; case LINUX_PR_GET_KEEPCAPS: /* From owner-svn-src-all@freebsd.org Mon May 13 11:17:33 2019 Return-Path: Delivered-To: svn-src-all@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 17782158C2B6; Mon, 13 May 2019 11:17:33 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ADC38752C1; Mon, 13 May 2019 11:17:32 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 82B669100; Mon, 13 May 2019 11:17:32 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DBHW3Z013532; Mon, 13 May 2019 11:17:32 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DBHWe4013530; Mon, 13 May 2019 11:17:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131117.x4DBHWe4013530@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 11:17:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347521 - stable/11/sys/compat/linux X-SVN-Group: stable-11 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: stable/11/sys/compat/linux X-SVN-Commit-Revision: 347521 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: ADC38752C1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 11:17:33 -0000 Author: dchagin Date: Mon May 13 11:17:31 2019 New Revision: 347521 URL: https://svnweb.freebsd.org/changeset/base/347521 Log: MFC r346965: Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. It was first introduced in r163734 and missied by me in r283383. Modified: stable/11/sys/compat/linux/linux_emul.c stable/11/sys/compat/linux/linux_emul.h stable/11/sys/compat/linux/linux_misc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_emul.c ============================================================================== --- stable/11/sys/compat/linux/linux_emul.c Mon May 13 10:43:18 2019 (r347520) +++ stable/11/sys/compat/linux/linux_emul.c Mon May 13 11:17:31 2019 (r347521) @@ -127,7 +127,6 @@ linux_proc_init(struct thread *td, struct thread *newt em->em_tid = p->p_pid; em->flags = 0; - em->pdeath_signal = 0; em->robust_futexes = NULL; em->child_clear_tid = NULL; em->child_set_tid = NULL; Modified: stable/11/sys/compat/linux/linux_emul.h ============================================================================== --- stable/11/sys/compat/linux/linux_emul.h Mon May 13 10:43:18 2019 (r347520) +++ stable/11/sys/compat/linux/linux_emul.h Mon May 13 11:17:31 2019 (r347521) @@ -40,7 +40,6 @@ struct linux_emuldata { int *child_set_tid; /* in clone(): Child's TID to set on clone */ int *child_clear_tid;/* in clone(): Child's TID to clear on exit */ - int pdeath_signal; /* parent death signal */ int flags; /* thread emuldata flags */ int em_tid; /* thread id */ Modified: stable/11/sys/compat/linux/linux_misc.c ============================================================================== --- stable/11/sys/compat/linux/linux_misc.c Mon May 13 10:43:18 2019 (r347520) +++ stable/11/sys/compat/linux/linux_misc.c Mon May 13 11:17:31 2019 (r347521) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1995,7 +1996,6 @@ linux_prctl(struct thread *td, struct linux_prctl_args int error = 0, max_size; struct proc *p = td->td_proc; char comm[LINUX_MAX_COMM_LEN]; - struct linux_emuldata *em; int pdeath_signal; #ifdef DEBUG @@ -2009,17 +2009,18 @@ linux_prctl(struct thread *td, struct linux_prctl_args case LINUX_PR_SET_PDEATHSIG: if (!LINUX_SIG_VALID(args->arg2)) return (EINVAL); - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - em->pdeath_signal = args->arg2; - break; + pdeath_signal = linux_to_bsd_signal(args->arg2); + return (kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_CTL, + &pdeath_signal)); case LINUX_PR_GET_PDEATHSIG: - em = em_find(td); - KASSERT(em != NULL, ("prctl: emuldata not found.\n")); - pdeath_signal = em->pdeath_signal; - error = copyout(&pdeath_signal, + error = kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_STATUS, + &pdeath_signal); + if (error != 0) + return (error); + pdeath_signal = bsd_to_linux_signal(pdeath_signal); + return (copyout(&pdeath_signal, (void *)(register_t)args->arg2, - sizeof(pdeath_signal)); + sizeof(pdeath_signal))); break; case LINUX_PR_GET_KEEPCAPS: /* From owner-svn-src-all@freebsd.org Mon May 13 12:38:34 2019 Return-Path: Delivered-To: svn-src-all@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 12BCF158F227; Mon, 13 May 2019 12:38:34 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AD35A80169; Mon, 13 May 2019 12:38:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 874819E51; Mon, 13 May 2019 12:38:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DCcXof055813; Mon, 13 May 2019 12:38:33 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DCcXml055812; Mon, 13 May 2019 12:38:33 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201905131238.x4DCcXml055812@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 13 May 2019 12:38:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347522 - head/etc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/etc X-SVN-Commit-Revision: 347522 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AD35A80169 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 12:38:34 -0000 Author: manu Date: Mon May 13 12:38:33 2019 New Revision: 347522 URL: https://svnweb.freebsd.org/changeset/base/347522 Log: Revert r347356 and r347371 passwd related files need to be tagged as config file so pkg update will attempt merging them when we install a new package. We should use CONFS for that. Revert for now until I come up with a better version of this patch as it breaks pkgbase for users. Modified: head/etc/Makefile Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Mon May 13 11:17:31 2019 (r347521) +++ head/etc/Makefile Mon May 13 12:38:33 2019 (r347522) @@ -18,10 +18,15 @@ BIN1= \ group \ login.access \ rc.bsdextended \ + rc.firewall \ termcap.small # NB: keep these sorted by MK_* knobs +.if ${MK_SENDMAIL} != "no" +BIN1+= rc.sendmail +.endif + .if ${MK_SENDMAIL} == "no" ETCMAIL=mailer.conf aliases .else @@ -58,20 +63,10 @@ distribution: @echo "set DESTDIR before running \"make ${.TARGET}\"" @false .endif -.if ${MK_SENDMAIL} != "no" cd ${.CURDIR}; \ - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 -T "tags=package=sendmail"\ - rc.sendmail ${DESTDIR}/etc; -.endif -.if ${MK_IPFW} != "no" - cd ${.CURDIR}; \ - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 -T "tags=package=ipfw"\ - rc.firewall ${DESTDIR}/etc; -.endif - cd ${.CURDIR}; \ - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 -T "tags=package=runtime"\ + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \ ${BIN1} ${DESTDIR}/etc; \ - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 -T "tags=package=runtime"\ + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \ master.passwd ${DESTDIR}/etc; .if ${MK_TCSH} == "no" From owner-svn-src-all@freebsd.org Mon May 13 13:28:43 2019 Return-Path: Delivered-To: svn-src-all@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 9F57815900FE; Mon, 13 May 2019 13:28:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D94A818BD; Mon, 13 May 2019 13:28:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E54A5A681; Mon, 13 May 2019 13:28:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DDSg3l082095; Mon, 13 May 2019 13:28:42 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DDSgP0082093; Mon, 13 May 2019 13:28:42 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201905131328.x4DDSgP0082093@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 13 May 2019 13:28:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347523 - in stable/12: sbin/nvmecontrol sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: sbin/nvmecontrol sys/dev/nvme X-SVN-Commit-Revision: 347523 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3D94A818BD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 13:28:43 -0000 Author: mav Date: Mon May 13 13:28:42 2019 New Revision: 347523 URL: https://svnweb.freebsd.org/changeset/base/347523 Log: MFC r347158: Decode Deallocate Logical Block Features. Modified: stable/12/sbin/nvmecontrol/identify.c stable/12/sys/dev/nvme/nvme.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/nvmecontrol/identify.c ============================================================================== --- stable/12/sbin/nvmecontrol/identify.c Mon May 13 12:38:33 2019 (r347522) +++ stable/12/sbin/nvmecontrol/identify.c Mon May 13 13:28:42 2019 (r347523) @@ -49,7 +49,7 @@ print_namespace(struct nvme_namespace_data *nsdata) uint32_t i; uint32_t lbaf, lbads, ms, rp; uint8_t thin_prov, ptype; - uint8_t flbas_fmt; + uint8_t flbas_fmt, t; thin_prov = (nsdata->nsfeat >> NVME_NS_DATA_NSFEAT_THIN_PROV_SHIFT) & NVME_NS_DATA_NSFEAT_THIN_PROV_MASK; @@ -122,6 +122,16 @@ print_namespace(struct nvme_namespace_data *nsdata) NVME_NS_DATA_FPI_PERC_MASK); } else printf("Not Supported\n"); + t = (nsdata->dlfeat >> NVME_NS_DATA_DLFEAT_READ_SHIFT) & + NVME_NS_DATA_DLFEAT_READ_MASK; + printf("Deallocate Logical Block: Read %s%s%s\n", + (t == NVME_NS_DATA_DLFEAT_READ_NR) ? "Not Reported" : + (t == NVME_NS_DATA_DLFEAT_READ_00) ? "00h" : + (t == NVME_NS_DATA_DLFEAT_READ_FF) ? "FFh" : "Unknown", + (nsdata->dlfeat >> NVME_NS_DATA_DLFEAT_DWZ_SHIFT) & + NVME_NS_DATA_DLFEAT_DWZ_MASK ? ", Write Zero" : "", + (nsdata->dlfeat >> NVME_NS_DATA_DLFEAT_GCRC_SHIFT) & + NVME_NS_DATA_DLFEAT_GCRC_MASK ? ", Guard CRC" : ""); printf("Optimal I/O Boundary (LBAs): %u\n", nsdata->noiob); printf("Globally Unique Identifier: "); for (i = 0; i < sizeof(nsdata->nguid); i++) Modified: stable/12/sys/dev/nvme/nvme.h ============================================================================== --- stable/12/sys/dev/nvme/nvme.h Mon May 13 12:38:33 2019 (r347522) +++ stable/12/sys/dev/nvme/nvme.h Mon May 13 13:28:42 2019 (r347523) @@ -349,6 +349,20 @@ #define NVME_NS_DATA_FPI_SUPP_SHIFT (7) #define NVME_NS_DATA_FPI_SUPP_MASK (0x1) +/** Deallocate Logical Block Features */ +/* deallocated logical block read behavior */ +#define NVME_NS_DATA_DLFEAT_READ_SHIFT (0) +#define NVME_NS_DATA_DLFEAT_READ_MASK (0x07) +#define NVME_NS_DATA_DLFEAT_READ_NR (0x00) +#define NVME_NS_DATA_DLFEAT_READ_00 (0x01) +#define NVME_NS_DATA_DLFEAT_READ_FF (0x02) +/* supports the Deallocate bit in the Write Zeroes */ +#define NVME_NS_DATA_DLFEAT_DWZ_SHIFT (3) +#define NVME_NS_DATA_DLFEAT_DWZ_MASK (0x01) +/* Guard field for deallocated logical blocks is set to the CRC */ +#define NVME_NS_DATA_DLFEAT_GCRC_SHIFT (4) +#define NVME_NS_DATA_DLFEAT_GCRC_MASK (0x01) + /** lba format support */ /* metadata size */ #define NVME_NS_DATA_LBAF_MS_SHIFT (0) From owner-svn-src-all@freebsd.org Mon May 13 13:29:53 2019 Return-Path: Delivered-To: svn-src-all@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 E22EE1590179; Mon, 13 May 2019 13:29:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 84B05819F4; Mon, 13 May 2019 13:29:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58389A682; Mon, 13 May 2019 13:29:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DDTqWw082194; Mon, 13 May 2019 13:29:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DDTq0g082193; Mon, 13 May 2019 13:29:52 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201905131329.x4DDTq0g082193@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 13 May 2019 13:29:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347524 - stable/12/sys/cam/ata X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ata X-SVN-Commit-Revision: 347524 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 84B05819F4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 13:29:53 -0000 Author: mav Date: Mon May 13 13:29:51 2019 New Revision: 347524 URL: https://svnweb.freebsd.org/changeset/base/347524 Log: MFC r347160: Decode some more ATA commands found in ACS-4. Modified: stable/12/sys/cam/ata/ata_all.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ata/ata_all.c ============================================================================== --- stable/12/sys/cam/ata/ata_all.c Mon May 13 13:28:42 2019 (r347523) +++ stable/12/sys/cam/ata/ata_all.c Mon May 13 13:29:51 2019 (r347524) @@ -89,8 +89,14 @@ ata_op_string(struct ata_cmd *cmd) case 0x01: return ("DSM TRIM"); } return "DSM"; + case 0x07: + switch (cmd->features) { + case 0x01: return ("DSM_XL TRIM"); + } + return "DSM_XL"; case 0x08: return ("DEVICE_RESET"); case 0x0b: return ("REQUEST_SENSE_DATA_EXT"); + case 0x12: return ("GET_PHYSICAL_ELEMENT_STATUS"); case 0x20: return ("READ"); case 0x24: return ("READ48"); case 0x25: return ("READ_DMA48"); @@ -113,7 +119,11 @@ ata_op_string(struct ata_cmd *cmd) case 0x3f: return ("WRITE_LOG_EXT"); case 0x40: return ("READ_VERIFY"); case 0x42: return ("READ_VERIFY48"); - case 0x44: return ("ZERO_EXT"); + case 0x44: + switch (cmd->features) { + case 0x01: return ("ZERO_EXT TRIM"); + } + return "ZERO_EXT"; case 0x45: switch (cmd->features) { case 0x55: return ("WRITE_UNCORRECTABLE48 PSEUDO"); @@ -135,6 +145,9 @@ ata_op_string(struct ata_cmd *cmd) switch (cmd->features & 0xf) { case 0x00: return ("NCQ_NON_DATA ABORT NCQ QUEUE"); case 0x01: return ("NCQ_NON_DATA DEADLINE HANDLING"); + case 0x02: return ("NCQ_NON_DATA HYBRID DEMOTE BY SIZE"); + case 0x03: return ("NCQ_NON_DATA HYBRID CHANGE BY LBA RANGE"); + case 0x04: return ("NCQ_NON_DATA HYBRID CONTROL"); case 0x05: return ("NCQ_NON_DATA SET FEATURES"); /* * XXX KDM need common decoding between NCQ and non-NCQ @@ -147,6 +160,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x64: switch (cmd->sector_count_exp & 0xf) { case 0x00: return ("SEND_FPDMA_QUEUED DATA SET MANAGEMENT"); + case 0x01: return ("SEND_FPDMA_QUEUED HYBRID EVICT"); case 0x02: return ("SEND_FPDMA_QUEUED WRITE LOG DMA EXT"); case 0x03: return ("SEND_FPDMA_QUEUED ZAC MANAGEMENT OUT"); case 0x04: return ("SEND_FPDMA_QUEUED DATA SET MANAGEMENT XL"); @@ -171,6 +185,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x70: return ("SEEK"); case 0x77: return ("SET_DATE_TIME_EXT"); case 0x78: return ("ACCESSIBLE_MAX_ADDRESS_CONFIGURATION"); + case 0x7C: return ("REMOVE_ELEMENT_AND_TRUNCATE"); case 0x87: return ("CFA_TRANSLATE_SECTOR"); case 0x90: return ("EXECUTE_DEVICE_DIAGNOSTIC"); case 0x92: return ("DOWNLOAD_MICROCODE"); @@ -185,13 +200,15 @@ ata_op_string(struct ata_cmd *cmd) case 0xd1: return ("SMART READ ATTR THRESHOLDS"); case 0xd3: return ("SMART SAVE ATTR VALUES"); case 0xd4: return ("SMART EXECUTE OFFLINE IMMEDIATE"); - case 0xd5: return ("SMART READ LOG DATA"); + case 0xd5: return ("SMART READ LOG"); + case 0xd6: return ("SMART WRITE LOG"); case 0xd8: return ("SMART ENABLE OPERATION"); case 0xd9: return ("SMART DISABLE OPERATION"); case 0xda: return ("SMART RETURN STATUS"); } return ("SMART"); case 0xb1: return ("DEVICE CONFIGURATION"); + case 0xb2: return ("SET_SECTOR_CONFIGURATION_EXT"); case 0xb4: return ("SANITIZE_DEVICE"); case 0xc0: return ("CFA_ERASE"); case 0xc4: return ("READ_MUL"); @@ -229,7 +246,7 @@ ata_op_string(struct ata_cmd *cmd) switch (cmd->features) { case 0x02: return ("SETFEATURES ENABLE WCACHE"); case 0x03: return ("SETFEATURES SET TRANSFER MODE"); - case 0x04: return ("SETFEATURES ENABLE APM"); + case 0x05: return ("SETFEATURES ENABLE APM"); case 0x06: return ("SETFEATURES ENABLE PUIS"); case 0x07: return ("SETFEATURES SPIN-UP"); case 0x0b: return ("SETFEATURES ENABLE WRITE READ VERIFY"); @@ -239,6 +256,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x43: return ("SETFEATURES SET MAX HOST INT SECT TIMES"); case 0x45: return ("SETFEATURES SET RATE BASIS"); case 0x4a: return ("SETFEATURES EXTENDED POWER CONDITIONS"); + case 0x50: return ("SETFEATURES ADVANCED BACKGROUD OPERATION"); case 0x55: return ("SETFEATURES DISABLE RCACHE"); case 0x5d: return ("SETFEATURES ENABLE RELIRQ"); case 0x5e: return ("SETFEATURES ENABLE SRVIRQ"); From owner-svn-src-all@freebsd.org Mon May 13 13:30:35 2019 Return-Path: Delivered-To: svn-src-all@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 3EF8F15901EE; Mon, 13 May 2019 13:30:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DAC9881BC1; Mon, 13 May 2019 13:30:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B52E2A687; Mon, 13 May 2019 13:30:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DDUYCa082310; Mon, 13 May 2019 13:30:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DDUYDf082309; Mon, 13 May 2019 13:30:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201905131330.x4DDUYDf082309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 13 May 2019 13:30:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347525 - stable/11/sys/cam/ata X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ata X-SVN-Commit-Revision: 347525 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DAC9881BC1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 13:30:35 -0000 Author: mav Date: Mon May 13 13:30:34 2019 New Revision: 347525 URL: https://svnweb.freebsd.org/changeset/base/347525 Log: MFC r347160: Decode some more ATA commands found in ACS-4. Modified: stable/11/sys/cam/ata/ata_all.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_all.c ============================================================================== --- stable/11/sys/cam/ata/ata_all.c Mon May 13 13:29:51 2019 (r347524) +++ stable/11/sys/cam/ata/ata_all.c Mon May 13 13:30:34 2019 (r347525) @@ -87,8 +87,14 @@ ata_op_string(struct ata_cmd *cmd) case 0x01: return ("DSM TRIM"); } return "DSM"; + case 0x07: + switch (cmd->features) { + case 0x01: return ("DSM_XL TRIM"); + } + return "DSM_XL"; case 0x08: return ("DEVICE_RESET"); case 0x0b: return ("REQUEST_SENSE_DATA_EXT"); + case 0x12: return ("GET_PHYSICAL_ELEMENT_STATUS"); case 0x20: return ("READ"); case 0x24: return ("READ48"); case 0x25: return ("READ_DMA48"); @@ -111,7 +117,11 @@ ata_op_string(struct ata_cmd *cmd) case 0x3f: return ("WRITE_LOG_EXT"); case 0x40: return ("READ_VERIFY"); case 0x42: return ("READ_VERIFY48"); - case 0x44: return ("ZERO_EXT"); + case 0x44: + switch (cmd->features) { + case 0x01: return ("ZERO_EXT TRIM"); + } + return "ZERO_EXT"; case 0x45: switch (cmd->features) { case 0x55: return ("WRITE_UNCORRECTABLE48 PSEUDO"); @@ -133,6 +143,9 @@ ata_op_string(struct ata_cmd *cmd) switch (cmd->features & 0xf) { case 0x00: return ("NCQ_NON_DATA ABORT NCQ QUEUE"); case 0x01: return ("NCQ_NON_DATA DEADLINE HANDLING"); + case 0x02: return ("NCQ_NON_DATA HYBRID DEMOTE BY SIZE"); + case 0x03: return ("NCQ_NON_DATA HYBRID CHANGE BY LBA RANGE"); + case 0x04: return ("NCQ_NON_DATA HYBRID CONTROL"); case 0x05: return ("NCQ_NON_DATA SET FEATURES"); /* * XXX KDM need common decoding between NCQ and non-NCQ @@ -145,6 +158,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x64: switch (cmd->sector_count_exp & 0xf) { case 0x00: return ("SEND_FPDMA_QUEUED DATA SET MANAGEMENT"); + case 0x01: return ("SEND_FPDMA_QUEUED HYBRID EVICT"); case 0x02: return ("SEND_FPDMA_QUEUED WRITE LOG DMA EXT"); case 0x03: return ("SEND_FPDMA_QUEUED ZAC MANAGEMENT OUT"); case 0x04: return ("SEND_FPDMA_QUEUED DATA SET MANAGEMENT XL"); @@ -169,6 +183,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x70: return ("SEEK"); case 0x77: return ("SET_DATE_TIME_EXT"); case 0x78: return ("ACCESSIBLE_MAX_ADDRESS_CONFIGURATION"); + case 0x7C: return ("REMOVE_ELEMENT_AND_TRUNCATE"); case 0x87: return ("CFA_TRANSLATE_SECTOR"); case 0x90: return ("EXECUTE_DEVICE_DIAGNOSTIC"); case 0x92: return ("DOWNLOAD_MICROCODE"); @@ -183,13 +198,15 @@ ata_op_string(struct ata_cmd *cmd) case 0xd1: return ("SMART READ ATTR THRESHOLDS"); case 0xd3: return ("SMART SAVE ATTR VALUES"); case 0xd4: return ("SMART EXECUTE OFFLINE IMMEDIATE"); - case 0xd5: return ("SMART READ LOG DATA"); + case 0xd5: return ("SMART READ LOG"); + case 0xd6: return ("SMART WRITE LOG"); case 0xd8: return ("SMART ENABLE OPERATION"); case 0xd9: return ("SMART DISABLE OPERATION"); case 0xda: return ("SMART RETURN STATUS"); } return ("SMART"); case 0xb1: return ("DEVICE CONFIGURATION"); + case 0xb2: return ("SET_SECTOR_CONFIGURATION_EXT"); case 0xb4: return ("SANITIZE_DEVICE"); case 0xc0: return ("CFA_ERASE"); case 0xc4: return ("READ_MUL"); @@ -227,7 +244,7 @@ ata_op_string(struct ata_cmd *cmd) switch (cmd->features) { case 0x02: return ("SETFEATURES ENABLE WCACHE"); case 0x03: return ("SETFEATURES SET TRANSFER MODE"); - case 0x04: return ("SETFEATURES ENABLE APM"); + case 0x05: return ("SETFEATURES ENABLE APM"); case 0x06: return ("SETFEATURES ENABLE PUIS"); case 0x07: return ("SETFEATURES SPIN-UP"); case 0x0b: return ("SETFEATURES ENABLE WRITE READ VERIFY"); @@ -237,6 +254,7 @@ ata_op_string(struct ata_cmd *cmd) case 0x43: return ("SETFEATURES SET MAX HOST INT SECT TIMES"); case 0x45: return ("SETFEATURES SET RATE BASIS"); case 0x4a: return ("SETFEATURES EXTENDED POWER CONDITIONS"); + case 0x50: return ("SETFEATURES ADVANCED BACKGROUD OPERATION"); case 0x55: return ("SETFEATURES DISABLE RCACHE"); case 0x5d: return ("SETFEATURES ENABLE RELIRQ"); case 0x5e: return ("SETFEATURES ENABLE SRVIRQ"); From owner-svn-src-all@freebsd.org Mon May 13 13:45:30 2019 Return-Path: Delivered-To: svn-src-all@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 E25081590A0A; Mon, 13 May 2019 13:45:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92F0482807; Mon, 13 May 2019 13:45:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4D359A9D3; Mon, 13 May 2019 13:45:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DDjTvV092670; Mon, 13 May 2019 13:45:29 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DDjTRn092669; Mon, 13 May 2019 13:45:29 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905131345.x4DDjTRn092669@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 13:45:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347526 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 347526 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 92F0482807 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 13:45:30 -0000 Author: ae Date: Mon May 13 13:45:28 2019 New Revision: 347526 URL: https://svnweb.freebsd.org/changeset/base/347526 Log: Rework locking in BPF code to remove rwlock from fast path. On high packets rate the contention on rwlock in bpf_*tap*() functions can lead to packets dropping. To avoid this, migrate this code to use epoch(9) KPI and ConcurrencyKit's lists. * all lists changed to use CK_LIST; * reference counting added to bpf_if and bpf_d; * now bpf_if references ifnet and releases this reference on destroy; * each bpf_d descriptor references bpf_if when it is attached; * new struct bpf_program_buffer introduced to keep BPF filter programs; * bpf_program_buffer, bpf_d and bpf_if structures are freed by epoch_call(); * bpf_freelist and ifnet_departure event are no longer needed, thus both are removed; Reviewed by: melifaro Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D20224 Modified: head/sys/net/bpf.c head/sys/net/bpf.h head/sys/net/bpfdesc.h Modified: head/sys/net/bpf.c ============================================================================== --- head/sys/net/bpf.c Mon May 13 13:30:34 2019 (r347525) +++ head/sys/net/bpf.c Mon May 13 13:45:28 2019 (r347526) @@ -3,6 +3,7 @@ * * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2019 Andrey V. Elsukov * * This code is derived from the Stanford/CMU enet packet filter, * (net/enet.c) distributed as part of 4.3BSD, and code contributed @@ -46,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -99,7 +99,7 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); static struct bpf_if_ext dead_bpf_if = { - .bif_dlist = LIST_HEAD_INITIALIZER() + .bif_dlist = CK_LIST_HEAD_INITIALIZER() }; struct bpf_if { @@ -108,19 +108,22 @@ struct bpf_if { struct bpf_if_ext bif_ext; /* public members */ u_int bif_dlt; /* link layer type */ u_int bif_hdrlen; /* length of link header */ + struct bpfd_list bif_wlist; /* writer-only list */ struct ifnet *bif_ifp; /* corresponding interface */ - struct rwlock bif_lock; /* interface lock */ - LIST_HEAD(, bpf_d) bif_wlist; /* writer-only list */ - int bif_flags; /* Interface flags */ struct bpf_if **bif_bpf; /* Pointer to pointer to us */ + volatile u_int bif_refcnt; + struct epoch_context epoch_ctx; }; CTASSERT(offsetof(struct bpf_if, bif_ext) == 0); -#define BPFIF_RLOCK(bif) rw_rlock(&(bif)->bif_lock) -#define BPFIF_RUNLOCK(bif) rw_runlock(&(bif)->bif_lock) -#define BPFIF_WLOCK(bif) rw_wlock(&(bif)->bif_lock) -#define BPFIF_WUNLOCK(bif) rw_wunlock(&(bif)->bif_lock) +struct bpf_program_buffer { + struct epoch_context epoch_ctx; +#ifdef BPF_JITTER + bpf_jit_filter *func; +#endif + void *buffer[0]; +}; #if defined(DEV_BPF) || defined(NETGRAPH_BPF) @@ -173,18 +176,24 @@ struct bpf_dltlist32 { #define BPF_LOCK_ASSERT() sx_assert(&bpf_sx, SA_XLOCKED) /* * bpf_iflist is a list of BPF interface structures, each corresponding to a - * specific DLT. The same network interface might have several BPF interface + * specific DLT. The same network interface might have several BPF interface * structures registered by different layers in the stack (i.e., 802.11 * frames, ethernet frames, etc). */ -static LIST_HEAD(, bpf_if) bpf_iflist, bpf_freelist; +CK_LIST_HEAD(bpf_iflist, bpf_if); +static struct bpf_iflist bpf_iflist; static struct sx bpf_sx; /* bpf global lock */ static int bpf_bpfd_cnt; +static void bpfif_ref(struct bpf_if *); +static void bpfif_rele(struct bpf_if *); + +static void bpfd_ref(struct bpf_d *); +static void bpfd_rele(struct bpf_d *); static void bpf_attachd(struct bpf_d *, struct bpf_if *); static void bpf_detachd(struct bpf_d *); -static void bpf_detachd_locked(struct bpf_d *); -static void bpf_freed(struct bpf_d *); +static void bpf_detachd_locked(struct bpf_d *, bool); +static void bpfd_free(epoch_context_t); static int bpf_movein(struct uio *, int, struct ifnet *, struct mbuf **, struct sockaddr *, int *, struct bpf_d *); static int bpf_setif(struct bpf_d *, struct ifreq *); @@ -243,37 +252,106 @@ static struct filterops bpfread_filtops = { .f_event = filt_bpfread, }; -eventhandler_tag bpf_ifdetach_cookie = NULL; - /* - * LOCKING MODEL USED BY BPF: + * LOCKING MODEL USED BY BPF + * * Locks: - * 1) global lock (BPF_LOCK). Mutex, used to protect interface addition/removal, - * some global counters and every bpf_if reference. - * 2) Interface lock. Rwlock, used to protect list of BPF descriptors and their filters. - * 3) Descriptor lock. Mutex, used to protect BPF buffers and various structure fields - * used by bpf_mtap code. + * 1) global lock (BPF_LOCK). Sx, used to protect some global counters, + * every bpf_iflist changes, serializes ioctl access to bpf descriptors. + * 2) Descriptor lock. Mutex, used to protect BPF buffers and various + * structure fields used by bpf_*tap* code. * - * Lock order: + * Lock order: global lock, then descriptor lock. * - * Global lock, interface lock, descriptor lock + * There are several possible consumers: * - * We have to acquire interface lock before descriptor main lock due to BPF_MTAP[2] - * working model. In many places (like bpf_detachd) we start with BPF descriptor - * (and we need to at least rlock it to get reliable interface pointer). This - * gives us potential LOR. As a result, we use global lock to protect from bpf_if - * change in every such place. + * 1. The kernel registers interface pointer with bpfattach(). + * Each call allocates new bpf_if structure, references ifnet pointer + * and links bpf_if into bpf_iflist chain. This is protected with global + * lock. * - * Changing d->bd_bif is protected by 1) global lock, 2) interface lock and - * 3) descriptor main wlock. - * Reading bd_bif can be protected by any of these locks, typically global lock. + * 2. An userland application uses ioctl() call to bpf_d descriptor. + * All such call are serialized with global lock. BPF filters can be + * changed, but pointer to old filter will be freed using epoch_call(). + * Thus it should be safe for bpf_tap/bpf_mtap* code to do access to + * filter pointers, even if change will happen during bpf_tap execution. + * Destroying of bpf_d descriptor also is doing using epoch_call(). * - * Changing read/write BPF filter is protected by the same three locks, - * the same applies for reading. + * 3. An userland application can write packets into bpf_d descriptor. + * There we need to be sure, that ifnet won't disappear during bpfwrite(). * - * Sleeping in global lock is not allowed due to bpfdetach() using it. + * 4. The kernel invokes bpf_tap/bpf_mtap* functions. The access to + * bif_dlist is protected with net_epoch_preempt section. So, it should + * be safe to make access to bpf_d descriptor inside the section. + * + * 5. The kernel invokes bpfdetach() on interface destroying. All lists + * are modified with global lock held and actual free() is done using + * epoch_call(). */ +static void +bpfif_free(epoch_context_t ctx) +{ + struct bpf_if *bp; + + bp = __containerof(ctx, struct bpf_if, epoch_ctx); + if_rele(bp->bif_ifp); + free(bp, M_BPF); +} + +static void +bpfif_ref(struct bpf_if *bp) +{ + + refcount_acquire(&bp->bif_refcnt); +} + +static void +bpfif_rele(struct bpf_if *bp) +{ + + if (!refcount_release(&bp->bif_refcnt)) + return; + epoch_call(net_epoch_preempt, &bp->epoch_ctx, bpfif_free); +} + +static void +bpfd_ref(struct bpf_d *d) +{ + + refcount_acquire(&d->bd_refcnt); +} + +static void +bpfd_rele(struct bpf_d *d) +{ + + if (!refcount_release(&d->bd_refcnt)) + return; + epoch_call(net_epoch_preempt, &d->epoch_ctx, bpfd_free); +} + +static struct bpf_program_buffer* +bpf_program_buffer_alloc(size_t size, int flags) +{ + + return (malloc(sizeof(struct bpf_program_buffer) + size, + M_BPF, flags)); +} + +static void +bpf_program_buffer_free(epoch_context_t ctx) +{ + struct bpf_program_buffer *ptr; + + ptr = __containerof(ctx, struct bpf_program_buffer, epoch_ctx); +#ifdef BPF_JITTER + if (ptr->func != NULL) + bpf_destroy_jit_filter(ptr->func); +#endif + free(ptr, M_BPF); +} + /* * Wrapper functions for various buffering methods. If the set of buffer * modes expands, we will probably want to introduce a switch data structure @@ -627,7 +705,8 @@ bad: } /* - * Attach file to the bpf interface, i.e. make d listen on bp. + * Attach descriptor to the bpf interface, i.e. make d listen on bp, + * then reset its buffers and counters with reset_d(). */ static void bpf_attachd(struct bpf_d *d, struct bpf_if *bp) @@ -643,7 +722,7 @@ bpf_attachd(struct bpf_d *d, struct bpf_if *bp) op_w = V_bpf_optimize_writers || d->bd_writer; if (d->bd_bif != NULL) - bpf_detachd_locked(d); + bpf_detachd_locked(d, false); /* * Point d at bp, and add d to the interface's list. * Since there are many applications using BPF for @@ -652,26 +731,27 @@ bpf_attachd(struct bpf_d *d, struct bpf_if *bp) * some filter is configured. */ - BPFIF_WLOCK(bp); BPFD_LOCK(d); - + /* + * Hold reference to bpif while descriptor uses this interface. + */ + bpfif_ref(bp); d->bd_bif = bp; - if (op_w != 0) { /* Add to writers-only list */ - LIST_INSERT_HEAD(&bp->bif_wlist, d, bd_next); + CK_LIST_INSERT_HEAD(&bp->bif_wlist, d, bd_next); /* * We decrement bd_writer on every filter set operation. * First BIOCSETF is done by pcap_open_live() to set up - * snap length. After that appliation usually sets its own filter + * snap length. After that appliation usually sets its own + * filter. */ d->bd_writer = 2; } else - LIST_INSERT_HEAD(&bp->bif_dlist, d, bd_next); + CK_LIST_INSERT_HEAD(&bp->bif_dlist, d, bd_next); + reset_d(d); BPFD_UNLOCK(d); - BPFIF_WUNLOCK(bp); - bpf_bpfd_cnt++; CTR3(KTR_NET, "%s: bpf_attach called by pid %d, adding to %s list", @@ -685,7 +765,8 @@ bpf_attachd(struct bpf_d *d, struct bpf_if *bp) * Check if we need to upgrade our descriptor @d from write-only mode. */ static int -bpf_check_upgrade(u_long cmd, struct bpf_d *d, struct bpf_insn *fcode, int flen) +bpf_check_upgrade(u_long cmd, struct bpf_d *d, struct bpf_insn *fcode, + int flen) { int is_snap, need_upgrade; @@ -705,7 +786,8 @@ bpf_check_upgrade(u_long cmd, struct bpf_d *d, struct * we'd prefer to treat k=0 (deny ALL) case the same way: e.g. * do not consider upgrading immediately */ - if (cmd == BIOCSETF && flen == 1 && fcode[0].code == (BPF_RET | BPF_K)) + if (cmd == BIOCSETF && flen == 1 && + fcode[0].code == (BPF_RET | BPF_K)) is_snap = 1; else is_snap = 0; @@ -743,88 +825,45 @@ bpf_check_upgrade(u_long cmd, struct bpf_d *d, struct } /* - * Add d to the list of active bp filters. - * Requires bpf_attachd() to be called before. - */ -static void -bpf_upgraded(struct bpf_d *d) -{ - struct bpf_if *bp; - - BPF_LOCK_ASSERT(); - - bp = d->bd_bif; - - /* - * Filter can be set several times without specifying interface. - * Mark d as reader and exit. - */ - if (bp == NULL) { - BPFD_LOCK(d); - d->bd_writer = 0; - BPFD_UNLOCK(d); - return; - } - - BPFIF_WLOCK(bp); - BPFD_LOCK(d); - - /* Remove from writers-only list */ - LIST_REMOVE(d, bd_next); - LIST_INSERT_HEAD(&bp->bif_dlist, d, bd_next); - /* Mark d as reader */ - d->bd_writer = 0; - - BPFD_UNLOCK(d); - BPFIF_WUNLOCK(bp); - - CTR2(KTR_NET, "%s: upgrade required by pid %d", __func__, d->bd_pid); - - EVENTHANDLER_INVOKE(bpf_track, bp->bif_ifp, bp->bif_dlt, 1); -} - -/* * Detach a file from its interface. */ static void bpf_detachd(struct bpf_d *d) { BPF_LOCK(); - bpf_detachd_locked(d); + bpf_detachd_locked(d, false); BPF_UNLOCK(); } static void -bpf_detachd_locked(struct bpf_d *d) +bpf_detachd_locked(struct bpf_d *d, bool detached_ifp) { - int error; struct bpf_if *bp; struct ifnet *ifp; + int error; + BPF_LOCK_ASSERT(); CTR2(KTR_NET, "%s: detach required by pid %d", __func__, d->bd_pid); - BPF_LOCK_ASSERT(); - /* Check if descriptor is attached */ if ((bp = d->bd_bif) == NULL) return; - BPFIF_WLOCK(bp); BPFD_LOCK(d); - + /* Remove d from the interface's descriptor list. */ + CK_LIST_REMOVE(d, bd_next); /* Save bd_writer value */ error = d->bd_writer; - - /* - * Remove d from the interface's descriptor list. - */ - LIST_REMOVE(d, bd_next); - ifp = bp->bif_ifp; d->bd_bif = NULL; + if (detached_ifp) { + /* + * Notify descriptor as it's detached, so that any + * sleepers wake up and get ENXIO. + */ + bpf_wakeup(d); + } BPFD_UNLOCK(d); - BPFIF_WUNLOCK(bp); - bpf_bpfd_cnt--; /* Call event handler iff d is attached */ @@ -833,9 +872,9 @@ bpf_detachd_locked(struct bpf_d *d) /* * Check if this descriptor had requested promiscuous mode. - * If so, turn it off. + * If so and ifnet is not detached, turn it off. */ - if (d->bd_promisc) { + if (d->bd_promisc && !detached_ifp) { d->bd_promisc = 0; CURVNET_SET(ifp->if_vnet); error = ifpromisc(ifp, 0); @@ -851,6 +890,7 @@ bpf_detachd_locked(struct bpf_d *d) "bpf_detach: ifpromisc failed (%d)\n", error); } } + bpfif_rele(bp); } /* @@ -875,8 +915,7 @@ bpf_dtor(void *data) seldrain(&d->bd_sel); knlist_destroy(&d->bd_sel.si_note); callout_drain(&d->bd_callout); - bpf_freed(d); - free(d, M_BPF); + bpfd_rele(d); } /* @@ -918,6 +957,7 @@ bpfopen(struct cdev *dev, int flags, int fmt, struct t d->bd_bufmode = BPF_BUFMODE_BUFFER; d->bd_sig = SIGIO; d->bd_direction = BPF_D_INOUT; + d->bd_refcnt = 1; BPF_PID_REFRESH(d, td); #ifdef MAC mac_bpfdesc_init(d); @@ -1093,7 +1133,8 @@ bpf_timed_out(void *arg) BPFD_LOCK_ASSERT(d); - if (callout_pending(&d->bd_callout) || !callout_active(&d->bd_callout)) + if (callout_pending(&d->bd_callout) || + !callout_active(&d->bd_callout)) return; if (d->bd_state == BPF_WAITING) { d->bd_state = BPF_TIMED_OUT; @@ -1119,47 +1160,71 @@ bpf_ready(struct bpf_d *d) static int bpfwrite(struct cdev *dev, struct uio *uio, int ioflag) { + struct route ro; + struct sockaddr dst; + struct epoch_tracker et; + struct bpf_if *bp; struct bpf_d *d; struct ifnet *ifp; struct mbuf *m, *mc; - struct sockaddr dst; - struct route ro; int error, hlen; error = devfs_get_cdevpriv((void **)&d); if (error != 0) return (error); + NET_EPOCH_ENTER(et); + BPFD_LOCK(d); BPF_PID_REFRESH_CUR(d); counter_u64_add(d->bd_wcount, 1); - /* XXX: locking required */ - if (d->bd_bif == NULL) { - counter_u64_add(d->bd_wdcount, 1); - return (ENXIO); + if ((bp = d->bd_bif) == NULL) { + error = ENXIO; + goto out_locked; } - ifp = d->bd_bif->bif_ifp; - + ifp = bp->bif_ifp; if ((ifp->if_flags & IFF_UP) == 0) { - counter_u64_add(d->bd_wdcount, 1); - return (ENETDOWN); + error = ENETDOWN; + goto out_locked; } - if (uio->uio_resid == 0) { - counter_u64_add(d->bd_wdcount, 1); - return (0); - } + if (uio->uio_resid == 0) + goto out_locked; bzero(&dst, sizeof(dst)); m = NULL; hlen = 0; - /* XXX: bpf_movein() can sleep */ - error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, ifp, + + /* + * Take extra reference, unlock d and exit from epoch section, + * since bpf_movein() can sleep. + */ + bpfd_ref(d); + NET_EPOCH_EXIT(et); + BPFD_UNLOCK(d); + + error = bpf_movein(uio, (int)bp->bif_dlt, ifp, &m, &dst, &hlen, d); - if (error) { + + if (error != 0) { counter_u64_add(d->bd_wdcount, 1); + bpfd_rele(d); return (error); } + + BPFD_LOCK(d); + /* + * Check that descriptor is still attached to the interface. + * This can happen on bpfdetach(). To avoid access to detached + * ifnet, free mbuf and return ENXIO. + */ + if (d->bd_bif == NULL) { + counter_u64_add(d->bd_wdcount, 1); + BPFD_UNLOCK(d); + bpfd_rele(d); + m_freem(m); + return (ENXIO); + } counter_u64_add(d->bd_wfcount, 1); if (d->bd_hdrcmplt) dst.sa_family = pseudo_AF_HDRCMPLT; @@ -1180,11 +1245,9 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag CURVNET_SET(ifp->if_vnet); #ifdef MAC - BPFD_LOCK(d); mac_bpfdesc_create_mbuf(d, m); if (mc != NULL) mac_bpfdesc_create_mbuf(d, mc); - BPFD_UNLOCK(d); #endif bzero(&ro, sizeof(ro)); @@ -1205,7 +1268,14 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag m_freem(mc); } CURVNET_RESTORE(); + BPFD_UNLOCK(d); + bpfd_rele(d); + return (error); +out_locked: + counter_u64_add(d->bd_wdcount, 1); + NET_EPOCH_EXIT(et); + BPFD_UNLOCK(d); return (error); } @@ -1830,16 +1900,11 @@ bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, i } /* - * Set d's packet filter program to fp. If this file already has a filter, - * free it and replace it. Returns EINVAL for bogus requests. + * Set d's packet filter program to fp. If this file already has a filter, + * free it and replace it. Returns EINVAL for bogus requests. * - * Note we need global lock here to serialize bpf_setf() and bpf_setif() calls - * since reading d->bd_bif can't be protected by d or interface lock due to - * lock order. - * - * Additionally, we have to acquire interface write lock due to bpf_mtap() uses - * interface read lock to read all filers. - * + * Note we use global lock here to serialize bpf_setf() and bpf_setif() + * calls. */ static int bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_long cmd) @@ -1848,13 +1913,14 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_lo struct bpf_program fp_swab; struct bpf_program32 *fp32; #endif - struct bpf_insn *fcode, *old; + struct bpf_program_buffer *fcode; + struct bpf_insn *filter; #ifdef BPF_JITTER - bpf_jit_filter *jfunc, *ofunc; + bpf_jit_filter *jfunc; #endif size_t size; u_int flen; - int need_upgrade; + bool track_event; #ifdef COMPAT_FREEBSD32 switch (cmd) { @@ -1863,7 +1929,8 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_lo case BIOCSETFNR32: fp32 = (struct bpf_program32 *)fp; fp_swab.bf_len = fp32->bf_len; - fp_swab.bf_insns = (struct bpf_insn *)(uintptr_t)fp32->bf_insns; + fp_swab.bf_insns = + (struct bpf_insn *)(uintptr_t)fp32->bf_insns; fp = &fp_swab; switch (cmd) { case BIOCSETF32: @@ -1877,12 +1944,10 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_lo } #endif - fcode = NULL; + filter = NULL; #ifdef BPF_JITTER - jfunc = ofunc = NULL; + jfunc = NULL; #endif - need_upgrade = 0; - /* * Check new filter validness before acquiring any locks. * Allocate memory for new filter, if needed. @@ -1892,10 +1957,11 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_lo return (EINVAL); size = flen * sizeof(*fp->bf_insns); if (size > 0) { - /* We're setting up new filter. Copy and check actual data. */ - fcode = malloc(size, M_BPF, M_WAITOK); - if (copyin(fp->bf_insns, fcode, size) != 0 || - !bpf_validate(fcode, flen)) { + /* We're setting up new filter. Copy and check actual data. */ + fcode = bpf_program_buffer_alloc(size, M_WAITOK); + filter = (struct bpf_insn *)fcode->buffer; + if (copyin(fp->bf_insns, filter, size) != 0 || + !bpf_validate(filter, flen)) { free(fcode, M_BPF); return (EINVAL); } @@ -1905,50 +1971,73 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_lo * Filter is copied inside fcode and is * perfectly valid. */ - jfunc = bpf_jitter(fcode, flen); + jfunc = bpf_jitter(filter, flen); } #endif } - BPF_LOCK(); + track_event = false; + fcode = NULL; - /* - * Set up new filter. - * Protect filter change by interface lock. - * Additionally, we are protected by global lock here. - */ - if (d->bd_bif != NULL) - BPFIF_WLOCK(d->bd_bif); + BPF_LOCK(); BPFD_LOCK(d); + /* Set up new filter. */ if (cmd == BIOCSETWF) { - old = d->bd_wfilter; - d->bd_wfilter = fcode; + if (d->bd_wfilter != NULL) { + fcode = __containerof((void *)d->bd_wfilter, + struct bpf_program_buffer, buffer); +#ifdef BPF_JITTER + fcode->func = NULL; +#endif + } + d->bd_wfilter = filter; } else { - old = d->bd_rfilter; - d->bd_rfilter = fcode; + if (d->bd_rfilter != NULL) { + fcode = __containerof((void *)d->bd_rfilter, + struct bpf_program_buffer, buffer); #ifdef BPF_JITTER - ofunc = d->bd_bfilter; + fcode->func = d->bd_bfilter; +#endif + } + d->bd_rfilter = filter; +#ifdef BPF_JITTER d->bd_bfilter = jfunc; #endif if (cmd == BIOCSETF) reset_d(d); - need_upgrade = bpf_check_upgrade(cmd, d, fcode, flen); + if (bpf_check_upgrade(cmd, d, filter, flen) != 0) { + /* + * Filter can be set several times without + * specifying interface. In this case just mark d + * as reader. + */ + d->bd_writer = 0; + if (d->bd_bif != NULL) { + /* + * Remove descriptor from writers-only list + * and add it to active readers list. + */ + CK_LIST_REMOVE(d, bd_next); + CK_LIST_INSERT_HEAD(&d->bd_bif->bif_dlist, + d, bd_next); + CTR2(KTR_NET, + "%s: upgrade required by pid %d", + __func__, d->bd_pid); + track_event = true; + } + } } BPFD_UNLOCK(d); - if (d->bd_bif != NULL) - BPFIF_WUNLOCK(d->bd_bif); - if (old != NULL) - free(old, M_BPF); -#ifdef BPF_JITTER - if (ofunc != NULL) - bpf_destroy_jit_filter(ofunc); -#endif - /* Move d to active readers list. */ - if (need_upgrade != 0) - bpf_upgraded(d); + if (fcode != NULL) + epoch_call(net_epoch_preempt, &fcode->epoch_ctx, + bpf_program_buffer_free); + if (track_event) + EVENTHANDLER_INVOKE(bpf_track, + d->bd_bif->bif_ifp, d->bd_bif->bif_dlt, 1); + BPF_UNLOCK(); return (0); } @@ -1971,15 +2060,6 @@ bpf_setif(struct bpf_d *d, struct ifreq *ifr) return (ENXIO); bp = theywant->if_bpf; - - /* Check if interface is not being detached from BPF */ - BPFIF_RLOCK(bp); - if (bp->bif_flags & BPFIF_FLAG_DYING) { - BPFIF_RUNLOCK(bp); - return (ENXIO); - } - BPFIF_RUNLOCK(bp); - /* * At this point, we expect the buffer is already allocated. If not, * return an error. @@ -1996,9 +2076,11 @@ bpf_setif(struct bpf_d *d, struct ifreq *ifr) } if (bp != d->bd_bif) bpf_attachd(d, bp); - BPFD_LOCK(d); - reset_d(d); - BPFD_UNLOCK(d); + else { + BPFD_LOCK(d); + reset_d(d); + BPFD_UNLOCK(d); + } return (0); } @@ -2150,6 +2232,7 @@ bpf_gettime(struct bintime *bt, int tstype, struct mbu void bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) { + struct epoch_tracker et; struct bintime bt; struct bpf_d *d; #ifdef BPF_JITTER @@ -2159,24 +2242,14 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) int gottime; gottime = BPF_TSTAMP_NONE; - - BPFIF_RLOCK(bp); - - LIST_FOREACH(d, &bp->bif_dlist, bd_next) { - /* - * We are not using any locks for d here because: - * 1) any filter change is protected by interface - * write lock - * 2) destroying/detaching d is protected by interface - * write lock, too - */ - + NET_EPOCH_ENTER(et); + CK_LIST_FOREACH(d, &bp->bif_dlist, bd_next) { counter_u64_add(d->bd_rcount, 1); /* - * NB: We dont call BPF_CHECK_DIRECTION() here since there is no - * way for the caller to indiciate to us whether this packet - * is inbound or outbound. In the bpf_mtap() routines, we use - * the interface pointers on the mbuf to figure it out. + * NB: We dont call BPF_CHECK_DIRECTION() here since there + * is no way for the caller to indiciate to us whether this + * packet is inbound or outbound. In the bpf_mtap() routines, + * we use the interface pointers on the mbuf to figure it out. */ #ifdef BPF_JITTER bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL; @@ -2190,10 +2263,10 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) * Filter matches. Let's to acquire write lock. */ BPFD_LOCK(d); - counter_u64_add(d->bd_fcount, 1); if (gottime < bpf_ts_quality(d->bd_tstamp)) - gottime = bpf_gettime(&bt, d->bd_tstamp, NULL); + gottime = bpf_gettime(&bt, d->bd_tstamp, + NULL); #ifdef MAC if (mac_bpfdesc_check_receive(d, bp->bif_ifp) == 0) #endif @@ -2202,7 +2275,7 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) BPFD_UNLOCK(d); } } - BPFIF_RUNLOCK(bp); + NET_EPOCH_EXIT(et); } #define BPF_CHECK_DIRECTION(d, r, i) \ @@ -2216,6 +2289,7 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) void bpf_mtap(struct bpf_if *bp, struct mbuf *m) { + struct epoch_tracker et; struct bintime bt; struct bpf_d *d; #ifdef BPF_JITTER @@ -2233,9 +2307,8 @@ bpf_mtap(struct bpf_if *bp, struct mbuf *m) pktlen = m_length(m, NULL); gottime = BPF_TSTAMP_NONE; - BPFIF_RLOCK(bp); - - LIST_FOREACH(d, &bp->bif_dlist, bd_next) { + NET_EPOCH_ENTER(et); + CK_LIST_FOREACH(d, &bp->bif_dlist, bd_next) { if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif, bp->bif_ifp)) continue; counter_u64_add(d->bd_rcount, 1); @@ -2243,7 +2316,8 @@ bpf_mtap(struct bpf_if *bp, struct mbuf *m) bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL; /* XXX We cannot handle multiple mbufs. */ if (bf != NULL && m->m_next == NULL) - slen = (*(bf->func))(mtod(m, u_char *), pktlen, pktlen); + slen = (*(bf->func))(mtod(m, u_char *), pktlen, + pktlen); else #endif slen = bpf_filter(d->bd_rfilter, (u_char *)m, pktlen, 0); @@ -2261,7 +2335,7 @@ bpf_mtap(struct bpf_if *bp, struct mbuf *m) BPFD_UNLOCK(d); } } - BPFIF_RUNLOCK(bp); + NET_EPOCH_EXIT(et); } /* @@ -2271,6 +2345,7 @@ bpf_mtap(struct bpf_if *bp, struct mbuf *m) void bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m) { + struct epoch_tracker et; struct bintime bt; struct mbuf mb; struct bpf_d *d; @@ -2296,9 +2371,8 @@ bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, s gottime = BPF_TSTAMP_NONE; - BPFIF_RLOCK(bp); - - LIST_FOREACH(d, &bp->bif_dlist, bd_next) { + NET_EPOCH_ENTER(et); + CK_LIST_FOREACH(d, &bp->bif_dlist, bd_next) { if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif, bp->bif_ifp)) continue; counter_u64_add(d->bd_rcount, 1); @@ -2317,11 +2391,10 @@ bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, s BPFD_UNLOCK(d); } } - BPFIF_RUNLOCK(bp); + NET_EPOCH_EXIT(et); } #undef BPF_CHECK_DIRECTION - #undef BPF_TSTAMP_NONE #undef BPF_TSTAMP_FAST #undef BPF_TSTAMP_NORMAL @@ -2540,26 +2613,30 @@ copy: * Called on close. */ static void -bpf_freed(struct bpf_d *d) +bpfd_free(epoch_context_t ctx) { + struct bpf_d *d; + struct bpf_program_buffer *p; /* * We don't need to lock out interrupts since this descriptor has * been detached from its interface and it yet hasn't been marked * free. */ + d = __containerof(ctx, struct bpf_d, epoch_ctx); bpf_free(d); if (d->bd_rfilter != NULL) { - free((caddr_t)d->bd_rfilter, M_BPF); -#ifdef BPF_JITTER - if (d->bd_bfilter != NULL) - bpf_destroy_jit_filter(d->bd_bfilter); -#endif + p = __containerof((void *)d->bd_rfilter, + struct bpf_program_buffer, buffer); + bpf_program_buffer_free(&p->epoch_ctx); } - if (d->bd_wfilter != NULL) - free((caddr_t)d->bd_wfilter, M_BPF); - mtx_destroy(&d->bd_lock); + if (d->bd_wfilter != NULL) { + p = __containerof((void *)d->bd_wfilter, + struct bpf_program_buffer, buffer); + bpf_program_buffer_free(&p->epoch_ctx); + } + mtx_destroy(&d->bd_lock); counter_u64_free(d->bd_rcount); counter_u64_free(d->bd_dcount); counter_u64_free(d->bd_fcount); @@ -2567,7 +2644,7 @@ bpf_freed(struct bpf_d *d) counter_u64_free(d->bd_wfcount); counter_u64_free(d->bd_wdcount); counter_u64_free(d->bd_zcopy); - + free(d, M_BPF); } /* @@ -2588,25 +2665,31 @@ bpfattach(struct ifnet *ifp, u_int dlt, u_int hdrlen) * headers are not yet supporrted). */ void -bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp) +bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, + struct bpf_if **driverp) { struct bpf_if *bp; - KASSERT(*driverp == NULL, ("bpfattach2: driverp already initialized")); + KASSERT(*driverp == NULL, + ("bpfattach2: driverp already initialized")); bp = malloc(sizeof(*bp), M_BPF, M_WAITOK | M_ZERO); - rw_init(&bp->bif_lock, "bpf interface lock"); - LIST_INIT(&bp->bif_dlist); - LIST_INIT(&bp->bif_wlist); + CK_LIST_INIT(&bp->bif_dlist); + CK_LIST_INIT(&bp->bif_wlist); bp->bif_ifp = ifp; bp->bif_dlt = dlt; bp->bif_hdrlen = hdrlen; bp->bif_bpf = driverp; + bp->bif_refcnt = 1; *driverp = bp; - + /* + * Reference ifnet pointer, so it won't freed until + * we release it. + */ + if_ref(ifp); BPF_LOCK(); - LIST_INSERT_HEAD(&bpf_iflist, bp, bif_next); + CK_LIST_INSERT_HEAD(&bpf_iflist, bp, bif_next); BPF_UNLOCK(); if (bootverbose && IS_DEFAULT_VNET(curvnet)) @@ -2647,103 +2730,37 @@ bpf_get_bp_params(struct bpf_if *bp, u_int *bif_dlt, u void bpfdetach(struct ifnet *ifp) { - struct bpf_if *bp, *bp_temp; - struct bpf_d *d; - int ndetached; + struct bpf_if *bp, *bp_temp; + struct bpf_d *d; - ndetached = 0; - BPF_LOCK(); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon May 13 14:07:03 2019 Return-Path: Delivered-To: svn-src-all@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 40B151590F53; Mon, 13 May 2019 14:07:03 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D566D830FA; Mon, 13 May 2019 14:07:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AA04CAD43; Mon, 13 May 2019 14:07:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DE72vH003612; Mon, 13 May 2019 14:07:02 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DE72Bu003611; Mon, 13 May 2019 14:07:02 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905131407.x4DE72Bu003611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 14:07:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347527 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 347527 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D566D830FA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 14:07:03 -0000 Author: ae Date: Mon May 13 14:07:02 2019 New Revision: 347527 URL: https://svnweb.freebsd.org/changeset/base/347527 Log: Do not leak memory used for binary filter. Modified: head/sys/net/bpf.c Modified: head/sys/net/bpf.c ============================================================================== --- head/sys/net/bpf.c Mon May 13 13:45:28 2019 (r347526) +++ head/sys/net/bpf.c Mon May 13 14:07:02 2019 (r347527) @@ -2628,11 +2628,17 @@ bpfd_free(epoch_context_t ctx) if (d->bd_rfilter != NULL) { p = __containerof((void *)d->bd_rfilter, struct bpf_program_buffer, buffer); +#ifdef BPF_JITTER + p->func = d->bd_bfilter; +#endif bpf_program_buffer_free(&p->epoch_ctx); } if (d->bd_wfilter != NULL) { p = __containerof((void *)d->bd_wfilter, struct bpf_program_buffer, buffer); +#ifdef BPF_JITTER + p->func = NULL; +#endif bpf_program_buffer_free(&p->epoch_ctx); } From owner-svn-src-all@freebsd.org Mon May 13 14:50:52 2019 Return-Path: Delivered-To: svn-src-all@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 47BDF1591DAB; Mon, 13 May 2019 14:50:52 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E3C168495E; Mon, 13 May 2019 14:50:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9C74B44C; Mon, 13 May 2019 14:50:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DEopWE027348; Mon, 13 May 2019 14:50:51 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DEoph7027347; Mon, 13 May 2019 14:50:51 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201905131450.x4DEoph7027347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 13 May 2019 14:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347528 - stable/12/sys/arm64/linux X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/sys/arm64/linux X-SVN-Commit-Revision: 347528 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E3C168495E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 14:50:52 -0000 Author: emaste Date: Mon May 13 14:50:51 2019 New Revision: 347528 URL: https://svnweb.freebsd.org/changeset/base/347528 Log: MFC r347186: Reformat arm64 linux syscalls.master per current style Modified: stable/12/sys/arm64/linux/syscalls.master Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/linux/syscalls.master ============================================================================== --- stable/12/sys/arm64/linux/syscalls.master Mon May 13 14:07:02 2019 (r347527) +++ stable/12/sys/arm64/linux/syscalls.master Mon May 13 14:50:51 2019 (r347528) @@ -18,499 +18,1557 @@ 2 AUE_NULL UNIMPL linux_io_submit 3 AUE_NULL UNIMPL linux_io_cancel 4 AUE_NULL UNIMPL linux_io_getevents -5 AUE_NULL STD { int linux_setxattr(void); } -6 AUE_NULL STD { int linux_lsetxattr(void); } -7 AUE_NULL STD { int linux_fsetxattr(void); } -8 AUE_NULL STD { int linux_getxattr(void); } -9 AUE_NULL STD { int linux_lgetxattr(void); } -10 AUE_NULL STD { int linux_fgetxattr(void); } -11 AUE_NULL STD { int linux_listxattr(void); } -12 AUE_NULL STD { int linux_llistxattr(void); } -13 AUE_NULL STD { int linux_flistxattr(void); } -14 AUE_NULL STD { int linux_removexattr(void); } -15 AUE_NULL STD { int linux_lremovexattr(void); } -16 AUE_NULL STD { int linux_fremovexattr(void); } -17 AUE_GETCWD STD { int linux_getcwd(char *buf, \ - l_ulong bufsize); } -18 AUE_NULL STD { int linux_lookup_dcookie(void); } -19 AUE_NULL STD { int linux_eventfd2(l_uint initval, \ - l_int flags); } -20 AUE_NULL STD { int linux_epoll_create1(l_int flags); } -21 AUE_NULL STD { int linux_epoll_ctl(l_int epfd, l_int op, \ - l_int fd, struct epoll_event *event); } -22 AUE_NULL STD { int linux_epoll_pwait(l_int epfd, \ - struct epoll_event *events, \ - l_int maxevents, l_int timeout, \ - l_sigset_t *mask, l_size_t sigsetsize); } -23 AUE_DUP NOPROTO { int dup(u_int fd); } -24 AUE_NULL STD { int linux_dup3(l_int oldfd, l_int newfd, \ - l_int flags); } -25 AUE_FCNTL STD { int linux_fcntl(l_uint fd, l_uint cmd, \ - l_ulong arg); } -26 AUE_NULL STD { int linux_inotify_init1(l_int flags); } -27 AUE_NULL STD { int linux_inotify_add_watch(void); } -28 AUE_NULL STD { int linux_inotify_rm_watch(void); } -29 AUE_IOCTL STD { int linux_ioctl(l_uint fd, l_uint cmd, \ - uintptr_t arg); } -30 AUE_NULL STD { int linux_ioprio_set(void); } -31 AUE_NULL STD { int linux_ioprio_get(void); } -32 AUE_FLOCK NOPROTO { int flock(int fd, int how); } -33 AUE_MKNODAT STD { int linux_mknodat(l_int dfd, \ - const char *filename, l_int mode, \ - l_uint dev); } -34 AUE_MKDIRAT STD { int linux_mkdirat(l_int dfd, \ - const char *pathname, l_int mode); } -35 AUE_UNLINKAT STD { int linux_unlinkat(l_int dfd, \ - const char *pathname, l_int flag); } -36 AUE_SYMLINKAT STD { int linux_symlinkat(const char *oldname, \ - l_int newdfd, const char *newname); } -37 AUE_LINKAT STD { int linux_linkat(l_int olddfd, \ - const char *oldname, l_int newdfd, \ - const char *newname, l_int flag); } -38 AUE_RENAMEAT STD { int linux_renameat(l_int olddfd, \ - const char *oldname, l_int newdfd, \ - const char *newname); } +5 AUE_NULL STD { + int linux_setxattr(void); + } +6 AUE_NULL STD { + int linux_lsetxattr(void); + } +7 AUE_NULL STD { + int linux_fsetxattr(void); + } +8 AUE_NULL STD { + int linux_getxattr(void); + } +9 AUE_NULL STD { + int linux_lgetxattr(void); + } +10 AUE_NULL STD { + int linux_fgetxattr(void); + } +11 AUE_NULL STD { + int linux_listxattr(void); + } +12 AUE_NULL STD { + int linux_llistxattr(void); + } +13 AUE_NULL STD { + int linux_flistxattr(void); + } +14 AUE_NULL STD { + int linux_removexattr(void); + } +15 AUE_NULL STD { + int linux_lremovexattr(void); + } +16 AUE_NULL STD { + int linux_fremovexattr(void); + } +17 AUE_GETCWD STD { + int linux_getcwd( + char *buf, + l_ulong bufsize + ); + } +18 AUE_NULL STD { + int linux_lookup_dcookie(void); + } +19 AUE_NULL STD { + int linux_eventfd2( + l_uint initval, + l_int flags + ); + } +20 AUE_NULL STD { + int linux_epoll_create1( + l_int flags + ); + } +21 AUE_NULL STD { + int linux_epoll_ctl( + l_int epfd, + l_int op, + l_int fd, + struct epoll_event *event + ); + } +22 AUE_NULL STD { + int linux_epoll_pwait( + l_int epfd, + struct epoll_event *events, + l_int maxevents, + l_int timeout, + l_sigset_t *mask, + l_size_t sigsetsize + ); + } +23 AUE_DUP NOPROTO { + int dup( + u_int fd); + } +24 AUE_NULL STD { + int linux_dup3( + l_int oldfd, + l_int newfd, + l_int flags + ); + } +25 AUE_FCNTL STD { + int linux_fcntl( + l_uint fd, + l_uint cmd, + l_ulong arg + ); + } +26 AUE_NULL STD { + int linux_inotify_init1( + l_int flags + ); + } +27 AUE_NULL STD { + int linux_inotify_add_watch(void); + } +28 AUE_NULL STD { + int linux_inotify_rm_watch(void); + } +29 AUE_IOCTL STD { + int linux_ioctl( + l_uint fd, + l_uint cmd, + uintptr_t arg + ); + } +30 AUE_NULL STD { + int linux_ioprio_set(void); + } +31 AUE_NULL STD { + int linux_ioprio_get(void); + } +32 AUE_FLOCK NOPROTO { + int flock( + int fd, + int how + ); + } +33 AUE_MKNODAT STD { + int linux_mknodat( + l_int dfd, + const char *filename, + l_int mode, + l_uint dev + ); + } +34 AUE_MKDIRAT STD { + int linux_mkdirat( + l_int dfd, + const char *pathname, + l_int mode + ); + } +35 AUE_UNLINKAT STD { + int linux_unlinkat( + l_int dfd, + const char *pathname, + l_int flag + ); + } +36 AUE_SYMLINKAT STD { + int linux_symlinkat( + const char *oldname, + l_int newdfd, + const char *newname + ); + } +37 AUE_LINKAT STD { + int linux_linkat( + l_int olddfd, + const char *oldname, + l_int newdfd, + const char *newname, + l_int flag + ); + } +38 AUE_RENAMEAT STD { + int linux_renameat( + l_int olddfd, + const char *oldname, + l_int newdfd, + const char *newname + ); + } 39 AUE_NULL UNIMPL linux_umount2 -40 AUE_MOUNT STD { int linux_mount(char *specialfile, \ - char *dir, char *filesystemtype, \ - l_ulong rwflag, void *data); } -41 AUE_PIVOT_ROOT STD { int linux_pivot_root(void); } +40 AUE_MOUNT STD { + int linux_mount( + char *specialfile, + char *dir, + char *filesystemtype, + l_ulong rwflag, + void *data + ); + } +41 AUE_PIVOT_ROOT STD { + int linux_pivot_root(void); + } 42 AUE_NULL UNIMPL nfsservctl -43 AUE_STATFS STD { int linux_statfs(char *path, \ - struct l_statfs_buf *buf); } -44 AUE_FSTATFS STD { int linux_fstatfs(l_uint fd, \ - struct l_statfs_buf *buf); } -45 AUE_TRUNCATE STD { int linux_truncate(char *path, \ - l_ulong length); } -46 AUE_FTRUNCATE STD { int linux_ftruncate(l_int fd, \ - l_long length); } -47 AUE_NULL STD { int linux_fallocate(l_int fd, l_int mode, \ - l_loff_t offset, l_loff_t len); } -48 AUE_FACCESSAT STD { int linux_faccessat(l_int dfd, \ - const char *filename, l_int amode); } -49 AUE_CHDIR STD { int linux_chdir(char *path); } -50 AUE_FCHDIR NOPROTO { int fchdir(int fd); } -51 AUE_CHROOT NOPROTO { int chroot(char *path); } -52 AUE_FCHMOD NOPROTO { int fchmod(int fd, int mode); } -53 AUE_FCHMODAT STD { int linux_fchmodat(l_int dfd, \ - const char *filename, l_mode_t mode); } -54 AUE_FCHOWNAT STD { int linux_fchownat(l_int dfd, \ - const char *filename, l_uid_t uid, \ - l_gid_t gid, l_int flag); } -55 AUE_FCHOWN NOPROTO { int fchown(int fd, int uid, int gid); } -56 AUE_OPEN_RWTC STD { int linux_openat(l_int dfd, \ - const char *filename, l_int flags, \ - l_int mode); } -57 AUE_CLOSE NOPROTO { int close(int fd); } -58 AUE_NULL STD { int linux_vhangup(void); } -59 AUE_NULL STD { int linux_pipe2(l_int *pipefds, \ - l_int flags); } +43 AUE_STATFS STD { + int linux_statfs( + char *path, + struct l_statfs_buf *buf + ); + } +44 AUE_FSTATFS STD { + int linux_fstatfs( + l_uint fd, + struct l_statfs_buf *buf + ); + } +45 AUE_TRUNCATE STD { + int linux_truncate( + char *path, + l_ulong length + ); + } +46 AUE_FTRUNCATE STD { + int linux_ftruncate( + l_int fd, + l_long length + ); + } +47 AUE_NULL STD { + int linux_fallocate( + l_int fd, + l_int mode, + l_loff_t offset, + l_loff_t len + ); + } +48 AUE_FACCESSAT STD { + int linux_faccessat( + l_int dfd, + const char *filename, + l_int amode + ); + } +49 AUE_CHDIR STD { + int linux_chdir( + char *path + ); + } +50 AUE_FCHDIR NOPROTO { + int fchdir( + int fd); + } +51 AUE_CHROOT NOPROTO { + int chroot( + char *path + ); + } +52 AUE_FCHMOD NOPROTO { + int fchmod( + int fd, + int mode + ); + } +53 AUE_FCHMODAT STD { + int linux_fchmodat( + l_int dfd, + const char *filename, + l_mode_t mode + ); + } +54 AUE_FCHOWNAT STD { + int linux_fchownat( + l_int dfd, + const char *filename, + l_uid_t uid, + l_gid_t gid, + l_int flag + ); + } +55 AUE_FCHOWN NOPROTO { + int fchown( + int fd, + int uid, + int gid); + } +56 AUE_OPEN_RWTC STD { + int linux_openat( + l_int dfd, + const char *filename, + l_int flags, + l_int mode + ); + } +57 AUE_CLOSE NOPROTO { + int close( + int fd); + } +58 AUE_NULL STD { + int linux_vhangup(void); + } +59 AUE_NULL STD { + int linux_pipe2( + l_int *pipefds, + l_int flags + ); + } 60 AUE_NULL UNIMPL linux_quotactl -61 AUE_GETDIRENTRIES STD { int linux_getdents64(l_uint fd, \ - void *dirent, l_uint count); } -62 AUE_LSEEK STD { int linux_lseek(l_uint fdes, l_off_t off, \ - l_int whence); } -63 AUE_NULL NOPROTO { int read(int fd, char *buf, \ - u_int nbyte); } -64 AUE_NULL NOPROTO { int write(int fd, char *buf, \ - u_int nbyte); } -65 AUE_READV NOPROTO { int readv(int fd, struct iovec *iovp, \ - u_int iovcnt); } -66 AUE_WRITEV NOPROTO { int writev(int fd, struct iovec *iovp, \ - u_int iovcnt); } -67 AUE_PREAD STD { int linux_pread(l_uint fd, char *buf, \ - l_size_t nbyte, l_loff_t offset); } -68 AUE_PWRITE STD { int linux_pwrite(l_uint fd, char *buf, \ - l_size_t nbyte, l_loff_t offset); } -69 AUE_NULL STD { int linux_preadv(l_ulong fd, \ - struct iovec *vec, l_ulong vlen, \ - l_ulong pos_l, l_ulong pos_h); } -70 AUE_NULL STD { int linux_pwritev(l_ulong fd, \ - struct iovec *vec, l_ulong vlen, \ - l_ulong pos_l, l_ulong pos_h); } -71 AUE_SENDFILE STD { int linux_sendfile(l_int out, l_int in, \ - l_long *offset, l_size_t count); } -72 AUE_SELECT STD { int linux_pselect6(l_int nfds, \ - l_fd_set *readfds, l_fd_set *writefds, \ - l_fd_set *exceptfds, \ - struct l_timespec *tsp, l_uintptr_t *sig); } -73 AUE_POLL STD { int linux_ppoll(struct pollfd *fds, \ - uint32_t nfds, struct l_timespec *tsp, \ - l_sigset_t *sset, l_size_t ssize); } -74 AUE_NULL STD { int linux_signalfd4(void); } -75 AUE_NULL STD { int linux_vmsplice(void); } -76 AUE_NULL STD { int linux_splice(void); } -77 AUE_NULL STD { int linux_tee(void); } -78 AUE_READLINKAT STD { int linux_readlinkat(l_int dfd, \ - const char *path, char *buf, \ - l_int bufsiz); } -79 AUE_FSTATAT STD { int linux_newfstatat(l_int dfd, \ - char *pathname, struct l_stat64 *statbuf, \ - l_int flag); } -80 AUE_FSTAT STD { int linux_newfstat(l_uint fd, \ - struct l_newstat *buf); } +61 AUE_GETDIRENTRIES STD { + int linux_getdents64( + l_uint fd, + void *dirent, + l_uint count + ); + } +62 AUE_LSEEK STD { + int linux_lseek( + l_uint fdes, + l_off_t off, + l_int whence + ); + } +63 AUE_NULL NOPROTO { + int read( + int fd, + char *buf, + u_int nbyte + ); + } +64 AUE_NULL NOPROTO { + int write( + int fd, + char *buf, + u_int nbyte + ); + } +65 AUE_READV NOPROTO { + int readv( + int fd, + struct iovec *iovp, + u_int iovcnt + ); + } +66 AUE_WRITEV NOPROTO { + int writev( + int fd, + struct iovec *iovp, + u_int iovcnt + ); + } +67 AUE_PREAD STD { + int linux_pread( + l_uint fd, + char *buf, + l_size_t nbyte, + l_loff_t offset + ); + } +68 AUE_PWRITE STD { + int linux_pwrite( + l_uint fd, + char *buf, + l_size_t nbyte, + l_loff_t offset + ); + } +69 AUE_NULL STD { + int linux_preadv( + l_ulong fd, + struct iovec *vec, + l_ulong vlen, + l_ulong pos_l, + l_ulong pos_h + ); + } +70 AUE_NULL STD { + int linux_pwritev( + l_ulong fd, + struct iovec *vec, + l_ulong vlen, + l_ulong pos_l, + l_ulong pos_h + ); + } +71 AUE_SENDFILE STD { + int linux_sendfile( + l_int out, + l_int in, + l_long *offset, + l_size_t count + ); + } +72 AUE_SELECT STD { + int linux_pselect6( + l_int nfds, + l_fd_set *readfds, + l_fd_set *writefds, + l_fd_set *exceptfds, + struct l_timespec *tsp, + l_uintptr_t *sig + ); + } +73 AUE_POLL STD { + int linux_ppoll( + struct pollfd *fds, + uint32_t nfds, + struct l_timespec *tsp, + l_sigset_t *sset, + l_size_t ssize + ); + } +74 AUE_NULL STD { + int linux_signalfd4(void); + } +75 AUE_NULL STD { + int linux_vmsplice(void); + } +76 AUE_NULL STD { + int linux_splice(void); + } +77 AUE_NULL STD { + int linux_tee(void); + } +78 AUE_READLINKAT STD { + int linux_readlinkat( + l_int dfd, + const char *path, + char *buf, + l_int bufsiz + ); + } +79 AUE_FSTATAT STD { + int linux_newfstatat( + l_int dfd, + char *pathname, + struct l_stat64 *statbuf, + l_int flag + ); + } +80 AUE_FSTAT STD { + int linux_newfstat( + l_uint fd, + struct l_newstat *buf + ); + } 81 AUE_NULL UNIMPL linux_sync -82 AUE_FSYNC NOPROTO { int fsync(int fd); } -83 AUE_NULL STD { int linux_fdatasync(l_uint fd); } -84 AUE_NULL STD { int linux_sync_file_range(void); } -85 AUE_NULL STD { int linux_timerfd_create(l_int clockid, \ - l_int flags); } -86 AUE_NULL STD { int linux_timerfd_settime(l_int fd, \ - l_int flags, \ - const struct l_itimerspec *new_value, \ - struct l_itimerspec *old_value); } -87 AUE_NULL STD { int linux_timerfd_gettime(l_int fd, \ - struct l_itimerspec *old_value); } -88 AUE_FUTIMESAT STD { int linux_utimensat(l_int dfd, \ - const char *pathname, \ - const struct l_timespec *times, \ - l_int flags); } -89 AUE_ACCT NOPROTO { int acct(char *path); } -90 AUE_CAPGET STD { int linux_capget( \ - struct l_user_cap_header *hdrp, \ - struct l_user_cap_data *datap); } -91 AUE_CAPSET STD { int linux_capset( \ - struct l_user_cap_header *hdrp, \ - struct l_user_cap_data *datap); } -92 AUE_PERSONALITY STD { int linux_personality(l_uint per); } -93 AUE_EXIT STD { int linux_exit(int rval); } -94 AUE_EXIT STD { int linux_exit_group(int error_code); } -95 AUE_WAIT6 STD { int linux_waitid(l_int idtype, l_pid_t id, \ - l_siginfo_t *info, l_int options, \ - struct rusage *rusage); } -96 AUE_NULL STD { int linux_set_tid_address(int *tidptr); } -97 AUE_NULL STD { int linux_unshare(void); } -98 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, \ - int val, struct l_timespec *timeout, \ - void *uaddr2, int val3); } -99 AUE_NULL STD { int linux_set_robust_list( \ - struct linux_robust_list_head *head, \ - l_size_t len); } -100 AUE_NULL STD { int linux_get_robust_list(l_int pid, \ - struct linux_robust_list_head **head, \ - l_size_t *len); } -101 AUE_NULL STD { int linux_nanosleep( \ - const struct l_timespec *rqtp, \ - struct l_timespec *rmtp); } -102 AUE_GETITIMER STD { int linux_getitimer(l_int which, \ - struct l_itimerval *itv); } -103 AUE_SETITIMER STD { int linux_setitimer(l_int which, \ - struct l_itimerval *itv, \ - struct l_itimerval *oitv); } -104 AUE_NULL STD { int linux_kexec_load(void); } -105 AUE_NULL STD { int linux_init_module(void); } -106 AUE_NULL STD { int linux_delete_module(void); } -107 AUE_NULL STD { int linux_timer_create(clockid_t clock_id, \ - struct sigevent *evp, l_timer_t *timerid); } -108 AUE_NULL STD { int linux_timer_gettime(l_timer_t timerid, \ - struct itimerspec *setting); } -109 AUE_NULL STD { int linux_timer_getoverrun( \ - l_timer_t timerid); } -110 AUE_NULL STD { int linux_timer_settime(l_timer_t timerid, \ - l_int flags, const struct itimerspec *new, \ - struct itimerspec *old); } -111 AUE_NULL STD { int linux_timer_delete(l_timer_t timerid); } -112 AUE_CLOCK_SETTIME STD { int linux_clock_settime( \ - clockid_t which, struct l_timespec *tp); } -113 AUE_NULL STD { int linux_clock_gettime(clockid_t which, \ - struct l_timespec *tp); } -114 AUE_NULL STD { int linux_clock_getres(clockid_t which, \ - struct l_timespec *tp); } -115 AUE_NULL STD { int linux_clock_nanosleep(clockid_t which, \ - int flags, struct l_timespec *rqtp, \ - struct l_timespec *rmtp); } -116 AUE_NULL STD { int linux_syslog(l_int type, char *buf, \ - l_int len); } -117 AUE_PTRACE STD { int linux_ptrace(l_long req, l_long pid, \ - l_ulong addr, l_ulong data); } -118 AUE_SCHED_SETPARAM STD { int linux_sched_setparam( \ - l_pid_t pid, struct sched_param *param); } -119 AUE_SCHED_SETSCHEDULER STD { int linux_sched_setscheduler( \ - l_pid_t pid, l_int policy, \ - struct sched_param *param); } -120 AUE_SCHED_GETSCHEDULER STD { int linux_sched_getscheduler( \ - l_pid_t pid); } -121 AUE_SCHED_GETPARAM STD { int linux_sched_getparam( \ - l_pid_t pid, struct sched_param *param); } -122 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, \ - l_uint len, l_ulong *user_mask_ptr); } -123 AUE_NULL STD { int linux_sched_getaffinity(l_pid_t pid, \ - l_uint len, l_ulong *user_mask_ptr); } -124 AUE_NULL NOPROTO { int sched_yield(void); } -125 AUE_SCHED_GET_PRIORITY_MAX STD { int linux_sched_get_priority_max(\ - l_int policy); } -126 AUE_SCHED_GET_PRIORITY_MIN STD { int linux_sched_get_priority_min(\ - l_int policy); } -127 AUE_SCHED_RR_GET_INTERVAL STD { int linux_sched_rr_get_interval( \ - l_pid_t pid, struct l_timespec *interval); } +82 AUE_FSYNC NOPROTO { + int fsync( + int fd); + } +83 AUE_NULL STD { + int linux_fdatasync( + l_uint fd); + } +84 AUE_NULL STD { + int linux_sync_file_range(void); + } +85 AUE_NULL STD { + int linux_timerfd_create( + l_int clockid, + l_int flags + ); + } +86 AUE_NULL STD { + int linux_timerfd_settime( + l_int fd, + l_int flags, + const struct l_itimerspec *new_value, + struct l_itimerspec *old_value + ); + } +87 AUE_NULL STD { + int linux_timerfd_gettime( + l_int fd, + struct l_itimerspec *old_value + ); + } +88 AUE_FUTIMESAT STD { + int linux_utimensat( + l_int dfd, + const char *pathname, + const struct l_timespec *times, + l_int flags + ); + } +89 AUE_ACCT NOPROTO { + int acct( + char *path + ); + } +90 AUE_CAPGET STD { + int linux_capget( + struct l_user_cap_header *hdrp, + struct l_user_cap_data *datap + ); + } +91 AUE_CAPSET STD { + int linux_capset( + struct l_user_cap_header *hdrp, + struct l_user_cap_data *datap + ); + } +92 AUE_PERSONALITY STD { + int linux_personality( + l_uint per + ); + } +93 AUE_EXIT STD { + int linux_exit( + int rval + ); + } +94 AUE_EXIT STD { + int linux_exit_group( + int error_code + ); + } +95 AUE_WAIT6 STD { + int linux_waitid( + l_int idtype, + l_pid_t id, + l_siginfo_t *info, + l_int options, + struct rusage *rusage + ); + } +96 AUE_NULL STD { + int linux_set_tid_address( + int *tidptr + ); + } +97 AUE_NULL STD { + int linux_unshare(void); + } +98 AUE_NULL STD { + int linux_sys_futex(void *uaddr, + int op, + int val, + struct l_timespec *timeout, + void *uaddr2, + int val3 + ); + } +99 AUE_NULL STD { + int linux_set_robust_list( + struct linux_robust_list_head *head, + l_size_t len + ); + } +100 AUE_NULL STD { + int linux_get_robust_list( + l_int pid, + struct linux_robust_list_head **head, + l_size_t *len + ); + } +101 AUE_NULL STD { + int linux_nanosleep( + const struct l_timespec *rqtp, + struct l_timespec *rmtp + ); + } +102 AUE_GETITIMER STD { + int linux_getitimer( + l_int which, + struct l_itimerval *itv + ); + } +103 AUE_SETITIMER STD { + int linux_setitimer( + l_int which, + struct l_itimerval *itv, + struct l_itimerval *oitv + ); + } +104 AUE_NULL STD { + int linux_kexec_load(void); + } +105 AUE_NULL STD { + int linux_init_module(void); + } +106 AUE_NULL STD { + int linux_delete_module(void); + } +107 AUE_NULL STD { + int linux_timer_create( + clockid_t clock_id, + struct sigevent *evp, + l_timer_t *timerid); + } +108 AUE_NULL STD { + int linux_timer_gettime( + l_timer_t timerid, + struct itimerspec *setting + ); + } +109 AUE_NULL STD { + int linux_timer_getoverrun( + l_timer_t timerid); + } +110 AUE_NULL STD { + int linux_timer_settime( + l_timer_t timerid, + l_int flags, + const struct itimerspec *new, + struct itimerspec *old); + } +111 AUE_NULL STD { + int linux_timer_delete( + l_timer_t timerid); + } +112 AUE_CLOCK_SETTIME STD { + int linux_clock_settime( + clockid_t which, + struct l_timespec *tp + ); + } +113 AUE_NULL STD { + int linux_clock_gettime( + clockid_t which, + struct l_timespec *tp + ); + } +114 AUE_NULL STD { + int linux_clock_getres( + clockid_t which, + struct l_timespec *tp + ); + } +115 AUE_NULL STD { + int linux_clock_nanosleep( + clockid_t which, + int flags, + struct l_timespec *rqtp, + struct l_timespec *rmtp + ); + } +116 AUE_NULL STD { + int linux_syslog( + l_int type, + char *buf, + l_int len + ); + } +117 AUE_PTRACE STD { + int linux_ptrace( + l_long req, + l_long pid, + l_ulong addr, + l_ulong data + ); + } +118 AUE_SCHED_SETPARAM STD { + int linux_sched_setparam( + l_pid_t pid, + struct sched_param *param + ); + } +119 AUE_SCHED_SETSCHEDULER STD { + int linux_sched_setscheduler( + l_pid_t pid, + l_int policy, + struct sched_param *param + ); + } +120 AUE_SCHED_GETSCHEDULER STD { + int linux_sched_getscheduler( + l_pid_t pid); + } +121 AUE_SCHED_GETPARAM STD { + int linux_sched_getparam( + l_pid_t pid, + struct sched_param *param + ); + } +122 AUE_NULL STD { + int linux_sched_setaffinity( + l_pid_t pid, + l_uint len, + l_ulong *user_mask_ptr + ); + } +123 AUE_NULL STD { + int linux_sched_getaffinity( + l_pid_t pid, + l_uint len, + l_ulong *user_mask_ptr + ); + } +124 AUE_NULL NOPROTO { + int sched_yield(void); + } +125 AUE_SCHED_GET_PRIORITY_MAX STD { + int linux_sched_get_priority_max( + \ + l_int policy + ); + } +126 AUE_SCHED_GET_PRIORITY_MIN STD { + int linux_sched_get_priority_min( + \ + l_int policy + ); + } +127 AUE_SCHED_RR_GET_INTERVAL STD { + int linux_sched_rr_get_interval( + l_pid_t pid, + struct l_timespec *interval + ); + } 128 AUE_NULL UNIMPL restart_syscall -129 AUE_KILL STD { int linux_kill(l_int pid, l_int signum); } -130 AUE_NULL STD { int linux_tkill(l_int tid, l_int sig); } -131 AUE_NULL STD { int linux_tgkill(l_int tgid, l_int pid, \ - l_int sig); } -132 AUE_NULL STD { int linux_sigaltstack(l_stack_t *uss, \ - l_stack_t *uoss); } -133 AUE_NULL STD { int linux_rt_sigsuspend( \ - l_sigset_t *newset, \ - l_size_t sigsetsize); } -134 AUE_NULL STD { int linux_rt_sigaction(l_int sig, \ - l_sigaction_t *act, l_sigaction_t *oact, \ - l_size_t sigsetsize); } -135 AUE_NULL STD { int linux_rt_sigprocmask(l_int how, \ - l_sigset_t *mask, l_sigset_t *omask, \ - l_size_t sigsetsize); } -136 AUE_NULL STD { int linux_rt_sigpending(l_sigset_t *set, \ - l_size_t sigsetsize); } -137 AUE_NULL STD { int linux_rt_sigtimedwait(l_sigset_t *mask, \ - l_siginfo_t *ptr, \ - struct l_timeval *timeout, \ - l_size_t sigsetsize); } -138 AUE_NULL STD { int linux_rt_sigqueueinfo(l_pid_t pid, \ - l_int sig, l_siginfo_t *info); } -139 AUE_NULL STD { int linux_rt_sigreturn( \ - struct l_ucontext *ucp); } -140 AUE_SETPRIORITY NOPROTO { int setpriority(int which, int who, \ - int prio); } -141 AUE_GETPRIORITY STD { int linux_getpriority(l_int which, \ - l_int who); } -142 AUE_REBOOT STD { int linux_reboot(l_int magic1, \ - l_int magic2, l_uint cmd, void *arg); } -143 AUE_SETREGID NOPROTO { int setregid(gid_t rgid, gid_t egid); } -144 AUE_SETGID NOPROTO { int setgid(gid_t gid); } -145 AUE_SETREUID NOPROTO { int setreuid(uid_t ruid, uid_t euid); } -146 AUE_SETUID NOPROTO { int setuid(uid_t uid); } -147 AUE_SETRESUID NOPROTO { int setresuid(uid_t ruid, uid_t euid, \ - uid_t suid); } -148 AUE_GETRESUID NOPROTO { int getresuid(uid_t *ruid, uid_t *euid, \ - uid_t *suid); } -149 AUE_SETRESGID NOPROTO { int setresgid(gid_t rgid, gid_t egid, \ - gid_t sgid); } -150 AUE_GETRESGID NOPROTO { int getresgid(gid_t *rgid, gid_t *egid, \ - gid_t *sgid); } -151 AUE_SETFSUID STD { int linux_setfsuid(l_uid_t uid); } -152 AUE_SETFSGID STD { int linux_setfsgid(l_gid_t gid); } -153 AUE_NULL STD { int linux_times(struct l_times_argv *buf); } -154 AUE_SETPGRP NOPROTO { int setpgid(int pid, int pgid); } -155 AUE_GETPGID NOPROTO { int getpgid(int pid); } -156 AUE_GETSID STD { int linux_getsid(l_pid_t pid); } -157 AUE_SETSID NOPROTO { int setsid(void); } -158 AUE_GETGROUPS STD { int linux_getgroups(l_int gidsetsize, \ - l_gid_t *grouplist); } -159 AUE_SETGROUPS STD { int linux_setgroups(l_int gidsetsize, \ - l_gid_t *grouplist); } -160 AUE_NULL STD { int linux_newuname( \ - struct l_new_utsname *buf); } -161 AUE_SYSCTL STD { int linux_sethostname(char *hostname, \ - l_uint len); } -162 AUE_SYSCTL STD { int linux_setdomainname(char *name, \ - l_int len); } -163 AUE_GETRLIMIT STD { int linux_getrlimit(l_uint resource, \ - struct l_rlimit *rlim); } -164 AUE_SETRLIMIT STD { int linux_setrlimit(l_uint resource, \ - struct l_rlimit *rlim); } -165 AUE_GETRUSAGE NOPROTO { int getrusage(int who, \ - struct rusage *rusage); } -166 AUE_UMASK NOPROTO { int umask(int newmask); } -167 AUE_PRCTL STD { int linux_prctl(l_int option, \ - l_uintptr_t arg2, l_uintptr_t arg3, \ - l_uintptr_t arg4, l_uintptr_t arg5); } -168 AUE_NULL STD { int linux_getcpu(l_uint *cpu, l_uint *node, \ - void *cache); } -169 AUE_NULL NOPROTO { int gettimeofday(struct l_timeval *tp, \ - struct timezone *tzp); } -170 AUE_SETTIMEOFDAY NOPROTO { int settimeofday( \ - struct l_timeval *tv, \ - struct timezone *tzp); } -171 AUE_ADJTIME STD { int linux_adjtimex(void); } -172 AUE_GETPID STD { int linux_getpid(void); } -173 AUE_GETPPID STD { int linux_getppid(void); } -174 AUE_GETUID STD { int linux_getuid(void); } -175 AUE_GETEUID NOPROTO { int geteuid(void); } -176 AUE_GETGID STD { int linux_getgid(void); } -177 AUE_GETEGID NOPROTO { int getegid(void); } -178 AUE_NULL STD { int linux_gettid(void); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon May 13 14:52:51 2019 Return-Path: Delivered-To: svn-src-all@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 B7A7C1591FA0; Mon, 13 May 2019 14:52:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5CA0F84CE3; Mon, 13 May 2019 14:52:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 47096B5D5; Mon, 13 May 2019 14:52:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DEqpbh029873; Mon, 13 May 2019 14:52:51 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DEqphq029872; Mon, 13 May 2019 14:52:51 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201905131452.x4DEqphq029872@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 13 May 2019 14:52:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347529 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 347529 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5CA0F84CE3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 14:52:51 -0000 Author: emaste Date: Mon May 13 14:52:50 2019 New Revision: 347529 URL: https://svnweb.freebsd.org/changeset/base/347529 Log: MFC r347031: iflib: remove assertion that isc_capabilities is nonzero It's atypical, but not invalid, for a driver to pass no capabilities. Submitted by: Gerald Aryeetey Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/iflib.c ============================================================================== --- stable/12/sys/net/iflib.c Mon May 13 14:50:51 2019 (r347528) +++ stable/12/sys/net/iflib.c Mon May 13 14:52:50 2019 (r347529) @@ -4444,7 +4444,6 @@ iflib_device_register(device_t dev, void *sc, if_share ctx->ifc_txrx = *scctx->isc_txrx; #ifdef INVARIANTS - MPASS(scctx->isc_capabilities); if (scctx->isc_capabilities & IFCAP_TXCSUM) MPASS(scctx->isc_tx_csum_flags); #endif @@ -4678,7 +4677,6 @@ iflib_pseudo_register(device_t dev, if_shared_ctx_t sc ifmedia_set(&ctx->ifc_media, IFM_ETHER | IFM_AUTO); #ifdef INVARIANTS - MPASS(scctx->isc_capabilities); if (scctx->isc_capabilities & IFCAP_TXCSUM) MPASS(scctx->isc_tx_csum_flags); #endif From owner-svn-src-all@freebsd.org Mon May 13 16:38:52 2019 Return-Path: Delivered-To: svn-src-all@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 65784159460F; Mon, 13 May 2019 16:38:52 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1688589A22; Mon, 13 May 2019 16:38:52 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3D18C858; Mon, 13 May 2019 16:38:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DGcp3p083453; Mon, 13 May 2019 16:38:51 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DGcmIw083437; Mon, 13 May 2019 16:38:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131638.x4DGcmIw083437@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 16:38:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347532 - in head: contrib/netbsd-tests/lib/libc/sys lib/libc/sys lib/libc/tests/sys sys/amd64/vmm sys/sys sys/vm usr.bin/vmstat X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: contrib/netbsd-tests/lib/libc/sys lib/libc/sys lib/libc/tests/sys sys/amd64/vmm sys/sys sys/vm usr.bin/vmstat X-SVN-Commit-Revision: 347532 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1688589A22 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 16:38:52 -0000 Author: markj Date: Mon May 13 16:38:48 2019 New Revision: 347532 URL: https://svnweb.freebsd.org/changeset/base/347532 Log: Provide separate accounting for user-wired pages. Historically we have not distinguished between kernel wirings and user wirings for accounting purposes. User wirings (via mlock(2)) were subject to a global limit on the number of wired pages, so if large swaths of physical memory were wired by the kernel, as happens with the ZFS ARC among other things, the limit could be exceeded, causing user wirings to fail. The change adds a new counter, v_user_wire_count, which counts the number of virtual pages wired by user processes via mlock(2) and mlockall(2). Only user-wired pages are subject to the system-wide limit which helps provide some safety against deadlocks. In particular, while sources of kernel wirings typically support some backpressure mechanism, there is no way to reclaim user-wired pages shorting of killing the wiring process. The limit is exported as vm.max_user_wired, renamed from vm.max_wired, and changed from u_int to u_long. The choice to count virtual user-wired pages rather than physical pages was done for simplicity. There are mechanisms that can cause user-wired mappings to be destroyed while maintaining a wiring of the backing physical page; these make it difficult to accurately track user wirings at the physical page layer. The change also closes some holes which allowed user wirings to succeed even when they would cause the system limit to be exceeded. For instance, mmap() may now fail with ENOMEM in a process that has called mlockall(MCL_FUTURE) if the new mapping would cause the user wiring limit to be exceeded. Note that bhyve -S is subject to the user wiring limit, which defaults to 1/3 of physical RAM. Users that wish to exceed the limit must tune vm.max_user_wired. Reviewed by: kib, ngie (mlock() test changes) Tested by: pho (earlier version) MFC after: 45 days Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D19908 Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c head/lib/libc/sys/mlock.2 head/lib/libc/sys/mlockall.2 head/lib/libc/tests/sys/mlock_helper.c head/sys/amd64/vmm/vmm.c head/sys/sys/vmmeter.h head/sys/vm/vm_glue.c head/sys/vm/vm_map.c head/sys/vm/vm_map.h head/sys/vm/vm_meter.c head/sys/vm/vm_mmap.c head/sys/vm/vm_pageout.c head/sys/vm/vm_pageout.h head/sys/vm/vm_unix.c head/usr.bin/vmstat/vmstat.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 15:39:54 2019 (r347531) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 16:38:48 2019 (r347532) @@ -51,7 +51,7 @@ __RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 #define _KMEMUSER #include -void set_vm_max_wired(int); +void set_vm_max_wired(u_long); void restore_vm_max_wired(void); #endif Modified: head/lib/libc/sys/mlock.2 ============================================================================== --- head/lib/libc/sys/mlock.2 Mon May 13 15:39:54 2019 (r347531) +++ head/lib/libc/sys/mlock.2 Mon May 13 16:38:48 2019 (r347532) @@ -28,7 +28,7 @@ .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd March 20, 2018 +.Dd May 13, 2019 .Dt MLOCK 2 .Os .Sh NAME @@ -97,13 +97,13 @@ resource limit and the system-wide .Dq wired pages limit -.Va vm.max_wired . -.Va vm.max_wired +.Va vm.max_user_wired . +.Va vm.max_user_wired applies to the system as a whole, so the amount available to a single process at any given time is the difference between -.Va vm.max_wired +.Va vm.max_user_wired and -.Va vm.stats.vm.v_wire_count . +.Va vm.stats.vm.v_user_wire_count . .Pp If .Va security.bsd.unprivileged_mlock @@ -124,13 +124,11 @@ will fail if: is set to 0 and the caller is not the super-user. .It Bq Er EINVAL The address range given wraps around zero. -.It Bq Er EAGAIN -Locking the indicated range would exceed the system limit for locked memory. .It Bq Er ENOMEM Some portion of the indicated address range is not allocated. There was an error faulting/mapping a page. -Locking the indicated range would exceed the per-process limit for locked -memory. +Locking the indicated range would exceed the per-process or system-wide limits +for locked memory. .El The .Fn munlock @@ -171,11 +169,11 @@ system calls first appeared in Allocating too much wired memory can lead to a memory-allocation deadlock which requires a reboot to recover from. .Pp -The per-process resource limit is a limit on the amount of virtual -memory locked, while the system-wide limit is for the number of locked -physical pages. -Hence a process with two distinct locked mappings of the same physical page -counts as 2 pages against the per-process limit and as only a single page -in the system limit. +The per-process and system-wide resource limits of locked memory apply +to the amount of virtual memory locked, not the amount of locked physical +pages. +Hence two distinct locked mappings of the same physical page counts as +2 pages aginst the system limit, and also against the per-process limit +if both mappings belong to the same physical map. .Pp The per-process resource limit is not currently supported. Modified: head/lib/libc/sys/mlockall.2 ============================================================================== --- head/lib/libc/sys/mlockall.2 Mon May 13 15:39:54 2019 (r347531) +++ head/lib/libc/sys/mlockall.2 Mon May 13 16:38:48 2019 (r347532) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 25, 2012 +.Dd May 13, 2019 .Dt MLOCKALL 2 .Os .Sh NAME @@ -69,7 +69,7 @@ limited in how much they can lock down. A single process can lock the minimum of a system-wide .Dq wired pages limit -.Va vm.max_wired +.Va vm.max_user_wired and the per-process .Dv RLIMIT_MEMLOCK resource limit. @@ -138,9 +138,9 @@ and functions first appeared in .Fx 5.1 . .Sh BUGS -The per-process resource limit is a limit on the amount of virtual -memory locked, while the system-wide limit is for the number of locked -physical pages. -Hence a process with two distinct locked mappings of the same physical page -counts as 2 pages against the per-process limit and as only a single page -in the system limit. +The per-process and system-wide resource limits of locked memory apply +to the amount of virtual memory locked, not the amount of locked physical +pages. +Hence two distinct locked mappings of the same physical page counts as +2 pages aginst the system limit, and also against the per-process limit +if both mappings belong to the same physical map. Modified: head/lib/libc/tests/sys/mlock_helper.c ============================================================================== --- head/lib/libc/tests/sys/mlock_helper.c Mon May 13 15:39:54 2019 (r347531) +++ head/lib/libc/tests/sys/mlock_helper.c Mon May 13 16:38:48 2019 (r347532) @@ -39,16 +39,16 @@ __FBSDID("$FreeBSD$"); #include #include -#define VM_MAX_WIRED "vm.max_wired" +#define VM_MAX_WIRED "vm.max_user_wired" static void -vm_max_wired_sysctl(int *old_value, int *new_value) +vm_max_wired_sysctl(u_long *old_value, u_long *new_value) { size_t old_len; - size_t new_len = (new_value == NULL ? 0 : sizeof(int)); + size_t new_len = (new_value == NULL ? 0 : sizeof(*new_value)); if (old_value == NULL) - printf("Setting the new value to %d\n", *new_value); + printf("Setting the new value to %lu\n", *new_value); else { ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len, new_value, new_len) == 0, @@ -60,14 +60,14 @@ vm_max_wired_sysctl(int *old_value, int *new_value) "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); if (old_value != NULL) - printf("Saved the old value (%d)\n", *old_value); + printf("Saved the old value (%lu)\n", *old_value); } void -set_vm_max_wired(int new_value) +set_vm_max_wired(u_long new_value) { FILE *fp; - int old_value; + u_long old_value; fp = fopen(VM_MAX_WIRED, "w"); if (fp == NULL) { @@ -78,7 +78,7 @@ set_vm_max_wired(int new_value) vm_max_wired_sysctl(&old_value, NULL); - ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0, + ATF_REQUIRE_MSG(fprintf(fp, "%lu", old_value) > 0, "saving %s failed", VM_MAX_WIRED); fclose(fp); @@ -90,7 +90,7 @@ void restore_vm_max_wired(void) { FILE *fp; - int saved_max_wired; + u_long saved_max_wired; fp = fopen(VM_MAX_WIRED, "r"); if (fp == NULL) { @@ -98,14 +98,14 @@ restore_vm_max_wired(void) return; } - if (fscanf(fp, "%d", &saved_max_wired) != 1) { + if (fscanf(fp, "%lu", &saved_max_wired) != 1) { perror("fscanf failed\n"); fclose(fp); return; } fclose(fp); - printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired); + printf("old value in %s: %lu\n", VM_MAX_WIRED, saved_max_wired); if (saved_max_wired == 0) /* This will cripple the test host */ return; Modified: head/sys/amd64/vmm/vmm.c ============================================================================== --- head/sys/amd64/vmm/vmm.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/amd64/vmm/vmm.c Mon May 13 16:38:48 2019 (r347532) @@ -754,7 +754,8 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segi VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); if (error != KERN_SUCCESS) { vm_map_remove(&vm->vmspace->vm_map, gpa, gpa + len); - return (EFAULT); + return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM : + EFAULT); } } Modified: head/sys/sys/vmmeter.h ============================================================================== --- head/sys/sys/vmmeter.h Mon May 13 15:39:54 2019 (r347531) +++ head/sys/sys/vmmeter.h Mon May 13 16:38:48 2019 (r347532) @@ -153,6 +153,8 @@ extern domainset_t vm_severe_domains; #define VM_CNT_INC(var) VM_CNT_ADD(var, 1) #define VM_CNT_FETCH(var) counter_u64_fetch(vm_cnt.var) +extern u_long vm_user_wire_count; + static inline void vm_wire_add(int cnt) { Modified: head/sys/vm/vm_glue.c ============================================================================== --- head/sys/vm/vm_glue.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_glue.c Mon May 13 16:38:48 2019 (r347532) @@ -181,21 +181,8 @@ vslock(void *addr, size_t len) if (last < (vm_offset_t)addr || end < (vm_offset_t)addr) return (EINVAL); npages = atop(end - start); - if (npages > vm_page_max_wired) + if (npages > vm_page_max_user_wired) return (ENOMEM); -#if 0 - /* - * XXX - not yet - * - * The limit for transient usage of wired pages should be - * larger than for "permanent" wired pages (mlock()). - * - * Also, the sysctl code, which is the only present user - * of vslock(), does a hard loop on EAGAIN. - */ - if (npages + vm_wire_count() > vm_page_max_wired) - return (EAGAIN); -#endif error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); if (error == KERN_SUCCESS) { Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_map.c Mon May 13 16:38:48 2019 (r347532) @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2917,12 +2918,12 @@ done: if (rv == KERN_SUCCESS && (!user_unwire || (entry->eflags & MAP_ENTRY_USER_WIRED))) { - if (user_unwire) - entry->eflags &= ~MAP_ENTRY_USER_WIRED; if (entry->wired_count == 1) vm_map_entry_unwire(map, entry); else entry->wired_count--; + if (user_unwire) + entry->eflags &= ~MAP_ENTRY_USER_WIRED; } KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) != 0, ("vm_map_unwire: in-transition flag missing %p", entry)); @@ -2942,6 +2943,28 @@ done: return (rv); } +static void +vm_map_wire_user_count_sub(u_long npages) +{ + + atomic_subtract_long(&vm_user_wire_count, npages); +} + +static bool +vm_map_wire_user_count_add(u_long npages) +{ + u_long wired; + + wired = vm_user_wire_count; + do { + if (npages + wired > vm_page_max_user_wired) + return (false); + } while (!atomic_fcmpset_long(&vm_user_wire_count, &wired, + npages + wired)); + + return (true); +} + /* * vm_map_wire_entry_failure: * @@ -2978,37 +3001,49 @@ vm_map_wire_entry_failure(vm_map_t map, vm_map_entry_t entry->wired_count = -1; } +int +vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) +{ + int rv; + + vm_map_lock(map); + rv = vm_map_wire_locked(map, start, end, flags); + vm_map_unlock(map); + return (rv); +} + + /* - * vm_map_wire: + * vm_map_wire_locked: * - * Implements both kernel and user wiring. + * Implements both kernel and user wiring. Returns with the map locked, + * the map lock may be dropped. */ int -vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, - int flags) +vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) { vm_map_entry_t entry, first_entry, tmp_entry; vm_offset_t faddr, saved_end, saved_start; - unsigned int last_timestamp; + u_long npages; + u_int last_timestamp; int rv; boolean_t need_wakeup, result, user_wire; vm_prot_t prot; + VM_MAP_ASSERT_LOCKED(map); + if (start == end) return (KERN_SUCCESS); prot = 0; if (flags & VM_MAP_WIRE_WRITE) prot |= VM_PROT_WRITE; user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; - vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); if (!vm_map_lookup_entry(map, start, &first_entry)) { if (flags & VM_MAP_WIRE_HOLESOK) first_entry = first_entry->next; - else { - vm_map_unlock(map); + else return (KERN_INVALID_ADDRESS); - } } last_timestamp = map->timestamp; entry = first_entry; @@ -3042,7 +3077,6 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset /* * first_entry has been deleted. */ - vm_map_unlock(map); return (KERN_INVALID_ADDRESS); } end = saved_start; @@ -3082,13 +3116,22 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset } if (entry->wired_count == 0) { entry->wired_count++; - saved_start = entry->start; - saved_end = entry->end; + npages = atop(entry->end - entry->start); + if (user_wire && !vm_map_wire_user_count_add(npages)) { + vm_map_wire_entry_failure(map, entry, + entry->start); + end = entry->end; + rv = KERN_RESOURCE_SHORTAGE; + goto done; + } + /* * Release the map lock, relying on the in-transition * mark. Mark the map busy for fork. */ + saved_start = entry->start; + saved_end = entry->end; vm_map_busy(map); vm_map_unlock(map); @@ -3136,6 +3179,8 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset last_timestamp = map->timestamp; if (rv != KERN_SUCCESS) { vm_map_wire_entry_failure(map, entry, faddr); + if (user_wire) + vm_map_wire_user_count_sub(npages); end = entry->end; goto done; } @@ -3201,9 +3246,12 @@ done: * Undo the wiring. Wiring succeeded on this entry * but failed on a later entry. */ - if (entry->wired_count == 1) + if (entry->wired_count == 1) { vm_map_entry_unwire(map, entry); - else + if (user_wire) + vm_map_wire_user_count_sub( + atop(entry->end - entry->start)); + } else entry->wired_count--; } next_entry_done: @@ -3220,7 +3268,6 @@ done: } vm_map_simplify_entry(map, entry); } - vm_map_unlock(map); if (need_wakeup) vm_map_wakeup(map); return (rv); @@ -3338,13 +3385,18 @@ vm_map_sync( static void vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry) { + vm_size_t size; VM_MAP_ASSERT_LOCKED(map); KASSERT(entry->wired_count > 0, ("vm_map_entry_unwire: entry %p isn't wired", entry)); + + size = entry->end - entry->start; + if ((entry->eflags & MAP_ENTRY_USER_WIRED) != 0) + vm_map_wire_user_count_sub(atop(size)); pmap_unwire(map->pmap, entry->start, entry->end); - vm_object_unwire(entry->object.vm_object, entry->offset, entry->end - - entry->start, PQ_ACTIVE); + vm_object_unwire(entry->object.vm_object, entry->offset, size, + PQ_ACTIVE); entry->wired_count = 0; } @@ -4311,12 +4363,11 @@ retry: * Heed the MAP_WIREFUTURE flag if it was set for this process. */ if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { - vm_map_unlock(map); - vm_map_wire(map, grow_start, grow_start + grow_amount, + rv = vm_map_wire_locked(map, grow_start, + grow_start + grow_amount, VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); - vm_map_lock_read(map); - } else - vm_map_lock_downgrade(map); + } + vm_map_lock_downgrade(map); out: #ifdef RACCT Modified: head/sys/vm/vm_map.h ============================================================================== --- head/sys/vm/vm_map.h Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_map.h Mon May 13 16:38:48 2019 (r347532) @@ -422,7 +422,8 @@ int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); -int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, +int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); +int vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); long vmspace_swap_count(struct vmspace *vmspace); void vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool add); Modified: head/sys/vm/vm_meter.c ============================================================================== --- head/sys/vm/vm_meter.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_meter.c Mon May 13 16:38:48 2019 (r347532) @@ -97,6 +97,8 @@ struct vmmeter __read_mostly vm_cnt = { .v_wire_count = EARLY_COUNTER, }; +u_long __exclusive_cache_line vm_user_wire_count; + static void vmcounter_startup(void) { @@ -394,6 +396,8 @@ sysctl_handle_vmstat_proc(SYSCTL_HANDLER_ARGS) #define VM_STATS_UINT(var, descr) \ SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) +#define VM_STATS_ULONG(var, descr) \ + SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) VM_STATS_UINT(v_page_size, "Page size in bytes"); VM_STATS_UINT(v_page_count, "Total number of pages in system"); @@ -410,6 +414,9 @@ VM_STATS_PROC(v_laundry_count, "Pages eligible for lau VM_STATS_UINT(v_pageout_free_min, "Min pages reserved for kernel"); VM_STATS_UINT(v_interrupt_free_min, "Reserved pages for interrupt code"); VM_STATS_UINT(v_free_severe, "Severe page depletion point"); + +SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, + &vm_user_wire_count, 0, "User-wired virtual memory"); #ifdef COMPAT_FREEBSD11 /* Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_mmap.c Mon May 13 16:38:48 2019 (r347532) @@ -1003,7 +1003,7 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint if (last < addr || end < addr) return (EINVAL); npages = atop(end - start); - if (npages > vm_page_max_wired) + if (npages > vm_page_max_user_wired) return (ENOMEM); map = &proc->p_vmspace->vm_map; PROC_LOCK(proc); @@ -1013,8 +1013,6 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint return (ENOMEM); } PROC_UNLOCK(proc); - if (npages + vm_wire_count() > vm_page_max_wired) - return (EAGAIN); #ifdef RACCT if (racct_enable) { PROC_LOCK(proc); @@ -1091,7 +1089,12 @@ sys_mlockall(struct thread *td, struct mlockall_args * */ error = vm_map_wire(map, vm_map_min(map), vm_map_max(map), VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); - error = (error == KERN_SUCCESS ? 0 : EAGAIN); + if (error == KERN_SUCCESS) + error = 0; + else if (error == KERN_RESOURCE_SHORTAGE) + error = ENOMEM; + else + error = EAGAIN; } #ifdef RACCT if (racct_enable && error != KERN_SUCCESS) { @@ -1558,10 +1561,16 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz * If the process has requested that all future mappings * be wired, then heed this. */ - if (map->flags & MAP_WIREFUTURE) { - vm_map_wire(map, *addr, *addr + size, - VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? - VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); + if ((map->flags & MAP_WIREFUTURE) != 0) { + vm_map_lock(map); + if ((map->flags & MAP_WIREFUTURE) != 0) + rv = vm_map_wire_locked(map, *addr, + *addr + size, VM_MAP_WIRE_USER | + ((flags & MAP_STACK) ? VM_MAP_WIRE_HOLESOK : + VM_MAP_WIRE_NOHOLES)); + if (rv != KERN_SUCCESS) + (void)vm_map_delete(map, *addr, *addr + size); + vm_map_unlock(map); } } return (vm_mmap_to_errno(rv)); Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_pageout.c Mon May 13 16:38:48 2019 (r347532) @@ -194,9 +194,10 @@ SYSCTL_UINT(_vm, OID_AUTO, background_launder_max, CTL int vm_pageout_page_count = 32; -int vm_page_max_wired; /* XXX max # of wired pages system-wide */ -SYSCTL_INT(_vm, OID_AUTO, max_wired, - CTLFLAG_RW, &vm_page_max_wired, 0, "System-wide limit to wired page count"); +u_long vm_page_max_user_wired; +SYSCTL_ULONG(_vm, OID_AUTO, max_user_wired, CTLFLAG_RW, + &vm_page_max_user_wired, 0, + "system-wide limit to user-wired page count"); static u_int isqrt(u_int num); static int vm_pageout_launder(struct vm_domain *vmd, int launder, @@ -2041,8 +2042,8 @@ vm_pageout_init(void) if (vm_pageout_update_period == 0) vm_pageout_update_period = 600; - if (vm_page_max_wired == 0) - vm_page_max_wired = freecount / 3; + if (vm_page_max_user_wired == 0) + vm_page_max_user_wired = freecount / 3; } /* Modified: head/sys/vm/vm_pageout.h ============================================================================== --- head/sys/vm/vm_pageout.h Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_pageout.h Mon May 13 16:38:48 2019 (r347532) @@ -75,7 +75,7 @@ * Exported data structures. */ -extern int vm_page_max_wired; +extern u_long vm_page_max_user_wired; extern int vm_pageout_page_count; #define VM_OOM_MEM 1 Modified: head/sys/vm/vm_unix.c ============================================================================== --- head/sys/vm/vm_unix.c Mon May 13 15:39:54 2019 (r347531) +++ head/sys/vm/vm_unix.c Mon May 13 16:38:48 2019 (r347532) @@ -95,13 +95,11 @@ kern_break(struct thread *td, uintptr_t *addr) rlim_t datalim, lmemlim, vmemlim; int prot, rv; int error = 0; - boolean_t do_map_wirefuture; datalim = lim_cur(td, RLIMIT_DATA); lmemlim = lim_cur(td, RLIMIT_MEMLOCK); vmemlim = lim_cur(td, RLIMIT_VMEM); - do_map_wirefuture = FALSE; new = round_page(*addr); vm_map_lock(map); @@ -184,7 +182,14 @@ kern_break(struct thread *td, uintptr_t *addr) if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32)) prot |= VM_PROT_EXECUTE; #endif - rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, 0); + rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, + 0); + if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { + rv = vm_map_wire_locked(map, old, new, + VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); + if (rv != KERN_SUCCESS) + vm_map_delete(map, old, new); + } if (rv != KERN_SUCCESS) { #ifdef RACCT if (racct_enable) { @@ -205,17 +210,6 @@ kern_break(struct thread *td, uintptr_t *addr) goto done; } vm->vm_dsize += btoc(new - old); - /* - * Handle the MAP_WIREFUTURE case for legacy applications, - * by marking the newly mapped range of pages as wired. - * We are not required to perform a corresponding - * vm_map_unwire() before vm_map_delete() below, as - * it will forcibly unwire the pages in the range. - * - * XXX If the pages cannot be wired, no error is returned. - */ - if ((map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) - do_map_wirefuture = TRUE; } else if (new < old) { rv = vm_map_delete(map, new, old); if (rv != KERN_SUCCESS) { @@ -238,10 +232,6 @@ kern_break(struct thread *td, uintptr_t *addr) } done: vm_map_unlock(map); - - if (do_map_wirefuture) - (void) vm_map_wire(map, old, new, - VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); if (error == 0) *addr = new; Modified: head/usr.bin/vmstat/vmstat.c ============================================================================== --- head/usr.bin/vmstat/vmstat.c Mon May 13 15:39:54 2019 (r347531) +++ head/usr.bin/vmstat/vmstat.c Mon May 13 16:38:48 2019 (r347532) @@ -156,6 +156,7 @@ static struct __vmmeter { u_int v_free_min; u_int v_free_count; u_int v_wire_count; + u_long v_user_wire_count; u_int v_active_count; u_int v_inactive_target; u_int v_inactive_count; @@ -566,6 +567,7 @@ fill_vmmeter(struct __vmmeter *vmmp) GET_VM_STATS(vm, v_free_min); GET_VM_STATS(vm, v_free_count); GET_VM_STATS(vm, v_wire_count); + GET_VM_STATS(vm, v_user_wire_count); GET_VM_STATS(vm, v_active_count); GET_VM_STATS(vm, v_inactive_target); GET_VM_STATS(vm, v_inactive_count); @@ -1057,6 +1059,8 @@ dosum(void) sum.v_laundry_count); xo_emit("{:wired-pages/%9u} {N:pages wired down}\n", sum.v_wire_count); + xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages wired " + "down}\n", sum.v_user_wire_count); xo_emit("{:free-pages/%9u} {N:pages free}\n", sum.v_free_count); xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size); From owner-svn-src-all@freebsd.org Mon May 13 16:44:18 2019 Return-Path: Delivered-To: svn-src-all@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 A97621594954; Mon, 13 May 2019 16:44:18 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 B4EEE89F6B; Mon, 13 May 2019 16:44:17 +0000 (UTC) (envelope-from delphij@gmail.com) Received: by mail-io1-xd34.google.com with SMTP id x24so3147677ion.5; Mon, 13 May 2019 09:44:17 -0700 (PDT) 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=owzjXIt3bRBvMlIikYEvwpek1MzaeHp0d6J9Cpt9Utw=; b=OK4xai17M74G2dDJvcDGB9yfPef/UMnGAo7RmzneZPjPewXe1h+cSEnLikaBHBjQ22 sNf0+k1JtLWLNbDV/HxXOOH1jK6XMJwlF3BJnjDg99QWq/bga7ZDdwj78OHFB7JH6X5g 2vaqXTjE9CfJQlBtmvGboYi7A5vLRHoogQWLjiOvNlVXztePGOegeybO0JLjiQpVGh8y geffmjszQRkfRzhO5gbvrS1WXhf8dk6S5K95O2ayVA+LZT2Jx8ruxbD+N7dzYZ6nCwi8 HwWewU5etJ2dnF5UVXrBHwWcHAA1dqn4AWXkP2Mg+f6UvBDd0x/5jljIcCpm597f2l4Z Lctg== 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=owzjXIt3bRBvMlIikYEvwpek1MzaeHp0d6J9Cpt9Utw=; b=ZOhjqAOhZJ1VM5U3h+R5vsW4/ZASVYeI9qJSgucZJoCouYqIxU50+VIghZFZ40nmG8 ldxTUc4YvqBdWTmnDp2Rn0ueh17VWyqoptaBhQMRqOGOWHeWaUyzZGrv0xJTeKDc05LQ L97lVtrgCyLTDo7uU09yEWlIwJXpMjvL436K/s9CjHmyO9pQ7Db5YDL1nPs22Pf7p84n mVsAga0WUKyGIaY6NTfsqvYJ7yB9XUWpmB6qUAlXWHLgZq5uQr9MCCq5XH3r3A3ic7I7 Xwl6/OLb7Ugoib2DlGYLdH1W8/w/6WSxNSvAjFbl5gP1m3XO+XlLX+w84kYvRc/vALKB gHxg== X-Gm-Message-State: APjAAAXuklQ3slSLcqD6T5ezNQcWNFPEB6Kr6Ik7bm4tL4uWUTdqglpa qslxrlUCh3EgqO7LAllKCs6DSBLAP3Mw5mndpC+5aVtw X-Google-Smtp-Source: APXvYqw2K+wR4zyrDug2JeRjlT26oGvp/M1a5v5ocdeVq0npcf2nOFuGCyUDPV3RCH/daQt09VZZ2Pnsl48KjePSA9E= X-Received: by 2002:a6b:8f51:: with SMTP id r78mr17414682iod.110.1557765856765; Mon, 13 May 2019 09:44:16 -0700 (PDT) MIME-Version: 1.0 References: <201905111637.x4BGbAWj032623@gndrsh.dnsmgr.net> <201905111741.x4BHflXP008848@slippy.cwsent.com> In-Reply-To: <201905111741.x4BHflXP008848@slippy.cwsent.com> From: Xin LI Date: Mon, 13 May 2019 09:44:05 -0700 Message-ID: Subject: Re: svn commit: r347488 - head/usr.sbin/ntp/ntpd To: Cy Schubert Cc: rgrimes@freebsd.org, Ian Lepore , Xin LI , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" X-Rspamd-Queue-Id: B4EEE89F6B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=OK4xai17; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of delphij@gmail.com designates 2607:f8b0:4864:20::d34 as permitted sender) smtp.mailfrom=delphij@gmail.com X-Spamd-Result: default: False [-6.52 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_TLS_LAST(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCPT_COUNT_SEVEN(0.00)[7]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; RCVD_IN_DNSWL_NONE(0.00)[4.3.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]; NEURAL_HAM_SHORT(-0.89)[-0.891,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-2.62)[ip: (-7.53), ipnet: 2607:f8b0::/32(-3.25), asn: 15169(-2.26), country: US(-0.06)]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 16:44:18 -0000 On Sat, May 11, 2019 at 10:42 AM Cy Schubert wrote: > In message <201905111637.x4BGbAWj032623@gndrsh.dnsmgr.net>, "Rodney W. > Grimes" > writes: > > > On Sat, 2019-05-11 at 14:22 +0000, Xin LI wrote: > > > > Author: delphij > > > > Date: Sat May 11 14:22:21 2019 > > > > New Revision: 347488 > > > > URL: https://svnweb.freebsd.org/changeset/base/347488 > > > > > > > > Log: > > > > Update leap-seconds to leap-seconds.3757622400. > > > > > > > > > > For future reference: it's a bit better to get this file from NIST [*] > > > than from USNO. The USNO boilerplate is full of typos, and USNO > > > incorrectly adjusts the "last update date" metadata every time they > > > change the expiration date of the file. That's not correct... as the > > > boilerplate itself states, that field is only supposed to be updated > > > when new leap seconds are added to the file. > > > > I would be very happy if that information would end up in the > > top of, or next to the leap-seconds file so that it was followed > > in the future, rather than being folk lore. > > > > Thanks, > > Rod > > Leap seconds hasn't been updated upstream since 2017. USNO updates the > file when they last paid attention to the file by not updating it. NIST > only updates the file when there is indeed an update, that being Ian's > point. > Yeah, obviously I somehow misread the commit message of r320256. I can do a follow commit to fix it tonight but if you have some time please feel free to fix it now. Cheers, From owner-svn-src-all@freebsd.org Mon May 13 17:35:13 2019 Return-Path: Delivered-To: svn-src-all@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 B6D5E1596280; Mon, 13 May 2019 17:35:12 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F38428C122; Mon, 13 May 2019 17:35:11 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x4DHZ2mH042283; Mon, 13 May 2019 10:35:02 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x4DHZ2BS042282; Mon, 13 May 2019 10:35:02 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201905131735.x4DHZ2BS042282@gndrsh.dnsmgr.net> Subject: Re: svn commit: r347532 - in head: contrib/netbsd-tests/lib/libc/sys lib/libc/sys lib/libc/tests/sys sys/amd64/vmm sys/sys sys/vm usr.bin/vmstat In-Reply-To: <201905131638.x4DGcmIw083437@repo.freebsd.org> To: Mark Johnston Date: Mon, 13 May 2019 10:35:02 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: F38428C122 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.972,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:35:13 -0000 > Author: markj > Date: Mon May 13 16:38:48 2019 > New Revision: 347532 > URL: https://svnweb.freebsd.org/changeset/base/347532 > > Log: > Provide separate accounting for user-wired pages. > > Historically we have not distinguished between kernel wirings and user > wirings for accounting purposes. User wirings (via mlock(2)) were > subject to a global limit on the number of wired pages, so if large > swaths of physical memory were wired by the kernel, as happens with > the ZFS ARC among other things, the limit could be exceeded, causing > user wirings to fail. > > The change adds a new counter, v_user_wire_count, which counts the > number of virtual pages wired by user processes via mlock(2) and > mlockall(2). Only user-wired pages are subject to the system-wide > limit which helps provide some safety against deadlocks. In > particular, while sources of kernel wirings typically support some > backpressure mechanism, there is no way to reclaim user-wired pages > shorting of killing the wiring process. The limit is exported as > vm.max_user_wired, renamed from vm.max_wired, and changed from u_int > to u_long. > > The choice to count virtual user-wired pages rather than physical > pages was done for simplicity. There are mechanisms that can cause > user-wired mappings to be destroyed while maintaining a wiring of > the backing physical page; these make it difficult to accurately > track user wirings at the physical page layer. > > The change also closes some holes which allowed user wirings to succeed > even when they would cause the system limit to be exceeded. For > instance, mmap() may now fail with ENOMEM in a process that has called > mlockall(MCL_FUTURE) if the new mapping would cause the user wiring > limit to be exceeded. > > Note that bhyve -S is subject to the user wiring limit, which defaults > to 1/3 of physical RAM. Users that wish to exceed the limit must tune > vm.max_user_wired. Because of that this should probably have a: Release Notes: Yes > Reviewed by: kib, ngie (mlock() test changes) > Tested by: pho (earlier version) > MFC after: 45 days > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D19908 > > Modified: > head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > head/lib/libc/sys/mlock.2 > head/lib/libc/sys/mlockall.2 > head/lib/libc/tests/sys/mlock_helper.c > head/sys/amd64/vmm/vmm.c > head/sys/sys/vmmeter.h > head/sys/vm/vm_glue.c > head/sys/vm/vm_map.c > head/sys/vm/vm_map.h > head/sys/vm/vm_meter.c > head/sys/vm/vm_mmap.c > head/sys/vm/vm_pageout.c > head/sys/vm/vm_pageout.h > head/sys/vm/vm_unix.c > head/usr.bin/vmstat/vmstat.c > > Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > ============================================================================== > --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 15:39:54 2019 (r347531) > +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 16:38:48 2019 (r347532) > @@ -51,7 +51,7 @@ __RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 > #define _KMEMUSER > #include > > -void set_vm_max_wired(int); > +void set_vm_max_wired(u_long); > void restore_vm_max_wired(void); > #endif > > > Modified: head/lib/libc/sys/mlock.2 > ============================================================================== > --- head/lib/libc/sys/mlock.2 Mon May 13 15:39:54 2019 (r347531) > +++ head/lib/libc/sys/mlock.2 Mon May 13 16:38:48 2019 (r347532) > @@ -28,7 +28,7 @@ > .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 > .\" $FreeBSD$ > .\" > -.Dd March 20, 2018 > +.Dd May 13, 2019 > .Dt MLOCK 2 > .Os > .Sh NAME > @@ -97,13 +97,13 @@ resource limit and the > system-wide > .Dq wired pages > limit > -.Va vm.max_wired . > -.Va vm.max_wired > +.Va vm.max_user_wired . > +.Va vm.max_user_wired > applies to the system as a whole, so the amount available to a single > process at any given time is the difference between > -.Va vm.max_wired > +.Va vm.max_user_wired > and > -.Va vm.stats.vm.v_wire_count . > +.Va vm.stats.vm.v_user_wire_count . > .Pp > If > .Va security.bsd.unprivileged_mlock > @@ -124,13 +124,11 @@ will fail if: > is set to 0 and the caller is not the super-user. > .It Bq Er EINVAL > The address range given wraps around zero. > -.It Bq Er EAGAIN > -Locking the indicated range would exceed the system limit for locked memory. > .It Bq Er ENOMEM > Some portion of the indicated address range is not allocated. > There was an error faulting/mapping a page. > -Locking the indicated range would exceed the per-process limit for locked > -memory. > +Locking the indicated range would exceed the per-process or system-wide limits > +for locked memory. > .El > The > .Fn munlock > @@ -171,11 +169,11 @@ system calls first appeared in > Allocating too much wired memory can lead to a memory-allocation deadlock > which requires a reboot to recover from. > .Pp > -The per-process resource limit is a limit on the amount of virtual > -memory locked, while the system-wide limit is for the number of locked > -physical pages. > -Hence a process with two distinct locked mappings of the same physical page > -counts as 2 pages against the per-process limit and as only a single page > -in the system limit. > +The per-process and system-wide resource limits of locked memory apply > +to the amount of virtual memory locked, not the amount of locked physical > +pages. > +Hence two distinct locked mappings of the same physical page counts as > +2 pages aginst the system limit, and also against the per-process limit > +if both mappings belong to the same physical map. > .Pp > The per-process resource limit is not currently supported. > > Modified: head/lib/libc/sys/mlockall.2 > ============================================================================== > --- head/lib/libc/sys/mlockall.2 Mon May 13 15:39:54 2019 (r347531) > +++ head/lib/libc/sys/mlockall.2 Mon May 13 16:38:48 2019 (r347532) > @@ -30,7 +30,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd December 25, 2012 > +.Dd May 13, 2019 > .Dt MLOCKALL 2 > .Os > .Sh NAME > @@ -69,7 +69,7 @@ limited in how much they can lock down. > A single process can lock the minimum of a system-wide > .Dq wired pages > limit > -.Va vm.max_wired > +.Va vm.max_user_wired > and the per-process > .Dv RLIMIT_MEMLOCK > resource limit. > @@ -138,9 +138,9 @@ and > functions first appeared in > .Fx 5.1 . > .Sh BUGS > -The per-process resource limit is a limit on the amount of virtual > -memory locked, while the system-wide limit is for the number of locked > -physical pages. > -Hence a process with two distinct locked mappings of the same physical page > -counts as 2 pages against the per-process limit and as only a single page > -in the system limit. > +The per-process and system-wide resource limits of locked memory apply > +to the amount of virtual memory locked, not the amount of locked physical > +pages. > +Hence two distinct locked mappings of the same physical page counts as > +2 pages aginst the system limit, and also against the per-process limit > +if both mappings belong to the same physical map. > > Modified: head/lib/libc/tests/sys/mlock_helper.c > ============================================================================== > --- head/lib/libc/tests/sys/mlock_helper.c Mon May 13 15:39:54 2019 (r347531) > +++ head/lib/libc/tests/sys/mlock_helper.c Mon May 13 16:38:48 2019 (r347532) > @@ -39,16 +39,16 @@ __FBSDID("$FreeBSD$"); > #include > #include > > -#define VM_MAX_WIRED "vm.max_wired" > +#define VM_MAX_WIRED "vm.max_user_wired" > > static void > -vm_max_wired_sysctl(int *old_value, int *new_value) > +vm_max_wired_sysctl(u_long *old_value, u_long *new_value) > { > size_t old_len; > - size_t new_len = (new_value == NULL ? 0 : sizeof(int)); > + size_t new_len = (new_value == NULL ? 0 : sizeof(*new_value)); > > if (old_value == NULL) > - printf("Setting the new value to %d\n", *new_value); > + printf("Setting the new value to %lu\n", *new_value); > else { > ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len, > new_value, new_len) == 0, > @@ -60,14 +60,14 @@ vm_max_wired_sysctl(int *old_value, int *new_value) > "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); > > if (old_value != NULL) > - printf("Saved the old value (%d)\n", *old_value); > + printf("Saved the old value (%lu)\n", *old_value); > } > > void > -set_vm_max_wired(int new_value) > +set_vm_max_wired(u_long new_value) > { > FILE *fp; > - int old_value; > + u_long old_value; > > fp = fopen(VM_MAX_WIRED, "w"); > if (fp == NULL) { > @@ -78,7 +78,7 @@ set_vm_max_wired(int new_value) > > vm_max_wired_sysctl(&old_value, NULL); > > - ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0, > + ATF_REQUIRE_MSG(fprintf(fp, "%lu", old_value) > 0, > "saving %s failed", VM_MAX_WIRED); > > fclose(fp); > @@ -90,7 +90,7 @@ void > restore_vm_max_wired(void) > { > FILE *fp; > - int saved_max_wired; > + u_long saved_max_wired; > > fp = fopen(VM_MAX_WIRED, "r"); > if (fp == NULL) { > @@ -98,14 +98,14 @@ restore_vm_max_wired(void) > return; > } > > - if (fscanf(fp, "%d", &saved_max_wired) != 1) { > + if (fscanf(fp, "%lu", &saved_max_wired) != 1) { > perror("fscanf failed\n"); > fclose(fp); > return; > } > > fclose(fp); > - printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired); > + printf("old value in %s: %lu\n", VM_MAX_WIRED, saved_max_wired); > > if (saved_max_wired == 0) /* This will cripple the test host */ > return; > > Modified: head/sys/amd64/vmm/vmm.c > ============================================================================== > --- head/sys/amd64/vmm/vmm.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/amd64/vmm/vmm.c Mon May 13 16:38:48 2019 (r347532) > @@ -754,7 +754,8 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segi > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > if (error != KERN_SUCCESS) { > vm_map_remove(&vm->vmspace->vm_map, gpa, gpa + len); > - return (EFAULT); > + return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM : > + EFAULT); > } > } > > > Modified: head/sys/sys/vmmeter.h > ============================================================================== > --- head/sys/sys/vmmeter.h Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/sys/vmmeter.h Mon May 13 16:38:48 2019 (r347532) > @@ -153,6 +153,8 @@ extern domainset_t vm_severe_domains; > #define VM_CNT_INC(var) VM_CNT_ADD(var, 1) > #define VM_CNT_FETCH(var) counter_u64_fetch(vm_cnt.var) > > +extern u_long vm_user_wire_count; > + > static inline void > vm_wire_add(int cnt) > { > > Modified: head/sys/vm/vm_glue.c > ============================================================================== > --- head/sys/vm/vm_glue.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_glue.c Mon May 13 16:38:48 2019 (r347532) > @@ -181,21 +181,8 @@ vslock(void *addr, size_t len) > if (last < (vm_offset_t)addr || end < (vm_offset_t)addr) > return (EINVAL); > npages = atop(end - start); > - if (npages > vm_page_max_wired) > + if (npages > vm_page_max_user_wired) > return (ENOMEM); > -#if 0 > - /* > - * XXX - not yet > - * > - * The limit for transient usage of wired pages should be > - * larger than for "permanent" wired pages (mlock()). > - * > - * Also, the sysctl code, which is the only present user > - * of vslock(), does a hard loop on EAGAIN. > - */ > - if (npages + vm_wire_count() > vm_page_max_wired) > - return (EAGAIN); > -#endif > error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, > VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); > if (error == KERN_SUCCESS) { > > Modified: head/sys/vm/vm_map.c > ============================================================================== > --- head/sys/vm/vm_map.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_map.c Mon May 13 16:38:48 2019 (r347532) > @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -2917,12 +2918,12 @@ done: > > if (rv == KERN_SUCCESS && (!user_unwire || > (entry->eflags & MAP_ENTRY_USER_WIRED))) { > - if (user_unwire) > - entry->eflags &= ~MAP_ENTRY_USER_WIRED; > if (entry->wired_count == 1) > vm_map_entry_unwire(map, entry); > else > entry->wired_count--; > + if (user_unwire) > + entry->eflags &= ~MAP_ENTRY_USER_WIRED; > } > KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) != 0, > ("vm_map_unwire: in-transition flag missing %p", entry)); > @@ -2942,6 +2943,28 @@ done: > return (rv); > } > > +static void > +vm_map_wire_user_count_sub(u_long npages) > +{ > + > + atomic_subtract_long(&vm_user_wire_count, npages); > +} > + > +static bool > +vm_map_wire_user_count_add(u_long npages) > +{ > + u_long wired; > + > + wired = vm_user_wire_count; > + do { > + if (npages + wired > vm_page_max_user_wired) > + return (false); > + } while (!atomic_fcmpset_long(&vm_user_wire_count, &wired, > + npages + wired)); > + > + return (true); > +} > + > /* > * vm_map_wire_entry_failure: > * > @@ -2978,37 +3001,49 @@ vm_map_wire_entry_failure(vm_map_t map, vm_map_entry_t > entry->wired_count = -1; > } > > +int > +vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) > +{ > + int rv; > + > + vm_map_lock(map); > + rv = vm_map_wire_locked(map, start, end, flags); > + vm_map_unlock(map); > + return (rv); > +} > + > + > /* > - * vm_map_wire: > + * vm_map_wire_locked: > * > - * Implements both kernel and user wiring. > + * Implements both kernel and user wiring. Returns with the map locked, > + * the map lock may be dropped. > */ > int > -vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > - int flags) > +vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) > { > vm_map_entry_t entry, first_entry, tmp_entry; > vm_offset_t faddr, saved_end, saved_start; > - unsigned int last_timestamp; > + u_long npages; > + u_int last_timestamp; > int rv; > boolean_t need_wakeup, result, user_wire; > vm_prot_t prot; > > + VM_MAP_ASSERT_LOCKED(map); > + > if (start == end) > return (KERN_SUCCESS); > prot = 0; > if (flags & VM_MAP_WIRE_WRITE) > prot |= VM_PROT_WRITE; > user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; > - vm_map_lock(map); > VM_MAP_RANGE_CHECK(map, start, end); > if (!vm_map_lookup_entry(map, start, &first_entry)) { > if (flags & VM_MAP_WIRE_HOLESOK) > first_entry = first_entry->next; > - else { > - vm_map_unlock(map); > + else > return (KERN_INVALID_ADDRESS); > - } > } > last_timestamp = map->timestamp; > entry = first_entry; > @@ -3042,7 +3077,6 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > /* > * first_entry has been deleted. > */ > - vm_map_unlock(map); > return (KERN_INVALID_ADDRESS); > } > end = saved_start; > @@ -3082,13 +3116,22 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > } > if (entry->wired_count == 0) { > entry->wired_count++; > - saved_start = entry->start; > - saved_end = entry->end; > > + npages = atop(entry->end - entry->start); > + if (user_wire && !vm_map_wire_user_count_add(npages)) { > + vm_map_wire_entry_failure(map, entry, > + entry->start); > + end = entry->end; > + rv = KERN_RESOURCE_SHORTAGE; > + goto done; > + } > + > /* > * Release the map lock, relying on the in-transition > * mark. Mark the map busy for fork. > */ > + saved_start = entry->start; > + saved_end = entry->end; > vm_map_busy(map); > vm_map_unlock(map); > > @@ -3136,6 +3179,8 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > last_timestamp = map->timestamp; > if (rv != KERN_SUCCESS) { > vm_map_wire_entry_failure(map, entry, faddr); > + if (user_wire) > + vm_map_wire_user_count_sub(npages); > end = entry->end; > goto done; > } > @@ -3201,9 +3246,12 @@ done: > * Undo the wiring. Wiring succeeded on this entry > * but failed on a later entry. > */ > - if (entry->wired_count == 1) > + if (entry->wired_count == 1) { > vm_map_entry_unwire(map, entry); > - else > + if (user_wire) > + vm_map_wire_user_count_sub( > + atop(entry->end - entry->start)); > + } else > entry->wired_count--; > } > next_entry_done: > @@ -3220,7 +3268,6 @@ done: > } > vm_map_simplify_entry(map, entry); > } > - vm_map_unlock(map); > if (need_wakeup) > vm_map_wakeup(map); > return (rv); > @@ -3338,13 +3385,18 @@ vm_map_sync( > static void > vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry) > { > + vm_size_t size; > > VM_MAP_ASSERT_LOCKED(map); > KASSERT(entry->wired_count > 0, > ("vm_map_entry_unwire: entry %p isn't wired", entry)); > + > + size = entry->end - entry->start; > + if ((entry->eflags & MAP_ENTRY_USER_WIRED) != 0) > + vm_map_wire_user_count_sub(atop(size)); > pmap_unwire(map->pmap, entry->start, entry->end); > - vm_object_unwire(entry->object.vm_object, entry->offset, entry->end - > - entry->start, PQ_ACTIVE); > + vm_object_unwire(entry->object.vm_object, entry->offset, size, > + PQ_ACTIVE); > entry->wired_count = 0; > } > > @@ -4311,12 +4363,11 @@ retry: > * Heed the MAP_WIREFUTURE flag if it was set for this process. > */ > if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { > - vm_map_unlock(map); > - vm_map_wire(map, grow_start, grow_start + grow_amount, > + rv = vm_map_wire_locked(map, grow_start, > + grow_start + grow_amount, > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > - vm_map_lock_read(map); > - } else > - vm_map_lock_downgrade(map); > + } > + vm_map_lock_downgrade(map); > > out: > #ifdef RACCT > > Modified: head/sys/vm/vm_map.h > ============================================================================== > --- head/sys/vm/vm_map.h Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_map.h Mon May 13 16:38:48 2019 (r347532) > @@ -422,7 +422,8 @@ int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t > int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); > int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, > int flags); > -int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > +int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); > +int vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, > int flags); > long vmspace_swap_count(struct vmspace *vmspace); > void vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool add); > > Modified: head/sys/vm/vm_meter.c > ============================================================================== > --- head/sys/vm/vm_meter.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_meter.c Mon May 13 16:38:48 2019 (r347532) > @@ -97,6 +97,8 @@ struct vmmeter __read_mostly vm_cnt = { > .v_wire_count = EARLY_COUNTER, > }; > > +u_long __exclusive_cache_line vm_user_wire_count; > + > static void > vmcounter_startup(void) > { > @@ -394,6 +396,8 @@ sysctl_handle_vmstat_proc(SYSCTL_HANDLER_ARGS) > > #define VM_STATS_UINT(var, descr) \ > SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) > +#define VM_STATS_ULONG(var, descr) \ > + SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) > > VM_STATS_UINT(v_page_size, "Page size in bytes"); > VM_STATS_UINT(v_page_count, "Total number of pages in system"); > @@ -410,6 +414,9 @@ VM_STATS_PROC(v_laundry_count, "Pages eligible for lau > VM_STATS_UINT(v_pageout_free_min, "Min pages reserved for kernel"); > VM_STATS_UINT(v_interrupt_free_min, "Reserved pages for interrupt code"); > VM_STATS_UINT(v_free_severe, "Severe page depletion point"); > + > +SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, > + &vm_user_wire_count, 0, "User-wired virtual memory"); > > #ifdef COMPAT_FREEBSD11 > /* > > Modified: head/sys/vm/vm_mmap.c > ============================================================================== > --- head/sys/vm/vm_mmap.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_mmap.c Mon May 13 16:38:48 2019 (r347532) > @@ -1003,7 +1003,7 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint > if (last < addr || end < addr) > return (EINVAL); > npages = atop(end - start); > - if (npages > vm_page_max_wired) > + if (npages > vm_page_max_user_wired) > return (ENOMEM); > map = &proc->p_vmspace->vm_map; > PROC_LOCK(proc); > @@ -1013,8 +1013,6 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint > return (ENOMEM); > } > PROC_UNLOCK(proc); > - if (npages + vm_wire_count() > vm_page_max_wired) > - return (EAGAIN); > #ifdef RACCT > if (racct_enable) { > PROC_LOCK(proc); > @@ -1091,7 +1089,12 @@ sys_mlockall(struct thread *td, struct mlockall_args * > */ > error = vm_map_wire(map, vm_map_min(map), vm_map_max(map), > VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); > - error = (error == KERN_SUCCESS ? 0 : EAGAIN); > + if (error == KERN_SUCCESS) > + error = 0; > + else if (error == KERN_RESOURCE_SHORTAGE) > + error = ENOMEM; > + else > + error = EAGAIN; > } > #ifdef RACCT > if (racct_enable && error != KERN_SUCCESS) { > @@ -1558,10 +1561,16 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz > * If the process has requested that all future mappings > * be wired, then heed this. > */ > - if (map->flags & MAP_WIREFUTURE) { > - vm_map_wire(map, *addr, *addr + size, > - VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? > - VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); > + if ((map->flags & MAP_WIREFUTURE) != 0) { > + vm_map_lock(map); > + if ((map->flags & MAP_WIREFUTURE) != 0) > + rv = vm_map_wire_locked(map, *addr, > + *addr + size, VM_MAP_WIRE_USER | > + ((flags & MAP_STACK) ? VM_MAP_WIRE_HOLESOK : > + VM_MAP_WIRE_NOHOLES)); > + if (rv != KERN_SUCCESS) > + (void)vm_map_delete(map, *addr, *addr + size); > + vm_map_unlock(map); > } > } > return (vm_mmap_to_errno(rv)); > > Modified: head/sys/vm/vm_pageout.c > ============================================================================== > --- head/sys/vm/vm_pageout.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_pageout.c Mon May 13 16:38:48 2019 (r347532) > @@ -194,9 +194,10 @@ SYSCTL_UINT(_vm, OID_AUTO, background_launder_max, CTL > > int vm_pageout_page_count = 32; > > -int vm_page_max_wired; /* XXX max # of wired pages system-wide */ > -SYSCTL_INT(_vm, OID_AUTO, max_wired, > - CTLFLAG_RW, &vm_page_max_wired, 0, "System-wide limit to wired page count"); > +u_long vm_page_max_user_wired; > +SYSCTL_ULONG(_vm, OID_AUTO, max_user_wired, CTLFLAG_RW, > + &vm_page_max_user_wired, 0, > + "system-wide limit to user-wired page count"); > > static u_int isqrt(u_int num); > static int vm_pageout_launder(struct vm_domain *vmd, int launder, > @@ -2041,8 +2042,8 @@ vm_pageout_init(void) > if (vm_pageout_update_period == 0) > vm_pageout_update_period = 600; > > - if (vm_page_max_wired == 0) > - vm_page_max_wired = freecount / 3; > + if (vm_page_max_user_wired == 0) > + vm_page_max_user_wired = freecount / 3; > } > > /* > > Modified: head/sys/vm/vm_pageout.h > ============================================================================== > --- head/sys/vm/vm_pageout.h Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_pageout.h Mon May 13 16:38:48 2019 (r347532) > @@ -75,7 +75,7 @@ > * Exported data structures. > */ > > -extern int vm_page_max_wired; > +extern u_long vm_page_max_user_wired; > extern int vm_pageout_page_count; > > #define VM_OOM_MEM 1 > > Modified: head/sys/vm/vm_unix.c > ============================================================================== > --- head/sys/vm/vm_unix.c Mon May 13 15:39:54 2019 (r347531) > +++ head/sys/vm/vm_unix.c Mon May 13 16:38:48 2019 (r347532) > @@ -95,13 +95,11 @@ kern_break(struct thread *td, uintptr_t *addr) > rlim_t datalim, lmemlim, vmemlim; > int prot, rv; > int error = 0; > - boolean_t do_map_wirefuture; > > datalim = lim_cur(td, RLIMIT_DATA); > lmemlim = lim_cur(td, RLIMIT_MEMLOCK); > vmemlim = lim_cur(td, RLIMIT_VMEM); > > - do_map_wirefuture = FALSE; > new = round_page(*addr); > vm_map_lock(map); > > @@ -184,7 +182,14 @@ kern_break(struct thread *td, uintptr_t *addr) > if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32)) > prot |= VM_PROT_EXECUTE; > #endif > - rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, 0); > + rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, > + 0); > + if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { > + rv = vm_map_wire_locked(map, old, new, > + VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > + if (rv != KERN_SUCCESS) > + vm_map_delete(map, old, new); > + } > if (rv != KERN_SUCCESS) { > #ifdef RACCT > if (racct_enable) { > @@ -205,17 +210,6 @@ kern_break(struct thread *td, uintptr_t *addr) > goto done; > } > vm->vm_dsize += btoc(new - old); > - /* > - * Handle the MAP_WIREFUTURE case for legacy applications, > - * by marking the newly mapped range of pages as wired. > - * We are not required to perform a corresponding > - * vm_map_unwire() before vm_map_delete() below, as > - * it will forcibly unwire the pages in the range. > - * > - * XXX If the pages cannot be wired, no error is returned. > - */ > - if ((map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) > - do_map_wirefuture = TRUE; > } else if (new < old) { > rv = vm_map_delete(map, new, old); > if (rv != KERN_SUCCESS) { > @@ -238,10 +232,6 @@ kern_break(struct thread *td, uintptr_t *addr) > } > done: > vm_map_unlock(map); > - > - if (do_map_wirefuture) > - (void) vm_map_wire(map, old, new, > - VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); > > if (error == 0) > *addr = new; > > Modified: head/usr.bin/vmstat/vmstat.c > ============================================================================== > --- head/usr.bin/vmstat/vmstat.c Mon May 13 15:39:54 2019 (r347531) > +++ head/usr.bin/vmstat/vmstat.c Mon May 13 16:38:48 2019 (r347532) > @@ -156,6 +156,7 @@ static struct __vmmeter { > u_int v_free_min; > u_int v_free_count; > u_int v_wire_count; > + u_long v_user_wire_count; > u_int v_active_count; > u_int v_inactive_target; > u_int v_inactive_count; > @@ -566,6 +567,7 @@ fill_vmmeter(struct __vmmeter *vmmp) > GET_VM_STATS(vm, v_free_min); > GET_VM_STATS(vm, v_free_count); > GET_VM_STATS(vm, v_wire_count); > + GET_VM_STATS(vm, v_user_wire_count); > GET_VM_STATS(vm, v_active_count); > GET_VM_STATS(vm, v_inactive_target); > GET_VM_STATS(vm, v_inactive_count); > @@ -1057,6 +1059,8 @@ dosum(void) > sum.v_laundry_count); > xo_emit("{:wired-pages/%9u} {N:pages wired down}\n", > sum.v_wire_count); > + xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages wired " > + "down}\n", sum.v_user_wire_count); > xo_emit("{:free-pages/%9u} {N:pages free}\n", > sum.v_free_count); > xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size); > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Mon May 13 17:41:46 2019 Return-Path: Delivered-To: svn-src-all@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 AAEBA15965F7; Mon, 13 May 2019 17:41:46 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4DC18C547; Mon, 13 May 2019 17:41:45 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x4DHfhmg042305; Mon, 13 May 2019 10:41:43 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x4DHfh2G042304; Mon, 13 May 2019 10:41:43 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201905131741.x4DHfh2G042304@gndrsh.dnsmgr.net> Subject: Re: svn commit: r347532 - in head: contrib/netbsd-tests/lib/libc/sys lib/libc/sys lib/libc/tests/sys sys/amd64/vmm sys/sys sys/vm usr.bin/vmstat In-Reply-To: <201905131735.x4DHZ2BS042282@gndrsh.dnsmgr.net> To: rgrimes@freebsd.org Date: Mon, 13 May 2019 10:41:43 -0700 (PDT) CC: Mark Johnston , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: B4DC18C547 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:41:47 -0000 > > Author: markj > > Date: Mon May 13 16:38:48 2019 > > New Revision: 347532 > > URL: https://svnweb.freebsd.org/changeset/base/347532 > > > > Log: > > Provide separate accounting for user-wired pages. > > > > Historically we have not distinguished between kernel wirings and user > > wirings for accounting purposes. User wirings (via mlock(2)) were > > subject to a global limit on the number of wired pages, so if large > > swaths of physical memory were wired by the kernel, as happens with > > the ZFS ARC among other things, the limit could be exceeded, causing > > user wirings to fail. > > > > The change adds a new counter, v_user_wire_count, which counts the > > number of virtual pages wired by user processes via mlock(2) and > > mlockall(2). Only user-wired pages are subject to the system-wide > > limit which helps provide some safety against deadlocks. In > > particular, while sources of kernel wirings typically support some > > backpressure mechanism, there is no way to reclaim user-wired pages > > shorting of killing the wiring process. The limit is exported as > > vm.max_user_wired, renamed from vm.max_wired, and changed from u_int > > to u_long. > > > > The choice to count virtual user-wired pages rather than physical > > pages was done for simplicity. There are mechanisms that can cause > > user-wired mappings to be destroyed while maintaining a wiring of > > the backing physical page; these make it difficult to accurately > > track user wirings at the physical page layer. > > > > The change also closes some holes which allowed user wirings to succeed > > even when they would cause the system limit to be exceeded. For > > instance, mmap() may now fail with ENOMEM in a process that has called > > mlockall(MCL_FUTURE) if the new mapping would cause the user wiring > > limit to be exceeded. > > > > Note that bhyve -S is subject to the user wiring limit, which defaults > > to 1/3 of physical RAM. Users that wish to exceed the limit must tune > > vm.max_user_wired. > > Because of that this should probably have a: > Release Notes: Yes And probably an UPDATING entry since this may cause some -head users VM's to fall over on a update/reboot. > > Reviewed by: kib, ngie (mlock() test changes) > > Tested by: pho (earlier version) > > MFC after: 45 days > > Sponsored by: Netflix > > Differential Revision: https://reviews.freebsd.org/D19908 > > > > Modified: > > head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > > head/lib/libc/sys/mlock.2 > > head/lib/libc/sys/mlockall.2 > > head/lib/libc/tests/sys/mlock_helper.c > > head/sys/amd64/vmm/vmm.c > > head/sys/sys/vmmeter.h > > head/sys/vm/vm_glue.c > > head/sys/vm/vm_map.c > > head/sys/vm/vm_map.h > > head/sys/vm/vm_meter.c > > head/sys/vm/vm_mmap.c > > head/sys/vm/vm_pageout.c > > head/sys/vm/vm_pageout.h > > head/sys/vm/vm_unix.c > > head/usr.bin/vmstat/vmstat.c > > > > Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > > ============================================================================== > > --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May 13 16:38:48 2019 (r347532) > > @@ -51,7 +51,7 @@ __RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 > > #define _KMEMUSER > > #include > > > > -void set_vm_max_wired(int); > > +void set_vm_max_wired(u_long); > > void restore_vm_max_wired(void); > > #endif > > > > > > Modified: head/lib/libc/sys/mlock.2 > > ============================================================================== > > --- head/lib/libc/sys/mlock.2 Mon May 13 15:39:54 2019 (r347531) > > +++ head/lib/libc/sys/mlock.2 Mon May 13 16:38:48 2019 (r347532) > > @@ -28,7 +28,7 @@ > > .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 > > .\" $FreeBSD$ > > .\" > > -.Dd March 20, 2018 > > +.Dd May 13, 2019 > > .Dt MLOCK 2 > > .Os > > .Sh NAME > > @@ -97,13 +97,13 @@ resource limit and the > > system-wide > > .Dq wired pages > > limit > > -.Va vm.max_wired . > > -.Va vm.max_wired > > +.Va vm.max_user_wired . > > +.Va vm.max_user_wired > > applies to the system as a whole, so the amount available to a single > > process at any given time is the difference between > > -.Va vm.max_wired > > +.Va vm.max_user_wired > > and > > -.Va vm.stats.vm.v_wire_count . > > +.Va vm.stats.vm.v_user_wire_count . > > .Pp > > If > > .Va security.bsd.unprivileged_mlock > > @@ -124,13 +124,11 @@ will fail if: > > is set to 0 and the caller is not the super-user. > > .It Bq Er EINVAL > > The address range given wraps around zero. > > -.It Bq Er EAGAIN > > -Locking the indicated range would exceed the system limit for locked memory. > > .It Bq Er ENOMEM > > Some portion of the indicated address range is not allocated. > > There was an error faulting/mapping a page. > > -Locking the indicated range would exceed the per-process limit for locked > > -memory. > > +Locking the indicated range would exceed the per-process or system-wide limits > > +for locked memory. > > .El > > The > > .Fn munlock > > @@ -171,11 +169,11 @@ system calls first appeared in > > Allocating too much wired memory can lead to a memory-allocation deadlock > > which requires a reboot to recover from. > > .Pp > > -The per-process resource limit is a limit on the amount of virtual > > -memory locked, while the system-wide limit is for the number of locked > > -physical pages. > > -Hence a process with two distinct locked mappings of the same physical page > > -counts as 2 pages against the per-process limit and as only a single page > > -in the system limit. > > +The per-process and system-wide resource limits of locked memory apply > > +to the amount of virtual memory locked, not the amount of locked physical > > +pages. > > +Hence two distinct locked mappings of the same physical page counts as > > +2 pages aginst the system limit, and also against the per-process limit > > +if both mappings belong to the same physical map. > > .Pp > > The per-process resource limit is not currently supported. > > > > Modified: head/lib/libc/sys/mlockall.2 > > ============================================================================== > > --- head/lib/libc/sys/mlockall.2 Mon May 13 15:39:54 2019 (r347531) > > +++ head/lib/libc/sys/mlockall.2 Mon May 13 16:38:48 2019 (r347532) > > @@ -30,7 +30,7 @@ > > .\" > > .\" $FreeBSD$ > > .\" > > -.Dd December 25, 2012 > > +.Dd May 13, 2019 > > .Dt MLOCKALL 2 > > .Os > > .Sh NAME > > @@ -69,7 +69,7 @@ limited in how much they can lock down. > > A single process can lock the minimum of a system-wide > > .Dq wired pages > > limit > > -.Va vm.max_wired > > +.Va vm.max_user_wired > > and the per-process > > .Dv RLIMIT_MEMLOCK > > resource limit. > > @@ -138,9 +138,9 @@ and > > functions first appeared in > > .Fx 5.1 . > > .Sh BUGS > > -The per-process resource limit is a limit on the amount of virtual > > -memory locked, while the system-wide limit is for the number of locked > > -physical pages. > > -Hence a process with two distinct locked mappings of the same physical page > > -counts as 2 pages against the per-process limit and as only a single page > > -in the system limit. > > +The per-process and system-wide resource limits of locked memory apply > > +to the amount of virtual memory locked, not the amount of locked physical > > +pages. > > +Hence two distinct locked mappings of the same physical page counts as > > +2 pages aginst the system limit, and also against the per-process limit > > +if both mappings belong to the same physical map. > > > > Modified: head/lib/libc/tests/sys/mlock_helper.c > > ============================================================================== > > --- head/lib/libc/tests/sys/mlock_helper.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/lib/libc/tests/sys/mlock_helper.c Mon May 13 16:38:48 2019 (r347532) > > @@ -39,16 +39,16 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > > > -#define VM_MAX_WIRED "vm.max_wired" > > +#define VM_MAX_WIRED "vm.max_user_wired" > > > > static void > > -vm_max_wired_sysctl(int *old_value, int *new_value) > > +vm_max_wired_sysctl(u_long *old_value, u_long *new_value) > > { > > size_t old_len; > > - size_t new_len = (new_value == NULL ? 0 : sizeof(int)); > > + size_t new_len = (new_value == NULL ? 0 : sizeof(*new_value)); > > > > if (old_value == NULL) > > - printf("Setting the new value to %d\n", *new_value); > > + printf("Setting the new value to %lu\n", *new_value); > > else { > > ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len, > > new_value, new_len) == 0, > > @@ -60,14 +60,14 @@ vm_max_wired_sysctl(int *old_value, int *new_value) > > "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); > > > > if (old_value != NULL) > > - printf("Saved the old value (%d)\n", *old_value); > > + printf("Saved the old value (%lu)\n", *old_value); > > } > > > > void > > -set_vm_max_wired(int new_value) > > +set_vm_max_wired(u_long new_value) > > { > > FILE *fp; > > - int old_value; > > + u_long old_value; > > > > fp = fopen(VM_MAX_WIRED, "w"); > > if (fp == NULL) { > > @@ -78,7 +78,7 @@ set_vm_max_wired(int new_value) > > > > vm_max_wired_sysctl(&old_value, NULL); > > > > - ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0, > > + ATF_REQUIRE_MSG(fprintf(fp, "%lu", old_value) > 0, > > "saving %s failed", VM_MAX_WIRED); > > > > fclose(fp); > > @@ -90,7 +90,7 @@ void > > restore_vm_max_wired(void) > > { > > FILE *fp; > > - int saved_max_wired; > > + u_long saved_max_wired; > > > > fp = fopen(VM_MAX_WIRED, "r"); > > if (fp == NULL) { > > @@ -98,14 +98,14 @@ restore_vm_max_wired(void) > > return; > > } > > > > - if (fscanf(fp, "%d", &saved_max_wired) != 1) { > > + if (fscanf(fp, "%lu", &saved_max_wired) != 1) { > > perror("fscanf failed\n"); > > fclose(fp); > > return; > > } > > > > fclose(fp); > > - printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired); > > + printf("old value in %s: %lu\n", VM_MAX_WIRED, saved_max_wired); > > > > if (saved_max_wired == 0) /* This will cripple the test host */ > > return; > > > > Modified: head/sys/amd64/vmm/vmm.c > > ============================================================================== > > --- head/sys/amd64/vmm/vmm.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/amd64/vmm/vmm.c Mon May 13 16:38:48 2019 (r347532) > > @@ -754,7 +754,8 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segi > > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > if (error != KERN_SUCCESS) { > > vm_map_remove(&vm->vmspace->vm_map, gpa, gpa + len); > > - return (EFAULT); > > + return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM : > > + EFAULT); > > } > > } > > > > > > Modified: head/sys/sys/vmmeter.h > > ============================================================================== > > --- head/sys/sys/vmmeter.h Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/sys/vmmeter.h Mon May 13 16:38:48 2019 (r347532) > > @@ -153,6 +153,8 @@ extern domainset_t vm_severe_domains; > > #define VM_CNT_INC(var) VM_CNT_ADD(var, 1) > > #define VM_CNT_FETCH(var) counter_u64_fetch(vm_cnt.var) > > > > +extern u_long vm_user_wire_count; > > + > > static inline void > > vm_wire_add(int cnt) > > { > > > > Modified: head/sys/vm/vm_glue.c > > ============================================================================== > > --- head/sys/vm/vm_glue.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_glue.c Mon May 13 16:38:48 2019 (r347532) > > @@ -181,21 +181,8 @@ vslock(void *addr, size_t len) > > if (last < (vm_offset_t)addr || end < (vm_offset_t)addr) > > return (EINVAL); > > npages = atop(end - start); > > - if (npages > vm_page_max_wired) > > + if (npages > vm_page_max_user_wired) > > return (ENOMEM); > > -#if 0 > > - /* > > - * XXX - not yet > > - * > > - * The limit for transient usage of wired pages should be > > - * larger than for "permanent" wired pages (mlock()). > > - * > > - * Also, the sysctl code, which is the only present user > > - * of vslock(), does a hard loop on EAGAIN. > > - */ > > - if (npages + vm_wire_count() > vm_page_max_wired) > > - return (EAGAIN); > > -#endif > > error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, > > VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); > > if (error == KERN_SUCCESS) { > > > > Modified: head/sys/vm/vm_map.c > > ============================================================================== > > --- head/sys/vm/vm_map.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_map.c Mon May 13 16:38:48 2019 (r347532) > > @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -2917,12 +2918,12 @@ done: > > > > if (rv == KERN_SUCCESS && (!user_unwire || > > (entry->eflags & MAP_ENTRY_USER_WIRED))) { > > - if (user_unwire) > > - entry->eflags &= ~MAP_ENTRY_USER_WIRED; > > if (entry->wired_count == 1) > > vm_map_entry_unwire(map, entry); > > else > > entry->wired_count--; > > + if (user_unwire) > > + entry->eflags &= ~MAP_ENTRY_USER_WIRED; > > } > > KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) != 0, > > ("vm_map_unwire: in-transition flag missing %p", entry)); > > @@ -2942,6 +2943,28 @@ done: > > return (rv); > > } > > > > +static void > > +vm_map_wire_user_count_sub(u_long npages) > > +{ > > + > > + atomic_subtract_long(&vm_user_wire_count, npages); > > +} > > + > > +static bool > > +vm_map_wire_user_count_add(u_long npages) > > +{ > > + u_long wired; > > + > > + wired = vm_user_wire_count; > > + do { > > + if (npages + wired > vm_page_max_user_wired) > > + return (false); > > + } while (!atomic_fcmpset_long(&vm_user_wire_count, &wired, > > + npages + wired)); > > + > > + return (true); > > +} > > + > > /* > > * vm_map_wire_entry_failure: > > * > > @@ -2978,37 +3001,49 @@ vm_map_wire_entry_failure(vm_map_t map, vm_map_entry_t > > entry->wired_count = -1; > > } > > > > +int > > +vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) > > +{ > > + int rv; > > + > > + vm_map_lock(map); > > + rv = vm_map_wire_locked(map, start, end, flags); > > + vm_map_unlock(map); > > + return (rv); > > +} > > + > > + > > /* > > - * vm_map_wire: > > + * vm_map_wire_locked: > > * > > - * Implements both kernel and user wiring. > > + * Implements both kernel and user wiring. Returns with the map locked, > > + * the map lock may be dropped. > > */ > > int > > -vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > - int flags) > > +vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags) > > { > > vm_map_entry_t entry, first_entry, tmp_entry; > > vm_offset_t faddr, saved_end, saved_start; > > - unsigned int last_timestamp; > > + u_long npages; > > + u_int last_timestamp; > > int rv; > > boolean_t need_wakeup, result, user_wire; > > vm_prot_t prot; > > > > + VM_MAP_ASSERT_LOCKED(map); > > + > > if (start == end) > > return (KERN_SUCCESS); > > prot = 0; > > if (flags & VM_MAP_WIRE_WRITE) > > prot |= VM_PROT_WRITE; > > user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; > > - vm_map_lock(map); > > VM_MAP_RANGE_CHECK(map, start, end); > > if (!vm_map_lookup_entry(map, start, &first_entry)) { > > if (flags & VM_MAP_WIRE_HOLESOK) > > first_entry = first_entry->next; > > - else { > > - vm_map_unlock(map); > > + else > > return (KERN_INVALID_ADDRESS); > > - } > > } > > last_timestamp = map->timestamp; > > entry = first_entry; > > @@ -3042,7 +3077,6 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > > /* > > * first_entry has been deleted. > > */ > > - vm_map_unlock(map); > > return (KERN_INVALID_ADDRESS); > > } > > end = saved_start; > > @@ -3082,13 +3116,22 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > > } > > if (entry->wired_count == 0) { > > entry->wired_count++; > > - saved_start = entry->start; > > - saved_end = entry->end; > > > > + npages = atop(entry->end - entry->start); > > + if (user_wire && !vm_map_wire_user_count_add(npages)) { > > + vm_map_wire_entry_failure(map, entry, > > + entry->start); > > + end = entry->end; > > + rv = KERN_RESOURCE_SHORTAGE; > > + goto done; > > + } > > + > > /* > > * Release the map lock, relying on the in-transition > > * mark. Mark the map busy for fork. > > */ > > + saved_start = entry->start; > > + saved_end = entry->end; > > vm_map_busy(map); > > vm_map_unlock(map); > > > > @@ -3136,6 +3179,8 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset > > last_timestamp = map->timestamp; > > if (rv != KERN_SUCCESS) { > > vm_map_wire_entry_failure(map, entry, faddr); > > + if (user_wire) > > + vm_map_wire_user_count_sub(npages); > > end = entry->end; > > goto done; > > } > > @@ -3201,9 +3246,12 @@ done: > > * Undo the wiring. Wiring succeeded on this entry > > * but failed on a later entry. > > */ > > - if (entry->wired_count == 1) > > + if (entry->wired_count == 1) { > > vm_map_entry_unwire(map, entry); > > - else > > + if (user_wire) > > + vm_map_wire_user_count_sub( > > + atop(entry->end - entry->start)); > > + } else > > entry->wired_count--; > > } > > next_entry_done: > > @@ -3220,7 +3268,6 @@ done: > > } > > vm_map_simplify_entry(map, entry); > > } > > - vm_map_unlock(map); > > if (need_wakeup) > > vm_map_wakeup(map); > > return (rv); > > @@ -3338,13 +3385,18 @@ vm_map_sync( > > static void > > vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry) > > { > > + vm_size_t size; > > > > VM_MAP_ASSERT_LOCKED(map); > > KASSERT(entry->wired_count > 0, > > ("vm_map_entry_unwire: entry %p isn't wired", entry)); > > + > > + size = entry->end - entry->start; > > + if ((entry->eflags & MAP_ENTRY_USER_WIRED) != 0) > > + vm_map_wire_user_count_sub(atop(size)); > > pmap_unwire(map->pmap, entry->start, entry->end); > > - vm_object_unwire(entry->object.vm_object, entry->offset, entry->end - > > - entry->start, PQ_ACTIVE); > > + vm_object_unwire(entry->object.vm_object, entry->offset, size, > > + PQ_ACTIVE); > > entry->wired_count = 0; > > } > > > > @@ -4311,12 +4363,11 @@ retry: > > * Heed the MAP_WIREFUTURE flag if it was set for this process. > > */ > > if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { > > - vm_map_unlock(map); > > - vm_map_wire(map, grow_start, grow_start + grow_amount, > > + rv = vm_map_wire_locked(map, grow_start, > > + grow_start + grow_amount, > > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > - vm_map_lock_read(map); > > - } else > > - vm_map_lock_downgrade(map); > > + } > > + vm_map_lock_downgrade(map); > > > > out: > > #ifdef RACCT > > > > Modified: head/sys/vm/vm_map.h > > ============================================================================== > > --- head/sys/vm/vm_map.h Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_map.h Mon May 13 16:38:48 2019 (r347532) > > @@ -422,7 +422,8 @@ int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t > > int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); > > int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > int flags); > > -int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > +int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); > > +int vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, > > int flags); > > long vmspace_swap_count(struct vmspace *vmspace); > > void vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool add); > > > > Modified: head/sys/vm/vm_meter.c > > ============================================================================== > > --- head/sys/vm/vm_meter.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_meter.c Mon May 13 16:38:48 2019 (r347532) > > @@ -97,6 +97,8 @@ struct vmmeter __read_mostly vm_cnt = { > > .v_wire_count = EARLY_COUNTER, > > }; > > > > +u_long __exclusive_cache_line vm_user_wire_count; > > + > > static void > > vmcounter_startup(void) > > { > > @@ -394,6 +396,8 @@ sysctl_handle_vmstat_proc(SYSCTL_HANDLER_ARGS) > > > > #define VM_STATS_UINT(var, descr) \ > > SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) > > +#define VM_STATS_ULONG(var, descr) \ > > + SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) > > > > VM_STATS_UINT(v_page_size, "Page size in bytes"); > > VM_STATS_UINT(v_page_count, "Total number of pages in system"); > > @@ -410,6 +414,9 @@ VM_STATS_PROC(v_laundry_count, "Pages eligible for lau > > VM_STATS_UINT(v_pageout_free_min, "Min pages reserved for kernel"); > > VM_STATS_UINT(v_interrupt_free_min, "Reserved pages for interrupt code"); > > VM_STATS_UINT(v_free_severe, "Severe page depletion point"); > > + > > +SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, > > + &vm_user_wire_count, 0, "User-wired virtual memory"); > > > > #ifdef COMPAT_FREEBSD11 > > /* > > > > Modified: head/sys/vm/vm_mmap.c > > ============================================================================== > > --- head/sys/vm/vm_mmap.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_mmap.c Mon May 13 16:38:48 2019 (r347532) > > @@ -1003,7 +1003,7 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint > > if (last < addr || end < addr) > > return (EINVAL); > > npages = atop(end - start); > > - if (npages > vm_page_max_wired) > > + if (npages > vm_page_max_user_wired) > > return (ENOMEM); > > map = &proc->p_vmspace->vm_map; > > PROC_LOCK(proc); > > @@ -1013,8 +1013,6 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint > > return (ENOMEM); > > } > > PROC_UNLOCK(proc); > > - if (npages + vm_wire_count() > vm_page_max_wired) > > - return (EAGAIN); > > #ifdef RACCT > > if (racct_enable) { > > PROC_LOCK(proc); > > @@ -1091,7 +1089,12 @@ sys_mlockall(struct thread *td, struct mlockall_args * > > */ > > error = vm_map_wire(map, vm_map_min(map), vm_map_max(map), > > VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); > > - error = (error == KERN_SUCCESS ? 0 : EAGAIN); > > + if (error == KERN_SUCCESS) > > + error = 0; > > + else if (error == KERN_RESOURCE_SHORTAGE) > > + error = ENOMEM; > > + else > > + error = EAGAIN; > > } > > #ifdef RACCT > > if (racct_enable && error != KERN_SUCCESS) { > > @@ -1558,10 +1561,16 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz > > * If the process has requested that all future mappings > > * be wired, then heed this. > > */ > > - if (map->flags & MAP_WIREFUTURE) { > > - vm_map_wire(map, *addr, *addr + size, > > - VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? > > - VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); > > + if ((map->flags & MAP_WIREFUTURE) != 0) { > > + vm_map_lock(map); > > + if ((map->flags & MAP_WIREFUTURE) != 0) > > + rv = vm_map_wire_locked(map, *addr, > > + *addr + size, VM_MAP_WIRE_USER | > > + ((flags & MAP_STACK) ? VM_MAP_WIRE_HOLESOK : > > + VM_MAP_WIRE_NOHOLES)); > > + if (rv != KERN_SUCCESS) > > + (void)vm_map_delete(map, *addr, *addr + size); > > + vm_map_unlock(map); > > } > > } > > return (vm_mmap_to_errno(rv)); > > > > Modified: head/sys/vm/vm_pageout.c > > ============================================================================== > > --- head/sys/vm/vm_pageout.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_pageout.c Mon May 13 16:38:48 2019 (r347532) > > @@ -194,9 +194,10 @@ SYSCTL_UINT(_vm, OID_AUTO, background_launder_max, CTL > > > > int vm_pageout_page_count = 32; > > > > -int vm_page_max_wired; /* XXX max # of wired pages system-wide */ > > -SYSCTL_INT(_vm, OID_AUTO, max_wired, > > - CTLFLAG_RW, &vm_page_max_wired, 0, "System-wide limit to wired page count"); > > +u_long vm_page_max_user_wired; > > +SYSCTL_ULONG(_vm, OID_AUTO, max_user_wired, CTLFLAG_RW, > > + &vm_page_max_user_wired, 0, > > + "system-wide limit to user-wired page count"); > > > > static u_int isqrt(u_int num); > > static int vm_pageout_launder(struct vm_domain *vmd, int launder, > > @@ -2041,8 +2042,8 @@ vm_pageout_init(void) > > if (vm_pageout_update_period == 0) > > vm_pageout_update_period = 600; > > > > - if (vm_page_max_wired == 0) > > - vm_page_max_wired = freecount / 3; > > + if (vm_page_max_user_wired == 0) > > + vm_page_max_user_wired = freecount / 3; > > } > > > > /* > > > > Modified: head/sys/vm/vm_pageout.h > > ============================================================================== > > --- head/sys/vm/vm_pageout.h Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_pageout.h Mon May 13 16:38:48 2019 (r347532) > > @@ -75,7 +75,7 @@ > > * Exported data structures. > > */ > > > > -extern int vm_page_max_wired; > > +extern u_long vm_page_max_user_wired; > > extern int vm_pageout_page_count; > > > > #define VM_OOM_MEM 1 > > > > Modified: head/sys/vm/vm_unix.c > > ============================================================================== > > --- head/sys/vm/vm_unix.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/sys/vm/vm_unix.c Mon May 13 16:38:48 2019 (r347532) > > @@ -95,13 +95,11 @@ kern_break(struct thread *td, uintptr_t *addr) > > rlim_t datalim, lmemlim, vmemlim; > > int prot, rv; > > int error = 0; > > - boolean_t do_map_wirefuture; > > > > datalim = lim_cur(td, RLIMIT_DATA); > > lmemlim = lim_cur(td, RLIMIT_MEMLOCK); > > vmemlim = lim_cur(td, RLIMIT_VMEM); > > > > - do_map_wirefuture = FALSE; > > new = round_page(*addr); > > vm_map_lock(map); > > > > @@ -184,7 +182,14 @@ kern_break(struct thread *td, uintptr_t *addr) > > if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32)) > > prot |= VM_PROT_EXECUTE; > > #endif > > - rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, 0); > > + rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, > > + 0); > > + if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { > > + rv = vm_map_wire_locked(map, old, new, > > + VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > + if (rv != KERN_SUCCESS) > > + vm_map_delete(map, old, new); > > + } > > if (rv != KERN_SUCCESS) { > > #ifdef RACCT > > if (racct_enable) { > > @@ -205,17 +210,6 @@ kern_break(struct thread *td, uintptr_t *addr) > > goto done; > > } > > vm->vm_dsize += btoc(new - old); > > - /* > > - * Handle the MAP_WIREFUTURE case for legacy applications, > > - * by marking the newly mapped range of pages as wired. > > - * We are not required to perform a corresponding > > - * vm_map_unwire() before vm_map_delete() below, as > > - * it will forcibly unwire the pages in the range. > > - * > > - * XXX If the pages cannot be wired, no error is returned. > > - */ > > - if ((map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) > > - do_map_wirefuture = TRUE; > > } else if (new < old) { > > rv = vm_map_delete(map, new, old); > > if (rv != KERN_SUCCESS) { > > @@ -238,10 +232,6 @@ kern_break(struct thread *td, uintptr_t *addr) > > } > > done: > > vm_map_unlock(map); > > - > > - if (do_map_wirefuture) > > - (void) vm_map_wire(map, old, new, > > - VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); > > > > if (error == 0) > > *addr = new; > > > > Modified: head/usr.bin/vmstat/vmstat.c > > ============================================================================== > > --- head/usr.bin/vmstat/vmstat.c Mon May 13 15:39:54 2019 (r347531) > > +++ head/usr.bin/vmstat/vmstat.c Mon May 13 16:38:48 2019 (r347532) > > @@ -156,6 +156,7 @@ static struct __vmmeter { > > u_int v_free_min; > > u_int v_free_count; > > u_int v_wire_count; > > + u_long v_user_wire_count; > > u_int v_active_count; > > u_int v_inactive_target; > > u_int v_inactive_count; > > @@ -566,6 +567,7 @@ fill_vmmeter(struct __vmmeter *vmmp) > > GET_VM_STATS(vm, v_free_min); > > GET_VM_STATS(vm, v_free_count); > > GET_VM_STATS(vm, v_wire_count); > > + GET_VM_STATS(vm, v_user_wire_count); > > GET_VM_STATS(vm, v_active_count); > > GET_VM_STATS(vm, v_inactive_target); > > GET_VM_STATS(vm, v_inactive_count); > > @@ -1057,6 +1059,8 @@ dosum(void) > > sum.v_laundry_count); > > xo_emit("{:wired-pages/%9u} {N:pages wired down}\n", > > sum.v_wire_count); > > + xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages wired " > > + "down}\n", sum.v_user_wire_count); > > xo_emit("{:free-pages/%9u} {N:pages free}\n", > > sum.v_free_count); > > xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size); > > > > > > -- > Rod Grimes rgrimes@freebsd.org > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Mon May 13 17:48:18 2019 Return-Path: Delivered-To: svn-src-all@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 62B6B1596736; Mon, 13 May 2019 17:48:18 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 130AB8C772; Mon, 13 May 2019 17:48:18 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DBD51D3E1; Mon, 13 May 2019 17:48:17 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DHmHYF020450; Mon, 13 May 2019 17:48:17 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DHmGaH020444; Mon, 13 May 2019 17:48:16 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131748.x4DHmGaH020444@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 17:48:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347533 - in head/sys: compat/linux modules/linux_common X-SVN-Group: head X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in head/sys: compat/linux modules/linux_common X-SVN-Commit-Revision: 347533 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 130AB8C772 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:48:18 -0000 Author: dchagin Date: Mon May 13 17:48:16 2019 New Revision: 347533 URL: https://svnweb.freebsd.org/changeset/base/347533 Log: Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations for one syscall. Also some syscall uses linux_sa_put() and linux_getsockaddr() when load sockaddr to userspace or from userspace accordingly. To avoid this chaos, especially converting sockaddr in the userspace, rewrite these 4 functions to convert sockaddr only in kernel and leave only 2 of this functions. Also in order to reduce duplication between MD parts of the Linuxulator put struct sockaddr conversion functions that are MI out into linux_common module. PR: 232920 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20157 Modified: head/sys/compat/linux/linux.c head/sys/compat/linux/linux.h head/sys/compat/linux/linux_common.h head/sys/compat/linux/linux_socket.c head/sys/compat/linux/linux_socket.h head/sys/modules/linux_common/Makefile Modified: head/sys/compat/linux/linux.c ============================================================================== --- head/sys/compat/linux/linux.c Mon May 13 16:38:48 2019 (r347532) +++ head/sys/compat/linux/linux.c Mon May 13 17:48:16 2019 (r347533) @@ -27,21 +27,29 @@ #include __FBSDID("$FreeBSD$"); +#include + #include #include #include #include #include +#include #include #include +#include #include #include #include #include +#include +#include + #include #include +#include CTASSERT(LINUX_IFNAMSIZ == IFNAMSIZ); @@ -322,4 +330,194 @@ linux_ifhwaddr(struct ifnet *ifp, struct l_sockaddr *l } return (ENOENT); +} + +int +linux_to_bsd_domain(int domain) +{ + + switch (domain) { + case LINUX_AF_UNSPEC: + return (AF_UNSPEC); + case LINUX_AF_UNIX: + return (AF_LOCAL); + case LINUX_AF_INET: + return (AF_INET); + case LINUX_AF_INET6: + return (AF_INET6); + case LINUX_AF_AX25: + return (AF_CCITT); + case LINUX_AF_IPX: + return (AF_IPX); + case LINUX_AF_APPLETALK: + return (AF_APPLETALK); + } + return (-1); +} + +int +bsd_to_linux_domain(int domain) +{ + + switch (domain) { + case AF_UNSPEC: + return (LINUX_AF_UNSPEC); + case AF_LOCAL: + return (LINUX_AF_UNIX); + case AF_INET: + return (LINUX_AF_INET); + case AF_INET6: + return (LINUX_AF_INET6); + case AF_CCITT: + return (LINUX_AF_AX25); + case AF_IPX: + return (LINUX_AF_IPX); + case AF_APPLETALK: + return (LINUX_AF_APPLETALK); + } + return (-1); +} + +/* + * Based on the fact that: + * 1. Native and Linux storage of struct sockaddr + * and struct sockaddr_in6 are equal. + * 2. On Linux sa_family is the first member of all struct sockaddr. + */ +int +bsd_to_linux_sockaddr(const struct sockaddr *sa, struct l_sockaddr **lsa, + socklen_t len) +{ + struct l_sockaddr *kosa; + int error, bdom; + + *lsa = NULL; + if (len < 2 || len > UCHAR_MAX) + return (EINVAL); + + kosa = malloc(len, M_SONAME, M_WAITOK); + bcopy(sa, kosa, len); + + bdom = bsd_to_linux_domain(sa->sa_family); + if (bdom == -1) { + error = EAFNOSUPPORT; + goto out; + } + + kosa->sa_family = bdom; + *lsa = kosa; + return (0); + +out: + free(kosa, M_SONAME); + return (error); +} + +int +linux_to_bsd_sockaddr(const struct l_sockaddr *osa, struct sockaddr **sap, + socklen_t *len) +{ + struct sockaddr *sa; + struct l_sockaddr *kosa; +#ifdef INET6 + struct sockaddr_in6 *sin6; + bool oldv6size; +#endif + char *name; + int salen, bdom, error, hdrlen, namelen; + + if (*len < 2 || *len > UCHAR_MAX) + return (EINVAL); + + salen = *len; + +#ifdef INET6 + oldv6size = false; + /* + * Check for old (pre-RFC2553) sockaddr_in6. We may accept it + * if it's a v4-mapped address, so reserve the proper space + * for it. + */ + if (salen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) { + salen += sizeof(uint32_t); + oldv6size = true; + } +#endif + + kosa = malloc(salen, M_SONAME, M_WAITOK); + + if ((error = copyin(osa, kosa, *len))) + goto out; + + bdom = linux_to_bsd_domain(kosa->sa_family); + if (bdom == -1) { + error = EAFNOSUPPORT; + goto out; + } + +#ifdef INET6 + /* + * Older Linux IPv6 code uses obsolete RFC2133 struct sockaddr_in6, + * which lacks the scope id compared with RFC2553 one. If we detect + * the situation, reject the address and write a message to system log. + * + * Still accept addresses for which the scope id is not used. + */ + if (oldv6size) { + if (bdom == AF_INET6) { + sin6 = (struct sockaddr_in6 *)kosa; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) || + (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && + !IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) && + !IN6_IS_ADDR_V4COMPAT(&sin6->sin6_addr) && + !IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) && + !IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))) { + sin6->sin6_scope_id = 0; + } else { + linux_msg(curthread, + "obsolete pre-RFC2553 sockaddr_in6 rejected\n"); + error = EINVAL; + goto out; + } + } else + salen -= sizeof(uint32_t); + } +#endif + if (bdom == AF_INET) { + if (salen < sizeof(struct sockaddr_in)) { + error = EINVAL; + goto out; + } + salen = sizeof(struct sockaddr_in); + } + + if (bdom == AF_LOCAL && salen > sizeof(struct sockaddr_un)) { + hdrlen = offsetof(struct sockaddr_un, sun_path); + name = ((struct sockaddr_un *)kosa)->sun_path; + if (*name == '\0') { + /* + * Linux abstract namespace starts with a NULL byte. + * XXX We do not support abstract namespace yet. + */ + namelen = strnlen(name + 1, salen - hdrlen - 1) + 1; + } else + namelen = strnlen(name, salen - hdrlen); + salen = hdrlen + namelen; + if (salen > sizeof(struct sockaddr_un)) { + error = ENAMETOOLONG; + goto out; + } + } + + sa = (struct sockaddr *)kosa; + sa->sa_family = bdom; + sa->sa_len = salen; + + *sap = sa; + *len = salen; + return (0); + +out: + free(kosa, M_SONAME); + return (error); } Modified: head/sys/compat/linux/linux.h ============================================================================== --- head/sys/compat/linux/linux.h Mon May 13 16:38:48 2019 (r347532) +++ head/sys/compat/linux/linux.h Mon May 13 17:48:16 2019 (r347533) @@ -47,6 +47,17 @@ struct l_sockaddr { #define LINUX_ARPHRD_LOOPBACK 772 /* + * Supported address families + */ +#define LINUX_AF_UNSPEC 0 +#define LINUX_AF_UNIX 1 +#define LINUX_AF_INET 2 +#define LINUX_AF_AX25 3 +#define LINUX_AF_IPX 4 +#define LINUX_AF_APPLETALK 5 +#define LINUX_AF_INET6 10 + +/* * net device flags */ #define LINUX_IFF_UP 0x0001 Modified: head/sys/compat/linux/linux_common.h ============================================================================== --- head/sys/compat/linux/linux_common.h Mon May 13 16:38:48 2019 (r347532) +++ head/sys/compat/linux/linux_common.h Mon May 13 17:48:16 2019 (r347533) @@ -35,4 +35,11 @@ struct ifnet *ifname_linux_to_bsd(struct thread *td, void linux_ifflags(struct ifnet *ifp, short *flags); int linux_ifhwaddr(struct ifnet *ifp, struct l_sockaddr *lsa); +int linux_to_bsd_domain(int domain); +int bsd_to_linux_domain(int domain); +int bsd_to_linux_sockaddr(const struct sockaddr *sa, + struct l_sockaddr **lsa, socklen_t len); +int linux_to_bsd_sockaddr(const struct l_sockaddr *lsa, + struct sockaddr **sap, socklen_t *len); + #endif /* _LINUX_COMMON_H_ */ Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Mon May 13 16:38:48 2019 (r347532) +++ head/sys/compat/linux/linux_socket.c Mon May 13 17:48:16 2019 (r347533) @@ -70,176 +70,20 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#include #include #include #include #include -static int linux_to_bsd_domain(int); static int linux_sendmsg_common(struct thread *, l_int, struct l_msghdr *, l_uint); static int linux_recvmsg_common(struct thread *, l_int, struct l_msghdr *, l_uint, struct msghdr *); static int linux_set_socket_flags(int, int *); -/* - * Reads a Linux sockaddr and does any necessary translation. - * Linux sockaddrs don't have a length field, only a family. - * Copy the osockaddr structure pointed to by osa to kernel, adjust - * family and convert to sockaddr. - */ -static int -linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int salen) -{ - struct sockaddr *sa; - struct osockaddr *kosa; -#ifdef INET6 - struct sockaddr_in6 *sin6; - int oldv6size; -#endif - char *name; - int bdom, error, hdrlen, namelen; - if (salen < 2 || salen > UCHAR_MAX || !osa) - return (EINVAL); - -#ifdef INET6 - oldv6size = 0; - /* - * Check for old (pre-RFC2553) sockaddr_in6. We may accept it - * if it's a v4-mapped address, so reserve the proper space - * for it. - */ - if (salen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) { - salen += sizeof(uint32_t); - oldv6size = 1; - } -#endif - - kosa = malloc(salen, M_SONAME, M_WAITOK); - - if ((error = copyin(osa, kosa, salen))) - goto out; - - bdom = linux_to_bsd_domain(kosa->sa_family); - if (bdom == -1) { - error = EAFNOSUPPORT; - goto out; - } - -#ifdef INET6 - /* - * Older Linux IPv6 code uses obsolete RFC2133 struct sockaddr_in6, - * which lacks the scope id compared with RFC2553 one. If we detect - * the situation, reject the address and write a message to system log. - * - * Still accept addresses for which the scope id is not used. - */ - if (oldv6size) { - if (bdom == AF_INET6) { - sin6 = (struct sockaddr_in6 *)kosa; - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) || - (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && - !IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) && - !IN6_IS_ADDR_V4COMPAT(&sin6->sin6_addr) && - !IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) && - !IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))) { - sin6->sin6_scope_id = 0; - } else { - log(LOG_DEBUG, - "obsolete pre-RFC2553 sockaddr_in6 rejected\n"); - error = EINVAL; - goto out; - } - } else - salen -= sizeof(uint32_t); - } -#endif - if (bdom == AF_INET) { - if (salen < sizeof(struct sockaddr_in)) { - error = EINVAL; - goto out; - } - salen = sizeof(struct sockaddr_in); - } - - if (bdom == AF_LOCAL && salen > sizeof(struct sockaddr_un)) { - hdrlen = offsetof(struct sockaddr_un, sun_path); - name = ((struct sockaddr_un *)kosa)->sun_path; - if (*name == '\0') { - /* - * Linux abstract namespace starts with a NULL byte. - * XXX We do not support abstract namespace yet. - */ - namelen = strnlen(name + 1, salen - hdrlen - 1) + 1; - } else - namelen = strnlen(name, salen - hdrlen); - salen = hdrlen + namelen; - if (salen > sizeof(struct sockaddr_un)) { - error = ENAMETOOLONG; - goto out; - } - } - - sa = (struct sockaddr *)kosa; - sa->sa_family = bdom; - sa->sa_len = salen; - - *sap = sa; - return (0); - -out: - free(kosa, M_SONAME); - return (error); -} - static int -linux_to_bsd_domain(int domain) -{ - - switch (domain) { - case LINUX_AF_UNSPEC: - return (AF_UNSPEC); - case LINUX_AF_UNIX: - return (AF_LOCAL); - case LINUX_AF_INET: - return (AF_INET); - case LINUX_AF_INET6: - return (AF_INET6); - case LINUX_AF_AX25: - return (AF_CCITT); - case LINUX_AF_IPX: - return (AF_IPX); - case LINUX_AF_APPLETALK: - return (AF_APPLETALK); - } - return (-1); -} - -static int -bsd_to_linux_domain(int domain) -{ - - switch (domain) { - case AF_UNSPEC: - return (LINUX_AF_UNSPEC); - case AF_LOCAL: - return (LINUX_AF_UNIX); - case AF_INET: - return (LINUX_AF_INET); - case AF_INET6: - return (LINUX_AF_INET6); - case AF_CCITT: - return (LINUX_AF_AX25); - case AF_IPX: - return (LINUX_AF_IPX); - case AF_APPLETALK: - return (LINUX_AF_APPLETALK); - } - return (-1); -} - -static int linux_to_bsd_sockopt_level(int level) { @@ -451,72 +295,7 @@ linux_to_bsd_msg_flags(int flags) return (ret_flags); } -/* -* If bsd_to_linux_sockaddr() or linux_to_bsd_sockaddr() faults, then the -* native syscall will fault. Thus, we don't really need to check the -* return values for these functions. -*/ - static int -bsd_to_linux_sockaddr(struct sockaddr *arg) -{ - struct sockaddr sa; - size_t sa_len = sizeof(struct sockaddr); - int error, bdom; - - if ((error = copyin(arg, &sa, sa_len))) - return (error); - - bdom = bsd_to_linux_domain(sa.sa_family); - if (bdom == -1) - return (EAFNOSUPPORT); - - *(u_short *)&sa = bdom; - return (copyout(&sa, arg, sa_len)); -} - -static int -linux_to_bsd_sockaddr(struct sockaddr *arg, int len) -{ - struct sockaddr sa; - size_t sa_len = sizeof(struct sockaddr); - int error, bdom; - - if ((error = copyin(arg, &sa, sa_len))) - return (error); - - bdom = linux_to_bsd_domain(*(sa_family_t *)&sa); - if (bdom == -1) - return (EAFNOSUPPORT); - - sa.sa_family = bdom; - sa.sa_len = len; - return (copyout(&sa, arg, sa_len)); -} - -static int -linux_sa_put(struct osockaddr *osa) -{ - struct osockaddr sa; - int error, bdom; - - /* - * Only read/write the osockaddr family part, the rest is - * not changed. - */ - error = copyin(osa, &sa, sizeof(sa.sa_family)); - if (error != 0) - return (error); - - bdom = bsd_to_linux_domain(sa.sa_family); - if (bdom == -1) - return (EINVAL); - - sa.sa_family = bdom; - return (copyout(&sa, osa, sizeof(sa.sa_family))); -} - -static int linux_to_bsd_cmsg_type(int cmsg_type) { @@ -609,10 +388,11 @@ linux_sendit(struct thread *td, int s, struct msghdr * struct mbuf *control, enum uio_seg segflg) { struct sockaddr *to; - int error; + int error, len; if (mp->msg_name != NULL) { - error = linux_getsockaddr(&to, mp->msg_name, mp->msg_namelen); + len = mp->msg_namelen; + error = linux_to_bsd_sockaddr(mp->msg_name, &to, &len); if (error != 0) return (error); mp->msg_name = to; @@ -751,13 +531,15 @@ linux_bind(struct thread *td, struct linux_bind_args * struct sockaddr *sa; int error; - error = linux_getsockaddr(&sa, PTRIN(args->name), - args->namelen); + error = linux_to_bsd_sockaddr(PTRIN(args->name), &sa, + &args->namelen); if (error != 0) return (error); error = kern_bindat(td, AT_FDCWD, args->s, sa); free(sa, M_SONAME); + + /* XXX */ if (error == EADDRNOTAVAIL && args->namelen != sizeof(struct sockaddr_in)) return (EINVAL); return (error); @@ -772,8 +554,8 @@ linux_connect(struct thread *td, struct linux_connect_ u_int fflag; int error; - error = linux_getsockaddr(&sa, (struct osockaddr *)PTRIN(args->name), - args->namelen); + error = linux_to_bsd_sockaddr(PTRIN(args->name), &sa, + &args->namelen); if (error != 0) return (error); @@ -817,43 +599,67 @@ static int linux_accept_common(struct thread *td, int s, l_uintptr_t addr, l_uintptr_t namelen, int flags) { - struct accept4_args /* { - int s; - struct sockaddr * __restrict name; - socklen_t * __restrict anamelen; - int flags; - } */ bsd_args; - struct socket *so; + struct l_sockaddr *lsa; + struct sockaddr *sa; struct file *fp; + int bflags, len; + struct socket *so; int error, error1; - bsd_args.s = s; - bsd_args.name = (struct sockaddr * __restrict)PTRIN(addr); - bsd_args.anamelen = PTRIN(namelen); - bsd_args.flags = 0; - error = linux_set_socket_flags(flags, &bsd_args.flags); + bflags = 0; + error = linux_set_socket_flags(flags, &bflags); if (error != 0) return (error); - error = sys_accept4(td, &bsd_args); - bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.name); + + sa = NULL; + if (PTRIN(addr) == NULL) { + len = 0; + error = kern_accept4(td, s, NULL, NULL, bflags, NULL); + } else { + error = copyin(PTRIN(namelen), &len, sizeof(len)); + if (error != 0) + return (error); + if (len < 0) + return (EINVAL); + error = kern_accept4(td, s, &sa, &len, bflags, &fp); + if (error == 0) + fdrop(fp, td); + } + if (error != 0) { + /* + * XXX. This is wrong, different sockaddr structures + * have different sizes. + */ if (error == EFAULT && namelen != sizeof(struct sockaddr_in)) - return (EINVAL); + { + error = EINVAL; + goto out; + } if (error == EINVAL) { error1 = getsock_cap(td, s, &cap_accept_rights, &fp, NULL, NULL); - if (error1 != 0) - return (error1); - so = fp->f_data; - if (so->so_type == SOCK_DGRAM) { - fdrop(fp, td); - return (EOPNOTSUPP); + if (error1 != 0) { + error = error1; + goto out; } + so = fp->f_data; + if (so->so_type == SOCK_DGRAM) + error = EOPNOTSUPP; fdrop(fp, td); } - return (error); + goto out; } - if (addr) - error = linux_sa_put(PTRIN(addr)); + + if (len != 0 && error == 0) { + error = bsd_to_linux_sockaddr(sa, &lsa, len); + if (error == 0) + error = copyout(lsa, PTRIN(addr), len); + free(lsa, M_SONAME); + } + + free(sa, M_SONAME); + +out: if (error != 0) { (void)kern_close(td, td->td_retval[0]); td->td_retval[0] = 0; @@ -880,41 +686,59 @@ linux_accept4(struct thread *td, struct linux_accept4_ int linux_getsockname(struct thread *td, struct linux_getsockname_args *args) { - struct getsockname_args /* { - int fdes; - struct sockaddr * __restrict asa; - socklen_t * __restrict alen; - } */ bsd_args; - int error; + struct l_sockaddr *lsa; + struct sockaddr *sa; + int len, error; - bsd_args.fdes = args->s; - bsd_args.asa = (struct sockaddr * __restrict)PTRIN(args->addr); - bsd_args.alen = PTRIN(args->namelen); - error = sys_getsockname(td, &bsd_args); - bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa); + error = copyin(PTRIN(args->namelen), &len, sizeof(len)); if (error != 0) return (error); - return (linux_sa_put(PTRIN(args->addr))); + + error = kern_getsockname(td, args->s, &sa, &len); + if (error != 0) + return (error); + + if (len != 0) { + error = bsd_to_linux_sockaddr(sa, &lsa, len); + if (error == 0) + error = copyout(lsa, PTRIN(args->addr), + len); + free(lsa, M_SONAME); + } + + free(sa, M_SONAME); + if (error == 0) + error = copyout(&len, PTRIN(args->namelen), sizeof(len)); + return (error); } int linux_getpeername(struct thread *td, struct linux_getpeername_args *args) { - struct getpeername_args /* { - int fdes; - caddr_t asa; - int *alen; - } */ bsd_args; - int error; + struct l_sockaddr *lsa; + struct sockaddr *sa; + int len, error; - bsd_args.fdes = args->s; - bsd_args.asa = (struct sockaddr *)PTRIN(args->addr); - bsd_args.alen = (socklen_t *)PTRIN(args->namelen); - error = sys_getpeername(td, &bsd_args); - bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa); + error = copyin(PTRIN(args->namelen), &len, sizeof(len)); if (error != 0) return (error); - return (linux_sa_put(PTRIN(args->addr))); + + error = kern_getpeername(td, args->s, &sa, &len); + if (error != 0) + return (error); + + if (len != 0) { + error = bsd_to_linux_sockaddr(sa, &lsa, len); + if (error == 0) + error = copyout(lsa, PTRIN(args->addr), + len); + free(lsa, M_SONAME); + } + + free(sa, M_SONAME); + if (error == 0) + error = copyout(&len, PTRIN(args->namelen), sizeof(len)); + return (error); } int @@ -1036,6 +860,8 @@ linux_sendto(struct thread *td, struct linux_sendto_ar int linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) { + struct l_sockaddr *lsa; + struct sockaddr *sa; struct msghdr msg; struct iovec aiov; int error, fromlen; @@ -1047,11 +873,14 @@ linux_recvfrom(struct thread *td, struct linux_recvfro return (error); if (fromlen < 0) return (EINVAL); - msg.msg_namelen = fromlen; - } else - msg.msg_namelen = 0; + sa = malloc(fromlen, M_SONAME, M_WAITOK); + } else { + fromlen = 0; + sa = NULL; + } - msg.msg_name = (struct sockaddr * __restrict)PTRIN(args->from); + msg.msg_name = sa; + msg.msg_namelen = fromlen; msg.msg_iov = &aiov; msg.msg_iovlen = 1; aiov.iov_base = PTRIN(args->buf); @@ -1059,24 +888,23 @@ linux_recvfrom(struct thread *td, struct linux_recvfro msg.msg_control = 0; msg.msg_flags = linux_to_bsd_msg_flags(args->flags); - error = kern_recvit(td, args->s, &msg, UIO_USERSPACE, NULL); + error = kern_recvit(td, args->s, &msg, UIO_SYSSPACE, NULL); if (error != 0) return (error); if (PTRIN(args->from) != NULL) { - error = bsd_to_linux_sockaddr((struct sockaddr *) - PTRIN(args->from)); - if (error != 0) - return (error); - - error = linux_sa_put((struct osockaddr *) - PTRIN(args->from)); + error = bsd_to_linux_sockaddr(sa, &lsa, msg.msg_namelen); + if (error == 0) + error = copyout(lsa, PTRIN(args->from), + msg.msg_namelen); + free(lsa, M_SONAME); } - if (PTRIN(args->fromlen) != NULL) + if (error == 0 && PTRIN(args->fromlen) != NULL) error = copyout(&msg.msg_namelen, PTRIN(args->fromlen), sizeof(msg.msg_namelen)); + free(sa, M_SONAME); return (error); } @@ -1282,6 +1110,8 @@ linux_recvmsg_common(struct thread *td, l_int s, struc struct mbuf *control = NULL; struct mbuf **controlp; struct timeval *ftmvl; + struct l_sockaddr *lsa; + struct sockaddr *sa; l_timeval ltmvl; caddr_t outbuf; void *data; @@ -1305,36 +1135,34 @@ linux_recvmsg_common(struct thread *td, l_int s, struc return (error); if (msg->msg_name) { - error = linux_to_bsd_sockaddr((struct sockaddr *)msg->msg_name, - msg->msg_namelen); - if (error != 0) - goto bad; + sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK); + msg->msg_name = sa; } uiov = msg->msg_iov; msg->msg_iov = iov; controlp = (msg->msg_control != NULL) ? &control : NULL; - error = kern_recvit(td, s, msg, UIO_USERSPACE, controlp); + error = kern_recvit(td, s, msg, UIO_SYSSPACE, controlp); msg->msg_iov = uiov; if (error != 0) goto bad; - error = bsd_to_linux_msghdr(msg, &linux_msg); - if (error != 0) - goto bad; - - if (linux_msg.msg_name) { - error = bsd_to_linux_sockaddr((struct sockaddr *) - PTRIN(linux_msg.msg_name)); + if (sa) { + msg->msg_name = PTRIN(linux_msg.msg_name); + error = bsd_to_linux_sockaddr(sa, &lsa, msg->msg_namelen); + if (error == 0) + error = copyout(lsa, PTRIN(msg->msg_name), + msg->msg_namelen); + free(lsa, M_SONAME); + free(sa, M_SONAME); if (error != 0) goto bad; } - if (linux_msg.msg_name && linux_msg.msg_namelen > 2) { - error = linux_sa_put(PTRIN(linux_msg.msg_name)); - if (error != 0) - goto bad; - } + error = bsd_to_linux_msghdr(msg, &linux_msg); + if (error != 0) + goto bad; + maxlen = linux_msg.msg_controllen; linux_msg.msg_controllen = 0; if (control) { @@ -1537,7 +1365,9 @@ linux_setsockopt(struct thread *td, struct linux_setso int valsize; } */ bsd_args; l_timeval linux_tv; + struct sockaddr *sa; struct timeval tv; + socklen_t len; int error, name; bsd_args.s = args->s; @@ -1578,18 +1408,23 @@ linux_setsockopt(struct thread *td, struct linux_setso if (name == -1) return (ENOPROTOOPT); - bsd_args.name = name; - bsd_args.val = PTRIN(args->optval); - bsd_args.valsize = args->optlen; if (name == IPV6_NEXTHOP) { - linux_to_bsd_sockaddr(__DECONST(struct sockaddr *, - bsd_args.val), bsd_args.valsize); + + len = args->optlen; + error = linux_to_bsd_sockaddr(PTRIN(args->optval), &sa, &len); + if (error != 0) + return (error); + + error = kern_setsockopt(td, args->s, bsd_args.level, + name, sa, UIO_SYSSPACE, len); + free(sa, M_SONAME); + } else { + bsd_args.name = name; + bsd_args.val = PTRIN(args->optval); + bsd_args.valsize = args->optlen; error = sys_setsockopt(td, &bsd_args); - bsd_to_linux_sockaddr(__DECONST(struct sockaddr *, - bsd_args.val)); - } else - error = sys_setsockopt(td, &bsd_args); + } return (error); } @@ -1607,6 +1442,8 @@ linux_getsockopt(struct thread *td, struct linux_getso l_timeval linux_tv; struct timeval tv; socklen_t tv_len, xulen, len; + struct l_sockaddr *lsa; + struct sockaddr *sa; struct xucred xu; struct l_ucred lxu; int error, name, newval; @@ -1681,14 +1518,32 @@ linux_getsockopt(struct thread *td, struct linux_getso return (EINVAL); bsd_args.name = name; - bsd_args.val = PTRIN(args->optval); bsd_args.avalsize = PTRIN(args->optlen); if (name == IPV6_NEXTHOP) { + error = copyin(PTRIN(args->optlen), &len, sizeof(len)); + if (error != 0) + return (error); + sa = malloc(len, M_SONAME, M_WAITOK); + + error = kern_getsockopt(td, args->s, bsd_args.level, + name, sa, UIO_SYSSPACE, &len); + if (error != 0) + goto out; + + error = bsd_to_linux_sockaddr(sa, &lsa, len); + if (error == 0) + error = copyout(lsa, PTRIN(args->optval), len); + free(lsa, M_SONAME); + if (error == 0) + error = copyout(&len, PTRIN(args->optlen), + sizeof(len)); +out: + free(sa, M_SONAME); + } else { + bsd_args.val = PTRIN(args->optval); error = sys_getsockopt(td, &bsd_args); - bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.val); - } else - error = sys_getsockopt(td, &bsd_args); + } return (error); } Modified: head/sys/compat/linux/linux_socket.h ============================================================================== --- head/sys/compat/linux/linux_socket.h Mon May 13 16:38:48 2019 (r347532) +++ head/sys/compat/linux/linux_socket.h Mon May 13 17:48:16 2019 (r347533) @@ -109,16 +109,6 @@ struct l_cmsghdr { #define CMSG_HDRSZ CMSG_LEN(0) #define L_CMSG_HDRSZ LINUX_CMSG_LEN(0) -/* Supported address families */ - -#define LINUX_AF_UNSPEC 0 -#define LINUX_AF_UNIX 1 -#define LINUX_AF_INET 2 -#define LINUX_AF_AX25 3 -#define LINUX_AF_IPX 4 -#define LINUX_AF_APPLETALK 5 -#define LINUX_AF_INET6 10 - /* Supported socket types */ #define LINUX_SOCK_STREAM 1 Modified: head/sys/modules/linux_common/Makefile ============================================================================== --- head/sys/modules/linux_common/Makefile Mon May 13 16:38:48 2019 (r347532) +++ head/sys/modules/linux_common/Makefile Mon May 13 17:48:16 2019 (r347533) @@ -5,7 +5,7 @@ KMOD= linux_common SRCS= linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \ linux_errno.c \ - linux.c device_if.h vnode_if.h bus_if.h + linux.c device_if.h vnode_if.h bus_if.h opt_inet6.h EXPORT_SYMS= EXPORT_SYMS+= linux_emul_path From owner-svn-src-all@freebsd.org Mon May 13 17:49:56 2019 Return-Path: Delivered-To: svn-src-all@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 A947E1596835; Mon, 13 May 2019 17:49:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 564478C94C; Mon, 13 May 2019 17:49:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2FCF4D3EB; Mon, 13 May 2019 17:49:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DHnu2k020575; Mon, 13 May 2019 17:49:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DHnt1M020569; Mon, 13 May 2019 17:49:55 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131749.x4DHnt1M020569@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 17:49:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347534 - in head: . lib/libcasper/services/cap_sysctl lib/libcasper/services/cap_sysctl/tests X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: . lib/libcasper/services/cap_sysctl lib/libcasper/services/cap_sysctl/tests X-SVN-Commit-Revision: 347534 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 564478C94C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:49:57 -0000 Author: markj Date: Mon May 13 17:49:54 2019 New Revision: 347534 URL: https://svnweb.freebsd.org/changeset/base/347534 Log: Add cap_sysctl(3) and cap_sysctlnametomib(3). These complement cap_sysctlbyname(3) to provide a drop-in replacement for the corresponding libc functions. Also revise the libcap_sysctl limit interface to provide access to sysctls by MIB, and to avoid direct manipulation of nvlists by the caller. Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17854 Modified: head/ObsoleteFiles.inc head/lib/libcasper/services/cap_sysctl/Makefile head/lib/libcasper/services/cap_sysctl/cap_sysctl.3 head/lib/libcasper/services/cap_sysctl/cap_sysctl.c head/lib/libcasper/services/cap_sysctl/cap_sysctl.h head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Mon May 13 17:48:16 2019 (r347533) +++ head/ObsoleteFiles.inc Mon May 13 17:49:54 2019 (r347534) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20190513: libcap_sysctl interface change +OLD_FILES+=lib/casper/libcap_sysctl.1 # 20190509: tests/sys/opencrypto requires the net/py-dpkt package. OLD_FILES+=usr/tests/sys/opencrypto/dpkt.py OLD_FILES+=usr/tests/sys/opencrypto/dpkt.pyc Modified: head/lib/libcasper/services/cap_sysctl/Makefile ============================================================================== --- head/lib/libcasper/services/cap_sysctl/Makefile Mon May 13 17:48:16 2019 (r347533) +++ head/lib/libcasper/services/cap_sysctl/Makefile Mon May 13 17:49:54 2019 (r347534) @@ -6,7 +6,7 @@ SHLIBDIR?= /lib/casper PACKAGE=libcasper -SHLIB_MAJOR= 1 +SHLIB_MAJOR= 2 INCSDIR?= ${INCLUDEDIR}/casper .if ${MK_CASPER} != "no" @@ -25,8 +25,12 @@ HAS_TESTS= SUBDIR.${MK_TESTS}+= tests MAN+= cap_sysctl.3 - -MLINKS+=cap_sysctl.3 libcap_sysctl.3 -MLINKS+=cap_sysctl.3 cap_sysctlbyname.3 +MLINKS+=cap_sysctl.3 libcap_sysctl.3 \ + cap_sysctl.3 cap_sysctlbyname.3 \ + cap_sysctl.3 cap_nametomib.3 \ + cap_sysctl.3 cap_sysctl_limit_init.3 \ + cap_sysctl.3 cap_sysctl_limit_mib.3 \ + cap_sysctl.3 cap_sysctl_limit_name.3 \ + cap_sysctl.3 cap_sysctl_limit.3 .include Modified: head/lib/libcasper/services/cap_sysctl/cap_sysctl.3 ============================================================================== --- head/lib/libcasper/services/cap_sysctl/cap_sysctl.3 Mon May 13 17:48:16 2019 (r347533) +++ head/lib/libcasper/services/cap_sysctl/cap_sysctl.3 Mon May 13 17:49:54 2019 (r347534) @@ -24,72 +24,113 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2018 +.Dd May 13, 2019 .Dt CAP_SYSCTL 3 .Os .Sh NAME -.Nm cap_sysctlbyname +.Nm cap_sysctl .Nd "library for getting or setting system information in capability mode" .Sh LIBRARY .Lb libcap_sysctl .Sh SYNOPSIS -.In sys/nv.h .In libcasper.h .In casper/cap_sysctl.h .Ft int -.Fn cap_sysctlbyname "cap_channel_t *chan" " const char *name" " void *oldp" " size_t *oldlenp" " const void *newp" " size_t newlen" +.Fn cap_sysctl "cap_channel_t *chan" "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" +.Ft int +.Fn cap_sysctlbyname "cap_channel_t *chan" "const char *name" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" +.Ft int +.Fn cap_sysctlnametomib "cap_channel_t *chan" "const char *name" "int *mibp" "size_t *sizep" +.Ft void * +.Fn cap_sysctl_limit_init "cap_channel_t *chan" +.Ft void * +.Fn cap_sysctl_limit_name "void *limit" "const char *name" "int flags" +.Ft void * +.Fn cap_sysctl_limit_mib "void *limit" "int *mibp" "u_int miblen" "int flags" +.Ft int +.Fn cap_sysctl_limit "void *limit" .Sh DESCRIPTION -The function +The +.Fn cap_sysctl , .Fn cap_sysctlbyname -is equivalent to +and +.Fn cap_sysctlnametomib +functions are equivalent to +.Xr sysctl 3 , .Xr sysctlbyname 3 -except that the connection to the -.Nm system.sysctl -service needs to be provided. +and +.Xr sysctlnametomib 3 , +except that they are implemented by the +.Ql system.sysctl +.Xr libcasper 3 +service and require a corresponding +.Xr libcasper 3 +capability. .Sh LIMITS -The service can be limited using -.Xr cap_limit_set 3 -function. +By default, the +.Nm +capability provides unrestricted access to the sysctl namespace. +Applications typically only require access to a small number of sysctl +variables; the +.Fn cap_sysctl_limit +interface can be used to restrict the sysctls that can be accessed using +the +.Nm +capability. +.Fn cap_sysctl_limit_init +returns an opaque limit handle used to store a list of permitted sysctls +and access rights. +Rights are encoded using the following flags: +.Pp +.Bd -literal -offset indent -compact +CAP_SYSCTL_READ allow reads of the sysctl variable +CAP_SYSCTL_WRITE allow writes of the sysctl variable +CAP_SYSCTL_RDWR allow reads and writes of the sysctl variable +CAP_RECURSIVE permit access to any child of the sysctl variable +.Ed +.Pp The -.Xr nvlist 9 -for that function can contain the following values and types: -.Bl -ohang -offset indent -.It ( NV_TYPE_NUMBER ) -The name of the element with type number will be treated as the limited sysctl. -The value of the element will describe the access rights for given sysctl. -There are four different rights +.Fn cap_sysctl_limit_name +function adds the sysctl identified by +.Ar name +to the limit list, and +.Fn cap_sysctl_limit_mib +function adds the sysctl identified by +.Ar mibp +to the limit list. +The access rights for the sysctl are specified in the +.Ar flags +parameter; at least one of .Dv CAP_SYSCTL_READ , -.Dv CAP_SYSCTL_WRITE , -.Dv CAP_SYSCTL_RDWR , +.Dv CAP_SYSCTL_WRITE and -.Dv CAP_SYSCTL_RECURSIVE . -The -.Dv CAP_SYSCTL_READ -flag allows to fetch the value of a given sysctl. -The -.Dv CAP_SYSCTL_WIRTE -flag allows to override the value of a given sysctl. -The .Dv CAP_SYSCTL_RDWR -is combination of the -.Dv CAP_SYSCTL_WIRTE -and -.Dv CAP_SYSCTL_READ -and allows to read and write the value of a given sysctl. -The -.Dv CAP_SYSCTL_RECURSIVE -allows access to all children of a given sysctl. -This right must be combined with at least one other right. +must be specified. +.Fn cap_sysctl_limit +applies a set of sysctl limits to the capability, denying access to sysctl +variables not belonging to the set. +.Pp +Once a set of limits is applied, subsequent calls to +.Fn cap_sysctl_limit +will fail unless the new set is a subset of the current set. +.Pp +.Fn cap_sysctlnametomib +will succeed so long as the named sysctl variable is present in the limit set, +regardless of its access rights. +When a sysctl variable name is added to a limit set, its MIB identifier is +automatically added to the set. .Sh EXAMPLES -The following example first opens a capability to casper and then uses this +The following example first opens a capability to casper, uses this capability to create the .Nm system.sysctl -casper service and uses it to get the value of +casper service, and then uses the +.Nm +capability to get the value of .Dv kern.trap_enotcap . .Bd -literal cap_channel_t *capcas, *capsysctl; const char *name = "kern.trap_enotcap"; -nvlist_t *limits; +void *limit; int value; size_t size; @@ -111,11 +152,11 @@ if (capsysctl == NULL) cap_close(capcas); /* Create limit for one MIB with read access only. */ -limits = nvlist_create(0); -nvlist_add_number(limits, name, CAP_SYSCTL_READ); +limit = cap_sysctl_limit_init(capsysctl); +(void)cap_sysctl_limit_name(limit, name, CAP_SYSCTL_READ); /* Limit system.sysctl. */ -if (cap_limit_set(capsysctl, limits) < 0) +if (cap_sysctl_limit(limit) < 0) err(1, "Unable to set limits"); /* Fetch value. */ @@ -129,7 +170,9 @@ cap_close(capsysctl); .Sh SEE ALSO .Xr cap_enter 2 , .Xr err 3 , +.Xr sysctl 3 , .Xr sysctlbyname 3 , +.Xr sysctlnametomib 3 , .Xr capsicum 4 , .Xr nv 9 .Sh AUTHORS Modified: head/lib/libcasper/services/cap_sysctl/cap_sysctl.c ============================================================================== --- head/lib/libcasper/services/cap_sysctl/cap_sysctl.c Mon May 13 17:48:16 2019 (r347533) +++ head/lib/libcasper/services/cap_sysctl/cap_sysctl.c Mon May 13 17:49:54 2019 (r347534) @@ -1,12 +1,15 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2013 The FreeBSD Foundation + * Copyright (c) 2013, 2018 The FreeBSD Foundation * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from * the FreeBSD Foundation. * + * Portions of this software were developed by Mark Johnston + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -32,9 +35,11 @@ #include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include +#include #include +#include #include #include @@ -46,24 +51,117 @@ __FBSDID("$FreeBSD$"); #include "cap_sysctl.h" +/* + * Limit interface. + */ + +struct cap_sysctl_limit { + cap_channel_t *chan; + nvlist_t *nv; +}; + +cap_sysctl_limit_t * +cap_sysctl_limit_init(cap_channel_t *chan) +{ + cap_sysctl_limit_t *limit; + int error; + + limit = malloc(sizeof(*limit)); + if (limit != NULL) { + limit->chan = chan; + limit->nv = nvlist_create(NV_FLAG_NO_UNIQUE); + if (limit->nv == NULL) { + error = errno; + free(limit); + limit = NULL; + errno = error; + } + } + return (limit); +} + +cap_sysctl_limit_t * +cap_sysctl_limit_name(cap_sysctl_limit_t *limit, const char *name, int flags) +{ + nvlist_t *lnv; + size_t mibsz; + int error, mib[CTL_MAXNAME]; + + lnv = nvlist_create(0); + if (lnv == NULL) { + error = errno; + if (limit->nv != NULL) + nvlist_destroy(limit->nv); + free(limit); + errno = error; + return (NULL); + } + nvlist_add_string(lnv, "name", name); + nvlist_add_number(lnv, "operation", flags); + + mibsz = nitems(mib); + error = cap_sysctlnametomib(limit->chan, name, mib, &mibsz); + if (error == 0) + nvlist_add_binary(lnv, "mib", mib, mibsz * sizeof(int)); + + nvlist_move_nvlist(limit->nv, "limit", lnv); + return (limit); +} + +cap_sysctl_limit_t * +cap_sysctl_limit_mib(cap_sysctl_limit_t *limit, int *mibp, u_int miblen, + int flags) +{ + nvlist_t *lnv; + int error; + + lnv = nvlist_create(0); + if (lnv == NULL) { + error = errno; + if (limit->nv != NULL) + nvlist_destroy(limit->nv); + free(limit); + errno = error; + return (NULL); + } + nvlist_add_binary(lnv, "mib", mibp, miblen * sizeof(int)); + nvlist_add_number(lnv, "operation", flags); + nvlist_add_nvlist(limit->nv, "limit", lnv); + return (limit); +} + int -cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp, - size_t *oldlenp, const void *newp, size_t newlen) +cap_sysctl_limit(cap_sysctl_limit_t *limit) { - nvlist_t *nvl; + cap_channel_t *chan; + nvlist_t *lnv; + + chan = limit->chan; + lnv = limit->nv; + free(limit); + + /* cap_limit_set(3) will always free the nvlist. */ + return (cap_limit_set(chan, lnv)); +} + +/* + * Service interface. + */ + +static int +do_sysctl(cap_channel_t *chan, nvlist_t *nvl, void *oldp, size_t *oldlenp, + const void *newp, size_t newlen) +{ const uint8_t *retoldp; - uint8_t operation; size_t oldlen; + int error; + uint8_t operation; operation = 0; - if (oldp != NULL) + if (oldlenp != NULL) operation |= CAP_SYSCTL_READ; if (newp != NULL) operation |= CAP_SYSCTL_WRITE; - - nvl = nvlist_create(0); - nvlist_add_string(nvl, "cmd", "sysctl"); - nvlist_add_string(nvl, "name", name); nvlist_add_number(nvl, "operation", (uint64_t)operation); if (oldp == NULL && oldlenp != NULL) nvlist_add_null(nvl, "justsize"); @@ -71,12 +169,14 @@ cap_sysctlbyname(cap_channel_t *chan, const char *name nvlist_add_number(nvl, "oldlen", (uint64_t)*oldlenp); if (newp != NULL) nvlist_add_binary(nvl, "newp", newp, newlen); + nvl = cap_xfer_nvlist(chan, nvl); if (nvl == NULL) return (-1); - if (nvlist_get_number(nvl, "error") != 0) { - errno = (int)nvlist_get_number(nvl, "error"); + error = (int)dnvlist_get_number(nvl, "error", 0); + if (error != 0) { nvlist_destroy(nvl); + errno = error; return (-1); } @@ -88,21 +188,87 @@ cap_sysctlbyname(cap_channel_t *chan, const char *name if (oldlenp != NULL) *oldlenp = oldlen; } + nvlist_destroy(nvl); return (0); } +int +cap_sysctl(cap_channel_t *chan, const int *name, u_int namelen, void *oldp, + size_t *oldlenp, const void *newp, size_t newlen) +{ + nvlist_t *req; + + req = nvlist_create(0); + nvlist_add_string(req, "cmd", "sysctl"); + nvlist_add_binary(req, "mib", name, (size_t)namelen * sizeof(int)); + return (do_sysctl(chan, req, oldp, oldlenp, newp, newlen)); +} + +int +cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp, + size_t *oldlenp, const void *newp, size_t newlen) +{ + nvlist_t *req; + + req = nvlist_create(0); + nvlist_add_string(req, "cmd", "sysctlbyname"); + nvlist_add_string(req, "name", name); + return (do_sysctl(chan, req, oldp, oldlenp, newp, newlen)); +} + +int +cap_sysctlnametomib(cap_channel_t *chan, const char *name, int *mibp, + size_t *sizep) +{ + nvlist_t *req; + const void *mib; + size_t mibsz; + int error; + + req = nvlist_create(0); + nvlist_add_string(req, "cmd", "sysctlnametomib"); + nvlist_add_string(req, "name", name); + nvlist_add_number(req, "operation", 0); + nvlist_add_number(req, "size", (uint64_t)*sizep); + + req = cap_xfer_nvlist(chan, req); + if (req == NULL) + return (-1); + error = (int)dnvlist_get_number(req, "error", 0); + if (error != 0) { + nvlist_destroy(req); + errno = error; + return (-1); + } + + mib = nvlist_get_binary(req, "mib", &mibsz); + *sizep = mibsz / sizeof(int); + + memcpy(mibp, mib, mibsz); + + nvlist_destroy(req); + + return (0); +} + /* - * Service functions. + * Service implementation. */ + +/* + * Validate a sysctl description. This must consist of an nvlist with either a + * binary "mib" field or a string "name", and an operation. + */ static int -sysctl_check_one(const nvlist_t *nvl, bool islimit) +sysctl_valid(const nvlist_t *nvl, bool limit) { const char *name; void *cookie; int type; - unsigned int fields; + size_t size; + unsigned int field, fields; /* NULL nvl is of course invalid. */ if (nvl == NULL) @@ -111,84 +277,120 @@ sysctl_check_one(const nvlist_t *nvl, bool islimit) return (nvlist_error(nvl)); #define HAS_NAME 0x01 -#define HAS_OPERATION 0x02 +#define HAS_MIB 0x02 +#define HAS_ID (HAS_NAME | HAS_MIB) +#define HAS_OPERATION 0x04 fields = 0; cookie = NULL; while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) { - /* We accept only one 'name' and one 'operation' in nvl. */ - if (strcmp(name, "name") == 0) { - if (type != NV_TYPE_STRING) + if ((strcmp(name, "name") == 0 && type == NV_TYPE_STRING) || + (strcmp(name, "mib") == 0 && type == NV_TYPE_BINARY)) { + if (strcmp(name, "mib") == 0) { + /* A MIB must be an array of integers. */ + (void)cnvlist_get_binary(cookie, &size); + if (size % sizeof(int) != 0) + return (EINVAL); + field = HAS_MIB; + } else + field = HAS_NAME; + + /* + * A limit may contain both a name and a MIB identifier. + */ + if ((fields & field) != 0 || + (!limit && (fields & HAS_ID) != 0)) return (EINVAL); - /* Only one 'name' can be present. */ - if ((fields & HAS_NAME) != 0) - return (EINVAL); - fields |= HAS_NAME; + fields |= field; } else if (strcmp(name, "operation") == 0) { - uint64_t operation; + uint64_t mask, operation; if (type != NV_TYPE_NUMBER) return (EINVAL); + + operation = cnvlist_get_number(cookie); + /* - * We accept only CAP_SYSCTL_READ and - * CAP_SYSCTL_WRITE flags. + * Requests can only include the RDWR flags; limits may + * also include the RECURSIVE flag. */ - operation = nvlist_get_number(nvl, name); - if ((operation & ~(CAP_SYSCTL_RDWR)) != 0) + mask = limit ? (CAP_SYSCTL_RDWR | + CAP_SYSCTL_RECURSIVE) : CAP_SYSCTL_RDWR; + if ((operation & ~limit) != 0 || + (operation & CAP_SYSCTL_RDWR) == 0) return (EINVAL); - /* ...but there has to be at least one of them. */ - if ((operation & (CAP_SYSCTL_RDWR)) == 0) - return (EINVAL); /* Only one 'operation' can be present. */ if ((fields & HAS_OPERATION) != 0) return (EINVAL); fields |= HAS_OPERATION; - } else if (islimit) { - /* If this is limit, there can be no other fields. */ + } else if (limit) return (EINVAL); - } } - /* Both fields has to be there. */ - if (fields != (HAS_NAME | HAS_OPERATION)) + if ((fields & HAS_OPERATION) == 0 || (fields & HAS_ID) == 0) return (EINVAL); -#undef HAS_OPERATION -#undef HAS_NAME +#undef HAS_OPERATION +#undef HAS_ID +#undef HAS_MIB +#undef HAS_NAME return (0); } static bool -sysctl_allowed(const nvlist_t *limits, const char *chname, uint64_t choperation) +sysctl_allowed(const nvlist_t *limits, const nvlist_t *req) { - uint64_t operation; - const char *name; + const nvlist_t *limit; + uint64_t op, reqop; + const char *lname, *name, *reqname; void *cookie; + size_t lsize, reqsize; + const int *lmib, *reqmib; int type; if (limits == NULL) return (true); + reqmib = dnvlist_get_binary(req, "mib", &reqsize, NULL, 0); + reqname = dnvlist_get_string(req, "name", NULL); + reqop = nvlist_get_number(req, "operation"); + cookie = NULL; while ((name = nvlist_next(limits, &type, &cookie)) != NULL) { - assert(type == NV_TYPE_NUMBER); + assert(type == NV_TYPE_NVLIST); - operation = nvlist_get_number(limits, name); - if ((operation & choperation) != choperation) + limit = cnvlist_get_nvlist(cookie); + op = nvlist_get_number(limit, "operation"); + if ((reqop & op) != reqop) continue; - if ((operation & CAP_SYSCTL_RECURSIVE) == 0) { - if (strcmp(name, chname) != 0) + if (reqname != NULL) { + lname = dnvlist_get_string(limit, "name", NULL); + if (lname == NULL) continue; - } else { - size_t namelen; + if ((op & CAP_SYSCTL_RECURSIVE) == 0) { + if (strcmp(lname, reqname) != 0) + continue; + } else { + size_t namelen; - namelen = strlen(name); - if (strncmp(name, chname, namelen) != 0) + namelen = strlen(lname); + if (strncmp(lname, reqname, namelen) != 0) + continue; + if (reqname[namelen] != '.' && + reqname[namelen] != '\0') + continue; + } + } else { + lmib = dnvlist_get_binary(limit, "mib", &lsize, NULL, 0); + if (lmib == NULL) continue; - if (chname[namelen] != '.' && chname[namelen] != '\0') + if (lsize > reqsize || ((op & CAP_SYSCTL_RECURSIVE) == 0 && + lsize < reqsize)) continue; + if (memcmp(lmib, reqmib, lsize) != 0) + continue; } return (true); @@ -200,21 +402,20 @@ sysctl_allowed(const nvlist_t *limits, const char *chn static int sysctl_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits) { + const nvlist_t *nvl; const char *name; void *cookie; - uint64_t operation; - int type; + int error, type; cookie = NULL; while ((name = nvlist_next(newlimits, &type, &cookie)) != NULL) { - if (type != NV_TYPE_NUMBER) + if (strcmp(name, "limit") != 0 || type != NV_TYPE_NVLIST) return (EINVAL); - operation = nvlist_get_number(newlimits, name); - if ((operation & ~(CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) != 0) - return (EINVAL); - if ((operation & (CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE)) == 0) - return (EINVAL); - if (!sysctl_allowed(oldlimits, name, operation)) + nvl = cnvlist_get_nvlist(cookie); + error = sysctl_valid(nvl, true); + if (error != 0) + return (error); + if (!sysctl_allowed(oldlimits, nvl)) return (ENOTCAPABLE); } @@ -222,28 +423,59 @@ sysctl_limit(const nvlist_t *oldlimits, const nvlist_t } static int +nametomib(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout) +{ + const char *name; + size_t size; + int error, *mibp; + + if (!sysctl_allowed(limits, nvlin)) + return (ENOTCAPABLE); + + name = nvlist_get_string(nvlin, "name"); + size = (size_t)nvlist_get_number(nvlin, "size"); + + mibp = malloc(size * sizeof(*mibp)); + if (mibp == NULL) + return (ENOMEM); + + error = sysctlnametomib(name, mibp, &size); + if (error != 0) { + error = errno; + free(mibp); + return (error); + } + + nvlist_add_binary(nvlout, "mib", mibp, size * sizeof(*mibp)); + + return (0); +} + +static int sysctl_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin, nvlist_t *nvlout) { const char *name; const void *newp; + const int *mibp; void *oldp; uint64_t operation; - size_t oldlen, newlen; + size_t oldlen, newlen, size; size_t *oldlenp; int error; - if (strcmp(cmd, "sysctl") != 0) + if (strcmp(cmd, "sysctlnametomib") == 0) + return (nametomib(limits, nvlin, nvlout)); + + if (strcmp(cmd, "sysctlbyname") != 0 && strcmp(cmd, "sysctl") != 0) return (EINVAL); - error = sysctl_check_one(nvlin, false); + error = sysctl_valid(nvlin, false); if (error != 0) return (error); - - name = nvlist_get_string(nvlin, "name"); - operation = nvlist_get_number(nvlin, "operation"); - if (!sysctl_allowed(limits, name, operation)) + if (!sysctl_allowed(limits, nvlin)) return (ENOTCAPABLE); + operation = nvlist_get_number(nvlin, "operation"); if ((operation & CAP_SYSCTL_WRITE) != 0) { if (!nvlist_exists_binary(nvlin, "newp")) return (EINVAL); @@ -276,7 +508,15 @@ sysctl_command(const char *cmd, const nvlist_t *limits oldlenp = NULL; } - if (sysctlbyname(name, oldp, oldlenp, newp, newlen) == -1) { + if (strcmp(cmd, "sysctlbyname") == 0) { + name = nvlist_get_string(nvlin, "name"); + error = sysctlbyname(name, oldp, oldlenp, newp, newlen); + } else { + mibp = nvlist_get_binary(nvlin, "mib", &size); + error = sysctl(mibp, size / sizeof(*mibp), oldp, oldlenp, newp, + newlen); + } + if (error != 0) { error = errno; free(oldp); return (error); Modified: head/lib/libcasper/services/cap_sysctl/cap_sysctl.h ============================================================================== --- head/lib/libcasper/services/cap_sysctl/cap_sysctl.h Mon May 13 17:48:16 2019 (r347533) +++ head/lib/libcasper/services/cap_sysctl/cap_sysctl.h Mon May 13 17:49:54 2019 (r347534) @@ -29,24 +29,47 @@ * $FreeBSD$ */ -#ifndef _CAP_SYSCTL_H_ +#ifndef _CAP_SYSCTL_H_ #define _CAP_SYSCTL_H_ #ifdef HAVE_CASPER -#define WITH_CASPER +#define WITH_CASPER #endif +#ifdef WITH_CASPER #define CAP_SYSCTL_READ 0x01 #define CAP_SYSCTL_WRITE 0x02 #define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE) #define CAP_SYSCTL_RECURSIVE 0x04 -#ifdef WITH_CASPER +int cap_sysctl(cap_channel_t *chan, const int *name, u_int namelen, void *oldp, + size_t *oldlenp, const void *newp, size_t newlen); int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); -#else -#define cap_sysctlbyname(chan, name, oldp, oldlenp, newp, newlen) \ - sysctlbyname(name, oldp, oldlenp, newp, newlen) -#endif +int cap_sysctlnametomib(cap_channel_t *chan, const char *name, int *mibp, + size_t *sizep); -#endif /* !_CAP_SYSCTL_H_ */ +struct cap_sysctl_limit; +typedef struct cap_sysctl_limit cap_sysctl_limit_t; + +cap_sysctl_limit_t *cap_sysctl_limit_init(cap_channel_t *); +cap_sysctl_limit_t *cap_sysctl_limit_name(cap_sysctl_limit_t *limit, + const char *name, int flags); +cap_sysctl_limit_t *cap_sysctl_limit_mib(cap_sysctl_limit_t *limit, int *mibp, + u_int miblen, int flags); +int cap_sysctl_limit(cap_sysctl_limit_t *limit); +#else /* !WITH_CASPER */ +#define cap_sysctl(chan, name, namelen, oldp, oldlenp, newp, newlen) \ + sysctl((name), (namelen), (oldp), (oldlenp), (newp), (newlen)) +#define cap_sysctlbyname(chan, name, oldp, oldlenp, newp, newlen) \ + sysctlbyname((name), (oldp), (oldlenp), (newp), (newlen)) +#define cap_sysctlnametomib(chan, name, mibp, sizep) \ + sysctlnametomib((name), (mibp), (sizep)) + +#define cap_sysctl_limit_init(chan) (NULL) +#define cap_sysctl_limit_name(limit, name, flags) (NULL) +#define cap_sysctl_limit_mib(limit, mibp, miblen, flags) (NULL) +#define cap_sysctl_limit(limit) (0) +#endif /* WITH_CASPER */ + +#endif /* !_CAP_SYSCTL_H_ */ Modified: head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:48:16 2019 (r347533) +++ head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:49:54 2019 (r347534) @@ -1,12 +1,15 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2013 The FreeBSD Foundation + * Copyright (c) 2013, 2018 The FreeBSD Foundation * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from * the FreeBSD Foundation. * + * Portions of this software were developed by Mark Johnston + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -185,7 +188,7 @@ static void test_operation(cap_channel_t *origcapsysctl) { cap_channel_t *capsysctl; - nvlist_t *limits; + void *limit; /* * Allow: @@ -196,61 +199,63 @@ test_operation(cap_channel_t *origcapsysctl) capsysctl = cap_clone(origcapsysctl); CHECK(capsysctl != NULL); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_PARENT, + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == 0); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, + CHECK(cap_sysctl_limit(limit) == 0); + + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_PARENT, + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, "foo.bar", + (void)cap_sysctl_limit_name(limit, "foo.bar", CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); - limits = nvlist_create(0); - nvlist_add_number(limits, "foo.bar", + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, "foo.bar", CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_NAME, + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_NAME, + (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == 0); + CHECK(cap_sysctl_limit(limit) == 0); CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_NAME, + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_NAME, + (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == 0); + CHECK(cap_sysctl_limit(limit) == 0); CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_NAME, CAP_SYSCTL_READ); - nvlist_add_number(limits, SYSCTL1_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_limit_set(capsysctl, limits) == 0); + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); + (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE); + CHECK(cap_sysctl_limit(limit) == 0); CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_NAME, CAP_SYSCTL_READ); - CHECK(cap_limit_set(capsysctl, limits) == 0); + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); + CHECK(cap_sysctl_limit(limit) == 0); CHECK(runtest(capsysctl) == SYSCTL0_READ0); @@ -265,29 +270,30 @@ test_operation(cap_channel_t *origcapsysctl) capsysctl = cap_clone(origcapsysctl); CHECK(capsysctl != NULL); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_NAME, + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_NAME, + (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == 0); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, + CHECK(cap_sysctl_limit(limit) == 0); + + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - nvlist_add_number(limits, SYSCTL1_PARENT, + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); - nvlist_add_number(limits, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, CAP_SYSCTL_READ); - nvlist_add_number(limits, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, CAP_SYSCTL_READ); - CHECK(cap_limit_set(capsysctl, limits) == -1 && errno == ENOTCAPABLE); + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); + CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | @@ -305,26 +311,26 @@ test_operation(cap_channel_t *origcapsysctl) capsysctl = cap_clone(origcapsysctl); CHECK(capsysctl != NULL); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); - nvlist_add_number(limits, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_limit_set(capsysctl, limits) == 0); - limits = nvlist_create(0); - nvlist_add_number(limits, SYSCTL0_PARENT, + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); + (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); + CHECK(cap_sysctl_limit(limit) == 0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon May 13 17:51:04 2019 Return-Path: Delivered-To: svn-src-all@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 69D861596921; Mon, 13 May 2019 17:51:04 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1BDCF8CB77; Mon, 13 May 2019 17:51:04 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA376D42E; Mon, 13 May 2019 17:51:03 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DHp3i6022586; Mon, 13 May 2019 17:51:03 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DHp3oA022584; Mon, 13 May 2019 17:51:03 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131751.x4DHp3oA022584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 17:51:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347535 - head/lib/libcasper/services/cap_sysctl/tests X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/lib/libcasper/services/cap_sysctl/tests X-SVN-Commit-Revision: 347535 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1BDCF8CB77 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:51:04 -0000 Author: markj Date: Mon May 13 17:51:03 2019 New Revision: 347535 URL: https://svnweb.freebsd.org/changeset/base/347535 Log: Convert the libcap_sysctl test cases to ATF. Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17855 Modified: head/lib/libcasper/services/cap_sysctl/tests/Makefile head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Modified: head/lib/libcasper/services/cap_sysctl/tests/Makefile ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/Makefile Mon May 13 17:49:54 2019 (r347534) +++ head/lib/libcasper/services/cap_sysctl/tests/Makefile Mon May 13 17:51:03 2019 (r347535) @@ -2,7 +2,7 @@ .include -TAP_TESTS_C= sysctl_test +ATF_TESTS_C= sysctl_test .if ${MK_CASPER} != "no" LIBADD+= casper Modified: head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:49:54 2019 (r347534) +++ head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:51:03 2019 (r347535) @@ -50,39 +50,21 @@ __FBSDID("$FreeBSD$"); #include #include - #include +#include + /* * We need some sysctls to perform the tests on. * We remember their values and restore them afer the test is done. */ #define SYSCTL0_PARENT "kern" #define SYSCTL0_NAME "kern.sync_on_panic" +#define SYSCTL0_FILE "./sysctl0" #define SYSCTL1_PARENT "debug" #define SYSCTL1_NAME "debug.minidump" +#define SYSCTL1_FILE "./sysctl1" -static int ntest = 1; - -#define CHECK(expr) do { \ - if ((expr)) \ - printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ - else \ - printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ - fflush(stdout); \ - ntest++; \ -} while (0) -#define CHECKX(expr) do { \ - if ((expr)) { \ - printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ - } else { \ - printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ - exit(1); \ - } \ - fflush(stdout); \ - ntest++; \ -} while (0) - #define SYSCTL0_READ0 0x0001 #define SYSCTL0_READ1 0x0002 #define SYSCTL0_READ2 0x0004 @@ -94,8 +76,77 @@ static int ntest = 1; #define SYSCTL1_WRITE 0x0100 #define SYSCTL1_READ_WRITE 0x0200 +static void +save_int_sysctl(const char *name, const char *file) +{ + ssize_t n; + size_t sz; + int error, fd, val; + + sz = sizeof(val); + error = sysctlbyname(name, &val, &sz, NULL, 0); + ATF_REQUIRE_MSG(error == 0, + "sysctlbyname(%s): %s", name, strerror(errno)); + + fd = open(file, O_CREAT | O_WRONLY, 0600); + ATF_REQUIRE_MSG(fd >= 0, "open(%s): %s", file, strerror(errno)); + n = write(fd, &val, sz); + ATF_REQUIRE(n >= 0 && (size_t)n == sz); + error = close(fd); + ATF_REQUIRE(error == 0); +} + +static void +restore_int_sysctl(const char *name, const char *file) +{ + ssize_t n; + size_t sz; + int error, fd, val; + + fd = open(file, O_RDONLY); + ATF_REQUIRE(fd >= 0); + sz = sizeof(val); + n = read(fd, &val, sz); + ATF_REQUIRE(n >= 0 && (size_t)n == sz); + error = unlink(file); + ATF_REQUIRE(error == 0); + error = close(fd); + ATF_REQUIRE(error == 0); + + error = sysctlbyname(name, NULL, NULL, &val, sz); + ATF_REQUIRE_MSG(error == 0, + "sysctlbyname(%s): %s", name, strerror(errno)); +} + +static cap_channel_t * +initcap(void) +{ + cap_channel_t *capcas, *capsysctl; + + save_int_sysctl(SYSCTL0_NAME, SYSCTL0_FILE); + save_int_sysctl(SYSCTL1_NAME, SYSCTL1_FILE); + + capcas = cap_init(); + ATF_REQUIRE(capcas != NULL); + + capsysctl = cap_service_open(capcas, "system.sysctl"); + ATF_REQUIRE(capsysctl != NULL); + + cap_close(capcas); + + return (capsysctl); +} + +static void +cleanup(void) +{ + + restore_int_sysctl(SYSCTL0_NAME, SYSCTL0_FILE); + restore_int_sysctl(SYSCTL1_NAME, SYSCTL1_FILE); +} + static unsigned int -runtest(cap_channel_t *capsysctl) +checkcaps(cap_channel_t *capsysctl) { unsigned int result; int oldvalue, newvalue; @@ -184,27 +235,32 @@ runtest(cap_channel_t *capsysctl) return (result); } -static void -test_operation(cap_channel_t *origcapsysctl) +ATF_TC_WITH_CLEANUP(cap_sysctl__operation); +ATF_TC_HEAD(cap_sysctl__operation, tc) { - cap_channel_t *capsysctl; +} +ATF_TC_BODY(cap_sysctl__operation, tc) +{ + cap_channel_t *capsysctl, *ocapsysctl; void *limit; + ocapsysctl = initcap(); + /* * Allow: * SYSCTL0_PARENT/RDWR/RECURSIVE * SYSCTL1_PARENT/RDWR/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, @@ -213,14 +269,14 @@ test_operation(cap_channel_t *origcapsysctl) CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, "foo.bar", CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, "foo.bar", CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); @@ -230,9 +286,9 @@ test_operation(cap_channel_t *origcapsysctl) CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); @@ -242,22 +298,22 @@ test_operation(cap_channel_t *origcapsysctl) CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_WRITE)); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); - CHECK(runtest(capsysctl) == SYSCTL0_READ0); + ATF_REQUIRE(checkcaps(capsysctl) == SYSCTL0_READ0); cap_close(capsysctl); @@ -267,35 +323,35 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/RDWR/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); @@ -308,31 +364,31 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/RDWR */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == 0); + ATF_REQUIRE(checkcaps(capsysctl) == 0); cap_close(capsysctl); @@ -342,31 +398,31 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/RDWR */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); @@ -379,34 +435,34 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/RDWR/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL1_READ0 | SYSCTL1_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); cap_close(capsysctl); @@ -417,30 +473,30 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/RDWR/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL0_READ1 | SYSCTL0_READ2 | SYSCTL0_WRITE | SYSCTL0_READ_WRITE | SYSCTL1_READ0 | SYSCTL1_READ1 | SYSCTL1_READ2 | SYSCTL1_WRITE | SYSCTL1_READ_WRITE)); @@ -453,51 +509,51 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/READ/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); cap_close(capsysctl); @@ -507,51 +563,51 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/READ/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); cap_close(capsysctl); @@ -561,59 +617,59 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/READ */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == 0); + ATF_REQUIRE(checkcaps(capsysctl) == 0); cap_close(capsysctl); @@ -623,59 +679,59 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/READ */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); cap_close(capsysctl); @@ -685,21 +741,21 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/READ/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == SYSCTL1_READ0); + ATF_REQUIRE(checkcaps(capsysctl) == SYSCTL1_READ0); cap_close(capsysctl); @@ -709,21 +765,21 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/READ/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_READ0 | SYSCTL1_READ0)); cap_close(capsysctl); @@ -733,51 +789,51 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/WRITE/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_WRITE | SYSCTL1_WRITE)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_WRITE | SYSCTL1_WRITE)); cap_close(capsysctl); @@ -787,51 +843,51 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/WRITE/RECURSIVE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == (SYSCTL0_WRITE | SYSCTL1_WRITE)); + ATF_REQUIRE(checkcaps(capsysctl) == (SYSCTL0_WRITE | SYSCTL1_WRITE)); cap_close(capsysctl); @@ -841,59 +897,59 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_PARENT/WRITE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL1_PARENT, CAP_SYSCTL_RDWR); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_PARENT, CAP_SYSCTL_READ); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); - CHECK(runtest(capsysctl) == 0); + ATF_REQUIRE(checkcaps(capsysctl) == 0); cap_close(capsysctl); @@ -903,59 +959,59 @@ test_operation(cap_channel_t *origcapsysctl) * SYSCTL1_NAME/WRITE */ - capsysctl = cap_clone(origcapsysctl); - CHECK(capsysctl != NULL); + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE); - CHECK(cap_sysctl_limit(limit) == 0); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_WRITE | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); (void)cap_sysctl_limit_name(limit, SYSCTL1_NAME, CAP_SYSCTL_READ | CAP_SYSCTL_RECURSIVE); - CHECK(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); + ATF_REQUIRE(cap_sysctl_limit(limit) == -1 && errno == ENOTCAPABLE); limit = cap_sysctl_limit_init(capsysctl); (void)cap_sysctl_limit_name(limit, SYSCTL0_NAME, CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon May 13 17:53:04 2019 Return-Path: Delivered-To: svn-src-all@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 A45E51596B2E; Mon, 13 May 2019 17:53:04 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48A1B8CF45; Mon, 13 May 2019 17:53:04 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 08BFAD5CB; Mon, 13 May 2019 17:53:04 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DHr3ab025689; Mon, 13 May 2019 17:53:03 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DHr3uR025688; Mon, 13 May 2019 17:53:03 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131753.x4DHr3uR025688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 17:53:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347536 - head/lib/libcasper/services/cap_sysctl/tests X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/lib/libcasper/services/cap_sysctl/tests X-SVN-Commit-Revision: 347536 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 48A1B8CF45 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 17:53:04 -0000 Author: markj Date: Mon May 13 17:53:03 2019 New Revision: 347536 URL: https://svnweb.freebsd.org/changeset/base/347536 Log: Extend the libcap_sysctl tests. - Add some coverage for cap_sysctl(3). - Add a test for the case where the caller wishes to find the sysctl output length without specifying an output buffer. Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17856 Modified: head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Modified: head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:51:03 2019 (r347535) +++ head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Mon May 13 17:53:03 2019 (r347536) @@ -149,17 +149,27 @@ static unsigned int checkcaps(cap_channel_t *capsysctl) { unsigned int result; - int oldvalue, newvalue; - size_t oldsize; + size_t len0, len1, oldsize; + int error, mib0[2], mib1[2], oldvalue, newvalue; result = 0; + len0 = nitems(mib0); + ATF_REQUIRE(sysctlnametomib(SYSCTL0_NAME, mib0, &len0) == 0); + len1 = nitems(mib1); + ATF_REQUIRE(sysctlnametomib(SYSCTL1_NAME, mib1, &len1) == 0); + oldsize = sizeof(oldvalue); if (cap_sysctlbyname(capsysctl, SYSCTL0_NAME, &oldvalue, &oldsize, NULL, 0) == 0) { if (oldsize == sizeof(oldvalue)) result |= SYSCTL0_READ0; } + error = cap_sysctl(capsysctl, mib0, len0, &oldvalue, &oldsize, NULL, 0); + if ((result & SYSCTL0_READ0) != 0) + ATF_REQUIRE(error == 0); + else + ATF_REQUIRE_ERRNO(ENOTCAPABLE, error != 0); newvalue = 123; if (cap_sysctlbyname(capsysctl, SYSCTL0_NAME, NULL, NULL, &newvalue, @@ -175,6 +185,13 @@ checkcaps(cap_channel_t *capsysctl) result |= SYSCTL0_READ1; } } + newvalue = 123; + error = cap_sysctl(capsysctl, mib0, len0, NULL, NULL, + &newvalue, sizeof(newvalue)); + if ((result & SYSCTL0_WRITE) != 0) + ATF_REQUIRE(error == 0); + else + ATF_REQUIRE_ERRNO(ENOTCAPABLE, error != 0); oldsize = sizeof(oldvalue); newvalue = 4567; @@ -199,6 +216,11 @@ checkcaps(cap_channel_t *capsysctl) if (oldsize == sizeof(oldvalue)) result |= SYSCTL1_READ0; } + error = cap_sysctl(capsysctl, mib1, len1, &oldvalue, &oldsize, NULL, 0); + if ((result & SYSCTL1_READ0) != 0) + ATF_REQUIRE(error == 0); + else + ATF_REQUIRE_ERRNO(ENOTCAPABLE, error != 0); newvalue = 506; if (cap_sysctlbyname(capsysctl, SYSCTL1_NAME, NULL, NULL, &newvalue, @@ -207,6 +229,10 @@ checkcaps(cap_channel_t *capsysctl) } if ((result & SYSCTL1_WRITE) != 0) { + newvalue = 506; + ATF_REQUIRE(cap_sysctl(capsysctl, mib1, len1, NULL, NULL, + &newvalue, sizeof(newvalue)) == 0); + oldsize = sizeof(oldvalue); if (cap_sysctlbyname(capsysctl, SYSCTL1_NAME, &oldvalue, &oldsize, NULL, 0) == 0) { @@ -214,6 +240,13 @@ checkcaps(cap_channel_t *capsysctl) result |= SYSCTL1_READ1; } } + newvalue = 506; + error = cap_sysctl(capsysctl, mib1, len1, NULL, NULL, + &newvalue, sizeof(newvalue)); + if ((result & SYSCTL1_WRITE) != 0) + ATF_REQUIRE(error == 0); + else + ATF_REQUIRE_ERRNO(ENOTCAPABLE, error != 0); oldsize = sizeof(oldvalue); newvalue = 7008; @@ -1563,11 +1596,98 @@ ATF_TC_CLEANUP(cap_sysctl__no_limits, tc) cleanup(); } +ATF_TC_WITH_CLEANUP(cap_sysctl__recursive_limits); +ATF_TC_HEAD(cap_sysctl__recursive_limits, tc) +{ +} +ATF_TC_BODY(cap_sysctl__recursive_limits, tc) +{ + cap_channel_t *capsysctl, *ocapsysctl; + void *limit; + size_t len; + int mib[2], val = 420; + + len = nitems(mib); + ATF_REQUIRE(sysctlnametomib(SYSCTL0_NAME, mib, &len) == 0); + + ocapsysctl = initcap(); + + /* + * Make sure that we match entire components. + */ + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); + + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, "ker", + CAP_SYSCTL_RDWR | CAP_SYSCTL_RECURSIVE); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); + + ATF_REQUIRE_ERRNO(ENOTCAPABLE, cap_sysctlbyname(capsysctl, SYSCTL0_NAME, + NULL, NULL, &val, sizeof(val))); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, cap_sysctl(capsysctl, mib, len, + NULL, NULL, &val, sizeof(val))); + + cap_close(capsysctl); + + /* + * Verify that we check for CAP_SYSCTL_RECURSIVE. + */ + capsysctl = cap_clone(ocapsysctl); + ATF_REQUIRE(capsysctl != NULL); + + limit = cap_sysctl_limit_init(capsysctl); + (void)cap_sysctl_limit_name(limit, "kern", CAP_SYSCTL_RDWR); + ATF_REQUIRE(cap_sysctl_limit(limit) == 0); + + ATF_REQUIRE_ERRNO(ENOTCAPABLE, cap_sysctlbyname(capsysctl, SYSCTL0_NAME, + NULL, NULL, &val, sizeof(val))); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, cap_sysctl(capsysctl, mib, len, + NULL, NULL, &val, sizeof(val))); + + cap_close(capsysctl); +} +ATF_TC_CLEANUP(cap_sysctl__recursive_limits, tc) +{ + cleanup(); +} + +ATF_TC_WITH_CLEANUP(cap_sysctl__just_size); +ATF_TC_HEAD(cap_sysctl__just_size, tc) +{ +} +ATF_TC_BODY(cap_sysctl__just_size, tc) +{ + cap_channel_t *capsysctl; + size_t len; + int mib0[2]; + + capsysctl = initcap(); + + len = nitems(mib0); + ATF_REQUIRE(sysctlnametomib(SYSCTL0_NAME, mib0, &len) == 0); + + ATF_REQUIRE(cap_sysctlbyname(capsysctl, SYSCTL0_NAME, + NULL, &len, NULL, 0) == 0); + ATF_REQUIRE(len == sizeof(int)); + ATF_REQUIRE(cap_sysctl(capsysctl, mib0, nitems(mib0), + NULL, &len, NULL, 0) == 0); + ATF_REQUIRE(len == sizeof(int)); + + cap_close(capsysctl); +} +ATF_TC_CLEANUP(cap_sysctl__just_size, tc) +{ + cleanup(); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, cap_sysctl__operation); ATF_TP_ADD_TC(tp, cap_sysctl__names); ATF_TP_ADD_TC(tp, cap_sysctl__no_limits); + ATF_TP_ADD_TC(tp, cap_sysctl__recursive_limits); + ATF_TP_ADD_TC(tp, cap_sysctl__just_size); return (atf_no_error()); } From owner-svn-src-all@freebsd.org Mon May 13 18:14:21 2019 Return-Path: Delivered-To: svn-src-all@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 24FFB15976AC; Mon, 13 May 2019 18:14:21 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BDFA38DA90; Mon, 13 May 2019 18:14:20 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8CDA6D91B; Mon, 13 May 2019 18:14:20 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DIEKSI036052; Mon, 13 May 2019 18:14:20 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DIEKLP036051; Mon, 13 May 2019 18:14:20 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131814.x4DIEKLP036051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 18:14:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347537 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 347537 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BDFA38DA90 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:14:21 -0000 Author: dchagin Date: Mon May 13 18:14:20 2019 New Revision: 347537 URL: https://svnweb.freebsd.org/changeset/base/347537 Log: Linuxulator getpeername() returns EINVAL in case then namelen less then 0. MFC after: 2 weeks Modified: head/sys/compat/linux/linux_socket.c Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Mon May 13 17:53:03 2019 (r347536) +++ head/sys/compat/linux/linux_socket.c Mon May 13 18:14:20 2019 (r347537) @@ -722,6 +722,8 @@ linux_getpeername(struct thread *td, struct linux_getp error = copyin(PTRIN(args->namelen), &len, sizeof(len)); if (error != 0) return (error); + if (len < 0) + return (EINVAL); error = kern_getpeername(td, args->s, &sa, &len); if (error != 0) From owner-svn-src-all@freebsd.org Mon May 13 18:24:32 2019 Return-Path: Delivered-To: svn-src-all@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 3016215979D6; Mon, 13 May 2019 18:24:32 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CED0C8DF9C; Mon, 13 May 2019 18:24:31 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A425DDAC8; Mon, 13 May 2019 18:24:31 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DIOVnK041670; Mon, 13 May 2019 18:24:31 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DIOTIS041656; Mon, 13 May 2019 18:24:29 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131824.x4DIOTIS041656@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 18:24:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347538 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux modules/linux modules/linux64 modules/linux_common X-SVN-Group: head X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux modules/linux modules/linux64 modules/linux_common X-SVN-Commit-Revision: 347538 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CED0C8DF9C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:24:32 -0000 Author: dchagin Date: Mon May 13 18:24:29 2019 New Revision: 347538 URL: https://svnweb.freebsd.org/changeset/base/347538 Log: Linuxulator depends on a fundamental kernel settings such as SMP. Many of them listed in opt_global.h which is not generated while building modules outside of a kernel and such modules never match real cofigured kernel. So, we should prevent our users from building obviously defective modules. Therefore, remove the root cause of the building of modules outside of a kernel - the possibility of building modules with DEBUG or KTR flags. And remove all of DEBUG printfs as it is incomplete and in threaded programms not informative, also a half of system call does not have DEBUG printf. For debuging Linux programms we have dtrace, ktr and ktrace ability. PR: 222861 Reviewed by: trasz MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20178 Modified: head/sys/amd64/linux/linux.h head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux.h head/sys/amd64/linux32/linux32_machdep.c head/sys/amd64/linux32/linux32_sysvec.c head/sys/arm64/linux/linux.h head/sys/arm64/linux/linux_sysvec.c head/sys/compat/linux/linux_file.c head/sys/compat/linux/linux_fork.c head/sys/compat/linux/linux_getcwd.c head/sys/compat/linux/linux_ioctl.c head/sys/compat/linux/linux_misc.c head/sys/compat/linux/linux_misc.h head/sys/compat/linux/linux_signal.c head/sys/compat/linux/linux_stats.c head/sys/i386/linux/linux.h head/sys/i386/linux/linux_machdep.c head/sys/i386/linux/linux_sysvec.c head/sys/modules/linux/Makefile head/sys/modules/linux64/Makefile head/sys/modules/linux_common/Makefile Modified: head/sys/amd64/linux/linux.h ============================================================================== --- head/sys/amd64/linux/linux.h Mon May 13 18:14:20 2019 (r347537) +++ head/sys/amd64/linux/linux.h Mon May 13 18:24:29 2019 (r347538) @@ -37,15 +37,6 @@ #define LINUX_LEGACY_SYSCALLS -/* - * debugging support - */ -extern u_char linux_debug_map[]; -#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid -#define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid #define LINUX_DTRACE linuxulator #define PTRIN(v) (void *)(v) Modified: head/sys/amd64/linux/linux_sysvec.c ============================================================================== --- head/sys/amd64/linux/linux_sysvec.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/amd64/linux/linux_sysvec.c Mon May 13 18:24:29 2019 (r347538) @@ -86,20 +86,6 @@ __FBSDID("$FreeBSD$"); MODULE_VERSION(linux64, 1); -#if defined(DEBUG) -SYSCTL_PROC(_compat_linux, OID_AUTO, debug, - CTLTYPE_STRING | CTLFLAG_RW, - 0, 0, linux_sysctl_debug, "A", - "Linux 64 debugging control"); -#endif - -/* - * Allow the sendsig functions to use the ldebug() facility even though they - * are not syscalls themselves. Map them to syscall 0. This is slightly less - * bogus than using ldebug(sigreturn). - */ -#define LINUX_SYS_linux_rt_sendsig 0 - const char *linux_kplatform; static int linux_szsigcode; static vm_object_t linux_shared_page_obj; @@ -645,9 +631,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigse /* Copy the sigframe out to the user's stack. */ if (copyout(&sf, sfp, sizeof(*sfp)) != 0) { -#ifdef DEBUG - printf("process %ld has trashed its stack\n", (long)p->p_pid); -#endif PROC_LOCK(p); sigexit(td, SIGILL); } Modified: head/sys/amd64/linux32/linux.h ============================================================================== --- head/sys/amd64/linux32/linux.h Mon May 13 18:14:20 2019 (r347537) +++ head/sys/amd64/linux32/linux.h Mon May 13 18:24:29 2019 (r347538) @@ -40,15 +40,6 @@ #define LINUX_LEGACY_SYSCALLS -/* - * debugging support - */ -extern u_char linux_debug_map[]; -#define ldebug(name) isclr(linux_debug_map, LINUX32_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid -#define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid #define LINUX_DTRACE linuxulator32 #define LINUX32_MAXUSER ((1ul << 32) - PAGE_SIZE) Modified: head/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- head/sys/amd64/linux32/linux32_machdep.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/amd64/linux32/linux32_machdep.c Mon May 13 18:24:29 2019 (r347538) @@ -133,11 +133,6 @@ linux_execve(struct thread *td, struct linux_execve_ar LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(execve)) - printf(ARGS(execve, "%s"), path); -#endif - error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp, args->envp); free(path, M_TEMP); @@ -382,11 +377,6 @@ linux_old_select(struct thread *td, struct linux_old_s struct linux_select_args newsel; int error; -#ifdef DEBUG - if (ldebug(old_select)) - printf(ARGS(old_select, "%p"), args->ptr); -#endif - error = copyin(args->ptr, &linux_args, sizeof(linux_args)); if (error) return (error); @@ -410,29 +400,19 @@ linux_set_cloned_tls(struct thread *td, void *desc) error = copyin(desc, &info, sizeof(struct l_user_desc)); if (error) { - printf(LMSG("copyin failed!")); + linux_msg(td, "set_cloned_tls copyin info failed!"); } else { + /* We might copy out the entry_number as GUGS32_SEL. */ info.entry_number = GUGS32_SEL; error = copyout(&info, desc, sizeof(struct l_user_desc)); if (error) - printf(LMSG("copyout failed!")); + linux_msg(td, "set_cloned_tls copyout info failed!"); a[0] = LINUX_LDT_entry_a(&info); a[1] = LINUX_LDT_entry_b(&info); memcpy(&sd, &a, sizeof(a)); -#ifdef DEBUG - if (ldebug(clone)) - printf("Segment created in clone with " - "CLONE_SETTLS: lobase: %x, hibase: %x, " - "lolimit: %x, hilimit: %x, type: %i, " - "dpl: %i, p: %i, xx: %i, long: %i, " - "def32: %i, gran: %i\n", sd.sd_lobase, - sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit, - sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx, - sd.sd_long, sd.sd_def32, sd.sd_gran); -#endif pcb = td->td_pcb; pcb->pcb_gsbase = (register_t)info.base_addr; td->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL); @@ -461,13 +441,6 @@ int linux_mmap2(struct thread *td, struct linux_mmap2_args *args) { -#ifdef DEBUG - if (ldebug(mmap2)) - printf(ARGS(mmap2, "0x%08x, %d, %d, 0x%08x, %d, %d"), - args->addr, args->len, args->prot, - args->flags, args->fd, args->pgoff); -#endif - return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot, args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff * PAGE_SIZE)); @@ -483,13 +456,6 @@ linux_mmap(struct thread *td, struct linux_mmap_args * if (error) return (error); -#ifdef DEBUG - if (ldebug(mmap)) - printf(ARGS(mmap, "0x%08x, %d, %d, 0x%08x, %d, %d"), - linux_args.addr, linux_args.len, linux_args.prot, - linux_args.flags, linux_args.fd, linux_args.pgoff); -#endif - return (linux_mmap_common(td, linux_args.addr, linux_args.len, linux_args.prot, linux_args.flags, linux_args.fd, (uint32_t)linux_args.pgoff)); @@ -526,12 +492,6 @@ linux_sigaction(struct thread *td, struct linux_sigact l_sigaction_t act, oact; int error; -#ifdef DEBUG - if (ldebug(sigaction)) - printf(ARGS(sigaction, "%d, %p, %p"), - args->sig, (void *)args->nsa, (void *)args->osa); -#endif - if (args->nsa != NULL) { error = copyin(args->nsa, &osa, sizeof(l_osigaction_t)); if (error) @@ -568,11 +528,6 @@ linux_sigsuspend(struct thread *td, struct linux_sigsu sigset_t sigmask; l_sigset_t mask; -#ifdef DEBUG - if (ldebug(sigsuspend)) - printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask); -#endif - LINUX_SIGEMPTYSET(mask); mask.__mask = args->mask; linux_to_bsd_sigset(&mask, &sigmask); @@ -586,12 +541,6 @@ linux_rt_sigsuspend(struct thread *td, struct linux_rt sigset_t sigmask; int error; -#ifdef DEBUG - if (ldebug(rt_sigsuspend)) - printf(ARGS(rt_sigsuspend, "%p, %d"), - (void *)uap->newset, uap->sigsetsize); -#endif - if (uap->sigsetsize != sizeof(l_sigset_t)) return (EINVAL); @@ -609,11 +558,6 @@ linux_pause(struct thread *td, struct linux_pause_args struct proc *p = td->td_proc; sigset_t sigmask; -#ifdef DEBUG - if (ldebug(pause)) - printf(ARGS(pause, "")); -#endif - PROC_LOCK(p); sigmask = td->td_sigmask; PROC_UNLOCK(p); @@ -627,11 +571,6 @@ linux_sigaltstack(struct thread *td, struct linux_siga l_stack_t lss; int error; -#ifdef DEBUG - if (ldebug(sigaltstack)) - printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss); -#endif - if (uap->uss != NULL) { error = copyin(uap->uss, &lss, sizeof(l_stack_t)); if (error) @@ -657,12 +596,6 @@ int linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args) { -#ifdef DEBUG - if (ldebug(ftruncate64)) - printf(ARGS(ftruncate64, "%u, %jd"), args->fd, - (intmax_t)args->length); -#endif - return (kern_ftruncate(td, args->fd, args->length)); } @@ -743,15 +676,6 @@ linux_set_thread_area(struct thread *td, if (error) return (error); -#ifdef DEBUG - if (ldebug(set_thread_area)) - printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, " - "%i, %i, %i"), info.entry_number, info.base_addr, - info.limit, info.seg_32bit, info.contents, - info.read_exec_only, info.limit_in_pages, - info.seg_not_present, info.useable); -#endif - /* * Semantics of Linux version: every thread in the system has array * of three TLS descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. @@ -805,25 +729,6 @@ linux_set_thread_area(struct thread *td, } memcpy(&sd, &a, sizeof(a)); -#ifdef DEBUG - if (ldebug(set_thread_area)) - printf("Segment created in set_thread_area: " - "lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, " - "type: %i, dpl: %i, p: %i, xx: %i, long: %i, " - "def32: %i, gran: %i\n", - sd.sd_lobase, - sd.sd_hibase, - sd.sd_lolimit, - sd.sd_hilimit, - sd.sd_type, - sd.sd_dpl, - sd.sd_p, - sd.sd_xx, - sd.sd_long, - sd.sd_def32, - sd.sd_gran); -#endif - pcb = td->td_pcb; pcb->pcb_gsbase = (register_t)info.base_addr; set_pcb_flags(pcb, PCB_32BIT); Modified: head/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysvec.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/amd64/linux32/linux32_sysvec.c Mon May 13 18:24:29 2019 (r347538) @@ -91,14 +91,6 @@ __FBSDID("$FreeBSD$"); MODULE_VERSION(linux, 1); -/* - * Allow the sendsig functions to use the ldebug() facility even though they - * are not syscalls themselves. Map them to syscall 0. This is slightly less - * bogus than using ldebug(sigreturn). - */ -#define LINUX32_SYS_linux_rt_sendsig 0 -#define LINUX32_SYS_linux_sendsig 0 - const char *linux_kplatform; static int linux_szsigcode; static vm_object_t linux_shared_page_obj; @@ -286,11 +278,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigse regs = td->td_frame; oonstack = sigonstack(regs->tf_rsp); -#ifdef DEBUG - if (ldebug(rt_sendsig)) - printf(ARGS(rt_sendsig, "%p, %d, %p, %u"), - catcher, sig, (void*)mask, code); -#endif /* Allocate space for the signal handler context. */ if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && SIGISMEMBER(psp->ps_sigonstack, sig)) { @@ -349,23 +336,11 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigse frame.sf_sc.uc_mcontext.sc_cr2 = (u_int32_t)(uintptr_t)ksi->ksi_addr; frame.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code); -#ifdef DEBUG - if (ldebug(rt_sendsig)) - printf(LMSG("rt_sendsig flags: 0x%x, sp: %p, ss: 0x%lx, mask: 0x%x"), - frame.sf_sc.uc_stack.ss_flags, td->td_sigstk.ss_sp, - td->td_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask); -#endif - if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ -#ifdef DEBUG - if (ldebug(rt_sendsig)) - printf(LMSG("rt_sendsig: bad stack %p, oonstack=%x"), - fp, oonstack); -#endif PROC_LOCK(p); sigexit(td, SIGILL); } @@ -423,12 +398,6 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t regs = td->td_frame; oonstack = sigonstack(regs->tf_rsp); -#ifdef DEBUG - if (ldebug(sendsig)) - printf(ARGS(sendsig, "%p, %d, %p, %u"), - catcher, sig, (void*)mask, code); -#endif - /* Allocate space for the signal handler context. */ if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && SIGISMEMBER(psp->ps_sigonstack, sig)) { @@ -521,10 +490,6 @@ linux_sigreturn(struct thread *td, struct linux_sigret regs = td->td_frame; -#ifdef DEBUG - if (ldebug(sigreturn)) - printf(ARGS(sigreturn, "%p"), (void *)args->sfp); -#endif /* * The trampoline code hands us the sigframe. * It is unsafe to keep track of it ourselves, in the event that a @@ -606,10 +571,6 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_ regs = td->td_frame; -#ifdef DEBUG - if (ldebug(rt_sigreturn)) - printf(ARGS(rt_sigreturn, "%p"), (void *)args->ucp); -#endif /* * The trampoline code hands us the ucontext. * It is unsafe to keep track of it ourselves, in the event that a @@ -674,11 +635,6 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_ ss.ss_size = lss->ss_size; ss.ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags); -#ifdef DEBUG - if (ldebug(rt_sigreturn)) - printf(LMSG("rt_sigret flags: 0x%x, sp: %p, ss: 0x%lx, mask: 0x%x"), - ss.ss_flags, ss.ss_sp, ss.ss_size, context->sc_mask); -#endif (void)kern_sigaltstack(td, &ss, NULL); return (EJUSTRETURN); @@ -868,11 +824,6 @@ SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFL static u_long linux32_maxvmem = LINUX32_MAXVMEM; SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW, &linux32_maxvmem, 0, ""); - -#if defined(DEBUG) -SYSCTL_PROC(_compat_linux32, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, - linux_sysctl_debug, "A", "Linux debugging control"); -#endif static void linux32_fixlimit(struct rlimit *rl, int which) Modified: head/sys/arm64/linux/linux.h ============================================================================== --- head/sys/arm64/linux/linux.h Mon May 13 18:14:20 2019 (r347537) +++ head/sys/arm64/linux/linux.h Mon May 13 18:24:29 2019 (r347538) @@ -34,14 +34,6 @@ #include #include -/* Debugging support */ -#define DEBUG -extern u_char linux_debug_map[]; -#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid -#define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \ - (long)td->td_proc->p_pid, (long)td->td_tid #define LINUX_DTRACE linuxulator #define PTRIN(v) (void *)(v) Modified: head/sys/arm64/linux/linux_sysvec.c ============================================================================== --- head/sys/arm64/linux/linux_sysvec.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/arm64/linux/linux_sysvec.c Mon May 13 18:24:29 2019 (r347538) @@ -59,11 +59,6 @@ __FBSDID("$FreeBSD$"); MODULE_VERSION(linux64elf, 1); -#if defined(DEBUG) -SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, - linux_sysctl_debug, "A", "64-bit Linux debugging control"); -#endif - const char *linux_kplatform; static int linux_szsigcode; static vm_object_t linux_shared_page_obj; Modified: head/sys/compat/linux/linux_file.c ============================================================================== --- head/sys/compat/linux/linux_file.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/compat/linux/linux_file.c Mon May 13 18:24:29 2019 (r347538) @@ -76,10 +76,7 @@ linux_creat(struct thread *td, struct linux_creat_args int error; LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(creat)) - printf(ARGS(creat, "%s, %d"), path, args->mode); -#endif + error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE, O_WRONLY | O_CREAT | O_TRUNC, args->mode); LFREEPATH(path); @@ -165,14 +162,6 @@ linux_common_open(struct thread *td, int dirfd, char * } done: -#ifdef DEBUG -#ifdef LINUX_LEGACY_SYSCALLS - if (ldebug(open)) -#else - if (ldebug(openat)) -#endif - printf(LMSG("open returns error %d"), error); -#endif LFREEPATH(path); return (error); } @@ -188,11 +177,7 @@ linux_openat(struct thread *td, struct linux_openat_ar LCONVPATH_AT(td, args->filename, &path, 1, dfd); else LCONVPATH_AT(td, args->filename, &path, 0, dfd); -#ifdef DEBUG - if (ldebug(openat)) - printf(ARGS(openat, "%i, %s, 0x%x, 0x%x"), args->dfd, - path, args->flags, args->mode); -#endif + return (linux_common_open(td, dfd, path, args->flags, args->mode)); } @@ -206,11 +191,7 @@ linux_open(struct thread *td, struct linux_open_args * LCONVPATHCREAT(td, args->path, &path); else LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(open)) - printf(ARGS(open, "%s, 0x%x, 0x%x"), - path, args->flags, args->mode); -#endif + return (linux_common_open(td, AT_FDCWD, path, args->flags, args->mode)); } #endif @@ -219,11 +200,6 @@ int linux_lseek(struct thread *td, struct linux_lseek_args *args) { -#ifdef DEBUG - if (ldebug(lseek)) - printf(ARGS(lseek, "%d, %ld, %d"), - args->fdes, (long)args->off, args->whence); -#endif return (kern_lseek(td, args->fdes, args->off, args->whence)); } @@ -234,11 +210,6 @@ linux_llseek(struct thread *td, struct linux_llseek_ar int error; off_t off; -#ifdef DEBUG - if (ldebug(llseek)) - printf(ARGS(llseek, "%d, %d:%d, %d"), - args->fd, args->ohigh, args->olow, args->whence); -#endif off = (args->olow) | (((off_t) args->ohigh) << 32); error = kern_lseek(td, args->fd, off, args->whence); @@ -327,10 +298,6 @@ linux_getdents(struct thread *td, struct linux_getdent int buflen, error; size_t retval; -#ifdef DEBUG - if (ldebug(getdents)) - printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count); -#endif buflen = min(args->count, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); @@ -408,10 +375,6 @@ linux_getdents64(struct thread *td, struct linux_getde int buflen, error; size_t retval; -#ifdef DEBUG - if (ldebug(getdents64)) - uprintf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count); -#endif buflen = min(args->count, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); @@ -483,10 +446,6 @@ linux_readdir(struct thread *td, struct linux_readdir_ struct l_dirent *linux_dirent; int buflen, error; -#ifdef DEBUG - if (ldebug(readdir)) - printf(ARGS(readdir, "%d, *"), args->fd); -#endif buflen = LINUX_RECLEN(LINUX_NAME_MAX); buf = malloc(buflen, M_TEMP, M_WAITOK); @@ -539,10 +498,6 @@ linux_access(struct thread *td, struct linux_access_ar LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(access)) - printf(ARGS(access, "%s, %d"), path, args->amode); -#endif error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE, 0, args->amode); LFREEPATH(path); @@ -564,11 +519,6 @@ linux_faccessat(struct thread *td, struct linux_facces dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->filename, &path, dfd); -#ifdef DEBUG - if (ldebug(faccessat)) - printf(ARGS(access, "%s, %d"), path, args->amode); -#endif - error = kern_accessat(td, dfd, path, UIO_SYSSPACE, 0, args->amode); LFREEPATH(path); @@ -585,11 +535,6 @@ linux_unlink(struct thread *td, struct linux_unlink_ar LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(unlink)) - printf(ARGS(unlink, "%s"), path); -#endif - error = kern_funlinkat(td, AT_FDCWD, path, FD_NONE, UIO_SYSSPACE, 0, 0); if (error == EPERM) { /* Introduce POSIX noncompliant behaviour of Linux */ @@ -617,11 +562,6 @@ linux_unlinkat(struct thread *td, struct linux_unlinka dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->pathname, &path, dfd); -#ifdef DEBUG - if (ldebug(unlinkat)) - printf(ARGS(unlinkat, "%s"), path); -#endif - if (args->flag & LINUX_AT_REMOVEDIR) error = kern_frmdirat(td, dfd, path, FD_NONE, UIO_SYSSPACE, 0); else @@ -644,10 +584,6 @@ linux_chdir(struct thread *td, struct linux_chdir_args LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(chdir)) - printf(ARGS(chdir, "%s"), path); -#endif error = kern_chdir(td, path, UIO_SYSSPACE); LFREEPATH(path); return (error); @@ -662,10 +598,6 @@ linux_chmod(struct thread *td, struct linux_chmod_args LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(chmod)) - printf(ARGS(chmod, "%s, %d"), path, args->mode); -#endif error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE, args->mode, 0); LFREEPATH(path); @@ -682,11 +614,6 @@ linux_fchmodat(struct thread *td, struct linux_fchmoda dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->filename, &path, dfd); -#ifdef DEBUG - if (ldebug(fchmodat)) - printf(ARGS(fchmodat, "%s, %d"), path, args->mode); -#endif - error = kern_fchmodat(td, dfd, path, UIO_SYSSPACE, args->mode, 0); LFREEPATH(path); return (error); @@ -701,10 +628,6 @@ linux_mkdir(struct thread *td, struct linux_mkdir_args LCONVPATHCREAT(td, args->path, &path); -#ifdef DEBUG - if (ldebug(mkdir)) - printf(ARGS(mkdir, "%s, %d"), path, args->mode); -#endif error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, args->mode); LFREEPATH(path); return (error); @@ -720,10 +643,6 @@ linux_mkdirat(struct thread *td, struct linux_mkdirat_ dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHCREAT_AT(td, args->pathname, &path, dfd); -#ifdef DEBUG - if (ldebug(mkdirat)) - printf(ARGS(mkdirat, "%s, %d"), path, args->mode); -#endif error = kern_mkdirat(td, dfd, path, UIO_SYSSPACE, args->mode); LFREEPATH(path); return (error); @@ -738,10 +657,6 @@ linux_rmdir(struct thread *td, struct linux_rmdir_args LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(rmdir)) - printf(ARGS(rmdir, "%s"), path); -#endif error = kern_frmdirat(td, AT_FDCWD, path, FD_NONE, UIO_SYSSPACE, 0); LFREEPATH(path); return (error); @@ -761,10 +676,6 @@ linux_rename(struct thread *td, struct linux_rename_ar return (error); } -#ifdef DEBUG - if (ldebug(rename)) - printf(ARGS(rename, "%s, %s"), from, to); -#endif error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE); LFREEPATH(from); LFREEPATH(to); @@ -788,10 +699,6 @@ linux_renameat(struct thread *td, struct linux_renamea return (error); } -#ifdef DEBUG - if (ldebug(renameat)) - printf(ARGS(renameat, "%s, %s"), from, to); -#endif error = kern_renameat(td, olddfd, from, newdfd, to, UIO_SYSSPACE); LFREEPATH(from); LFREEPATH(to); @@ -813,10 +720,6 @@ linux_symlink(struct thread *td, struct linux_symlink_ return (error); } -#ifdef DEBUG - if (ldebug(symlink)) - printf(ARGS(symlink, "%s, %s"), path, to); -#endif error = kern_symlinkat(td, path, AT_FDCWD, to, UIO_SYSSPACE); LFREEPATH(path); LFREEPATH(to); @@ -839,11 +742,6 @@ linux_symlinkat(struct thread *td, struct linux_symlin return (error); } -#ifdef DEBUG - if (ldebug(symlinkat)) - printf(ARGS(symlinkat, "%s, %s"), path, to); -#endif - error = kern_symlinkat(td, path, dfd, to, UIO_SYSSPACE); LFREEPATH(path); LFREEPATH(to); @@ -859,11 +757,6 @@ linux_readlink(struct thread *td, struct linux_readlin LCONVPATHEXIST(td, args->name, &name); -#ifdef DEBUG - if (ldebug(readlink)) - printf(ARGS(readlink, "%s, %p, %d"), name, (void *)args->buf, - args->count); -#endif error = kern_readlinkat(td, AT_FDCWD, name, UIO_SYSSPACE, args->buf, UIO_USERSPACE, args->count); LFREEPATH(name); @@ -880,12 +773,6 @@ linux_readlinkat(struct thread *td, struct linux_readl dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->path, &name, dfd); -#ifdef DEBUG - if (ldebug(readlinkat)) - printf(ARGS(readlinkat, "%s, %p, %d"), name, (void *)args->buf, - args->bufsiz); -#endif - error = kern_readlinkat(td, dfd, name, UIO_SYSSPACE, args->buf, UIO_USERSPACE, args->bufsiz); LFREEPATH(name); @@ -900,11 +787,6 @@ linux_truncate(struct thread *td, struct linux_truncat LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(truncate)) - printf(ARGS(truncate, "%s, %ld"), path, (long)args->length); -#endif - error = kern_truncate(td, path, UIO_SYSSPACE, args->length); LFREEPATH(path); return (error); @@ -919,11 +801,6 @@ linux_truncate64(struct thread *td, struct linux_trunc LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(truncate64)) - printf(ARGS(truncate64, "%s, %jd"), path, args->length); -#endif - error = kern_truncate(td, path, UIO_SYSSPACE, args->length); LFREEPATH(path); return (error); @@ -952,10 +829,6 @@ linux_link(struct thread *td, struct linux_link_args * return (error); } -#ifdef DEBUG - if (ldebug(link)) - printf(ARGS(link, "%s, %s"), path, to); -#endif error = kern_linkat(td, AT_FDCWD, AT_FDCWD, path, to, UIO_SYSSPACE, FOLLOW); LFREEPATH(path); @@ -983,12 +856,6 @@ linux_linkat(struct thread *td, struct linux_linkat_ar return (error); } -#ifdef DEBUG - if (ldebug(linkat)) - printf(ARGS(linkat, "%i, %s, %i, %s, %i"), args->olddfd, path, - args->newdfd, to, args->flag); -#endif - follow = (args->flag & LINUX_AT_SYMLINK_FOLLOW) == 0 ? NOFOLLOW : FOLLOW; error = kern_linkat(td, olddfd, newdfd, path, to, UIO_SYSSPACE, follow); @@ -1110,12 +977,6 @@ linux_mount(struct thread *td, struct linux_mount_args if (error != 0) goto out; -#ifdef DEBUG - if (ldebug(mount)) - printf(ARGS(mount, "%s, %s, %s"), - fstypename, mntfromname, mntonname); -#endif - if (strcmp(fstypename, "ext2") == 0) { strcpy(fstypename, "ext2fs"); } else if (strcmp(fstypename, "proc") == 0) { @@ -1424,11 +1285,6 @@ int linux_fcntl(struct thread *td, struct linux_fcntl_args *args) { -#ifdef DEBUG - if (ldebug(fcntl)) - printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd); -#endif - return (fcntl_common(td, args)); } @@ -1441,11 +1297,6 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_ struct linux_fcntl_args fcntl_args; int error; -#ifdef DEBUG - if (ldebug(fcntl64)) - printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd); -#endif - switch (args->cmd) { case LINUX_F_GETLK64: error = copyin((void *)args->arg, &linux_flock, @@ -1495,10 +1346,6 @@ linux_chown(struct thread *td, struct linux_chown_args LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(chown)) - printf(ARGS(chown, "%s, %d, %d"), path, args->uid, args->gid); -#endif error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid, args->gid, 0); LFREEPATH(path); @@ -1518,11 +1365,6 @@ linux_fchownat(struct thread *td, struct linux_fchowna dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->filename, &path, dfd); -#ifdef DEBUG - if (ldebug(fchownat)) - printf(ARGS(fchownat, "%s, %d, %d"), path, args->uid, args->gid); -#endif - flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) == 0 ? 0 : AT_SYMLINK_NOFOLLOW; error = kern_fchownat(td, dfd, path, UIO_SYSSPACE, args->uid, args->gid, @@ -1540,10 +1382,6 @@ linux_lchown(struct thread *td, struct linux_lchown_ar LCONVPATHEXIST(td, args->path, &path); -#ifdef DEBUG - if (ldebug(lchown)) - printf(ARGS(lchown, "%s, %d, %d"), path, args->uid, args->gid); -#endif error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid, args->gid, AT_SYMLINK_NOFOLLOW); LFREEPATH(path); @@ -1605,11 +1443,6 @@ linux_pipe(struct thread *td, struct linux_pipe_args * int fildes[2]; int error; -#ifdef DEBUG - if (ldebug(pipe)) - printf(ARGS(pipe, "*")); -#endif - error = kern_pipe(td, fildes, 0, NULL, NULL); if (error != 0) return (error); @@ -1629,11 +1462,6 @@ linux_pipe2(struct thread *td, struct linux_pipe2_args { int fildes[2]; int error, flags; - -#ifdef DEBUG - if (ldebug(pipe2)) - printf(ARGS(pipe2, "*, %d"), args->flags); -#endif if ((args->flags & ~(LINUX_O_NONBLOCK | LINUX_O_CLOEXEC)) != 0) return (EINVAL); Modified: head/sys/compat/linux/linux_fork.c ============================================================================== --- head/sys/compat/linux/linux_fork.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/compat/linux/linux_fork.c Mon May 13 18:24:29 2019 (r347538) @@ -74,11 +74,6 @@ linux_fork(struct thread *td, struct linux_fork_args * struct proc *p2; struct thread *td2; -#ifdef DEBUG - if (ldebug(fork)) - printf(ARGS(fork, "")); -#endif - bzero(&fr, sizeof(fr)); fr.fr_flags = RFFDG | RFPROC | RFSTOPPED; fr.fr_procp = &p2; @@ -110,11 +105,6 @@ linux_vfork(struct thread *td, struct linux_vfork_args struct proc *p2; struct thread *td2; -#ifdef DEBUG - if (ldebug(vfork)) - printf(ARGS(vfork, "")); -#endif - bzero(&fr, sizeof(fr)); fr.fr_flags = RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED; fr.fr_procp = &p2; @@ -149,14 +139,6 @@ linux_clone_proc(struct thread *td, struct linux_clone int exit_signal; struct linux_emuldata *em; -#ifdef DEBUG - if (ldebug(clone)) { - printf(ARGS(clone, "flags %x, stack %p, parent tid: %p, " - "child tid: %p"), (unsigned)args->flags, - args->stack, args->parent_tidptr, args->child_tidptr); - } -#endif - exit_signal = args->flags & 0x000000ff; if (LINUX_SIG_VALID(exit_signal)) { exit_signal = linux_to_bsd_signal(exit_signal); @@ -212,7 +194,7 @@ linux_clone_proc(struct thread *td, struct linux_clone error = copyout(&p2->p_pid, args->parent_tidptr, sizeof(p2->p_pid)); if (error) - printf(LMSG("copyout failed!")); + linux_msg(td, "copyout p_pid failed!"); } PROC_LOCK(p2); @@ -240,13 +222,6 @@ linux_clone_proc(struct thread *td, struct linux_clone sx_xunlock(&proctree_lock); } -#ifdef DEBUG - if (ldebug(clone)) - printf(LMSG("clone: successful rfork to %d, " - "stack %p sig = %d"), (int)p2->p_pid, args->stack, - exit_signal); -#endif - /* * Make this runnable after we are finished with it. */ @@ -268,14 +243,6 @@ linux_clone_thread(struct thread *td, struct linux_clo struct proc *p; int error; -#ifdef DEBUG - if (ldebug(clone)) { - printf(ARGS(clone, "thread: flags %x, stack %p, parent tid: %p, " - "child tid: %p"), (unsigned)args->flags, - args->stack, args->parent_tidptr, args->child_tidptr); - } -#endif - LINUX_CTR4(clone_thread, "thread(%d) flags %x ptid %p ctid %p", td->td_tid, (unsigned)args->flags, args->parent_tidptr, args->child_tidptr); @@ -360,12 +327,6 @@ linux_clone_thread(struct thread *td, struct linux_clo tidhash_add(newtd); -#ifdef DEBUG - if (ldebug(clone)) - printf(ARGS(clone, "successful clone to %d, stack %p"), - (int)newtd->td_tid, args->stack); -#endif - LINUX_CTR2(clone_thread, "thread(%d) successful clone to %d", td->td_tid, newtd->td_tid); @@ -373,7 +334,7 @@ linux_clone_thread(struct thread *td, struct linux_clo error = copyout(&newtd->td_tid, args->parent_tidptr, sizeof(newtd->td_tid)); if (error) - printf(LMSG("clone_thread: copyout failed!")); + linux_msg(td, "clone_thread: copyout td_tid failed!"); } /* Modified: head/sys/compat/linux/linux_getcwd.c ============================================================================== --- head/sys/compat/linux/linux_getcwd.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/compat/linux/linux_getcwd.c Mon May 13 18:24:29 2019 (r347538) @@ -65,11 +65,6 @@ linux_getcwd(struct thread *td, struct linux_getcwd_ar char *path; int error, lenused; -#ifdef DEBUG - if (ldebug(getcwd)) - printf(ARGS(getcwd, "%p, %ld"), args->buf, (long)args->bufsize); -#endif - /* * Linux returns ERANGE instead of EINVAL. */ Modified: head/sys/compat/linux/linux_ioctl.c ============================================================================== --- head/sys/compat/linux/linux_ioctl.c Mon May 13 18:14:20 2019 (r347537) +++ head/sys/compat/linux/linux_ioctl.c Mon May 13 18:24:29 2019 (r347538) @@ -238,12 +238,7 @@ linux_ioctl_hdio(struct thread *td, struct linux_ioctl */ bytespercyl = (off_t) sectorsize * fwheads * fwsectors; fwcylinders = mediasize / bytespercyl; -#if defined(DEBUG) - linux_msg(td, "HDIO_GET_GEO: mediasize %jd, c/h/s %d/%d/%d, " - "bpc %jd", - (intmax_t)mediasize, fwcylinders, fwheads, fwsectors, - (intmax_t)bytespercyl); -#endif + if ((args->cmd & 0xffff) == LINUX_HDIO_GET_GEO) { struct linux_hd_geometry hdg; @@ -404,19 +399,6 @@ bsd_to_linux_termios(struct termios *bios, struct linu { int i; -#ifdef DEBUG - if (ldebug(ioctl)) { - printf("LINUX: BSD termios structure (input):\n"); - printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, - bios->c_ispeed, bios->c_ospeed); - printf("c_cc "); - for (i=0; ic_cc[i]); - printf("\n"); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon May 13 18:28:42 2019 Return-Path: Delivered-To: svn-src-all@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 03FEA1597ABD; Mon, 13 May 2019 18:28:42 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 965C58E240; Mon, 13 May 2019 18:28:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D95DDAD8; Mon, 13 May 2019 18:28:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DISfZT041958; Mon, 13 May 2019 18:28:41 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DISeYG041954; Mon, 13 May 2019 18:28:40 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201905131828.x4DISeYG041954@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 13 May 2019 18:28:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347540 - in head/sys/modules: linprocfs linsysfs linux linux64 linux_common X-SVN-Group: head X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in head/sys/modules: linprocfs linsysfs linux linux64 linux_common X-SVN-Commit-Revision: 347540 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 965C58E240 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.961,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:28:42 -0000 Author: dchagin Date: Mon May 13 18:28:40 2019 New Revision: 347540 URL: https://svnweb.freebsd.org/changeset/base/347540 Log: Add warning to the Linuxulator makefiles that building it outside of a kernel does not make sence. PR: 222861 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20179 Modified: head/sys/modules/linprocfs/Makefile head/sys/modules/linsysfs/Makefile head/sys/modules/linux/Makefile head/sys/modules/linux64/Makefile head/sys/modules/linux_common/Makefile Modified: head/sys/modules/linprocfs/Makefile ============================================================================== --- head/sys/modules/linprocfs/Makefile Mon May 13 18:25:55 2019 (r347539) +++ head/sys/modules/linprocfs/Makefile Mon May 13 18:28:40 2019 (r347540) @@ -7,4 +7,8 @@ SRCS= vnode_if.h \ device_if.h bus_if.h \ linprocfs.c +.if !defined(KERNBUILDDIR) +.warning Building Linuxulator outside of a kernel does not make sense +.endif + .include Modified: head/sys/modules/linsysfs/Makefile ============================================================================== --- head/sys/modules/linsysfs/Makefile Mon May 13 18:25:55 2019 (r347539) +++ head/sys/modules/linsysfs/Makefile Mon May 13 18:28:40 2019 (r347540) @@ -7,4 +7,8 @@ SRCS= vnode_if.h \ device_if.h bus_if.h pci_if.h \ linsysfs.c +.if !defined(KERNBUILDDIR) +.warning Building Linuxulator outside of a kernel does not make sense +.endif + .include Modified: head/sys/modules/linux/Makefile ============================================================================== --- head/sys/modules/linux/Makefile Mon May 13 18:25:55 2019 (r347539) +++ head/sys/modules/linux/Makefile Mon May 13 18:28:40 2019 (r347540) @@ -80,4 +80,8 @@ ${VDSO}.so: linux${SFX}_locore.o linux${SFX}_genassym.o: offset.inc ${CC} -c ${CFLAGS:N-flto:N-fno-common} ${.IMPSRC} +.if !defined(KERNBUILDDIR) +.warning Building Linuxulator outside of a kernel does not make sense +.endif + .include Modified: head/sys/modules/linux64/Makefile ============================================================================== --- head/sys/modules/linux64/Makefile Mon May 13 18:25:55 2019 (r347539) +++ head/sys/modules/linux64/Makefile Mon May 13 18:28:40 2019 (r347540) @@ -55,4 +55,8 @@ linux_support.o: assym.inc linux_assym.h linux_genassym.o: offset.inc ${CC} -c ${CFLAGS:N-flto:N-fno-common} ${.IMPSRC} +.if !defined(KERNBUILDDIR) +.warning Building Linuxulator outside of a kernel does not make sense +.endif + .include Modified: head/sys/modules/linux_common/Makefile ============================================================================== --- head/sys/modules/linux_common/Makefile Mon May 13 18:25:55 2019 (r347539) +++ head/sys/modules/linux_common/Makefile Mon May 13 18:28:40 2019 (r347540) @@ -15,4 +15,8 @@ EXPORT_SYMS+= linux_ioctl_unregister_handler EXPORT_SYMS+= linux_get_osname EXPORT_SYMS+= linux_get_osrelease +.if !defined(KERNBUILDDIR) +.warning Building Linuxulator outside of a kernel does not make sense +.endif + .include From owner-svn-src-all@freebsd.org Mon May 13 18:29:15 2019 Return-Path: Delivered-To: svn-src-all@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 0D5731597AFD for ; Mon, 13 May 2019 18:29:15 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-yw1-xc2a.google.com (mail-yw1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) (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 9009B8E361 for ; Mon, 13 May 2019 18:29:14 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-yw1-xc2a.google.com with SMTP id q185so11804893ywe.3 for ; Mon, 13 May 2019 11:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P6ESao7H5yEOTgeBUxn4YC62hsE+s5SNoCIMatr6sKo=; b=c+L+b24wbGdRtEGSzM2e+FUM6AEaa0KCdxn+ZUYw/V3wpZejm9T2Bsb66J0HdeO6HS xDSxHz3NeqQnqNGbzLVl4JW7W20kzcrfOX0Irr+54cuY67RtQsbjBAgchn66NKI32J2y 0VUG0YhKCniWFHpMxNBlUC5IvzobW4ZDrn51GOZoXM3Qf17k4vv+JL/MfOVzqmyC3jZi ZwvI30R/6Amh1XMBBWDDMT4kTgJWIl6HjZzoAgn0QP0QJRWrXqn3gQOo/ghHm/R3VxUi y7wp3SeuU/AO5iuddd7iOpqi4JInZ/HwzW+N8LlKUD0Sa6SCndP13mjv7gX3eA5L2S2B PsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P6ESao7H5yEOTgeBUxn4YC62hsE+s5SNoCIMatr6sKo=; b=WQCCHRcihFGx9Au4Kb/gYkqdquR6wuqVGdBnBLWRrotk3lGUZjfkNv45ZW9fQa31c9 TAeWKTApSLm3G5SJMrK6AQo76/Wn7CqnIWoFI4ugbAGywhMhqLBKqKf5EnqSktAl4O7W iDDSpSvQZzRpUjCmSqH4xP5I+o5oashGGrt4pcFtp21E5poIzzGn6kXqzPGxc7apiBnB Z2MnHz/0YtP4E1U8mxP5g/AHf1CpqKjWQBa7w3Dbzl70Xunl7xiQ3kA1OVgkQudMxCCC UH0hjHJB61tDneYsFEYuX3pfK1OzN8flpbdtld0NtQYsOFs+7uS6/FXd6yOLIZmjaPqw lMaQ== X-Gm-Message-State: APjAAAUoh+Rz1sOjw0I4l4z1K5H9oMAYNEsApFnxGVC13a0vATzJx5bR vhRC9eIZY6MwoV4bMG0rC3I1XavUy9h8/sUt5jKxYg== X-Google-Smtp-Source: APXvYqxRaVheJPgEP5REe3oePHKp3X5yUmicYkQGK0e5qBYuNkTg/jnNIUk4KnlBOTtT+7GaE7nNeXZDw2uIL+qhXYE= X-Received: by 2002:a0d:c1c4:: with SMTP id c187mr14643355ywd.79.1557772153138; Mon, 13 May 2019 11:29:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:4dd4:0:0:0:0:0 with HTTP; Mon, 13 May 2019 11:29:12 -0700 (PDT) In-Reply-To: <201905131741.x4DHfh2G042304@gndrsh.dnsmgr.net> References: <201905131735.x4DHZ2BS042282@gndrsh.dnsmgr.net> <201905131741.x4DHfh2G042304@gndrsh.dnsmgr.net> From: Oliver Pinter Date: Mon, 13 May 2019 20:29:12 +0200 Message-ID: Subject: Re: svn commit: r347532 - in head: contrib/netbsd-tests/lib/libc/sys lib/libc/sys lib/libc/tests/sys sys/amd64/vmm sys/sys sys/vm usr.bin/vmstat To: "rgrimes@freebsd.org" Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , Mark Johnston , "src-committers@freebsd.org" X-Rspamd-Queue-Id: 9009B8E361 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:29:15 -0000 And it would be nice to bump __freebsd_version too. On Monday, May 13, 2019, Rodney W. Grimes wrote: > > > Author: markj > > > Date: Mon May 13 16:38:48 2019 > > > New Revision: 347532 > > > URL: https://svnweb.freebsd.org/changeset/base/347532 > > > > > > Log: > > > Provide separate accounting for user-wired pages. > > > > > > Historically we have not distinguished between kernel wirings and > user > > > wirings for accounting purposes. User wirings (via mlock(2)) were > > > subject to a global limit on the number of wired pages, so if large > > > swaths of physical memory were wired by the kernel, as happens with > > > the ZFS ARC among other things, the limit could be exceeded, causing > > > user wirings to fail. > > > > > > The change adds a new counter, v_user_wire_count, which counts the > > > number of virtual pages wired by user processes via mlock(2) and > > > mlockall(2). Only user-wired pages are subject to the system-wide > > > limit which helps provide some safety against deadlocks. In > > > particular, while sources of kernel wirings typically support some > > > backpressure mechanism, there is no way to reclaim user-wired pages > > > shorting of killing the wiring process. The limit is exported as > > > vm.max_user_wired, renamed from vm.max_wired, and changed from u_int > > > to u_long. > > > > > > The choice to count virtual user-wired pages rather than physical > > > pages was done for simplicity. There are mechanisms that can cause > > > user-wired mappings to be destroyed while maintaining a wiring of > > > the backing physical page; these make it difficult to accurately > > > track user wirings at the physical page layer. > > > > > > The change also closes some holes which allowed user wirings to > succeed > > > even when they would cause the system limit to be exceeded. For > > > instance, mmap() may now fail with ENOMEM in a process that has > called > > > mlockall(MCL_FUTURE) if the new mapping would cause the user wiring > > > limit to be exceeded. > > > > > > Note that bhyve -S is subject to the user wiring limit, which > defaults > > > to 1/3 of physical RAM. Users that wish to exceed the limit must > tune > > > vm.max_user_wired. > > > > Because of that this should probably have a: > > Release Notes: Yes > > And probably an UPDATING entry since this may cause some -head > users VM's to fall over on a update/reboot. > > > > > Reviewed by: kib, ngie (mlock() test changes) > > > Tested by: pho (earlier version) > > > MFC after: 45 days > > > Sponsored by: Netflix > > > Differential Revision: https://reviews.freebsd.org/D19908 > > > > > > Modified: > > > head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > > > head/lib/libc/sys/mlock.2 > > > head/lib/libc/sys/mlockall.2 > > > head/lib/libc/tests/sys/mlock_helper.c > > > head/sys/amd64/vmm/vmm.c > > > head/sys/sys/vmmeter.h > > > head/sys/vm/vm_glue.c > > > head/sys/vm/vm_map.c > > > head/sys/vm/vm_map.h > > > head/sys/vm/vm_meter.c > > > head/sys/vm/vm_mmap.c > > > head/sys/vm/vm_pageout.c > > > head/sys/vm/vm_pageout.h > > > head/sys/vm/vm_unix.c > > > head/usr.bin/vmstat/vmstat.c > > > > > > Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c > > > ============================================================ > ================== > > > --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May > 13 15:39:54 2019 (r347531) > > > +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon May > 13 16:38:48 2019 (r347532) > > > @@ -51,7 +51,7 @@ __RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 > 12:02:44 > > > #define _KMEMUSER > > > #include > > > > > > -void set_vm_max_wired(int); > > > +void set_vm_max_wired(u_long); > > > void restore_vm_max_wired(void); > > > #endif > > > > > > > > > Modified: head/lib/libc/sys/mlock.2 > > > ============================================================ > ================== > > > --- head/lib/libc/sys/mlock.2 Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/lib/libc/sys/mlock.2 Mon May 13 16:38:48 2019 > (r347532) > > > @@ -28,7 +28,7 @@ > > > .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 > > > .\" $FreeBSD$ > > > .\" > > > -.Dd March 20, 2018 > > > +.Dd May 13, 2019 > > > .Dt MLOCK 2 > > > .Os > > > .Sh NAME > > > @@ -97,13 +97,13 @@ resource limit and the > > > system-wide > > > .Dq wired pages > > > limit > > > -.Va vm.max_wired . > > > -.Va vm.max_wired > > > +.Va vm.max_user_wired . > > > +.Va vm.max_user_wired > > > applies to the system as a whole, so the amount available to a single > > > process at any given time is the difference between > > > -.Va vm.max_wired > > > +.Va vm.max_user_wired > > > and > > > -.Va vm.stats.vm.v_wire_count . > > > +.Va vm.stats.vm.v_user_wire_count . > > > .Pp > > > If > > > .Va security.bsd.unprivileged_mlock > > > @@ -124,13 +124,11 @@ will fail if: > > > is set to 0 and the caller is not the super-user. > > > .It Bq Er EINVAL > > > The address range given wraps around zero. > > > -.It Bq Er EAGAIN > > > -Locking the indicated range would exceed the system limit for locked > memory. > > > .It Bq Er ENOMEM > > > Some portion of the indicated address range is not allocated. > > > There was an error faulting/mapping a page. > > > -Locking the indicated range would exceed the per-process limit for > locked > > > -memory. > > > +Locking the indicated range would exceed the per-process or > system-wide limits > > > +for locked memory. > > > .El > > > The > > > .Fn munlock > > > @@ -171,11 +169,11 @@ system calls first appeared in > > > Allocating too much wired memory can lead to a memory-allocation > deadlock > > > which requires a reboot to recover from. > > > .Pp > > > -The per-process resource limit is a limit on the amount of virtual > > > -memory locked, while the system-wide limit is for the number of locked > > > -physical pages. > > > -Hence a process with two distinct locked mappings of the same > physical page > > > -counts as 2 pages against the per-process limit and as only a single > page > > > -in the system limit. > > > +The per-process and system-wide resource limits of locked memory apply > > > +to the amount of virtual memory locked, not the amount of locked > physical > > > +pages. > > > +Hence two distinct locked mappings of the same physical page counts as > > > +2 pages aginst the system limit, and also against the per-process > limit > > > +if both mappings belong to the same physical map. > > > .Pp > > > The per-process resource limit is not currently supported. > > > > > > Modified: head/lib/libc/sys/mlockall.2 > > > ============================================================ > ================== > > > --- head/lib/libc/sys/mlockall.2 Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/lib/libc/sys/mlockall.2 Mon May 13 16:38:48 2019 > (r347532) > > > @@ -30,7 +30,7 @@ > > > .\" > > > .\" $FreeBSD$ > > > .\" > > > -.Dd December 25, 2012 > > > +.Dd May 13, 2019 > > > .Dt MLOCKALL 2 > > > .Os > > > .Sh NAME > > > @@ -69,7 +69,7 @@ limited in how much they can lock down. > > > A single process can lock the minimum of a system-wide > > > .Dq wired pages > > > limit > > > -.Va vm.max_wired > > > +.Va vm.max_user_wired > > > and the per-process > > > .Dv RLIMIT_MEMLOCK > > > resource limit. > > > @@ -138,9 +138,9 @@ and > > > functions first appeared in > > > .Fx 5.1 . > > > .Sh BUGS > > > -The per-process resource limit is a limit on the amount of virtual > > > -memory locked, while the system-wide limit is for the number of locked > > > -physical pages. > > > -Hence a process with two distinct locked mappings of the same > physical page > > > -counts as 2 pages against the per-process limit and as only a single > page > > > -in the system limit. > > > +The per-process and system-wide resource limits of locked memory apply > > > +to the amount of virtual memory locked, not the amount of locked > physical > > > +pages. > > > +Hence two distinct locked mappings of the same physical page counts as > > > +2 pages aginst the system limit, and also against the per-process > limit > > > +if both mappings belong to the same physical map. > > > > > > Modified: head/lib/libc/tests/sys/mlock_helper.c > > > ============================================================ > ================== > > > --- head/lib/libc/tests/sys/mlock_helper.c Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/lib/libc/tests/sys/mlock_helper.c Mon May 13 16:38:48 2019 > (r347532) > > > @@ -39,16 +39,16 @@ __FBSDID("$FreeBSD$"); > > > #include > > > #include > > > > > > -#define VM_MAX_WIRED "vm.max_wired" > > > +#define VM_MAX_WIRED "vm.max_user_wired" > > > > > > static void > > > -vm_max_wired_sysctl(int *old_value, int *new_value) > > > +vm_max_wired_sysctl(u_long *old_value, u_long *new_value) > > > { > > > size_t old_len; > > > - size_t new_len = (new_value == NULL ? 0 : sizeof(int)); > > > + size_t new_len = (new_value == NULL ? 0 : sizeof(*new_value)); > > > > > > if (old_value == NULL) > > > - printf("Setting the new value to %d\n", *new_value); > > > + printf("Setting the new value to %lu\n", *new_value); > > > else { > > > ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len, > > > new_value, new_len) == 0, > > > @@ -60,14 +60,14 @@ vm_max_wired_sysctl(int *old_value, int *new_value) > > > "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); > > > > > > if (old_value != NULL) > > > - printf("Saved the old value (%d)\n", *old_value); > > > + printf("Saved the old value (%lu)\n", *old_value); > > > } > > > > > > void > > > -set_vm_max_wired(int new_value) > > > +set_vm_max_wired(u_long new_value) > > > { > > > FILE *fp; > > > - int old_value; > > > + u_long old_value; > > > > > > fp = fopen(VM_MAX_WIRED, "w"); > > > if (fp == NULL) { > > > @@ -78,7 +78,7 @@ set_vm_max_wired(int new_value) > > > > > > vm_max_wired_sysctl(&old_value, NULL); > > > > > > - ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0, > > > + ATF_REQUIRE_MSG(fprintf(fp, "%lu", old_value) > 0, > > > "saving %s failed", VM_MAX_WIRED); > > > > > > fclose(fp); > > > @@ -90,7 +90,7 @@ void > > > restore_vm_max_wired(void) > > > { > > > FILE *fp; > > > - int saved_max_wired; > > > + u_long saved_max_wired; > > > > > > fp = fopen(VM_MAX_WIRED, "r"); > > > if (fp == NULL) { > > > @@ -98,14 +98,14 @@ restore_vm_max_wired(void) > > > return; > > > } > > > > > > - if (fscanf(fp, "%d", &saved_max_wired) != 1) { > > > + if (fscanf(fp, "%lu", &saved_max_wired) != 1) { > > > perror("fscanf failed\n"); > > > fclose(fp); > > > return; > > > } > > > > > > fclose(fp); > > > - printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired); > > > + printf("old value in %s: %lu\n", VM_MAX_WIRED, saved_max_wired); > > > > > > if (saved_max_wired == 0) /* This will cripple the test host */ > > > return; > > > > > > Modified: head/sys/amd64/vmm/vmm.c > > > ============================================================ > ================== > > > --- head/sys/amd64/vmm/vmm.c Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/sys/amd64/vmm/vmm.c Mon May 13 16:38:48 2019 > (r347532) > > > @@ -754,7 +754,8 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int > segi > > > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > > if (error != KERN_SUCCESS) { > > > vm_map_remove(&vm->vmspace->vm_map, gpa, gpa + > len); > > > - return (EFAULT); > > > + return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM : > > > + EFAULT); > > > } > > > } > > > > > > > > > Modified: head/sys/sys/vmmeter.h > > > ============================================================ > ================== > > > --- head/sys/sys/vmmeter.h Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/sys/vmmeter.h Mon May 13 16:38:48 2019 (r347532) > > > @@ -153,6 +153,8 @@ extern domainset_t vm_severe_domains; > > > #define VM_CNT_INC(var) VM_CNT_ADD(var, 1) > > > #define VM_CNT_FETCH(var) counter_u64_fetch(vm_cnt.var) > > > > > > +extern u_long vm_user_wire_count; > > > + > > > static inline void > > > vm_wire_add(int cnt) > > > { > > > > > > Modified: head/sys/vm/vm_glue.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_glue.c Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_glue.c Mon May 13 16:38:48 2019 (r347532) > > > @@ -181,21 +181,8 @@ vslock(void *addr, size_t len) > > > if (last < (vm_offset_t)addr || end < (vm_offset_t)addr) > > > return (EINVAL); > > > npages = atop(end - start); > > > - if (npages > vm_page_max_wired) > > > + if (npages > vm_page_max_user_wired) > > > return (ENOMEM); > > > -#if 0 > > > - /* > > > - * XXX - not yet > > > - * > > > - * The limit for transient usage of wired pages should be > > > - * larger than for "permanent" wired pages (mlock()). > > > - * > > > - * Also, the sysctl code, which is the only present user > > > - * of vslock(), does a hard loop on EAGAIN. > > > - */ > > > - if (npages + vm_wire_count() > vm_page_max_wired) > > > - return (EAGAIN); > > > -#endif > > > error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, > > > VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); > > > if (error == KERN_SUCCESS) { > > > > > > Modified: head/sys/vm/vm_map.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_map.c Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_map.c Mon May 13 16:38:48 2019 (r347532) > > > @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -2917,12 +2918,12 @@ done: > > > > > > if (rv == KERN_SUCCESS && (!user_unwire || > > > (entry->eflags & MAP_ENTRY_USER_WIRED))) { > > > - if (user_unwire) > > > - entry->eflags &= ~MAP_ENTRY_USER_WIRED; > > > if (entry->wired_count == 1) > > > vm_map_entry_unwire(map, entry); > > > else > > > entry->wired_count--; > > > + if (user_unwire) > > > + entry->eflags &= ~MAP_ENTRY_USER_WIRED; > > > } > > > KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) != 0, > > > ("vm_map_unwire: in-transition flag missing %p", > entry)); > > > @@ -2942,6 +2943,28 @@ done: > > > return (rv); > > > } > > > > > > +static void > > > +vm_map_wire_user_count_sub(u_long npages) > > > +{ > > > + > > > + atomic_subtract_long(&vm_user_wire_count, npages); > > > +} > > > + > > > +static bool > > > +vm_map_wire_user_count_add(u_long npages) > > > +{ > > > + u_long wired; > > > + > > > + wired = vm_user_wire_count; > > > + do { > > > + if (npages + wired > vm_page_max_user_wired) > > > + return (false); > > > + } while (!atomic_fcmpset_long(&vm_user_wire_count, &wired, > > > + npages + wired)); > > > + > > > + return (true); > > > +} > > > + > > > /* > > > * vm_map_wire_entry_failure: > > > * > > > @@ -2978,37 +3001,49 @@ vm_map_wire_entry_failure(vm_map_t map, > vm_map_entry_t > > > entry->wired_count = -1; > > > } > > > > > > +int > > > +vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int > flags) > > > +{ > > > + int rv; > > > + > > > + vm_map_lock(map); > > > + rv = vm_map_wire_locked(map, start, end, flags); > > > + vm_map_unlock(map); > > > + return (rv); > > > +} > > > + > > > + > > > /* > > > - * vm_map_wire: > > > + * vm_map_wire_locked: > > > * > > > - * Implements both kernel and user wiring. > > > + * Implements both kernel and user wiring. Returns with the map > locked, > > > + * the map lock may be dropped. > > > */ > > > int > > > -vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > > - int flags) > > > +vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, > int flags) > > > { > > > vm_map_entry_t entry, first_entry, tmp_entry; > > > vm_offset_t faddr, saved_end, saved_start; > > > - unsigned int last_timestamp; > > > + u_long npages; > > > + u_int last_timestamp; > > > int rv; > > > boolean_t need_wakeup, result, user_wire; > > > vm_prot_t prot; > > > > > > + VM_MAP_ASSERT_LOCKED(map); > > > + > > > if (start == end) > > > return (KERN_SUCCESS); > > > prot = 0; > > > if (flags & VM_MAP_WIRE_WRITE) > > > prot |= VM_PROT_WRITE; > > > user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; > > > - vm_map_lock(map); > > > VM_MAP_RANGE_CHECK(map, start, end); > > > if (!vm_map_lookup_entry(map, start, &first_entry)) { > > > if (flags & VM_MAP_WIRE_HOLESOK) > > > first_entry = first_entry->next; > > > - else { > > > - vm_map_unlock(map); > > > + else > > > return (KERN_INVALID_ADDRESS); > > > - } > > > } > > > last_timestamp = map->timestamp; > > > entry = first_entry; > > > @@ -3042,7 +3077,6 @@ vm_map_wire(vm_map_t map, vm_offset_t start, > vm_offset > > > /* > > > * first_entry has > been deleted. > > > */ > > > - vm_map_unlock(map); > > > return > (KERN_INVALID_ADDRESS); > > > } > > > end = saved_start; > > > @@ -3082,13 +3116,22 @@ vm_map_wire(vm_map_t map, vm_offset_t start, > vm_offset > > > } > > > if (entry->wired_count == 0) { > > > entry->wired_count++; > > > - saved_start = entry->start; > > > - saved_end = entry->end; > > > > > > + npages = atop(entry->end - entry->start); > > > + if (user_wire && !vm_map_wire_user_count_add(npages)) > { > > > + vm_map_wire_entry_failure(map, entry, > > > + entry->start); > > > + end = entry->end; > > > + rv = KERN_RESOURCE_SHORTAGE; > > > + goto done; > > > + } > > > + > > > /* > > > * Release the map lock, relying on the > in-transition > > > * mark. Mark the map busy for fork. > > > */ > > > + saved_start = entry->start; > > > + saved_end = entry->end; > > > vm_map_busy(map); > > > vm_map_unlock(map); > > > > > > @@ -3136,6 +3179,8 @@ vm_map_wire(vm_map_t map, vm_offset_t start, > vm_offset > > > last_timestamp = map->timestamp; > > > if (rv != KERN_SUCCESS) { > > > vm_map_wire_entry_failure(map, entry, > faddr); > > > + if (user_wire) > > > + vm_map_wire_user_count_sub( > npages); > > > end = entry->end; > > > goto done; > > > } > > > @@ -3201,9 +3246,12 @@ done: > > > * Undo the wiring. Wiring succeeded on this entry > > > * but failed on a later entry. > > > */ > > > - if (entry->wired_count == 1) > > > + if (entry->wired_count == 1) { > > > vm_map_entry_unwire(map, entry); > > > - else > > > + if (user_wire) > > > + vm_map_wire_user_count_sub( > > > + atop(entry->end - > entry->start)); > > > + } else > > > entry->wired_count--; > > > } > > > next_entry_done: > > > @@ -3220,7 +3268,6 @@ done: > > > } > > > vm_map_simplify_entry(map, entry); > > > } > > > - vm_map_unlock(map); > > > if (need_wakeup) > > > vm_map_wakeup(map); > > > return (rv); > > > @@ -3338,13 +3385,18 @@ vm_map_sync( > > > static void > > > vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry) > > > { > > > + vm_size_t size; > > > > > > VM_MAP_ASSERT_LOCKED(map); > > > KASSERT(entry->wired_count > 0, > > > ("vm_map_entry_unwire: entry %p isn't wired", entry)); > > > + > > > + size = entry->end - entry->start; > > > + if ((entry->eflags & MAP_ENTRY_USER_WIRED) != 0) > > > + vm_map_wire_user_count_sub(atop(size)); > > > pmap_unwire(map->pmap, entry->start, entry->end); > > > - vm_object_unwire(entry->object.vm_object, entry->offset, > entry->end - > > > - entry->start, PQ_ACTIVE); > > > + vm_object_unwire(entry->object.vm_object, entry->offset, size, > > > + PQ_ACTIVE); > > > entry->wired_count = 0; > > > } > > > > > > @@ -4311,12 +4363,11 @@ retry: > > > * Heed the MAP_WIREFUTURE flag if it was set for this process. > > > */ > > > if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) { > > > - vm_map_unlock(map); > > > - vm_map_wire(map, grow_start, grow_start + grow_amount, > > > + rv = vm_map_wire_locked(map, grow_start, > > > + grow_start + grow_amount, > > > VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > > - vm_map_lock_read(map); > > > - } else > > > - vm_map_lock_downgrade(map); > > > + } > > > + vm_map_lock_downgrade(map); > > > > > > out: > > > #ifdef RACCT > > > > > > Modified: head/sys/vm/vm_map.h > > > ============================================================ > ================== > > > --- head/sys/vm/vm_map.h Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_map.h Mon May 13 16:38:48 2019 (r347532) > > > @@ -422,7 +422,8 @@ int vm_map_madvise (vm_map_t, vm_offset_t, > vm_offset_t > > > int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, > vm_prot_t, int); > > > int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > > int flags); > > > -int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > > > +int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int > flags); > > > +int vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t > end, > > > int flags); > > > long vmspace_swap_count(struct vmspace *vmspace); > > > void vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool add); > > > > > > Modified: head/sys/vm/vm_meter.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_meter.c Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_meter.c Mon May 13 16:38:48 2019 (r347532) > > > @@ -97,6 +97,8 @@ struct vmmeter __read_mostly vm_cnt = { > > > .v_wire_count = EARLY_COUNTER, > > > }; > > > > > > +u_long __exclusive_cache_line vm_user_wire_count; > > > + > > > static void > > > vmcounter_startup(void) > > > { > > > @@ -394,6 +396,8 @@ sysctl_handle_vmstat_proc(SYSCTL_HANDLER_ARGS) > > > > > > #define VM_STATS_UINT(var, descr) \ > > > SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, > 0, descr) > > > +#define VM_STATS_ULONG(var, descr) \ > > > + SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, > &vm_cnt.var, 0, descr) > > > > > > VM_STATS_UINT(v_page_size, "Page size in bytes"); > > > VM_STATS_UINT(v_page_count, "Total number of pages in system"); > > > @@ -410,6 +414,9 @@ VM_STATS_PROC(v_laundry_count, "Pages eligible for > lau > > > VM_STATS_UINT(v_pageout_free_min, "Min pages reserved for kernel"); > > > VM_STATS_UINT(v_interrupt_free_min, "Reserved pages for interrupt > code"); > > > VM_STATS_UINT(v_free_severe, "Severe page depletion point"); > > > + > > > +SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, > > > + &vm_user_wire_count, 0, "User-wired virtual memory"); > > > > > > #ifdef COMPAT_FREEBSD11 > > > /* > > > > > > Modified: head/sys/vm/vm_mmap.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_mmap.c Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_mmap.c Mon May 13 16:38:48 2019 (r347532) > > > @@ -1003,7 +1003,7 @@ kern_mlock(struct proc *proc, struct ucred > *cred, uint > > > if (last < addr || end < addr) > > > return (EINVAL); > > > npages = atop(end - start); > > > - if (npages > vm_page_max_wired) > > > + if (npages > vm_page_max_user_wired) > > > return (ENOMEM); > > > map = &proc->p_vmspace->vm_map; > > > PROC_LOCK(proc); > > > @@ -1013,8 +1013,6 @@ kern_mlock(struct proc *proc, struct ucred > *cred, uint > > > return (ENOMEM); > > > } > > > PROC_UNLOCK(proc); > > > - if (npages + vm_wire_count() > vm_page_max_wired) > > > - return (EAGAIN); > > > #ifdef RACCT > > > if (racct_enable) { > > > PROC_LOCK(proc); > > > @@ -1091,7 +1089,12 @@ sys_mlockall(struct thread *td, struct > mlockall_args * > > > */ > > > error = vm_map_wire(map, vm_map_min(map), vm_map_max(map), > > > VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); > > > - error = (error == KERN_SUCCESS ? 0 : EAGAIN); > > > + if (error == KERN_SUCCESS) > > > + error = 0; > > > + else if (error == KERN_RESOURCE_SHORTAGE) > > > + error = ENOMEM; > > > + else > > > + error = EAGAIN; > > > } > > > #ifdef RACCT > > > if (racct_enable && error != KERN_SUCCESS) { > > > @@ -1558,10 +1561,16 @@ vm_mmap_object(vm_map_t map, vm_offset_t > *addr, vm_siz > > > * If the process has requested that all future mappings > > > * be wired, then heed this. > > > */ > > > - if (map->flags & MAP_WIREFUTURE) { > > > - vm_map_wire(map, *addr, *addr + size, > > > - VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? > > > - VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); > > > + if ((map->flags & MAP_WIREFUTURE) != 0) { > > > + vm_map_lock(map); > > > + if ((map->flags & MAP_WIREFUTURE) != 0) > > > + rv = vm_map_wire_locked(map, *addr, > > > + *addr + size, VM_MAP_WIRE_USER | > > > + ((flags & MAP_STACK) ? > VM_MAP_WIRE_HOLESOK : > > > + VM_MAP_WIRE_NOHOLES)); > > > + if (rv != KERN_SUCCESS) > > > + (void)vm_map_delete(map, *addr, *addr + > size); > > > + vm_map_unlock(map); > > > } > > > } > > > return (vm_mmap_to_errno(rv)); > > > > > > Modified: head/sys/vm/vm_pageout.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_pageout.c Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/sys/vm/vm_pageout.c Mon May 13 16:38:48 2019 > (r347532) > > > @@ -194,9 +194,10 @@ SYSCTL_UINT(_vm, OID_AUTO, > background_launder_max, CTL > > > > > > int vm_pageout_page_count = 32; > > > > > > -int vm_page_max_wired; /* XXX max # of wired pages > system-wide */ > > > -SYSCTL_INT(_vm, OID_AUTO, max_wired, > > > - CTLFLAG_RW, &vm_page_max_wired, 0, "System-wide limit to wired > page count"); > > > +u_long vm_page_max_user_wired; > > > +SYSCTL_ULONG(_vm, OID_AUTO, max_user_wired, CTLFLAG_RW, > > > + &vm_page_max_user_wired, 0, > > > + "system-wide limit to user-wired page count"); > > > > > > static u_int isqrt(u_int num); > > > static int vm_pageout_launder(struct vm_domain *vmd, int launder, > > > @@ -2041,8 +2042,8 @@ vm_pageout_init(void) > > > if (vm_pageout_update_period == 0) > > > vm_pageout_update_period = 600; > > > > > > - if (vm_page_max_wired == 0) > > > - vm_page_max_wired = freecount / 3; > > > + if (vm_page_max_user_wired == 0) > > > + vm_page_max_user_wired = freecount / 3; > > > } > > > > > > /* > > > > > > Modified: head/sys/vm/vm_pageout.h > > > ============================================================ > ================== > > > --- head/sys/vm/vm_pageout.h Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/sys/vm/vm_pageout.h Mon May 13 16:38:48 2019 > (r347532) > > > @@ -75,7 +75,7 @@ > > > * Exported data structures. > > > */ > > > > > > -extern int vm_page_max_wired; > > > +extern u_long vm_page_max_user_wired; > > > extern int vm_pageout_page_count; > > > > > > #define VM_OOM_MEM 1 > > > > > > Modified: head/sys/vm/vm_unix.c > > > ============================================================ > ================== > > > --- head/sys/vm/vm_unix.c Mon May 13 15:39:54 2019 (r347531) > > > +++ head/sys/vm/vm_unix.c Mon May 13 16:38:48 2019 (r347532) > > > @@ -95,13 +95,11 @@ kern_break(struct thread *td, uintptr_t *addr) > > > rlim_t datalim, lmemlim, vmemlim; > > > int prot, rv; > > > int error = 0; > > > - boolean_t do_map_wirefuture; > > > > > > datalim = lim_cur(td, RLIMIT_DATA); > > > lmemlim = lim_cur(td, RLIMIT_MEMLOCK); > > > vmemlim = lim_cur(td, RLIMIT_VMEM); > > > > > > - do_map_wirefuture = FALSE; > > > new = round_page(*addr); > > > vm_map_lock(map); > > > > > > @@ -184,7 +182,14 @@ kern_break(struct thread *td, uintptr_t *addr) > > > if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32)) > > > prot |= VM_PROT_EXECUTE; > > > #endif > > > - rv = vm_map_insert(map, NULL, 0, old, new, prot, > VM_PROT_ALL, 0); > > > + rv = vm_map_insert(map, NULL, 0, old, new, prot, > VM_PROT_ALL, > > > + 0); > > > + if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != > 0) { > > > + rv = vm_map_wire_locked(map, old, new, > > > + VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); > > > + if (rv != KERN_SUCCESS) > > > + vm_map_delete(map, old, new); > > > + } > > > if (rv != KERN_SUCCESS) { > > > #ifdef RACCT > > > if (racct_enable) { > > > @@ -205,17 +210,6 @@ kern_break(struct thread *td, uintptr_t *addr) > > > goto done; > > > } > > > vm->vm_dsize += btoc(new - old); > > > - /* > > > - * Handle the MAP_WIREFUTURE case for legacy applications, > > > - * by marking the newly mapped range of pages as wired. > > > - * We are not required to perform a corresponding > > > - * vm_map_unwire() before vm_map_delete() below, as > > > - * it will forcibly unwire the pages in the range. > > > - * > > > - * XXX If the pages cannot be wired, no error is returned. > > > - */ > > > - if ((map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) > > > - do_map_wirefuture = TRUE; > > > } else if (new < old) { > > > rv = vm_map_delete(map, new, old); > > > if (rv != KERN_SUCCESS) { > > > @@ -238,10 +232,6 @@ kern_break(struct thread *td, uintptr_t *addr) > > > } > > > done: > > > vm_map_unlock(map); > > > - > > > - if (do_map_wirefuture) > > > - (void) vm_map_wire(map, old, new, > > > - VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); > > > > > > if (error == 0) > > > *addr = new; > > > > > > Modified: head/usr.bin/vmstat/vmstat.c > > > ============================================================ > ================== > > > --- head/usr.bin/vmstat/vmstat.c Mon May 13 15:39:54 2019 > (r347531) > > > +++ head/usr.bin/vmstat/vmstat.c Mon May 13 16:38:48 2019 > (r347532) > > > @@ -156,6 +156,7 @@ static struct __vmmeter { > > > u_int v_free_min; > > > u_int v_free_count; > > > u_int v_wire_count; > > > + u_long v_user_wire_count; > > > u_int v_active_count; > > > u_int v_inactive_target; > > > u_int v_inactive_count; > > > @@ -566,6 +567,7 @@ fill_vmmeter(struct __vmmeter *vmmp) > > > GET_VM_STATS(vm, v_free_min); > > > GET_VM_STATS(vm, v_free_count); > > > GET_VM_STATS(vm, v_wire_count); > > > + GET_VM_STATS(vm, v_user_wire_count); > > > GET_VM_STATS(vm, v_active_count); > > > GET_VM_STATS(vm, v_inactive_target); > > > GET_VM_STATS(vm, v_inactive_count); > > > @@ -1057,6 +1059,8 @@ dosum(void) > > > sum.v_laundry_count); > > > xo_emit("{:wired-pages/%9u} {N:pages wired down}\n", > > > sum.v_wire_count); > > > + xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages > wired " > > > + "down}\n", sum.v_user_wire_count); > > > xo_emit("{:free-pages/%9u} {N:pages free}\n", > > > sum.v_free_count); > > > xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", > sum.v_page_size); > > > > > > > > > > -- > > Rod Grimes > rgrimes@freebsd.org > > > > > > -- > Rod Grimes > rgrimes@freebsd.org > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" > From owner-svn-src-all@freebsd.org Mon May 13 18:40:02 2019 Return-Path: Delivered-To: svn-src-all@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 047C41597ECC; Mon, 13 May 2019 18:40:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9C5BB8EB48; Mon, 13 May 2019 18:40:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A5E7DCA4; Mon, 13 May 2019 18:40:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DIe1bX049160; Mon, 13 May 2019 18:40:01 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DIe1E0049159; Mon, 13 May 2019 18:40:01 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131840.x4DIe1E0049159@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 18:40:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347541 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 347541 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9C5BB8EB48 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:40:02 -0000 Author: markj Date: Mon May 13 18:40:01 2019 New Revision: 347541 URL: https://svnweb.freebsd.org/changeset/base/347541 Log: Restore the pre-r347532 behaviour of ignoring wiring failures in mmap(). The error handling added in r347532 is not right when mapping vnodes and will be fixed separately. Reported by: syzbot+1d2cc393bd6c88a548be@syzkaller.appspotmail.com MFC with: r347532 Modified: head/sys/vm/vm_mmap.c Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Mon May 13 18:28:40 2019 (r347540) +++ head/sys/vm/vm_mmap.c Mon May 13 18:40:01 2019 (r347541) @@ -1564,12 +1564,10 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz if ((map->flags & MAP_WIREFUTURE) != 0) { vm_map_lock(map); if ((map->flags & MAP_WIREFUTURE) != 0) - rv = vm_map_wire_locked(map, *addr, + (void)vm_map_wire_locked(map, *addr, *addr + size, VM_MAP_WIRE_USER | ((flags & MAP_STACK) ? VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES)); - if (rv != KERN_SUCCESS) - (void)vm_map_delete(map, *addr, *addr + size); vm_map_unlock(map); } } From owner-svn-src-all@freebsd.org Mon May 13 18:48:09 2019 Return-Path: Delivered-To: svn-src-all@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 AED651598106; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 542648EFD5; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28DCEDE3E; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DIm9oh054360; Mon, 13 May 2019 18:48:09 GMT (envelope-from shurd@FreeBSD.org) Received: (from shurd@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DIm8hG054346; Mon, 13 May 2019 18:48:08 GMT (envelope-from shurd@FreeBSD.org) Message-Id: <201905131848.x4DIm8hG054346@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: shurd set sender to shurd@FreeBSD.org using -f From: Stephen Hurd Date: Mon, 13 May 2019 18:48:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347542 - in stable/12: share/man/man4 sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: shurd X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/net X-SVN-Commit-Revision: 347542 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 542648EFD5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:48:10 -0000 Author: shurd Date: Mon May 13 18:48:08 2019 New Revision: 347542 URL: https://svnweb.freebsd.org/changeset/base/347542 Log: MFC r346708: iflib: Better control over queue core assignment By default, cores are now assigned to queues in a sequential manner rather than all NICs starting at the first core. On a four-core system with two NICs each using two queue pairs, the nic:queue -> core mapping has changed from this: 0:0 -> 0, 0:1 -> 1 1:0 -> 0, 1:1 -> 1 To this: 0:0 -> 0, 0:1 -> 1 1:0 -> 2, 1:1 -> 3 Additionally, a device can now be configured to use separate cores for TX and RX queues. Two new tunables have been added, dev.X.Y.iflib.separate_txrx and dev.X.Y.iflib.core_offset. If core_offset is set, the NIC is not part of the auto-assigned sequence. Reviewed by: marius Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D20029 Modified: stable/12/share/man/man4/iflib.4 stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/iflib.4 ============================================================================== --- stable/12/share/man/man4/iflib.4 Mon May 13 18:40:01 2019 (r347541) +++ stable/12/share/man/man4/iflib.4 Mon May 13 18:48:08 2019 (r347542) @@ -55,6 +55,16 @@ If zero, the number of TX queues is derived from the n socket connected to the controller. .It Va disable_msix Disables MSI-X interrupts for the device. +.It Va core_offset +Specifies a starting core offset to assign queues to. +If the value is unspecified or 65535, cores are assigned sequentially across +controllers. +.It Va separate_txrx +Requests that RX and TX queues not be paired on the same core. +If this is zero or not set, an RX and TX queue pair will be assigned to each +core. +When set to a non-zero value, TX queues are assigned to cores following the +last RX queue. .El .Pp These Modified: stable/12/sys/net/iflib.c ============================================================================== --- stable/12/sys/net/iflib.c Mon May 13 18:40:01 2019 (r347541) +++ stable/12/sys/net/iflib.c Mon May 13 18:48:08 2019 (r347542) @@ -191,6 +191,9 @@ struct iflib_ctx { uint16_t ifc_sysctl_qs_eq_override; uint16_t ifc_sysctl_rx_budget; uint16_t ifc_sysctl_tx_abdicate; + uint16_t ifc_sysctl_core_offset; +#define CORE_OFFSET_UNSPECIFIED 0xffff + uint8_t ifc_sysctl_separate_txrx; qidx_t ifc_sysctl_ntxds[8]; qidx_t ifc_sysctl_nrxds[8]; @@ -728,6 +731,18 @@ static void iflib_free_intr_mem(if_ctx_t ctx); static struct mbuf * iflib_fixup_rx(struct mbuf *m); #endif +static SLIST_HEAD(cpu_offset_list, cpu_offset) cpu_offsets = + SLIST_HEAD_INITIALIZER(cpu_offsets); +struct cpu_offset { + SLIST_ENTRY(cpu_offset) entries; + cpuset_t set; + unsigned int refcount; + uint16_t offset; +}; +static struct mtx cpu_offset_mtx; +MTX_SYSINIT(iflib_cpu_offset, &cpu_offset_mtx, "iflib_cpu_offset lock", + MTX_DEF); + NETDUMP_DEFINE(iflib); #ifdef DEV_NETMAP @@ -4401,6 +4416,71 @@ iflib_reset_qvalues(if_ctx_t ctx) } } +static uint16_t +get_ctx_core_offset(if_ctx_t ctx) +{ + if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; + struct cpu_offset *op; + uint16_t qc; + uint16_t ret = ctx->ifc_sysctl_core_offset; + + if (ret != CORE_OFFSET_UNSPECIFIED) + return (ret); + + if (ctx->ifc_sysctl_separate_txrx) + qc = scctx->isc_ntxqsets + scctx->isc_nrxqsets; + else + qc = max(scctx->isc_ntxqsets, scctx->isc_nrxqsets); + + mtx_lock(&cpu_offset_mtx); + SLIST_FOREACH(op, &cpu_offsets, entries) { + if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) { + ret = op->offset; + op->offset += qc; + MPASS(op->refcount < UINT_MAX); + op->refcount++; + break; + } + } + if (ret == CORE_OFFSET_UNSPECIFIED) { + ret = 0; + op = malloc(sizeof(struct cpu_offset), M_IFLIB, + M_NOWAIT | M_ZERO); + if (op == NULL) { + device_printf(ctx->ifc_dev, + "allocation for cpu offset failed.\n"); + } else { + op->offset = qc; + op->refcount = 1; + CPU_COPY(&ctx->ifc_cpus, &op->set); + SLIST_INSERT_HEAD(&cpu_offsets, op, entries); + } + } + mtx_unlock(&cpu_offset_mtx); + + return (ret); +} + +static void +unref_ctx_core_offset(if_ctx_t ctx) +{ + struct cpu_offset *op, *top; + + mtx_lock(&cpu_offset_mtx); + SLIST_FOREACH_SAFE(op, &cpu_offsets, entries, top) { + if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) { + MPASS(op->refcount > 0); + op->refcount--; + if (op->refcount == 0) { + SLIST_REMOVE(&cpu_offsets, op, cpu_offset, entries); + free(op, M_IFLIB); + } + break; + } + } + mtx_unlock(&cpu_offset_mtx); +} + int iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ctxp) { @@ -4551,6 +4631,11 @@ iflib_device_register(device_t dev, void *sc, if_share goto fail_queues; /* + * Now that we know how many queues there are, get the core offset. + */ + ctx->ifc_sysctl_core_offset = get_ctx_core_offset(ctx); + + /* * Group taskqueues aren't properly set up until SMP is started, * so we disable interrupts until we can handle them post * SI_SUB_SMP. @@ -4971,6 +5056,7 @@ iflib_device_deregister(if_ctx_t ctx) iflib_rx_structures_free(ctx); if (ctx->ifc_flags & IFC_SC_ALLOCATED) free(ctx->ifc_softc, M_IFLIB); + unref_ctx_core_offset(ctx); STATE_LOCK_DESTROY(ctx); free(ctx, M_IFLIB); return (0); @@ -5589,7 +5675,7 @@ find_child_with_core(int cpu, struct cpu_group *grp) * Find the nth "close" core to the specified core * "close" is defined as the deepest level that shares * at least an L2 cache. With threads, this will be - * threads on the same core. If the sahred cache is L3 + * threads on the same core. If the shared cache is L3 * or higher, simply returns the same core. */ static int @@ -5671,10 +5757,12 @@ static inline int iflib_irq_set_affinity(if_ctx_t ctx, int irq, iflib_intr_type_t type, int qid, struct grouptask *gtask, struct taskqgroup *tqg, void *uniq, const char *name) { - int cpuid; - int err, tid; + int co, cpuid, err, tid; - cpuid = find_nth(ctx, qid); + co = ctx->ifc_sysctl_core_offset; + if (ctx->ifc_sysctl_separate_txrx && type == IFLIB_INTR_TX) + co += ctx->ifc_softc_ctx.isc_nrxqsets; + cpuid = find_nth(ctx, qid + co); tid = get_core_offset(ctx, type, qid); MPASS(tid >= 0); cpuid = find_close_core(cpuid, tid); @@ -6264,6 +6352,13 @@ iflib_add_device_sysctl_pre(if_ctx_t ctx) SYSCTL_ADD_U16(ctx_list, oid_list, OID_AUTO, "tx_abdicate", CTLFLAG_RWTUN, &ctx->ifc_sysctl_tx_abdicate, 0, "cause tx to abdicate instead of running to completion"); + ctx->ifc_sysctl_core_offset = CORE_OFFSET_UNSPECIFIED; + SYSCTL_ADD_U16(ctx_list, oid_list, OID_AUTO, "core_offset", + CTLFLAG_RDTUN, &ctx->ifc_sysctl_core_offset, 0, + "offset to start using cores at"); + SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "separate_txrx", + CTLFLAG_RDTUN, &ctx->ifc_sysctl_separate_txrx, 0, + "use separate cores for TX and RX"); /* XXX change for per-queue sizes */ SYSCTL_ADD_PROC(ctx_list, oid_list, OID_AUTO, "override_ntxds", From owner-svn-src-all@freebsd.org Mon May 13 18:48:10 2019 Return-Path: Delivered-To: svn-src-all@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 F1CA21598107; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 975608EFD6; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6F663DE3F; Mon, 13 May 2019 18:48:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DIm9Tl054371; Mon, 13 May 2019 18:48:09 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DIm9ug054363; Mon, 13 May 2019 18:48:09 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905131848.x4DIm9ug054363@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 13 May 2019 18:48:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347543 - in head: . sys/sys X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: . sys/sys X-SVN-Commit-Revision: 347543 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 975608EFD6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 18:48:10 -0000 Author: markj Date: Mon May 13 18:48:08 2019 New Revision: 347543 URL: https://svnweb.freebsd.org/changeset/base/347543 Log: Add an UPDATING entry and bump __FreeBSD_version for r347532. Reported by: rgrimes, Oliver Pinter Modified: head/UPDATING head/sys/sys/param.h Modified: head/UPDATING ============================================================================== --- head/UPDATING Mon May 13 18:48:08 2019 (r347542) +++ head/UPDATING Mon May 13 18:48:08 2019 (r347543) @@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20190513: + User-wired pages now have their own counter, + vm.stats.vm.v_user_wire_count. The vm.max_wired sysctl was renamed + to vm.max_user_wired and changed from an unsigned int to an unsigned + long. bhyve VMs wired with the -S are now subject to the user + wiring limit; the vm.max_user_wired sysctl may need to be tuned to + avoid running into the limit. + 20190507: The IPSEC option has been removed from GENERIC. Users requiring ipsec(4) must now load the ipsec(4) kernel module. Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Mon May 13 18:48:08 2019 (r347542) +++ head/sys/sys/param.h Mon May 13 18:48:08 2019 (r347543) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300024 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300025 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-all@freebsd.org Mon May 13 19:35:37 2019 Return-Path: Delivered-To: svn-src-all@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 EE533159957E; Mon, 13 May 2019 19:35:36 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9552F6A51F; Mon, 13 May 2019 19:35:36 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64B8BE69C; Mon, 13 May 2019 19:35:36 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DJZagc081656; Mon, 13 May 2019 19:35:36 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DJZafj081655; Mon, 13 May 2019 19:35:36 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201905131935.x4DJZafj081655@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 13 May 2019 19:35:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347546 - head/sys/dev/random X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/random X-SVN-Commit-Revision: 347546 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9552F6A51F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 19:35:37 -0000 Author: cem Date: Mon May 13 19:35:35 2019 New Revision: 347546 URL: https://svnweb.freebsd.org/changeset/base/347546 Log: Fortuna: Fix false negatives in is_random_seeded() (1) We may have had sufficient entropy to consider Fortuna seeded, but the random_fortuna_seeded() function would produce a false negative if fs_counter was still zero. This condition could arise after random_harvestq_prime() processed the /boot/entropy file and before any read-type operation invoked "pre_read()." Fortuna's fs_counter variable is only incremented (if certain conditions are met) by reseeding, which is invoked by random_fortuna_pre_read(). is_random_seeded(9) was introduced in r346282, but the function was unused prior to r346358, which introduced this regression. The regression broke initial seeding of arc4random(9) and broke periodic reseeding[A], until something other than arc4random(9) invoked read_random(9) or read_random_uio(9) directly. (Such as userspace getrandom(2) or read(2) of /dev/random. By default, /etc/rc.d/random does this during multiuser start-up.) (2) The conditions under which Fortuna will reseed (including initial seeding) are: (a) sufficient "entropy" (by sheer byte count; default 64) is collected in the zeroth pool (of 32 pools), and (b) it has been at least 100ms since the last reseed (to prevent trivial DoS; part of FS&K design). Prior to this revision, initial seeding might have been prevented if the reseed function was invoked during the first 100ms of boot. This revision addresses both of these issues. If random_fortuna_seeded() observes a zero fs_counter, it invokes random_fortuna_pre_read() and checks again. This addresses the problem where entropy actually was sufficient, but nothing had attempted a read -> pre_read yet. The second change is to disable the 100ms reseed guard when Fortuna has never been seeded yet (fs_lasttime == 0). The guard is intended to prevent gratuitous subsequent reseeds, not initial seeding! Machines running CURRENT between r346358 and this revision are encouraged to refresh when possible. Keys generated by userspace with /dev/random or getrandom(9) during this timeframe are safe, but any long-term session keys generated by kernel arc4random consumers are potentially suspect. [A]: Broken in the sense that is_random_seeded(9) false negatives would cause arc4random(9) to (re-)seed with weak entropy (SHA256(cyclecount || FreeBSD_version)). PR: 237869 Reported by: delphij, dim Reviewed by: delphij Approved by: secteam(delphij) X-MFC-With: r346282, r346358 (if ever) Security: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D20239 Modified: head/sys/dev/random/fortuna.c Modified: head/sys/dev/random/fortuna.c ============================================================================== --- head/sys/dev/random/fortuna.c Mon May 13 19:31:09 2019 (r347545) +++ head/sys/dev/random/fortuna.c Mon May 13 19:35:35 2019 (r347546) @@ -130,6 +130,7 @@ static uint8_t zero_region[RANDOM_ZERO_BLOCKSIZE]; static void random_fortuna_pre_read(void); static void random_fortuna_read(uint8_t *, u_int); static bool random_fortuna_seeded(void); +static bool random_fortuna_seeded_internal(void); static void random_fortuna_process_event(struct harvest_event *); static void random_fortuna_init_alg(void *); static void random_fortuna_deinit_alg(void *); @@ -277,7 +278,7 @@ random_fortuna_reseed_internal(uint32_t *entropy_data, RANDOM_RESEED_ASSERT_LOCK_OWNED(); - seeded = random_fortuna_seeded(); + seeded = random_fortuna_seeded_internal(); if (seeded) { randomdev_getkey(&fortuna_state.fs_key, &keymaterial, &keysz); KASSERT(keysz == RANDOM_KEYSIZE, ("%s: key size %zu not %u", @@ -377,8 +378,12 @@ random_fortuna_pre_read(void) if (fortuna_state.fs_pool[0].fsp_length < fortuna_state.fs_minpoolsize #ifdef _KERNEL - /* FS&K - Use 'getsbinuptime()' to prevent reseed-spamming. */ - || (now - fortuna_state.fs_lasttime <= SBT_1S/10) + /* + * FS&K - Use 'getsbinuptime()' to prevent reseed-spamming, but do + * not block initial seeding (fs_lasttime == 0). + */ + || (__predict_true(fortuna_state.fs_lasttime != 0) && + now - fortuna_state.fs_lasttime <= SBT_1S/10) #endif ) { RANDOM_RESEED_UNLOCK(); @@ -460,7 +465,13 @@ SYSCTL_BOOL(_kern_random, OID_AUTO, block_seeded_statu "unavailable."); #endif -bool +static bool +random_fortuna_seeded_internal(void) +{ + return (!uint128_is_zero(fortuna_state.fs_counter)); +} + +static bool random_fortuna_seeded(void) { @@ -469,5 +480,14 @@ random_fortuna_seeded(void) return (false); #endif - return (!uint128_is_zero(fortuna_state.fs_counter)); + if (__predict_true(random_fortuna_seeded_internal())) + return (true); + + /* + * Maybe we have enough entropy in the zeroth pool but just haven't + * kicked the initial seed step. Do so now. + */ + random_fortuna_pre_read(); + + return (random_fortuna_seeded_internal()); } From owner-svn-src-all@freebsd.org Mon May 13 19:38:02 2019 Return-Path: Delivered-To: svn-src-all@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 CECA21599635; Mon, 13 May 2019 19:38:01 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-it1-x12a.google.com (mail-it1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 6BD2E6A711; Mon, 13 May 2019 19:38:01 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-it1-x12a.google.com with SMTP id q65so1057780itg.2; Mon, 13 May 2019 12:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Nk/8sfq4Tok6/qoaRcuxwjKDdJ7+AcJxrUL1JPkWuSo=; b=eOlG81UDgtTjgXQM4Swf2wWDXzheb/s83nRSVDE+unXPHmiPL6BI+AlTBB+lUir0e7 1MHnhbnDbcv1Pf/VdvroChX89cm1q//GgCDVzIYJUC536ME3kAWdkFp1SNIRNGplA2g3 q1CytoJ+QNOako3dUoQdwwK4VoXK3iFwEh5/systb8RlPLO2cbA2Hk+wufOH3QbvvAV9 tB7BjOPIAMEtRw9aK8XO2A6m9/0TV+jwYNfUUPJUn4wEHBlxCjOi9i7p4Xtj+r23ie8o dnOZA7DsABbbNZuC7EAiyO/Dm0mmoCSjIhEOxdYvp4+1+VUZ42E/2DohGeKdecI0Wo0I soDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Nk/8sfq4Tok6/qoaRcuxwjKDdJ7+AcJxrUL1JPkWuSo=; b=KCzPbFPidDhTuwVRop+X/BGaKtLt61LeK/RM/LtMdQ8iZfXqSOeagwYC6kYPnRBD+c /c8I3NbkHMq4KWadQ68BccDCdBuGRj0KeY3p4GB8u65vsBMoNnyOS/vsnXys6AR9MNS/ F2UsHX2QeJ2I0DB/VZIKPHZHE3+VPW6ewcuj5jcTgWtFhllOLnTVv9cve+OONpHrm5fs vbqS0URxxQrml519Y93eJFd1DPQTECWP5Ok5L9YeMshBqyp++UMA2BQyz5dcHiQnMb1g hp9W12lds1gt7YHkc3EQDfGjTSGf3EtAO6X1fy4BabPBzv9yzqcuFCy8qY7OeqDJzryJ vKag== X-Gm-Message-State: APjAAAU+SlItGJUnv/SspTtGXoY+8l9scowwQ/3kwzam0y8MdFpbKHpa UnESKLHBI+XxKieHpBb2IqaTktgu X-Google-Smtp-Source: APXvYqz25Uxd/oIkhBQr5gmjkhGRHhDlLZQ2FCbb0sagf5muWdtjfC1n6Tp+SEw/yc5riGl7eY80kg== X-Received: by 2002:a24:9412:: with SMTP id j18mr661915ite.124.1557776279730; Mon, 13 May 2019 12:37:59 -0700 (PDT) Received: from raichu (toroon0560w-lp140-01-69-159-36-31.dsl.bell.ca. [69.159.36.31]) by smtp.gmail.com with ESMTPSA id b1sm206699itd.12.2019.05.13.12.37.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 12:37:58 -0700 (PDT) Sender: Mark Johnston Date: Mon, 13 May 2019 15:37:54 -0400 From: Mark Johnston To: "Andrey V. Elsukov" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, melifaro@freebsd.org Subject: Re: svn commit: r347526 - head/sys/net Message-ID: <20190513193754.GA37655@raichu> References: <201905131345.x4DDjTRn092669@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201905131345.x4DDjTRn092669@repo.freebsd.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Rspamd-Queue-Id: 6BD2E6A711 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.990,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 19:38:02 -0000 On Mon, May 13, 2019 at 01:45:29PM +0000, Andrey V. Elsukov wrote: > Author: ae > Date: Mon May 13 13:45:28 2019 > New Revision: 347526 > URL: https://svnweb.freebsd.org/changeset/base/347526 > > Log: > Rework locking in BPF code to remove rwlock from fast path. > > On high packets rate the contention on rwlock in bpf_*tap*() functions > can lead to packets dropping. To avoid this, migrate this code to use > epoch(9) KPI and ConcurrencyKit's lists. > > * all lists changed to use CK_LIST; > * reference counting added to bpf_if and bpf_d; > * now bpf_if references ifnet and releases this reference on destroy; > * each bpf_d descriptor references bpf_if when it is attached; > * new struct bpf_program_buffer introduced to keep BPF filter programs; > * bpf_program_buffer, bpf_d and bpf_if structures are freed by > epoch_call(); > * bpf_freelist and ifnet_departure event are no longer needed, thus > both are removed; > > Reviewed by: melifaro > Sponsored by: Yandex LLC > Differential Revision: https://reviews.freebsd.org/D20224 This seems to introduce a possible recursion on the bpf cdev mutex. Now bpfwrite() holds the mutex over the if_output call, which may enter bpf_mtap() via bridge_transmit(), and bpf_mtap() may attempt to reacquire the mutex. From owner-svn-src-all@freebsd.org Mon May 13 20:17:56 2019 Return-Path: Delivered-To: svn-src-all@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 8085B159A2BF; Mon, 13 May 2019 20:17:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 278DE6C1EC; Mon, 13 May 2019 20:17:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 00BCFED6C; Mon, 13 May 2019 20:17:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DKHtfm003355; Mon, 13 May 2019 20:17:55 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DKHtvn003354; Mon, 13 May 2019 20:17:55 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905132017.x4DKHtvn003354@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 13 May 2019 20:17:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347549 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 347549 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 278DE6C1EC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 20:17:56 -0000 Author: ae Date: Mon May 13 20:17:55 2019 New Revision: 347549 URL: https://svnweb.freebsd.org/changeset/base/347549 Log: Avoid possible recursion on BPF_LOCK() in bpfwrite(). Release BPF_LOCK() before invoking if_output() and if_input(). Also enter epoch section before releasing lock, this should prevent access to ifnet that may be freed on interface detach. Reported by: markj Modified: head/sys/net/bpf.c Modified: head/sys/net/bpf.c ============================================================================== --- head/sys/net/bpf.c Mon May 13 19:48:57 2019 (r347548) +++ head/sys/net/bpf.c Mon May 13 20:17:55 2019 (r347549) @@ -1257,6 +1257,9 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag ro.ro_flags = RT_HAS_HEADER; } + /* Avoid possible recursion on BPFD_LOCK(). */ + NET_EPOCH_ENTER(et); + BPFD_UNLOCK(d); error = (*ifp->if_output)(ifp, m, &dst, &ro); if (error) counter_u64_add(d->bd_wdcount, 1); @@ -1267,8 +1270,8 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag else m_freem(mc); } + NET_EPOCH_EXIT(et); CURVNET_RESTORE(); - BPFD_UNLOCK(d); bpfd_rele(d); return (error); From owner-svn-src-all@freebsd.org Mon May 13 22:10:19 2019 Return-Path: Delivered-To: svn-src-all@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 11335159C120; Mon, 13 May 2019 22:10:19 +0000 (UTC) (envelope-from lwhsu.freebsd@gmail.com) Received: from mail-yw1-f68.google.com (mail-yw1-f68.google.com [209.85.161.68]) (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 8703A7070B; Mon, 13 May 2019 22:10:18 +0000 (UTC) (envelope-from lwhsu.freebsd@gmail.com) Received: by mail-yw1-f68.google.com with SMTP id q185so12318579ywe.3; Mon, 13 May 2019 15:10:18 -0700 (PDT) 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=qkKLrEaY9WbdrD28Mq3TG+CqxIXQHRdW62x4Zm5IjgY=; b=VvCWDt2WOlryOAMWe/qYxibEKkqLjeY1YJh0xewL8y81ETPjQ5G8X86v1SPD9RyA6U 8kQwioorRaZKirglMj871BYMivplJsg9o6XiQ7/1SJMfLwF4javdZy0Vwg4gkl8YSVaS IAXpdDCZzTwn9lIH1M/tQR4zT0uTi3jgBjT5nBNTMCXe6NEpNw8YA4lkLDH8QOuvqzA4 H/jiZBsX0wPBKgkM+HsItvVsEpt03Za6E7UEZxC8NtqiOZX9xLCeRPuSJo8e03qy3FAU 5fuzZvK5GHW+HjHyxjjWtN+rBrzW3hPduMK771BV1xzyNk0GB905+GDJLVFqeQ3YVrAZ VLug== X-Gm-Message-State: APjAAAUS/5gRMQ+WR3ZKZAlHL1ECez4vmPglSauXI5sBEIdboIlcJ0kp nASoeaBdZqtAPcN3tWrrVzUEEsRRC3cDLTDg9Ur2AnOLRtU= X-Google-Smtp-Source: APXvYqw0RHsct/N3piuNLJaYSO/FlXSuGJ0Hh73/Zo+Tvy8lbzDEFpMEMSqq0AaSwIEb4R0IsdwwNSIzD+Ib4xB4mbA= X-Received: by 2002:a81:a34a:: with SMTP id a71mr5002222ywh.318.1557785411817; Mon, 13 May 2019 15:10:11 -0700 (PDT) MIME-Version: 1.0 References: <201905131345.x4DDjTRn092669@repo.freebsd.org> <20190513193754.GA37655@raichu> In-Reply-To: <20190513193754.GA37655@raichu> From: Li-Wen Hsu Date: Mon, 13 May 2019 18:09:59 -0400 Message-ID: Subject: Re: svn commit: r347526 - head/sys/net To: Mark Johnston Cc: "Andrey V. Elsukov" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, melifaro@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 8703A7070B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.94 / 15.00]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; TAGGED_FROM(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 22:10:19 -0000 On Mon, May 13, 2019 at 3:38 PM Mark Johnston wrote: > > On Mon, May 13, 2019 at 01:45:29PM +0000, Andrey V. Elsukov wrote: > > Author: ae > > Date: Mon May 13 13:45:28 2019 > > New Revision: 347526 > > URL: https://svnweb.freebsd.org/changeset/base/347526 > > > > Log: > > Rework locking in BPF code to remove rwlock from fast path. > > > > On high packets rate the contention on rwlock in bpf_*tap*() functions > > can lead to packets dropping. To avoid this, migrate this code to use > > epoch(9) KPI and ConcurrencyKit's lists. > > > > * all lists changed to use CK_LIST; > > * reference counting added to bpf_if and bpf_d; > > * now bpf_if references ifnet and releases this reference on destroy; > > * each bpf_d descriptor references bpf_if when it is attached; > > * new struct bpf_program_buffer introduced to keep BPF filter programs; > > * bpf_program_buffer, bpf_d and bpf_if structures are freed by > > epoch_call(); > > * bpf_freelist and ifnet_departure event are no longer needed, thus > > both are removed; > > > > Reviewed by: melifaro > > Sponsored by: Yandex LLC > > Differential Revision: https://reviews.freebsd.org/D20224 > > This seems to introduce a possible recursion on the bpf cdev mutex. Now > bpfwrite() holds the mutex over the if_output call, which may enter > bpf_mtap() via bridge_transmit(), and bpf_mtap() may attempt to > reacquire the mutex. It does, the sys.netinet.fibs_test.arpresolve_checks_interface_fib case can trigger a panic: root@:/usr/tests/sys/netinet # kyua test fibs_test:arpresolve_checks_interface_fib fibs_test:arpresolve_checks_interface_fib -> panic: _mtx_lock_sleep: recursed on non-recursive mutex bpf @ /usr/src/sys/net/bpf.c:2325 From owner-svn-src-all@freebsd.org Mon May 13 22:17:12 2019 Return-Path: Delivered-To: svn-src-all@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 9CE97159C3A4; Mon, 13 May 2019 22:17:12 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35B5770B43; Mon, 13 May 2019 22:17:12 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B619B1818F; Mon, 13 May 2019 22:17:11 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DMHBrL066372; Mon, 13 May 2019 22:17:11 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DMHBr7066371; Mon, 13 May 2019 22:17:11 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201905132217.x4DMHBr7066371@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Mon, 13 May 2019 22:17:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347553 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 347553 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 35B5770B43 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 22:17:12 -0000 Author: tsoome Date: Mon May 13 22:17:11 2019 New Revision: 347553 URL: https://svnweb.freebsd.org/changeset/base/347553 Log: loader: fix memory handling errors in module.c file_loadraw(): check for file_alloc() and strdup() results. we leak 'name'. mod_load() does leak 'filename'. mod_loadkld() does not need to check fp, file_discard() does check. Modified: head/stand/common/module.c Modified: head/stand/common/module.c ============================================================================== --- head/stand/common/module.c Mon May 13 20:57:21 2019 (r347552) +++ head/stand/common/module.c Mon May 13 22:17:11 2019 (r347553) @@ -499,7 +499,14 @@ file_loadraw(const char *fname, char *type, int insert /* Looks OK so far; create & populate control structure */ fp = file_alloc(); - fp->f_name = strdup(name); + if (fp == NULL) { + snprintf(command_errbuf, sizeof (command_errbuf), + "no memory to load %s", name); + free(name); + close(fd); + return (NULL); + } + fp->f_name = name; fp->f_type = strdup(type); fp->f_args = NULL; fp->f_metadata = NULL; @@ -507,6 +514,13 @@ file_loadraw(const char *fname, char *type, int insert fp->f_addr = loadaddr; fp->f_size = laddr - loadaddr; + if (fp->f_type == NULL) { + snprintf(command_errbuf, sizeof (command_errbuf), + "no memory to load %s", name); + free(name); + close(fd); + return (NULL); + } /* recognise space consumption */ loadaddr = laddr; @@ -552,6 +566,7 @@ mod_load(char *modname, struct mod_depend *verinfo, in return (ENOENT); } err = mod_loadkld(filename, argc, argv); + free(filename); return (err); } @@ -607,7 +622,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[ snprintf(command_errbuf, sizeof(command_errbuf), "don't know how to load module '%s'", filename); } - if (err && fp) + if (err) file_discard(fp); free(filename); return (err); From owner-svn-src-all@freebsd.org Mon May 13 23:37:46 2019 Return-Path: Delivered-To: svn-src-all@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 18213159D78E; Mon, 13 May 2019 23:37:46 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F4D372A3C; Mon, 13 May 2019 23:37:45 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5D38718ED0; Mon, 13 May 2019 23:37:45 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DNbjDa008732; Mon, 13 May 2019 23:37:45 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DNbiVs008730; Mon, 13 May 2019 23:37:44 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201905132337.x4DNbiVs008730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 13 May 2019 23:37:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347555 - in head: . sys/kern X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: . sys/kern X-SVN-Commit-Revision: 347555 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9F4D372A3C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.955,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 13 May 2019 23:37:46 -0000 Author: cem Date: Mon May 13 23:37:44 2019 New Revision: 347555 URL: https://svnweb.freebsd.org/changeset/base/347555 Log: Revert r346292 (permit_nonrandom_stackcookies) We have a better, more comprehensive knob for this now: kern.random.initial_seeding.bypass_before_seeding=1. Requested by: delphij Sponsored by: Dell EMC Isilon Modified: head/UPDATING head/sys/kern/stack_protector.c Modified: head/UPDATING ============================================================================== --- head/UPDATING Mon May 13 23:30:06 2019 (r347554) +++ head/UPDATING Mon May 13 23:37:44 2019 (r347555) @@ -76,13 +76,6 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: produce warnings in dmesg when the conditions are met. 20190416: - The tunable "security.stack_protect.permit_nonrandom_cookies" may be - set to a non-zero value to boot systems that do not provide early - entropy. Otherwise, such systems may see the panic message: - "cannot initialize stack cookies because random device is not yet - seeded." - -20190416: The loadable random module KPI has changed; the random_infra_init() routine now requires a 3rd function pointer for a bool (*)(void) method that returns true if the random device is seeded (and Modified: head/sys/kern/stack_protector.c ============================================================================== --- head/sys/kern/stack_protector.c Mon May 13 23:30:06 2019 (r347554) +++ head/sys/kern/stack_protector.c Mon May 13 23:37:44 2019 (r347555) @@ -4,28 +4,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include #include long __stack_chk_guard[8] = {}; void __stack_chk_fail(void); -/* - * XXX This default is unsafe!!! We intend to change it after resolving issues - * with early entropy in the installer; some kinds of systems that do not use - * loader(8), such as riscv, aarch64, and power; and perhaps others that I am - * forgetting off the top of my head. - */ -static bool permit_nonrandom_cookies = true; - -SYSCTL_NODE(_security, OID_AUTO, stack_protect, CTLFLAG_RW, 0, - "-fstack-protect support"); -SYSCTL_BOOL(_security_stack_protect, OID_AUTO, permit_nonrandom_cookies, - CTLFLAG_RDTUN, &permit_nonrandom_cookies, 0, - "Allow stack guard to be used without real random cookies"); - void __stack_chk_fail(void) { @@ -39,37 +23,8 @@ __stack_chk_init(void *dummy __unused) size_t i; long guard[nitems(__stack_chk_guard)]; - if (is_random_seeded()) { - arc4rand(guard, sizeof(guard), 0); - for (i = 0; i < nitems(guard); i++) - __stack_chk_guard[i] = guard[i]; - return; - } - - if (permit_nonrandom_cookies) { - printf("%s: WARNING: Initializing stack protection with " - "non-random cookies!\n", __func__); - printf("%s: WARNING: This severely limits the benefit of " - "-fstack-protector!\n", __func__); - - /* - * The emperor is naked, but I rolled some dice and at least - * these values aren't zero. - */ - __stack_chk_guard[0] = (long)0xe7318d5959af899full; - __stack_chk_guard[1] = (long)0x35a9481c089348bfull; - __stack_chk_guard[2] = (long)0xde657fdc04117255ull; - __stack_chk_guard[3] = (long)0x0dd44c61c22e4a6bull; - __stack_chk_guard[4] = (long)0x0a5869a354edb0a5ull; - __stack_chk_guard[5] = (long)0x05cebfed255b5232ull; - __stack_chk_guard[6] = (long)0x270ffac137c4c72full; - __stack_chk_guard[7] = (long)0xd8141a789bad478dull; - _Static_assert(nitems(__stack_chk_guard) == 8, - "__stack_chk_guard doesn't have 8 items"); - return; - } - - panic("%s: cannot initialize stack cookies because random device is " - "not yet seeded", __func__); + arc4rand(guard, sizeof(guard), 0); + for (i = 0; i < nitems(guard); i++) + __stack_chk_guard[i] = guard[i]; } SYSINIT(stack_chk, SI_SUB_RANDOM, SI_ORDER_ANY, __stack_chk_init, NULL); From owner-svn-src-all@freebsd.org Tue May 14 00:24:44 2019 Return-Path: Delivered-To: svn-src-all@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 B3937159EE3B; Tue, 14 May 2019 00:24:44 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 4A7D174723; Tue, 14 May 2019 00:24:44 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-it1-x141.google.com with SMTP id q132so2112077itc.5; Mon, 13 May 2019 17:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qIuDtgOGHmeOp+qgq+hFNiFfd+yTXKCmcZ391Ja4QMs=; b=plWtn3OzgxaMrua51Mh7TOCud+6Hj2oC+DI4FtvoFl/cqRvrErw9UboCrtpyaemZWf ITue5HR3dLbjNHS4ku7FFUFCGWoL+Pjvn7Tnd0D0Dpr9Ocd07JFcz5AxgrWe0s7mFBvt BemWOmt2FC0vdUna50Q4LuCaALlgIIy1wfm0YS0yw2bNVAREE914Dnc269xnB5OHmkEA yK23zrC8iApy9eQH4gffSmnIhW1AEddgmW1hcbMm2ugBcMajtzqeVbCJhD321CSco2mO 3JWRwp9qNlYtgMBfOPrPp+AMXUYrt9JhG1nbS7RoQH8TvKyA5P9jGrE0LKQDatL/EPj5 OLcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=qIuDtgOGHmeOp+qgq+hFNiFfd+yTXKCmcZ391Ja4QMs=; b=lQhfImjrjLRWXGXfvaXrVIKOkx3JEHdVrlIppl8zlD3BNmj6rPLSjKneBd8UoG9zJw XsPjw+FT4xywanr4XQ07woh9x0ABDiPqf8OXxZlVKCWgJuR6vA/dqxbAtrQjWocfeOC0 KhzjGaPMFCNd7yweX92Hiz7LpTdn404DnOLxi5PMoXxJ4ueXt+gb7qFtRjMv36jxGCTl 8g509jTzV6fsCL40SqkDHPIqnncsiuXgElFeXDvxQx21qbcYdFmVctOewdj8Lf1vrF0/ AU95/0+XrYDy4BOT/ztXMgnga7IJMzkJ9++epO8+6Rs1RiGM4rvNcGHgWVKtqNMzKwpy cyww== X-Gm-Message-State: APjAAAW0L7fcfjcBXWK8z0ZPsbItWnuxi4wjs0OOvBLjdCLh5UmZeBwK r2ObytHq8XNGcs5sCqmJTbdEkHd7 X-Google-Smtp-Source: APXvYqwNmWc/zgyGk/D4WO+FgCYasutcEB1AqahypeqXVHcGA7gFOm2QpBtC/dNKE/0k2Q9UdxQi9g== X-Received: by 2002:a02:83ce:: with SMTP id j14mr21150179jah.61.1557793483118; Mon, 13 May 2019 17:24:43 -0700 (PDT) Received: from raichu (toroon0560w-lp140-01-69-159-36-31.dsl.bell.ca. [69.159.36.31]) by smtp.gmail.com with ESMTPSA id x23sm5092110iob.57.2019.05.13.17.24.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 17:24:42 -0700 (PDT) Sender: Mark Johnston Date: Mon, 13 May 2019 20:24:37 -0400 From: Mark Johnston To: Li-Wen Hsu Cc: "Andrey V. Elsukov" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, melifaro@freebsd.org Subject: Re: svn commit: r347526 - head/sys/net Message-ID: <20190514002437.GA51157@raichu> References: <201905131345.x4DDjTRn092669@repo.freebsd.org> <20190513193754.GA37655@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) X-Rspamd-Queue-Id: 4A7D174723 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.986,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 00:24:44 -0000 On Mon, May 13, 2019 at 06:09:59PM -0400, Li-Wen Hsu wrote: > On Mon, May 13, 2019 at 3:38 PM Mark Johnston wrote: > > > > On Mon, May 13, 2019 at 01:45:29PM +0000, Andrey V. Elsukov wrote: > > > Author: ae > > > Date: Mon May 13 13:45:28 2019 > > > New Revision: 347526 > > > URL: https://svnweb.freebsd.org/changeset/base/347526 > > > > > > Log: > > > Rework locking in BPF code to remove rwlock from fast path. > > > > > > On high packets rate the contention on rwlock in bpf_*tap*() functions > > > can lead to packets dropping. To avoid this, migrate this code to use > > > epoch(9) KPI and ConcurrencyKit's lists. > > > > > > * all lists changed to use CK_LIST; > > > * reference counting added to bpf_if and bpf_d; > > > * now bpf_if references ifnet and releases this reference on destroy; > > > * each bpf_d descriptor references bpf_if when it is attached; > > > * new struct bpf_program_buffer introduced to keep BPF filter programs; > > > * bpf_program_buffer, bpf_d and bpf_if structures are freed by > > > epoch_call(); > > > * bpf_freelist and ifnet_departure event are no longer needed, thus > > > both are removed; > > > > > > Reviewed by: melifaro > > > Sponsored by: Yandex LLC > > > Differential Revision: https://reviews.freebsd.org/D20224 > > > > This seems to introduce a possible recursion on the bpf cdev mutex. Now > > bpfwrite() holds the mutex over the if_output call, which may enter > > bpf_mtap() via bridge_transmit(), and bpf_mtap() may attempt to > > reacquire the mutex. > > It does, the sys.netinet.fibs_test.arpresolve_checks_interface_fib > case can trigger a panic: > > root@:/usr/tests/sys/netinet # kyua test > fibs_test:arpresolve_checks_interface_fib > fibs_test:arpresolve_checks_interface_fib -> panic: _mtx_lock_sleep: > recursed on non-recursive mutex bpf @ /usr/src/sys/net/bpf.c:2325 The problem should be fixed by r347549. From owner-svn-src-all@freebsd.org Tue May 14 00:34:09 2019 Return-Path: Delivered-To: svn-src-all@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 8D88E159F165; Tue, 14 May 2019 00:34:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2FE2A74B71; Tue, 14 May 2019 00:34:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 04A72198B1; Tue, 14 May 2019 00:34:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E0Y8Fg040717; Tue, 14 May 2019 00:34:08 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E0Y8u3040716; Tue, 14 May 2019 00:34:08 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905140034.x4E0Y8u3040716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 May 2019 00:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347556 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347556 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2FE2A74B71 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 00:34:09 -0000 Author: markj Date: Tue May 14 00:34:08 2019 New Revision: 347556 URL: https://svnweb.freebsd.org/changeset/base/347556 Log: MFC r347227: Simplify the test against maxproc in fork1(). Modified: stable/12/sys/kern/kern_fork.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_fork.c ============================================================================== --- stable/12/sys/kern/kern_fork.c Mon May 13 23:37:44 2019 (r347555) +++ stable/12/sys/kern/kern_fork.c Tue May 14 00:34:08 2019 (r347556) @@ -885,17 +885,20 @@ fork1(struct thread *td, struct fork_req *fr) * processes; don't let root exceed the limit. */ nprocs_new = atomic_fetchadd_int(&nprocs, 1) + 1; - if ((nprocs_new >= maxproc - 10 && priv_check_cred(td->td_ucred, - PRIV_MAXPROC, 0) != 0) || nprocs_new >= maxproc) { - error = EAGAIN; - sx_xlock(&allproc_lock); - if (ppsratecheck(&lastfail, &curfail, 1)) { - printf("maxproc limit exceeded by uid %u (pid %d); " - "see tuning(7) and login.conf(5)\n", - td->td_ucred->cr_ruid, p1->p_pid); + if (nprocs_new >= maxproc - 10) { + if (priv_check_cred(td->td_ucred, PRIV_MAXPROC, 0) != 0 || + nprocs_new >= maxproc) { + error = EAGAIN; + sx_xlock(&allproc_lock); + if (ppsratecheck(&lastfail, &curfail, 1)) { + printf("maxproc limit exceeded by uid %u " + "(pid %d); see tuning(7) and " + "login.conf(5)\n", + td->td_ucred->cr_ruid, p1->p_pid); + } + sx_xunlock(&allproc_lock); + goto fail2; } - sx_xunlock(&allproc_lock); - goto fail2; } /* From owner-svn-src-all@freebsd.org Tue May 14 02:00:14 2019 Return-Path: Delivered-To: svn-src-all@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 E5C7C15A10E9; Tue, 14 May 2019 02:00:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89FD676F15; Tue, 14 May 2019 02:00:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 653691A627; Tue, 14 May 2019 02:00:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E20DhL083821; Tue, 14 May 2019 02:00:13 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E20DjS083820; Tue, 14 May 2019 02:00:13 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201905140200.x4E20DjS083820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 14 May 2019 02:00:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347557 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Commit-Revision: 347557 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 89FD676F15 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 02:00:14 -0000 Author: kevans Date: Tue May 14 02:00:12 2019 New Revision: 347557 URL: https://svnweb.freebsd.org/changeset/base/347557 Log: MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld if_tun/if_tap mappings have been removed and the vmnet mapping has been updated to the if_tap module. MFC r347392: ifconfig(8): Partial revert of r347241 r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet can autoload the correct module on use. It also inadvertently made bogus some previously valid uses of sizeof(). Revert back to ifkind on the stack for simplicity sake. This reduces the diff from the previous version of ifmaybeload for easiser auditing. MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc Additionally, providing mappings makes the comparison for already loaded modules a little more strict. This should have been done at initial introduction, but there was no real reason- however, it proves necessary for enc which has a standard enc -> if_enc mapping but there also exists an 'enc' module that's actually CAM. The mapping lets us unambiguously determine the correct module. Modified: stable/11/sbin/ifconfig/ifconfig.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sbin/ifconfig/ifconfig.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/11/sbin/ifconfig/ifconfig.c Tue May 14 00:34:08 2019 (r347556) +++ stable/11/sbin/ifconfig/ifconfig.c Tue May 14 02:00:12 2019 (r347557) @@ -69,6 +69,7 @@ static const char rcsid[] = #ifdef JAIL #include #endif +#include #include #include #include @@ -125,6 +126,31 @@ struct ifa_order_elt { TAILQ_HEAD(ifa_queue, ifa_order_elt); +static struct module_map_entry { + const char *ifname; + const char *kldname; +} module_map[] = { + { + .ifname = "vmnet", + .kldname = "if_tap", + }, + { + .ifname = "ipsec", + .kldname = "ipsec", + }, + { + /* + * This mapping exists because there is a conflicting enc module + * in CAM. ifconfig's guessing behavior will attempt to match + * the ifname to a module as well as if_${ifname} and clash with + * CAM enc. This is an assertion of the correct module to load. + */ + .ifname = "enc", + .kldname = "if_enc", + }, +}; + + void opt_register(struct option *p) { @@ -1371,9 +1397,11 @@ ifmaybeload(const char *name) { #define MOD_PREFIX_LEN 3 /* "if_" */ struct module_stat mstat; - int fileid, modid; + int i, fileid, modid; char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp; const char *cp; + struct module_map_entry *mme; + bool found; /* loading suppressed by the user */ if (noload) @@ -1387,10 +1415,25 @@ ifmaybeload(const char *name) break; } - /* turn interface and unit into module name */ - strlcpy(ifkind, "if_", sizeof(ifkind)); - strlcat(ifkind, ifname, sizeof(ifkind)); + /* Either derive it from the map or guess otherwise */ + *ifkind = '\0'; + found = false; + for (i = 0; i < nitems(module_map); ++i) { + mme = &module_map[i]; + if (strcmp(mme->ifname, ifname) == 0) { + strlcpy(ifkind, mme->kldname, sizeof(ifkind)); + found = true; + break; + } + } + /* We didn't have an alias for it... we'll guess. */ + if (!found) { + /* turn interface and unit into module name */ + strlcpy(ifkind, "if_", sizeof(ifkind)); + strlcat(ifkind, ifname, sizeof(ifkind)); + } + /* scan files in kernel */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { @@ -1405,8 +1448,12 @@ ifmaybeload(const char *name) } else { cp = mstat.name; } - /* already loaded? */ - if (strcmp(ifname, cp) == 0 || + /* + * Is it already loaded? Don't compare with ifname if + * we were specifically told which kld to use. Doing + * so could lead to conflicts not trivially solved. + */ + if ((!found && strcmp(ifname, cp) == 0) || strcmp(ifkind, cp) == 0) return; } From owner-svn-src-all@freebsd.org Tue May 14 02:00:14 2019 Return-Path: Delivered-To: svn-src-all@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 465D015A10EF; Tue, 14 May 2019 02:00:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E078176F16; Tue, 14 May 2019 02:00:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BABF61A628; Tue, 14 May 2019 02:00:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E20DrO083827; Tue, 14 May 2019 02:00:13 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E20DTV083826; Tue, 14 May 2019 02:00:13 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201905140200.x4E20DTV083826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 14 May 2019 02:00:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347557 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Commit-Revision: 347557 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E078176F16 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 02:00:14 -0000 Author: kevans Date: Tue May 14 02:00:12 2019 New Revision: 347557 URL: https://svnweb.freebsd.org/changeset/base/347557 Log: MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld if_tun/if_tap mappings have been removed and the vmnet mapping has been updated to the if_tap module. MFC r347392: ifconfig(8): Partial revert of r347241 r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet can autoload the correct module on use. It also inadvertently made bogus some previously valid uses of sizeof(). Revert back to ifkind on the stack for simplicity sake. This reduces the diff from the previous version of ifmaybeload for easiser auditing. MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc Additionally, providing mappings makes the comparison for already loaded modules a little more strict. This should have been done at initial introduction, but there was no real reason- however, it proves necessary for enc which has a standard enc -> if_enc mapping but there also exists an 'enc' module that's actually CAM. The mapping lets us unambiguously determine the correct module. Modified: stable/12/sbin/ifconfig/ifconfig.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sbin/ifconfig/ifconfig.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/12/sbin/ifconfig/ifconfig.c Tue May 14 00:34:08 2019 (r347556) +++ stable/12/sbin/ifconfig/ifconfig.c Tue May 14 02:00:12 2019 (r347557) @@ -71,6 +71,7 @@ static const char rcsid[] = #ifdef JAIL #include #endif +#include #include #include #include @@ -130,6 +131,31 @@ struct ifa_order_elt { TAILQ_HEAD(ifa_queue, ifa_order_elt); +static struct module_map_entry { + const char *ifname; + const char *kldname; +} module_map[] = { + { + .ifname = "vmnet", + .kldname = "if_tap", + }, + { + .ifname = "ipsec", + .kldname = "ipsec", + }, + { + /* + * This mapping exists because there is a conflicting enc module + * in CAM. ifconfig's guessing behavior will attempt to match + * the ifname to a module as well as if_${ifname} and clash with + * CAM enc. This is an assertion of the correct module to load. + */ + .ifname = "enc", + .kldname = "if_enc", + }, +}; + + void opt_register(struct option *p) { @@ -1413,9 +1439,11 @@ ifmaybeload(const char *name) { #define MOD_PREFIX_LEN 3 /* "if_" */ struct module_stat mstat; - int fileid, modid; + int i, fileid, modid; char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp; const char *cp; + struct module_map_entry *mme; + bool found; /* loading suppressed by the user */ if (noload) @@ -1429,10 +1457,25 @@ ifmaybeload(const char *name) break; } - /* turn interface and unit into module name */ - strlcpy(ifkind, "if_", sizeof(ifkind)); - strlcat(ifkind, ifname, sizeof(ifkind)); + /* Either derive it from the map or guess otherwise */ + *ifkind = '\0'; + found = false; + for (i = 0; i < nitems(module_map); ++i) { + mme = &module_map[i]; + if (strcmp(mme->ifname, ifname) == 0) { + strlcpy(ifkind, mme->kldname, sizeof(ifkind)); + found = true; + break; + } + } + /* We didn't have an alias for it... we'll guess. */ + if (!found) { + /* turn interface and unit into module name */ + strlcpy(ifkind, "if_", sizeof(ifkind)); + strlcat(ifkind, ifname, sizeof(ifkind)); + } + /* scan files in kernel */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { @@ -1447,8 +1490,12 @@ ifmaybeload(const char *name) } else { cp = mstat.name; } - /* already loaded? */ - if (strcmp(ifname, cp) == 0 || + /* + * Is it already loaded? Don't compare with ifname if + * we were specifically told which kld to use. Doing + * so could lead to conflicts not trivially solved. + */ + if ((!found && strcmp(ifname, cp) == 0) || strcmp(ifkind, cp) == 0) return; } From owner-svn-src-all@freebsd.org Tue May 14 03:05:07 2019 Return-Path: Delivered-To: svn-src-all@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 870B915A30BC; Tue, 14 May 2019 03:05:07 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 28A1C81507; Tue, 14 May 2019 03:05:07 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 036EA1B232; Tue, 14 May 2019 03:05:07 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E35641022022; Tue, 14 May 2019 03:05:06 GMT (envelope-from ganbold@FreeBSD.org) Received: (from ganbold@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E356wE022021; Tue, 14 May 2019 03:05:06 GMT (envelope-from ganbold@FreeBSD.org) Message-Id: <201905140305.x4E356wE022021@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ganbold set sender to ganbold@FreeBSD.org using -f From: Ganbold Tsagaankhuu Date: Tue, 14 May 2019 03:05:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347558 - stable/11/sys/dev/usb/net X-SVN-Group: stable-11 X-SVN-Commit-Author: ganbold X-SVN-Commit-Paths: stable/11/sys/dev/usb/net X-SVN-Commit-Revision: 347558 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 28A1C81507 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 03:05:07 -0000 Author: ganbold Date: Tue May 14 03:05:06 2019 New Revision: 347558 URL: https://svnweb.freebsd.org/changeset/base/347558 Log: MFC r346028: Fix URE_WDT6_SET_MODE value in the register definition. Both linux and u-boot sources for RTL8152 driver has this value. RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet. This fixes RTL8152 USB ethernet not detected problem after reboot. Modified: stable/11/sys/dev/usb/net/if_urereg.h Modified: stable/11/sys/dev/usb/net/if_urereg.h ============================================================================== --- stable/11/sys/dev/usb/net/if_urereg.h Tue May 14 02:00:12 2019 (r347557) +++ stable/11/sys/dev/usb/net/if_urereg.h Tue May 14 03:05:06 2019 (r347558) @@ -176,7 +176,7 @@ #define URE_EEEP_CR_EEEP_TX 0x0002 /* PLA_WDT6_CTRL */ -#define URE_WDT6_SET_MODE 0x001 +#define URE_WDT6_SET_MODE 0x0010 /* PLA_TCR0 */ #define URE_TCR0_TX_EMPTY 0x0800 From owner-svn-src-all@freebsd.org Tue May 14 03:08:38 2019 Return-Path: Delivered-To: svn-src-all@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 AF6FC15A318A; Tue, 14 May 2019 03:08:38 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 53216816DB; Tue, 14 May 2019 03:08:38 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2AB841B262; Tue, 14 May 2019 03:08:38 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E38cAj022232; Tue, 14 May 2019 03:08:38 GMT (envelope-from ganbold@FreeBSD.org) Received: (from ganbold@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E38cMb022231; Tue, 14 May 2019 03:08:38 GMT (envelope-from ganbold@FreeBSD.org) Message-Id: <201905140308.x4E38cMb022231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ganbold set sender to ganbold@FreeBSD.org using -f From: Ganbold Tsagaankhuu Date: Tue, 14 May 2019 03:08:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347559 - stable/12/sys/dev/usb/net X-SVN-Group: stable-12 X-SVN-Commit-Author: ganbold X-SVN-Commit-Paths: stable/12/sys/dev/usb/net X-SVN-Commit-Revision: 347559 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 53216816DB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 03:08:38 -0000 Author: ganbold Date: Tue May 14 03:08:37 2019 New Revision: 347559 URL: https://svnweb.freebsd.org/changeset/base/347559 Log: MFC r346028: Fix URE_WDT6_SET_MODE value in the register definition. Both linux and u-boot sources for RTL8152 driver has this value. RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet. This fixes RTL8152 USB ethernet not detected problem after reboot. Modified: stable/12/sys/dev/usb/net/if_urereg.h Modified: stable/12/sys/dev/usb/net/if_urereg.h ============================================================================== --- stable/12/sys/dev/usb/net/if_urereg.h Tue May 14 03:05:06 2019 (r347558) +++ stable/12/sys/dev/usb/net/if_urereg.h Tue May 14 03:08:37 2019 (r347559) @@ -176,7 +176,7 @@ #define URE_EEEP_CR_EEEP_TX 0x0002 /* PLA_WDT6_CTRL */ -#define URE_WDT6_SET_MODE 0x001 +#define URE_WDT6_SET_MODE 0x0010 /* PLA_TCR0 */ #define URE_TCR0_TX_EMPTY 0x0800 From owner-svn-src-all@freebsd.org Tue May 14 04:14:33 2019 Return-Path: Delivered-To: svn-src-all@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 EA3A615A46AE; Tue, 14 May 2019 04:14:32 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BC3F83ACF; Tue, 14 May 2019 04:14:32 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 661641BE97; Tue, 14 May 2019 04:14:32 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E4EWIG059043; Tue, 14 May 2019 04:14:32 GMT (envelope-from obrien@FreeBSD.org) Received: (from obrien@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E4EWFe059042; Tue, 14 May 2019 04:14:32 GMT (envelope-from obrien@FreeBSD.org) Message-Id: <201905140414.x4E4EWFe059042@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: obrien set sender to obrien@FreeBSD.org using -f From: "David E. O'Brien" Date: Tue, 14 May 2019 04:14:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347561 - stable/11/lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: obrien X-SVN-Commit-Paths: stable/11/lib/libc/gen X-SVN-Commit-Revision: 347561 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8BC3F83ACF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 04:14:33 -0000 Author: obrien Date: Tue May 14 04:14:31 2019 New Revision: 347561 URL: https://svnweb.freebsd.org/changeset/base/347561 Log: MFC r344085: Note that readpassphrase() came into FreeBSD's libc at 4.6. Modified: stable/11/lib/libc/gen/readpassphrase.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/readpassphrase.3 ============================================================================== --- stable/11/lib/libc/gen/readpassphrase.3 Tue May 14 03:52:06 2019 (r347560) +++ stable/11/lib/libc/gen/readpassphrase.3 Tue May 14 04:14:31 2019 (r347561) @@ -178,4 +178,6 @@ extension and should not be used if portability is des The .Fn readpassphrase function first appeared in +.Fx 4.6 +and .Ox 2.9 . From owner-svn-src-all@freebsd.org Tue May 14 04:34:59 2019 Return-Path: Delivered-To: svn-src-all@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 9347715A4B68; Tue, 14 May 2019 04:34:59 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 28BAB8438D; Tue, 14 May 2019 04:34:59 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F13DB1C1EC; Tue, 14 May 2019 04:34:58 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4E4YwSH069627; Tue, 14 May 2019 04:34:58 GMT (envelope-from obrien@FreeBSD.org) Received: (from obrien@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4E4Yw6K069626; Tue, 14 May 2019 04:34:58 GMT (envelope-from obrien@FreeBSD.org) Message-Id: <201905140434.x4E4Yw6K069626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: obrien set sender to obrien@FreeBSD.org using -f From: "David E. O'Brien" Date: Tue, 14 May 2019 04:34:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r347562 - stable/10/lib/libc/gen X-SVN-Group: stable-10 X-SVN-Commit-Author: obrien X-SVN-Commit-Paths: stable/10/lib/libc/gen X-SVN-Commit-Revision: 347562 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 28BAB8438D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 04:34:59 -0000 Author: obrien Date: Tue May 14 04:34:58 2019 New Revision: 347562 URL: https://svnweb.freebsd.org/changeset/base/347562 Log: MF11 r347561. MFC r344085: Note that readpassphrase() came into FreeBSD's libc at 4.6. Modified: stable/10/lib/libc/gen/readpassphrase.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/readpassphrase.3 ============================================================================== --- stable/10/lib/libc/gen/readpassphrase.3 Tue May 14 04:14:31 2019 (r347561) +++ stable/10/lib/libc/gen/readpassphrase.3 Tue May 14 04:34:58 2019 (r347562) @@ -178,4 +178,6 @@ extension and should not be used if portability is des The .Fn readpassphrase function first appeared in +.Fx 4.6 +and .Ox 2.9 . From owner-svn-src-all@freebsd.org Tue May 14 10:21:29 2019 Return-Path: Delivered-To: svn-src-all@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 9AFD215AB209; Tue, 14 May 2019 10:21:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 42A188E3C4; Tue, 14 May 2019 10:21:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1CC931FBAC; Tue, 14 May 2019 10:21:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EALSCD053883; Tue, 14 May 2019 10:21:28 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EALSRO053882; Tue, 14 May 2019 10:21:28 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201905141021.x4EALSRO053882@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 14 May 2019 10:21:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347563 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 347563 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 42A188E3C4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.952,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 10:21:29 -0000 Author: ae Date: Tue May 14 10:21:28 2019 New Revision: 347563 URL: https://svnweb.freebsd.org/changeset/base/347563 Log: Remove bpf interface lock, it is no longer exist. Modified: head/sys/kern/subr_witness.c Modified: head/sys/kern/subr_witness.c ============================================================================== --- head/sys/kern/subr_witness.c Tue May 14 04:34:58 2019 (r347562) +++ head/sys/kern/subr_witness.c Tue May 14 10:21:28 2019 (r347563) @@ -576,7 +576,6 @@ static struct witness_order_list_entry order_lists[] = * BPF */ { "bpf global lock", &lock_class_sx }, - { "bpf interface lock", &lock_class_rw }, { "bpf cdev lock", &lock_class_mtx_sleep }, { NULL, NULL }, /* From owner-svn-src-all@freebsd.org Tue May 14 15:19:49 2019 Return-Path: Delivered-To: svn-src-all@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 42A9D15909F6; Tue, 14 May 2019 15:19:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DD014711EA; Tue, 14 May 2019 15:19:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B724722C30; Tue, 14 May 2019 15:19:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EFJmG7007334; Tue, 14 May 2019 15:19:48 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EFJmBj007333; Tue, 14 May 2019 15:19:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905141519.x4EFJmBj007333@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 May 2019 15:19:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347564 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 347564 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DD014711EA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 15:19:49 -0000 Author: markj Date: Tue May 14 15:19:48 2019 New Revision: 347564 URL: https://svnweb.freebsd.org/changeset/base/347564 Log: Fix formatting. MFC after: 3 days Modified: head/sys/amd64/amd64/trap.c Modified: head/sys/amd64/amd64/trap.c ============================================================================== --- head/sys/amd64/amd64/trap.c Tue May 14 10:21:28 2019 (r347563) +++ head/sys/amd64/amd64/trap.c Tue May 14 15:19:48 2019 (r347564) @@ -904,8 +904,8 @@ trap_fatal(frame, eva) code & PGEX_U ? "user" : "supervisor", code & PGEX_W ? "write" : "read", code & PGEX_I ? "instruction" : "data", - code & PGEX_PK ? " prot key" : " ", - code & PGEX_SGX ? " SGX" : " ", + code & PGEX_PK ? " prot key" : "", + code & PGEX_SGX ? " SGX" : "", code & PGEX_RSV ? "reserved bits in PTE" : code & PGEX_P ? "protection violation" : "page not present"); } From owner-svn-src-all@freebsd.org Tue May 14 15:41:35 2019 Return-Path: Delivered-To: svn-src-all@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 38EE71591420; Tue, 14 May 2019 15:41:35 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D2A4871D24; Tue, 14 May 2019 15:41:34 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AC5FA22FBA; Tue, 14 May 2019 15:41:34 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EFfY6P019679; Tue, 14 May 2019 15:41:34 GMT (envelope-from ygy@FreeBSD.org) Received: (from ygy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EFfYPT019678; Tue, 14 May 2019 15:41:34 GMT (envelope-from ygy@FreeBSD.org) Message-Id: <201905141541.x4EFfYPT019678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ygy set sender to ygy@FreeBSD.org using -f From: Guangyuan Yang Date: Tue, 14 May 2019 15:41:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347565 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: ygy X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 347565 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D2A4871D24 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 15:41:35 -0000 Author: ygy (doc committer) Date: Tue May 14 15:41:34 2019 New Revision: 347565 URL: https://svnweb.freebsd.org/changeset/base/347565 Log: Fix some spelling errors in ng_eiface(4). MFC after: 3 days PR: 237764 Submitted by: Tom Marcoen Modified: head/share/man/man4/ng_eiface.4 Modified: head/share/man/man4/ng_eiface.4 ============================================================================== --- head/share/man/man4/ng_eiface.4 Tue May 14 15:19:48 2019 (r347564) +++ head/share/man/man4/ng_eiface.4 Tue May 14 15:41:34 2019 (r347565) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 3, 2005 +.Dd May 14, 2019 .Dt NG_EIFACE 4 .Os .Sh NAME @@ -36,7 +36,7 @@ The .Vt eiface netgraph node implements the generic Ethernet interface. -When +When an .Vt eiface node is created, a new interface appears which is accessible via .Xr ifconfig 8 . @@ -78,7 +78,7 @@ which requires as an argument an string consisting of 6 colon-separated hex digits. .It Dv NGM_EIFACE_GET_IFNAME Pq Ic getifname Return the name of the associated interface as a -.Dv NUL Ns -terminated +.Dv NULL Ns -terminated .Tn ASCII string. .It Dv NGM_EIFACE_GET_IFADDRS @@ -97,7 +97,7 @@ Unlike most other node types, an .Vt eiface node does .Em not -go away when all hooks have been disconnected; rather, and explicit +go away when all hooks have been disconnected; rather, an explicit .Dv NGM_SHUTDOWN control message is required. .Sh SEE ALSO From owner-svn-src-all@freebsd.org Tue May 14 17:02:24 2019 Return-Path: Delivered-To: svn-src-all@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 691821592DDA; Tue, 14 May 2019 17:02:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1BC6A7464C; Tue, 14 May 2019 17:02:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E361423E30; Tue, 14 May 2019 17:02:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EH2NEY061073; Tue, 14 May 2019 17:02:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EH2LuD061054; Tue, 14 May 2019 17:02:21 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905141702.x4EH2LuD061054@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 14 May 2019 17:02:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347566 - in head/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 347566 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1BC6A7464C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 17:02:24 -0000 Author: kib Date: Tue May 14 17:02:20 2019 New Revision: 347566 URL: https://svnweb.freebsd.org/changeset/base/347566 Log: Mitigations for Microarchitectural Data Sampling. Microarchitectural buffers on some Intel processors utilizing speculative execution may allow a local process to obtain a memory disclosure. An attacker may be able to read secret data from the kernel or from a process when executing untrusted code (for example, in a web browser). Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00233.html Security: CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091 Security: FreeBSD-SA-19:07.mds Reviewed by: jhb Tested by: emaste, lwhsu Approved by: so (gtetlow) Modified: head/sys/amd64/amd64/exception.S head/sys/amd64/amd64/genassym.c head/sys/amd64/amd64/initcpu.c head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/support.S head/sys/amd64/include/pcpu.h head/sys/dev/cpuctl/cpuctl.c head/sys/i386/i386/exception.s head/sys/i386/i386/genassym.c head/sys/i386/i386/initcpu.c head/sys/i386/i386/support.s head/sys/i386/include/pcpu.h head/sys/x86/include/specialreg.h head/sys/x86/include/x86_var.h head/sys/x86/x86/cpu_machdep.c Modified: head/sys/amd64/amd64/exception.S ============================================================================== --- head/sys/amd64/amd64/exception.S Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/amd64/exception.S Tue May 14 17:02:20 2019 (r347566) @@ -512,6 +512,7 @@ fast_syscall_common: testl $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax) jne 3f call handle_ibrs_exit + callq *mds_handler /* Restore preserved registers. */ MEXITCOUNT movq TF_RDI(%rsp),%rdi /* bonus; preserve arg 1 */ @@ -1157,6 +1158,7 @@ ld_regs: jz 2f /* keep running with kernel GS.base */ cli call handle_ibrs_exit_rs + callq *mds_handler cmpq $~0,PCPU(UCR3) je 1f pushq %rdx Modified: head/sys/amd64/amd64/genassym.c ============================================================================== --- head/sys/amd64/amd64/genassym.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/amd64/genassym.c Tue May 14 17:02:20 2019 (r347566) @@ -233,6 +233,9 @@ ASSYM(PC_PTI_STACK, offsetof(struct pcpu, pc_pti_stack ASSYM(PC_PTI_STACK_SZ, PC_PTI_STACK_SZ); ASSYM(PC_PTI_RSP0, offsetof(struct pcpu, pc_pti_rsp0)); ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); ASSYM(LA_ISR, LAPIC_ISR0 * LAPIC_MEM_MUL); Modified: head/sys/amd64/amd64/initcpu.c ============================================================================== --- head/sys/amd64/amd64/initcpu.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/amd64/initcpu.c Tue May 14 17:02:20 2019 (r347566) @@ -257,6 +257,7 @@ initializecpu(void) hw_ibrs_recalculate(); hw_ssb_recalculate(false); amd64_syscall_ret_flush_l1d_recalc(); + hw_mds_recalculate(); switch (cpu_vendor_id) { case CPU_VENDOR_AMD: init_amd(); Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/amd64/machdep.c Tue May 14 17:02:20 2019 (r347566) @@ -1732,6 +1732,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush", &syscall_ret_l1d_flush_mode); + TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/amd64/support.S Tue May 14 17:02:20 2019 (r347566) @@ -1,8 +1,13 @@ /*- + * Copyright (c) 2018-2019 The FreeBSD Foundation * Copyright (c) 2003 Peter Wemm. * Copyright (c) 1993 The Regents of the University of California. * All rights reserved. * + * Portions of this software were developed by + * Konstantin Belousov under sponsorship from + * the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -1622,3 +1627,239 @@ ENTRY(flush_l1d_sw_abi) popq %rbx ret END(flush_l1d_sw_abi) + +ENTRY(mds_handler_void) + retq +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subq $8, %rsp + movw %ds, (%rsp) + verw (%rsp) + addq $8, %rsp + retq +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + mfence + movl $40, %ecx + addq $16, %rdx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdi + pushq %rsi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rbx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movq %rbx, %rdi + movq %rbx, %rsi + movl $40, %ecx +2: movntdq %xmm0, (%rbx) + addq $16, %rbx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rsi + popq %rdi + popq %rcx + popq %rbx + popq %rax + retq +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%rdx), %ymm0, %ymm0 + vorpd (%rdx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%rdx), %zmm0, %zmm0 + vorpd (%rdx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_silvermont) Modified: head/sys/amd64/include/pcpu.h ============================================================================== --- head/sys/amd64/include/pcpu.h Tue May 14 15:41:34 2019 (r347565) +++ head/sys/amd64/include/pcpu.h Tue May 14 17:02:20 2019 (r347566) @@ -84,8 +84,12 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c uint32_t pc_pcid_gen; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[2]; \ + uint8_t pc_mds_tmp[64]; \ u_int pc_ipi_bitmap; \ - char __pad[3284] /* pad to UMA_PCPU_ALLOC_SIZE */ + char __pad[3172] /* pad to UMA_PCPU_ALLOC_SIZE */ #define PC_DBREG_CMD_NONE 0 #define PC_DBREG_CMD_LOAD 1 Modified: head/sys/dev/cpuctl/cpuctl.c ============================================================================== --- head/sys/dev/cpuctl/cpuctl.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/dev/cpuctl/cpuctl.c Tue May 14 17:02:20 2019 (r347566) @@ -540,6 +540,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td #ifdef __amd64__ amd64_syscall_ret_flush_l1d_recalc(); #endif + hw_mds_recalculate(); printcpuinfo(); return (0); } Modified: head/sys/i386/i386/exception.s ============================================================================== --- head/sys/i386/i386/exception.s Tue May 14 15:41:34 2019 (r347565) +++ head/sys/i386/i386/exception.s Tue May 14 17:02:20 2019 (r347566) @@ -522,6 +522,8 @@ doreti_exit: 2: movl $handle_ibrs_exit,%eax pushl %ecx /* preserve enough call-used regs */ call *%eax + movl mds_handler,%eax + call *%eax popl %ecx movl %esp, %esi movl PCPU(TRAMPSTK), %edx Modified: head/sys/i386/i386/genassym.c ============================================================================== --- head/sys/i386/i386/genassym.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/i386/i386/genassym.c Tue May 14 17:02:20 2019 (r347566) @@ -209,6 +209,9 @@ ASSYM(PC_KESP0, offsetof(struct pcpu, pc_kesp0)); ASSYM(PC_TRAMPSTK, offsetof(struct pcpu, pc_trampstk)); ASSYM(PC_COPYOUT_BUF, offsetof(struct pcpu, pc_copyout_buf)); ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); ASSYM(PMAP_TRM_MIN_ADDRESS, PMAP_TRM_MIN_ADDRESS); ASSYM(KERNLOAD, KERNLOAD); ASSYM(KERNBASE, KERNBASE); Modified: head/sys/i386/i386/initcpu.c ============================================================================== --- head/sys/i386/i386/initcpu.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/i386/i386/initcpu.c Tue May 14 17:02:20 2019 (r347566) @@ -749,6 +749,7 @@ initializecpu(void) msr = rdmsr(MSR_EFER) | EFER_NXE; wrmsr(MSR_EFER, msr); } + hw_mds_recalculate(); if ((amd_feature & AMDID_RDTSCP) != 0 || (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0) wrmsr(MSR_TSC_AUX, PCPU_GET(cpuid)); Modified: head/sys/i386/i386/support.s ============================================================================== --- head/sys/i386/i386/support.s Tue May 14 15:41:34 2019 (r347565) +++ head/sys/i386/i386/support.s Tue May 14 17:02:20 2019 (r347566) @@ -472,3 +472,187 @@ ENTRY(handle_ibrs_exit) movb $0,PCPU(IBPB_SET) 1: ret END(handle_ibrs_exit) + +ENTRY(mds_handler_void) + ret +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subl $4, %esp + movw %ds, (%esp) + verw (%esp) + addl $4, %esp + ret +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + mfence + movl $40, %ecx + addl $16, %edx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %ebx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl %ebx, %edi + movl %ebx, %esi + movl $40, %ecx +2: movntdq %xmm0, (%ebx) + addl $16, %ebx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%edx), %ymm0, %ymm0 + vorpd (%edx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%edx), %zmm0, %zmm0 + vorpd (%edx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_silvermont) Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Tue May 14 15:41:34 2019 (r347565) +++ head/sys/i386/include/pcpu.h Tue May 14 17:02:20 2019 (r347566) @@ -84,11 +84,15 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x c struct sx pc_copyout_slock; \ char *pc_copyout_buf; \ vm_offset_t pc_pmap_eh_va; \ - caddr_t pc_pmap_eh_ptep; \ + caddr_t pc_pmap_eh_ptep; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[4]; \ + uint8_t pc_mds_tmp[64]; \ u_int pc_ipi_bitmap; \ - char __pad[3606] + char __pad[3518] #ifdef _KERNEL Modified: head/sys/x86/include/specialreg.h ============================================================================== --- head/sys/x86/include/specialreg.h Tue May 14 15:41:34 2019 (r347565) +++ head/sys/x86/include/specialreg.h Tue May 14 17:02:20 2019 (r347566) @@ -448,6 +448,7 @@ /* * CPUID instruction 7 Structured Extended Features, leaf 0 edx info */ +#define CPUID_STDEXT3_MD_CLEAR 0x00000400 #define CPUID_STDEXT3_TSXFA 0x00002000 #define CPUID_STDEXT3_IBPB 0x04000000 #define CPUID_STDEXT3_STIBP 0x08000000 @@ -462,6 +463,7 @@ #define IA32_ARCH_CAP_RSBA 0x00000004 #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY 0x00000008 #define IA32_ARCH_CAP_SSB_NO 0x00000010 +#define IA32_ARCH_CAP_MDS_NO 0x00000020 /* * CPUID manufacturers identifiers Modified: head/sys/x86/include/x86_var.h ============================================================================== --- head/sys/x86/include/x86_var.h Tue May 14 15:41:34 2019 (r347565) +++ head/sys/x86/include/x86_var.h Tue May 14 17:02:20 2019 (r347566) @@ -86,6 +86,7 @@ extern u_int max_apic_id; extern int i386_read_exec; extern int pti; extern int hw_ibrs_active; +extern int hw_mds_disable; extern int hw_ssb_active; struct pcb; @@ -128,6 +129,7 @@ int isa_nmi(int cd); void handle_ibrs_entry(void); void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); +void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Tue May 14 15:41:34 2019 (r347565) +++ head/sys/x86/x86/cpu_machdep.c Tue May 14 17:02:20 2019 (r347566) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -929,6 +930,203 @@ SYSCTL_PROC(_hw, OID_AUTO, spec_store_bypass_disable, CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, hw_ssb_disable_handler, "I", "Speculative Store Bypass Disable (0 - off, 1 - on, 2 - auto"); + +int hw_mds_disable; + +/* + * Handler for Microarchitectural Data Sampling issues. Really not a + * pointer to C function: on amd64 the code must not change any CPU + * architectural state except possibly %rflags. Also, it is always + * called with interrupts disabled. + */ +void (*mds_handler)(void); +void mds_handler_void(void); +void mds_handler_verw(void); +void mds_handler_ivb(void); +void mds_handler_bdw(void); +void mds_handler_skl_sse(void); +void mds_handler_skl_avx(void); +void mds_handler_skl_avx512(void); +void mds_handler_silvermont(void); + +static int +sysctl_hw_mds_disable_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + if (mds_handler == mds_handler_void) + state = "inactive"; + else if (mds_handler == mds_handler_verw) + state = "VERW"; + else if (mds_handler == mds_handler_ivb) + state = "software IvyBridge"; + else if (mds_handler == mds_handler_bdw) + state = "software Broadwell"; + else if (mds_handler == mds_handler_skl_sse) + state = "software Skylake SSE"; + else if (mds_handler == mds_handler_skl_avx) + state = "software Skylake AVX"; + else if (mds_handler == mds_handler_skl_avx512) + state = "software Skylake AVX512"; + else if (mds_handler == mds_handler_silvermont) + state = "software Silvermont"; + else + state = "unknown"; + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable_state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_mds_disable_state_handler, "A", + "Microarchitectural Data Sampling Mitigation state"); + +_Static_assert(__offsetof(struct pcpu, pc_mds_tmp) % 64 == 0, "MDS AVX512"); + +void +hw_mds_recalculate(void) +{ + struct pcpu *pc; + vm_offset_t b64; + u_long xcr0; + int i; + + /* + * Allow user to force VERW variant even if MD_CLEAR is not + * reported. For instance, hypervisor might unknowingly + * filter the cap out. + * For the similar reasons, and for testing, allow to enable + * mitigation even for RDCL_NO or MDS_NO caps. + */ + if (cpu_vendor_id != CPU_VENDOR_INTEL || hw_mds_disable == 0 || + ((cpu_ia32_arch_caps & (IA32_ARCH_CAP_RDCL_NO | + IA32_ARCH_CAP_MDS_NO)) != 0 && hw_mds_disable == 3)) { + mds_handler = mds_handler_void; + } else if (((cpu_stdext_feature3 & CPUID_STDEXT3_MD_CLEAR) != 0 && + hw_mds_disable == 3) || hw_mds_disable == 1) { + mds_handler = mds_handler_verw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x2e || CPUID_TO_MODEL(cpu_id) == 0x1e || + CPUID_TO_MODEL(cpu_id) == 0x1f || CPUID_TO_MODEL(cpu_id) == 0x1a || + CPUID_TO_MODEL(cpu_id) == 0x2f || CPUID_TO_MODEL(cpu_id) == 0x25 || + CPUID_TO_MODEL(cpu_id) == 0x2c || CPUID_TO_MODEL(cpu_id) == 0x2d || + CPUID_TO_MODEL(cpu_id) == 0x2a || CPUID_TO_MODEL(cpu_id) == 0x3e || + CPUID_TO_MODEL(cpu_id) == 0x3a) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Nehalem, SandyBridge, IvyBridge + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(672, M_TEMP, + DOMAINSET_PREF(pc->pc_domain), M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_ivb; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x3f || CPUID_TO_MODEL(cpu_id) == 0x3c || + CPUID_TO_MODEL(cpu_id) == 0x45 || CPUID_TO_MODEL(cpu_id) == 0x46 || + CPUID_TO_MODEL(cpu_id) == 0x56 || CPUID_TO_MODEL(cpu_id) == 0x4f || + CPUID_TO_MODEL(cpu_id) == 0x47 || CPUID_TO_MODEL(cpu_id) == 0x3d) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Haswell, Broadwell + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(1536, M_TEMP, + DOMAINSET_PREF(pc->pc_domain), M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_bdw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x55 && (cpu_id & + CPUID_STEPPING) <= 5) || + CPUID_TO_MODEL(cpu_id) == 0x4e || CPUID_TO_MODEL(cpu_id) == 0x5e || + (CPUID_TO_MODEL(cpu_id) == 0x8e && (cpu_id & + CPUID_STEPPING) <= 0xb) || + (CPUID_TO_MODEL(cpu_id) == 0x9e && (cpu_id & + CPUID_STEPPING) <= 0xc)) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Skylake, KabyLake, CoffeeLake, WhiskeyLake, + * CascadeLake + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(6 * 1024, + M_TEMP, DOMAINSET_PREF(pc->pc_domain), + M_WAITOK); + b64 = (vm_offset_t)malloc_domainset(64 + 63, + M_TEMP, DOMAINSET_PREF(pc->pc_domain), + M_WAITOK); + pc->pc_mds_buf64 = (void *)roundup2(b64, 64); + bzero(pc->pc_mds_buf64, 64); + } + } + xcr0 = rxcr(0); + if ((xcr0 & XFEATURE_ENABLED_ZMM_HI256) != 0 && + (cpu_stdext_feature2 & CPUID_STDEXT_AVX512DQ) != 0) + mds_handler = mds_handler_skl_avx512; + else if ((xcr0 & XFEATURE_ENABLED_AVX) != 0 && + (cpu_feature2 & CPUID2_AVX) != 0) + mds_handler = mds_handler_skl_avx; + else + mds_handler = mds_handler_skl_sse; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x37 || + CPUID_TO_MODEL(cpu_id) == 0x4a || + CPUID_TO_MODEL(cpu_id) == 0x4c || + CPUID_TO_MODEL(cpu_id) == 0x4d || + CPUID_TO_MODEL(cpu_id) == 0x5a || + CPUID_TO_MODEL(cpu_id) == 0x5d || + CPUID_TO_MODEL(cpu_id) == 0x6e || + CPUID_TO_MODEL(cpu_id) == 0x65 || + CPUID_TO_MODEL(cpu_id) == 0x75 || + CPUID_TO_MODEL(cpu_id) == 0x1c || + CPUID_TO_MODEL(cpu_id) == 0x26 || + CPUID_TO_MODEL(cpu_id) == 0x27 || + CPUID_TO_MODEL(cpu_id) == 0x35 || + CPUID_TO_MODEL(cpu_id) == 0x36 || + CPUID_TO_MODEL(cpu_id) == 0x7a))) { + /* Silvermont, Airmont */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) + pc->pc_mds_buf = malloc(256, M_TEMP, M_WAITOK); + } + mds_handler = mds_handler_silvermont; + } else { + hw_mds_disable = 0; + mds_handler = mds_handler_void; + } +} + +static int +sysctl_mds_disable_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = hw_mds_disable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < 0 || val > 3) + return (EINVAL); + hw_mds_disable = val; + hw_mds_recalculate(); + return (0); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_mds_disable_handler, "I", + "Microarchitectural Data Sampling Mitigation " + "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); /* * Enable and restore kernel text write permissions. From owner-svn-src-all@freebsd.org Tue May 14 17:04:04 2019 Return-Path: Delivered-To: svn-src-all@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 887FA1593162; Tue, 14 May 2019 17:04:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A77D74A13; Tue, 14 May 2019 17:04:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E0BF923E42; Tue, 14 May 2019 17:04:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EH43oT064420; Tue, 14 May 2019 17:04:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EH41w1064403; Tue, 14 May 2019 17:04:01 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905141704.x4EH41w1064403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 14 May 2019 17:04:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347567 - in stable/12/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 347567 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3A77D74A13 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 17:04:04 -0000 Author: kib Date: Tue May 14 17:04:00 2019 New Revision: 347567 URL: https://svnweb.freebsd.org/changeset/base/347567 Log: MFC r347566: Mitigations for Microarchitectural Data Sampling. Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00233.html Security: CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091 Security: FreeBSD-SA-19:07.mds Reviewed by: jhb Tested by: emaste, lwhsu Approved by: so (gtetlow) Modified: stable/12/sys/amd64/amd64/exception.S stable/12/sys/amd64/amd64/genassym.c stable/12/sys/amd64/amd64/initcpu.c stable/12/sys/amd64/amd64/machdep.c stable/12/sys/amd64/amd64/support.S stable/12/sys/amd64/include/pcpu.h stable/12/sys/dev/cpuctl/cpuctl.c stable/12/sys/i386/i386/exception.s stable/12/sys/i386/i386/genassym.c stable/12/sys/i386/i386/initcpu.c stable/12/sys/i386/i386/support.s stable/12/sys/i386/include/pcpu.h stable/12/sys/x86/include/specialreg.h stable/12/sys/x86/include/x86_var.h stable/12/sys/x86/x86/cpu_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/exception.S ============================================================================== --- stable/12/sys/amd64/amd64/exception.S Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/amd64/exception.S Tue May 14 17:04:00 2019 (r347567) @@ -512,6 +512,7 @@ fast_syscall_common: testl $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax) jne 3f call handle_ibrs_exit + callq *mds_handler /* Restore preserved registers. */ MEXITCOUNT movq TF_RDI(%rsp),%rdi /* bonus; preserve arg 1 */ @@ -1157,6 +1158,7 @@ ld_regs: jz 2f /* keep running with kernel GS.base */ cli call handle_ibrs_exit_rs + callq *mds_handler cmpq $~0,PCPU(UCR3) je 1f pushq %rdx Modified: stable/12/sys/amd64/amd64/genassym.c ============================================================================== --- stable/12/sys/amd64/amd64/genassym.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/amd64/genassym.c Tue May 14 17:04:00 2019 (r347567) @@ -233,6 +233,9 @@ ASSYM(PC_PTI_STACK, offsetof(struct pcpu, pc_pti_stack ASSYM(PC_PTI_STACK_SZ, PC_PTI_STACK_SZ); ASSYM(PC_PTI_RSP0, offsetof(struct pcpu, pc_pti_rsp0)); ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); ASSYM(LA_ISR, LAPIC_ISR0 * LAPIC_MEM_MUL); Modified: stable/12/sys/amd64/amd64/initcpu.c ============================================================================== --- stable/12/sys/amd64/amd64/initcpu.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/amd64/initcpu.c Tue May 14 17:04:00 2019 (r347567) @@ -257,6 +257,7 @@ initializecpu(void) hw_ibrs_recalculate(); hw_ssb_recalculate(false); amd64_syscall_ret_flush_l1d_recalc(); + hw_mds_recalculate(); switch (cpu_vendor_id) { case CPU_VENDOR_AMD: init_amd(); Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/amd64/machdep.c Tue May 14 17:04:00 2019 (r347567) @@ -1733,6 +1733,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush", &syscall_ret_l1d_flush_mode); + TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ Modified: stable/12/sys/amd64/amd64/support.S ============================================================================== --- stable/12/sys/amd64/amd64/support.S Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/amd64/support.S Tue May 14 17:04:00 2019 (r347567) @@ -1,8 +1,13 @@ /*- + * Copyright (c) 2018-2019 The FreeBSD Foundation * Copyright (c) 2003 Peter Wemm. * Copyright (c) 1993 The Regents of the University of California. * All rights reserved. * + * Portions of this software were developed by + * Konstantin Belousov under sponsorship from + * the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -1626,3 +1631,239 @@ ENTRY(flush_l1d_sw_abi) popq %rbx ret END(flush_l1d_sw_abi) + +ENTRY(mds_handler_void) + retq +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subq $8, %rsp + movw %ds, (%rsp) + verw (%rsp) + addq $8, %rsp + retq +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + mfence + movl $40, %ecx + addq $16, %rdx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdi + pushq %rsi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rbx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movq %rbx, %rdi + movq %rbx, %rsi + movl $40, %ecx +2: movntdq %xmm0, (%rbx) + addq $16, %rbx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rsi + popq %rdi + popq %rcx + popq %rbx + popq %rax + retq +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%rdx), %ymm0, %ymm0 + vorpd (%rdx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%rdx), %zmm0, %zmm0 + vorpd (%rdx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_silvermont) Modified: stable/12/sys/amd64/include/pcpu.h ============================================================================== --- stable/12/sys/amd64/include/pcpu.h Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/amd64/include/pcpu.h Tue May 14 17:04:00 2019 (r347567) @@ -76,7 +76,11 @@ uint32_t pc_pcid_gen; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[3288] /* pad to UMA_PCPU_ALLOC_SIZE */ + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[2]; \ + uint8_t pc_mds_tmp[64]; \ + char __pad[3176] /* pad to UMA_PCPU_ALLOC_SIZE */ #define PC_DBREG_CMD_NONE 0 #define PC_DBREG_CMD_LOAD 1 Modified: stable/12/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/12/sys/dev/cpuctl/cpuctl.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/dev/cpuctl/cpuctl.c Tue May 14 17:04:00 2019 (r347567) @@ -524,6 +524,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td #ifdef __amd64__ amd64_syscall_ret_flush_l1d_recalc(); #endif + hw_mds_recalculate(); printcpuinfo(); return (0); } Modified: stable/12/sys/i386/i386/exception.s ============================================================================== --- stable/12/sys/i386/i386/exception.s Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/i386/i386/exception.s Tue May 14 17:04:00 2019 (r347567) @@ -522,6 +522,8 @@ doreti_exit: 2: movl $handle_ibrs_exit,%eax pushl %ecx /* preserve enough call-used regs */ call *%eax + movl mds_handler,%eax + call *%eax popl %ecx movl %esp, %esi movl PCPU(TRAMPSTK), %edx Modified: stable/12/sys/i386/i386/genassym.c ============================================================================== --- stable/12/sys/i386/i386/genassym.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/i386/i386/genassym.c Tue May 14 17:04:00 2019 (r347567) @@ -222,6 +222,9 @@ ASSYM(PC_KESP0, offsetof(struct pcpu, pc_kesp0)); ASSYM(PC_TRAMPSTK, offsetof(struct pcpu, pc_trampstk)); ASSYM(PC_COPYOUT_BUF, offsetof(struct pcpu, pc_copyout_buf)); ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); #ifdef DEV_APIC ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); Modified: stable/12/sys/i386/i386/initcpu.c ============================================================================== --- stable/12/sys/i386/i386/initcpu.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/i386/i386/initcpu.c Tue May 14 17:04:00 2019 (r347567) @@ -754,6 +754,7 @@ initializecpu(void) elf32_nxstack = 1; } #endif + hw_mds_recalculate(); if ((amd_feature & AMDID_RDTSCP) != 0 || (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0) wrmsr(MSR_TSC_AUX, PCPU_GET(cpuid)); Modified: stable/12/sys/i386/i386/support.s ============================================================================== --- stable/12/sys/i386/i386/support.s Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/i386/i386/support.s Tue May 14 17:04:00 2019 (r347567) @@ -472,3 +472,187 @@ ENTRY(handle_ibrs_exit) movb $0,PCPU(IBPB_SET) 1: ret END(handle_ibrs_exit) + +ENTRY(mds_handler_void) + ret +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subl $4, %esp + movw %ds, (%esp) + verw (%esp) + addl $4, %esp + ret +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + mfence + movl $40, %ecx + addl $16, %edx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %ebx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl %ebx, %edi + movl %ebx, %esi + movl $40, %ecx +2: movntdq %xmm0, (%ebx) + addl $16, %ebx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%edx), %ymm0, %ymm0 + vorpd (%edx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%edx), %zmm0, %zmm0 + vorpd (%edx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_silvermont) Modified: stable/12/sys/i386/include/pcpu.h ============================================================================== --- stable/12/sys/i386/include/pcpu.h Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/i386/include/pcpu.h Tue May 14 17:04:00 2019 (r347567) @@ -77,10 +77,14 @@ struct sx pc_copyout_slock; \ char *pc_copyout_buf; \ vm_offset_t pc_pmap_eh_va; \ - caddr_t pc_pmap_eh_ptep; \ + caddr_t pc_pmap_eh_ptep; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[3610] + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[4]; \ + uint8_t pc_mds_tmp[64]; \ + char __pad[3522] #ifdef _KERNEL Modified: stable/12/sys/x86/include/specialreg.h ============================================================================== --- stable/12/sys/x86/include/specialreg.h Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/x86/include/specialreg.h Tue May 14 17:04:00 2019 (r347567) @@ -431,6 +431,7 @@ /* * CPUID instruction 7 Structured Extended Features, leaf 0 edx info */ +#define CPUID_STDEXT3_MD_CLEAR 0x00000400 #define CPUID_STDEXT3_TSXFA 0x00002000 #define CPUID_STDEXT3_IBPB 0x04000000 #define CPUID_STDEXT3_STIBP 0x08000000 @@ -445,6 +446,7 @@ #define IA32_ARCH_CAP_RSBA 0x00000004 #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY 0x00000008 #define IA32_ARCH_CAP_SSB_NO 0x00000010 +#define IA32_ARCH_CAP_MDS_NO 0x00000020 /* * CPUID manufacturers identifiers Modified: stable/12/sys/x86/include/x86_var.h ============================================================================== --- stable/12/sys/x86/include/x86_var.h Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/x86/include/x86_var.h Tue May 14 17:04:00 2019 (r347567) @@ -85,6 +85,7 @@ extern uint64_t xsave_mask; extern u_int max_apic_id; extern int pti; extern int hw_ibrs_active; +extern int hw_mds_disable; extern int hw_ssb_active; struct pcb; @@ -140,6 +141,7 @@ int isa_nmi(int cd); void handle_ibrs_entry(void); void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); +void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); Modified: stable/12/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/12/sys/x86/x86/cpu_machdep.c Tue May 14 17:02:20 2019 (r347566) +++ stable/12/sys/x86/x86/cpu_machdep.c Tue May 14 17:04:00 2019 (r347567) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -914,6 +915,203 @@ SYSCTL_PROC(_hw, OID_AUTO, spec_store_bypass_disable, CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, hw_ssb_disable_handler, "I", "Speculative Store Bypass Disable (0 - off, 1 - on, 2 - auto"); + +int hw_mds_disable; + +/* + * Handler for Microarchitectural Data Sampling issues. Really not a + * pointer to C function: on amd64 the code must not change any CPU + * architectural state except possibly %rflags. Also, it is always + * called with interrupts disabled. + */ +void (*mds_handler)(void); +void mds_handler_void(void); +void mds_handler_verw(void); +void mds_handler_ivb(void); +void mds_handler_bdw(void); +void mds_handler_skl_sse(void); +void mds_handler_skl_avx(void); +void mds_handler_skl_avx512(void); +void mds_handler_silvermont(void); + +static int +sysctl_hw_mds_disable_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + if (mds_handler == mds_handler_void) + state = "inactive"; + else if (mds_handler == mds_handler_verw) + state = "VERW"; + else if (mds_handler == mds_handler_ivb) + state = "software IvyBridge"; + else if (mds_handler == mds_handler_bdw) + state = "software Broadwell"; + else if (mds_handler == mds_handler_skl_sse) + state = "software Skylake SSE"; + else if (mds_handler == mds_handler_skl_avx) + state = "software Skylake AVX"; + else if (mds_handler == mds_handler_skl_avx512) + state = "software Skylake AVX512"; + else if (mds_handler == mds_handler_silvermont) + state = "software Silvermont"; + else + state = "unknown"; + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable_state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_mds_disable_state_handler, "A", + "Microarchitectural Data Sampling Mitigation state"); + +_Static_assert(__offsetof(struct pcpu, pc_mds_tmp) % 64 == 0, "MDS AVX512"); + +void +hw_mds_recalculate(void) +{ + struct pcpu *pc; + vm_offset_t b64; + u_long xcr0; + int i; + + /* + * Allow user to force VERW variant even if MD_CLEAR is not + * reported. For instance, hypervisor might unknowingly + * filter the cap out. + * For the similar reasons, and for testing, allow to enable + * mitigation even for RDCL_NO or MDS_NO caps. + */ + if (cpu_vendor_id != CPU_VENDOR_INTEL || hw_mds_disable == 0 || + ((cpu_ia32_arch_caps & (IA32_ARCH_CAP_RDCL_NO | + IA32_ARCH_CAP_MDS_NO)) != 0 && hw_mds_disable == 3)) { + mds_handler = mds_handler_void; + } else if (((cpu_stdext_feature3 & CPUID_STDEXT3_MD_CLEAR) != 0 && + hw_mds_disable == 3) || hw_mds_disable == 1) { + mds_handler = mds_handler_verw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x2e || CPUID_TO_MODEL(cpu_id) == 0x1e || + CPUID_TO_MODEL(cpu_id) == 0x1f || CPUID_TO_MODEL(cpu_id) == 0x1a || + CPUID_TO_MODEL(cpu_id) == 0x2f || CPUID_TO_MODEL(cpu_id) == 0x25 || + CPUID_TO_MODEL(cpu_id) == 0x2c || CPUID_TO_MODEL(cpu_id) == 0x2d || + CPUID_TO_MODEL(cpu_id) == 0x2a || CPUID_TO_MODEL(cpu_id) == 0x3e || + CPUID_TO_MODEL(cpu_id) == 0x3a) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Nehalem, SandyBridge, IvyBridge + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(672, M_TEMP, + DOMAINSET_PREF(pc->pc_domain), M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_ivb; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x3f || CPUID_TO_MODEL(cpu_id) == 0x3c || + CPUID_TO_MODEL(cpu_id) == 0x45 || CPUID_TO_MODEL(cpu_id) == 0x46 || + CPUID_TO_MODEL(cpu_id) == 0x56 || CPUID_TO_MODEL(cpu_id) == 0x4f || + CPUID_TO_MODEL(cpu_id) == 0x47 || CPUID_TO_MODEL(cpu_id) == 0x3d) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Haswell, Broadwell + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(1536, M_TEMP, + DOMAINSET_PREF(pc->pc_domain), M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_bdw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x55 && (cpu_id & + CPUID_STEPPING) <= 5) || + CPUID_TO_MODEL(cpu_id) == 0x4e || CPUID_TO_MODEL(cpu_id) == 0x5e || + (CPUID_TO_MODEL(cpu_id) == 0x8e && (cpu_id & + CPUID_STEPPING) <= 0xb) || + (CPUID_TO_MODEL(cpu_id) == 0x9e && (cpu_id & + CPUID_STEPPING) <= 0xc)) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Skylake, KabyLake, CoffeeLake, WhiskeyLake, + * CascadeLake + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc_domainset(6 * 1024, + M_TEMP, DOMAINSET_PREF(pc->pc_domain), + M_WAITOK); + b64 = (vm_offset_t)malloc_domainset(64 + 63, + M_TEMP, DOMAINSET_PREF(pc->pc_domain), + M_WAITOK); + pc->pc_mds_buf64 = (void *)roundup2(b64, 64); + bzero(pc->pc_mds_buf64, 64); + } + } + xcr0 = rxcr(0); + if ((xcr0 & XFEATURE_ENABLED_ZMM_HI256) != 0 && + (cpu_stdext_feature2 & CPUID_STDEXT_AVX512DQ) != 0) + mds_handler = mds_handler_skl_avx512; + else if ((xcr0 & XFEATURE_ENABLED_AVX) != 0 && + (cpu_feature2 & CPUID2_AVX) != 0) + mds_handler = mds_handler_skl_avx; + else + mds_handler = mds_handler_skl_sse; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x37 || + CPUID_TO_MODEL(cpu_id) == 0x4a || + CPUID_TO_MODEL(cpu_id) == 0x4c || + CPUID_TO_MODEL(cpu_id) == 0x4d || + CPUID_TO_MODEL(cpu_id) == 0x5a || + CPUID_TO_MODEL(cpu_id) == 0x5d || + CPUID_TO_MODEL(cpu_id) == 0x6e || + CPUID_TO_MODEL(cpu_id) == 0x65 || + CPUID_TO_MODEL(cpu_id) == 0x75 || + CPUID_TO_MODEL(cpu_id) == 0x1c || + CPUID_TO_MODEL(cpu_id) == 0x26 || + CPUID_TO_MODEL(cpu_id) == 0x27 || + CPUID_TO_MODEL(cpu_id) == 0x35 || + CPUID_TO_MODEL(cpu_id) == 0x36 || + CPUID_TO_MODEL(cpu_id) == 0x7a))) { + /* Silvermont, Airmont */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) + pc->pc_mds_buf = malloc(256, M_TEMP, M_WAITOK); + } + mds_handler = mds_handler_silvermont; + } else { + hw_mds_disable = 0; + mds_handler = mds_handler_void; + } +} + +static int +sysctl_mds_disable_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = hw_mds_disable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < 0 || val > 3) + return (EINVAL); + hw_mds_disable = val; + hw_mds_recalculate(); + return (0); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_mds_disable_handler, "I", + "Microarchitectural Data Sampling Mitigation " + "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); /* * Enable and restore kernel text write permissions. From owner-svn-src-all@freebsd.org Tue May 14 17:05:06 2019 Return-Path: Delivered-To: svn-src-all@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 CB6491593223; Tue, 14 May 2019 17:05:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7D7F874B68; Tue, 14 May 2019 17:05:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 56C2823E44; Tue, 14 May 2019 17:05:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EH55ib064540; Tue, 14 May 2019 17:05:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EH52k9064526; Tue, 14 May 2019 17:05:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905141705.x4EH52k9064526@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 14 May 2019 17:05:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r347568 - in stable/11/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 amd64/include dev/cpuctl i386/i386 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 347568 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7D7F874B68 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 17:05:06 -0000 Author: kib Date: Tue May 14 17:05:02 2019 New Revision: 347568 URL: https://svnweb.freebsd.org/changeset/base/347568 Log: MFC r347566: Mitigations for Microarchitectural Data Sampling. Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00233.html Security: CVE-2018-12126, CVE-2018-12127, CVE-2018-12130, CVE-2019-11091 Security: FreeBSD-SA-19:07.mds Reviewed by: jhb Tested by: emaste, lwhsu Approved by: so (gtetlow) Modified: stable/11/sys/amd64/amd64/exception.S stable/11/sys/amd64/amd64/genassym.c stable/11/sys/amd64/amd64/initcpu.c stable/11/sys/amd64/amd64/machdep.c stable/11/sys/amd64/amd64/support.S stable/11/sys/amd64/include/pcpu.h stable/11/sys/dev/cpuctl/cpuctl.c stable/11/sys/i386/i386/exception.s stable/11/sys/i386/i386/genassym.c stable/11/sys/i386/i386/initcpu.c stable/11/sys/i386/i386/support.s stable/11/sys/i386/include/pcpu.h stable/11/sys/x86/include/specialreg.h stable/11/sys/x86/include/x86_var.h stable/11/sys/x86/x86/cpu_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/exception.S ============================================================================== --- stable/11/sys/amd64/amd64/exception.S Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/amd64/exception.S Tue May 14 17:05:02 2019 (r347568) @@ -502,6 +502,7 @@ fast_syscall_common: testl $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax) jne 3f call handle_ibrs_exit + callq *mds_handler /* Restore preserved registers. */ MEXITCOUNT movq TF_RDI(%rsp),%rdi /* bonus; preserve arg 1 */ @@ -1139,6 +1140,7 @@ ld_regs: jz 2f /* keep running with kernel GS.base */ cli call handle_ibrs_exit_rs + callq *mds_handler cmpq $~0,PCPU(UCR3) je 1f pushq %rdx Modified: stable/11/sys/amd64/amd64/genassym.c ============================================================================== --- stable/11/sys/amd64/amd64/genassym.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/amd64/genassym.c Tue May 14 17:05:02 2019 (r347568) @@ -231,6 +231,9 @@ ASSYM(PC_PTI_STACK, offsetof(struct pcpu, pc_pti_stack ASSYM(PC_PTI_STACK_SZ, PC_PTI_STACK_SZ); ASSYM(PC_PTI_RSP0, offsetof(struct pcpu, pc_pti_rsp0)); ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); ASSYM(LA_ISR, LAPIC_ISR0 * LAPIC_MEM_MUL); Modified: stable/11/sys/amd64/amd64/initcpu.c ============================================================================== --- stable/11/sys/amd64/amd64/initcpu.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/amd64/initcpu.c Tue May 14 17:05:02 2019 (r347568) @@ -247,6 +247,7 @@ initializecpu(void) } hw_ibrs_recalculate(); hw_ssb_recalculate(false); + hw_mds_recalculate(); switch (cpu_vendor_id) { case CPU_VENDOR_AMD: init_amd(); Modified: stable/11/sys/amd64/amd64/machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/machdep.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/amd64/machdep.c Tue May 14 17:05:02 2019 (r347568) @@ -1864,6 +1864,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable); TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); + TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); /* Location of kernel stack for locore */ return ((u_int64_t)thread0.td_pcb); Modified: stable/11/sys/amd64/amd64/support.S ============================================================================== --- stable/11/sys/amd64/amd64/support.S Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/amd64/support.S Tue May 14 17:05:02 2019 (r347568) @@ -1,8 +1,13 @@ /*- + * Copyright (c) 2018-2019 The FreeBSD Foundation * Copyright (c) 2003 Peter Wemm. * Copyright (c) 1993 The Regents of the University of California. * All rights reserved. * + * Portions of this software were developed by + * Konstantin Belousov under sponsorship from + * the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -925,3 +930,239 @@ ENTRY(flush_l1d_sw) ret #undef L1D_FLUSH_SIZE END(flush_l1d_sw) + +ENTRY(mds_handler_void) + retq +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subq $8, %rsp + movw %ds, (%rsp) + verw (%rsp) + addq $8, %rsp + retq +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + mfence + movl $40, %ecx + addq $16, %rdx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdi + pushq %rsi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rbx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movq %rbx, %rdi + movq %rbx, %rsi + movl $40, %ecx +2: movntdq %xmm0, (%rbx) + addq $16, %rbx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rsi + popq %rdi + popq %rcx + popq %rbx + popq %rax + retq +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%rdx), %xmm0 + orpd (%rdx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%rdx), %ymm0, %ymm0 + vorpd (%rdx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + pushq %rax + pushq %rdx + pushq %rcx + pushq %rdi + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdi + movq PCPU(MDS_BUF64), %rdx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%rdx), %zmm0, %zmm0 + vorpd (%rdx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%rdi, %rax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rdi + popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + pushq %rax + pushq %rdx + pushq %rcx + + movq %cr0, %rax + testb $CR0_TS, %al + je 1f + clts +1: movq PCPU(MDS_BUF), %rdx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%rdx) + addq $16, %rdx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movq %rax, %cr0 +3: popq %rcx + popq %rdx + popq %rax + retq +END(mds_handler_silvermont) Modified: stable/11/sys/amd64/include/pcpu.h ============================================================================== --- stable/11/sys/amd64/include/pcpu.h Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/amd64/include/pcpu.h Tue May 14 17:05:02 2019 (r347568) @@ -74,7 +74,11 @@ uint32_t pc_pcid_gen; \ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[88] /* be divisor of PAGE_SIZE \ + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[2]; \ + uint8_t pc_mds_tmp[64]; \ + char __pad[1024] /* be divisor of PAGE_SIZE \ after cache alignment */ #define PC_DBREG_CMD_NONE 0 Modified: stable/11/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/11/sys/dev/cpuctl/cpuctl.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/dev/cpuctl/cpuctl.c Tue May 14 17:05:02 2019 (r347568) @@ -530,6 +530,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td hw_ibrs_recalculate(); restore_cpu(oldcpu, is_bound, td); hw_ssb_recalculate(true); + hw_mds_recalculate(); printcpuinfo(); return (0); } Modified: stable/11/sys/i386/i386/exception.s ============================================================================== --- stable/11/sys/i386/i386/exception.s Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/i386/i386/exception.s Tue May 14 17:05:02 2019 (r347568) @@ -406,6 +406,7 @@ doreti_ast: */ doreti_exit: MEXITCOUNT + call *mds_handler .globl doreti_popl_fs doreti_popl_fs: Modified: stable/11/sys/i386/i386/genassym.c ============================================================================== --- stable/11/sys/i386/i386/genassym.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/i386/i386/genassym.c Tue May 14 17:05:02 2019 (r347568) @@ -217,6 +217,9 @@ ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentl ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap)); ASSYM(PC_PRIVATE_TSS, offsetof(struct pcpu, pc_private_tss)); +ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp)); +ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf)); +ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64)); #ifdef DEV_APIC ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); Modified: stable/11/sys/i386/i386/initcpu.c ============================================================================== --- stable/11/sys/i386/i386/initcpu.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/i386/i386/initcpu.c Tue May 14 17:05:02 2019 (r347568) @@ -769,6 +769,7 @@ initializecpu(void) elf32_nxstack = 1; } #endif + hw_mds_recalculate(); if ((amd_feature & AMDID_RDTSCP) != 0 || (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0) wrmsr(MSR_TSC_AUX, PCPU_GET(cpuid)); Modified: stable/11/sys/i386/i386/support.s ============================================================================== --- stable/11/sys/i386/i386/support.s Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/i386/i386/support.s Tue May 14 17:05:02 2019 (r347568) @@ -826,3 +826,187 @@ END(handle_ibrs_entry) ENTRY(handle_ibrs_exit) ret END(handle_ibrs_exit) + +ENTRY(mds_handler_void) + ret +END(mds_handler_void) + +ENTRY(mds_handler_verw) + subl $4, %esp + movw %ds, (%esp) + verw (%esp) + addl $4, %esp + ret +END(mds_handler_verw) + +ENTRY(mds_handler_ivb) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + mfence + movl $40, %ecx + addl $16, %edx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_ivb) + +ENTRY(mds_handler_bdw) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %ebx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl %ebx, %edi + movl %ebx, %esi + movl $40, %ecx +2: movntdq %xmm0, (%ebx) + addl $16, %ebx + decl %ecx + jnz 2b + mfence + movl $1536, %ecx + rep; movsb + lfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_bdw) + +ENTRY(mds_handler_skl_sse) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + lfence + orpd (%edx), %xmm0 + orpd (%edx), %xmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + movdqa PCPU(MDS_TMP), %xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_sse) + +ENTRY(mds_handler_skl_avx) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa %ymm0, PCPU(MDS_TMP) + vpxor %ymm0, %ymm0, %ymm0 + + lfence + vorpd (%edx), %ymm0, %ymm0 + vorpd (%edx), %ymm0, %ymm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa PCPU(MDS_TMP), %ymm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx) + +ENTRY(mds_handler_skl_avx512) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edi + movl PCPU(MDS_BUF64), %edx + vmovdqa64 %zmm0, PCPU(MDS_TMP) + vpxor %zmm0, %zmm0, %zmm0 + + lfence + vorpd (%edx), %zmm0, %zmm0 + vorpd (%edx), %zmm0, %zmm0 + xorl %eax, %eax +2: clflushopt 5376(%edi, %eax, 8) + addl $8, %eax + cmpl $8 * 12, %eax + jb 2b + sfence + movl $6144, %ecx + xorl %eax, %eax + rep; stosb + mfence + + vmovdqa64 PCPU(MDS_TMP), %zmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_skl_avx512) + +ENTRY(mds_handler_silvermont) + movl %cr0, %eax + testb $CR0_TS, %al + je 1f + clts +1: movl PCPU(MDS_BUF), %edx + movdqa %xmm0, PCPU(MDS_TMP) + pxor %xmm0, %xmm0 + + movl $16, %ecx +2: movntdq %xmm0, (%edx) + addl $16, %edx + decl %ecx + jnz 2b + mfence + + movdqa PCPU(MDS_TMP),%xmm0 + testb $CR0_TS, %al + je 3f + movl %eax, %cr0 +3: ret +END(mds_handler_silvermont) Modified: stable/11/sys/i386/include/pcpu.h ============================================================================== --- stable/11/sys/i386/include/pcpu.h Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/i386/include/pcpu.h Tue May 14 17:05:02 2019 (r347568) @@ -69,7 +69,11 @@ vm_offset_t pc_qmap_addr; /* KVA for temporary mappings */\ uint32_t pc_smp_tlb_done; /* TLB op acknowledgement */ \ uint32_t pc_ibpb_set; \ - char __pad[185] + void *pc_mds_buf; \ + void *pc_mds_buf64; \ + uint32_t pc_pad[12]; \ + uint8_t pc_mds_tmp[64]; \ + char __pad[153] #ifdef _KERNEL Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/x86/include/specialreg.h Tue May 14 17:05:02 2019 (r347568) @@ -390,6 +390,7 @@ /* * CPUID instruction 7 Structured Extended Features, leaf 0 edx info */ +#define CPUID_STDEXT3_MD_CLEAR 0x00000400 #define CPUID_STDEXT3_TSXFA 0x00002000 #define CPUID_STDEXT3_IBPB 0x04000000 #define CPUID_STDEXT3_STIBP 0x08000000 @@ -404,6 +405,7 @@ #define IA32_ARCH_CAP_RSBA 0x00000004 #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY 0x00000008 #define IA32_ARCH_CAP_SSB_NO 0x00000010 +#define IA32_ARCH_CAP_MDS_NO 0x00000020 /* * CPUID manufacturers identifiers Modified: stable/11/sys/x86/include/x86_var.h ============================================================================== --- stable/11/sys/x86/include/x86_var.h Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/x86/include/x86_var.h Tue May 14 17:05:02 2019 (r347568) @@ -83,6 +83,7 @@ extern int use_xsave; extern uint64_t xsave_mask; extern int pti; extern int hw_ibrs_active; +extern int hw_mds_disable; extern int hw_ssb_active; struct pcb; @@ -134,6 +135,7 @@ int isa_nmi(int cd); void handle_ibrs_entry(void); void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); +void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); Modified: stable/11/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/11/sys/x86/x86/cpu_machdep.c Tue May 14 17:04:00 2019 (r347567) +++ stable/11/sys/x86/x86/cpu_machdep.c Tue May 14 17:05:02 2019 (r347568) @@ -945,3 +945,198 @@ SYSCTL_PROC(_hw, OID_AUTO, spec_store_bypass_disable, hw_ssb_disable_handler, "I", "Speculative Store Bypass Disable (0 - off, 1 - on, 2 - auto"); +int hw_mds_disable; + +/* + * Handler for Microarchitectural Data Sampling issues. Really not a + * pointer to C function: on amd64 the code must not change any CPU + * architectural state except possibly %rflags. Also, it is always + * called with interrupts disabled. + */ +void (*mds_handler)(void); +void mds_handler_void(void); +void mds_handler_verw(void); +void mds_handler_ivb(void); +void mds_handler_bdw(void); +void mds_handler_skl_sse(void); +void mds_handler_skl_avx(void); +void mds_handler_skl_avx512(void); +void mds_handler_silvermont(void); + +static int +sysctl_hw_mds_disable_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + if (mds_handler == mds_handler_void) + state = "inactive"; + else if (mds_handler == mds_handler_verw) + state = "VERW"; + else if (mds_handler == mds_handler_ivb) + state = "software IvyBridge"; + else if (mds_handler == mds_handler_bdw) + state = "software Broadwell"; + else if (mds_handler == mds_handler_skl_sse) + state = "software Skylake SSE"; + else if (mds_handler == mds_handler_skl_avx) + state = "software Skylake AVX"; + else if (mds_handler == mds_handler_skl_avx512) + state = "software Skylake AVX512"; + else if (mds_handler == mds_handler_silvermont) + state = "software Silvermont"; + else + state = "unknown"; + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable_state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_mds_disable_state_handler, "A", + "Microarchitectural Data Sampling Mitigation state"); + +_Static_assert(__offsetof(struct pcpu, pc_mds_tmp) % 64 == 0, "MDS AVX512"); + +void +hw_mds_recalculate(void) +{ + struct pcpu *pc; + vm_offset_t b64; + u_long xcr0; + int i; + + /* + * Allow user to force VERW variant even if MD_CLEAR is not + * reported. For instance, hypervisor might unknowingly + * filter the cap out. + * For the similar reasons, and for testing, allow to enable + * mitigation even for RDCL_NO or MDS_NO caps. + */ + if (cpu_vendor_id != CPU_VENDOR_INTEL || hw_mds_disable == 0 || + ((cpu_ia32_arch_caps & (IA32_ARCH_CAP_RDCL_NO | + IA32_ARCH_CAP_MDS_NO)) != 0 && hw_mds_disable == 3)) { + mds_handler = mds_handler_void; + } else if (((cpu_stdext_feature3 & CPUID_STDEXT3_MD_CLEAR) != 0 && + hw_mds_disable == 3) || hw_mds_disable == 1) { + mds_handler = mds_handler_verw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x2e || CPUID_TO_MODEL(cpu_id) == 0x1e || + CPUID_TO_MODEL(cpu_id) == 0x1f || CPUID_TO_MODEL(cpu_id) == 0x1a || + CPUID_TO_MODEL(cpu_id) == 0x2f || CPUID_TO_MODEL(cpu_id) == 0x25 || + CPUID_TO_MODEL(cpu_id) == 0x2c || CPUID_TO_MODEL(cpu_id) == 0x2d || + CPUID_TO_MODEL(cpu_id) == 0x2a || CPUID_TO_MODEL(cpu_id) == 0x3e || + CPUID_TO_MODEL(cpu_id) == 0x3a) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Nehalem, SandyBridge, IvyBridge + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc(672, M_TEMP, + M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_ivb; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x3f || CPUID_TO_MODEL(cpu_id) == 0x3c || + CPUID_TO_MODEL(cpu_id) == 0x45 || CPUID_TO_MODEL(cpu_id) == 0x46 || + CPUID_TO_MODEL(cpu_id) == 0x56 || CPUID_TO_MODEL(cpu_id) == 0x4f || + CPUID_TO_MODEL(cpu_id) == 0x47 || CPUID_TO_MODEL(cpu_id) == 0x3d) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Haswell, Broadwell + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc(1536, M_TEMP, + M_WAITOK); + bzero(pc->pc_mds_buf, 16); + } + } + mds_handler = mds_handler_bdw; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x55 && (cpu_id & + CPUID_STEPPING) <= 5) || + CPUID_TO_MODEL(cpu_id) == 0x4e || CPUID_TO_MODEL(cpu_id) == 0x5e || + (CPUID_TO_MODEL(cpu_id) == 0x8e && (cpu_id & + CPUID_STEPPING) <= 0xb) || + (CPUID_TO_MODEL(cpu_id) == 0x9e && (cpu_id & + CPUID_STEPPING) <= 0xc)) && + (hw_mds_disable == 2 || hw_mds_disable == 3)) { + /* + * Skylake, KabyLake, CoffeeLake, WhiskeyLake, + * CascadeLake + */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) { + pc->pc_mds_buf = malloc(6 * 1024, + M_TEMP, M_WAITOK); + b64 = (vm_offset_t)malloc(64 + 63, + M_TEMP, M_WAITOK); + pc->pc_mds_buf64 = (void *)roundup2(b64, 64); + bzero(pc->pc_mds_buf64, 64); + } + } + xcr0 = rxcr(0); + if ((xcr0 & XFEATURE_ENABLED_ZMM_HI256) != 0 && + (cpu_stdext_feature2 & CPUID_STDEXT_AVX512DQ) != 0) + mds_handler = mds_handler_skl_avx512; + else if ((xcr0 & XFEATURE_ENABLED_AVX) != 0 && + (cpu_feature2 & CPUID2_AVX) != 0) + mds_handler = mds_handler_skl_avx; + else + mds_handler = mds_handler_skl_sse; + } else if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + ((CPUID_TO_MODEL(cpu_id) == 0x37 || + CPUID_TO_MODEL(cpu_id) == 0x4a || + CPUID_TO_MODEL(cpu_id) == 0x4c || + CPUID_TO_MODEL(cpu_id) == 0x4d || + CPUID_TO_MODEL(cpu_id) == 0x5a || + CPUID_TO_MODEL(cpu_id) == 0x5d || + CPUID_TO_MODEL(cpu_id) == 0x6e || + CPUID_TO_MODEL(cpu_id) == 0x65 || + CPUID_TO_MODEL(cpu_id) == 0x75 || + CPUID_TO_MODEL(cpu_id) == 0x1c || + CPUID_TO_MODEL(cpu_id) == 0x26 || + CPUID_TO_MODEL(cpu_id) == 0x27 || + CPUID_TO_MODEL(cpu_id) == 0x35 || + CPUID_TO_MODEL(cpu_id) == 0x36 || + CPUID_TO_MODEL(cpu_id) == 0x7a))) { + /* Silvermont, Airmont */ + CPU_FOREACH(i) { + pc = pcpu_find(i); + if (pc->pc_mds_buf == NULL) + pc->pc_mds_buf = malloc(256, M_TEMP, M_WAITOK); + } + mds_handler = mds_handler_silvermont; + } else { + hw_mds_disable = 0; + mds_handler = mds_handler_void; + } +} + +static int +sysctl_mds_disable_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = hw_mds_disable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < 0 || val > 3) + return (EINVAL); + hw_mds_disable = val; + hw_mds_recalculate(); + return (0); +} + +SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_mds_disable_handler, "I", + "Microarchitectural Data Sampling Mitigation " + "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); + From owner-svn-src-all@freebsd.org Tue May 14 18:10:33 2019 Return-Path: Delivered-To: svn-src-all@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 9CF4315947B4; Tue, 14 May 2019 18:10:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F7C076A33; Tue, 14 May 2019 18:10:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 190C824889; Tue, 14 May 2019 18:10:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EIAWgS095911; Tue, 14 May 2019 18:10:32 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EIAW3D095910; Tue, 14 May 2019 18:10:32 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905141810.x4EIAW3D095910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 May 2019 18:10:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347569 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 347569 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3F7C076A33 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 18:10:33 -0000 Author: markj Date: Tue May 14 18:10:32 2019 New Revision: 347569 URL: https://svnweb.freebsd.org/changeset/base/347569 Log: Remove redundant -Wl uses from the kernel's LDFLAGS. No functional change intended. MFC after: 3 days Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/kern.pre.mk head/sys/conf/kmod.mk Modified: head/sys/conf/kern.pre.mk ============================================================================== --- head/sys/conf/kern.pre.mk Tue May 14 17:05:02 2019 (r347568) +++ head/sys/conf/kern.pre.mk Tue May 14 18:10:32 2019 (r347569) @@ -144,7 +144,7 @@ CFLAGS+= ${GCOV_CFLAGS} CFLAGS+= ${CONF_CFLAGS} .if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id} -LDFLAGS+= -Wl,--build-id=sha1 +LDFLAGS+= --build-id=sha1 .endif .if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ @@ -153,11 +153,11 @@ LDFLAGS+= -Wl,--build-id=sha1 .error amd64/arm64/i386 kernel requires linker ifunc support .endif .if ${MACHINE_CPUARCH} == "amd64" -LDFLAGS+= -Wl,-z max-page-size=2097152 +LDFLAGS+= -z max-page-size=2097152 .if ${LINKER_TYPE} != "lld" -LDFLAGS+= -Wl,-z common-page-size=4096 +LDFLAGS+= -z common-page-size=4096 .else -LDFLAGS+= -Wl,-z -Wl,ifunc-noplt +LDFLAGS+= -z ifunc-noplt .endif .endif Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Tue May 14 17:05:02 2019 (r347568) +++ head/sys/conf/kmod.mk Tue May 14 18:10:32 2019 (r347569) @@ -138,7 +138,7 @@ CFLAGS+= -fno-common LDFLAGS+= -d -warn-common .if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id} -LDFLAGS+= -Wl,--build-id=sha1 +LDFLAGS+= --build-id=sha1 .endif CFLAGS+= ${DEBUG_FLAGS} From owner-svn-src-all@freebsd.org Tue May 14 18:26:40 2019 Return-Path: Delivered-To: svn-src-all@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 BE2011594E9B; Tue, 14 May 2019 18:26:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C6E377514; Tue, 14 May 2019 18:26:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36AAC24BE3; Tue, 14 May 2019 18:26:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EIQdQV006297; Tue, 14 May 2019 18:26:39 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EIQdUI006296; Tue, 14 May 2019 18:26:39 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905141826.x4EIQdUI006296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 May 2019 18:26:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347570 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 347570 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5C6E377514 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 18:26:40 -0000 Author: markj Date: Tue May 14 18:26:39 2019 New Revision: 347570 URL: https://svnweb.freebsd.org/changeset/base/347570 Log: Specify -z notext when building with -z ifunc-noplt. The upstream implementation of -z ifunc-noplt disallows its combination with -z text. The option does not have much significance for kernel builds, though. Reviewed by: kib (previous version) Discussed with: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20260 Modified: head/sys/conf/kern.pre.mk Modified: head/sys/conf/kern.pre.mk ============================================================================== --- head/sys/conf/kern.pre.mk Tue May 14 18:10:32 2019 (r347569) +++ head/sys/conf/kern.pre.mk Tue May 14 18:26:39 2019 (r347570) @@ -157,7 +157,7 @@ LDFLAGS+= -z max-page-size=2097152 .if ${LINKER_TYPE} != "lld" LDFLAGS+= -z common-page-size=4096 .else -LDFLAGS+= -z ifunc-noplt +LDFLAGS+= -z notext -z ifunc-noplt .endif .endif From owner-svn-src-all@freebsd.org Tue May 14 19:52:24 2019 Return-Path: Delivered-To: svn-src-all@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 4EB6C1596E3E; Tue, 14 May 2019 19:52:24 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0083B81E03; Tue, 14 May 2019 19:52:24 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D618625AA7; Tue, 14 May 2019 19:52:23 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EJqNib053261; Tue, 14 May 2019 19:52:23 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EJqIYE053236; Tue, 14 May 2019 19:52:18 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905141952.x4EJqIYE053236@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 19:52:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347571 - in stable/12/sys: amd64/amd64 amd64/cloudabi32 amd64/cloudabi64 amd64/linux amd64/linux32 arm/arm arm/cloudabi32 arm64/arm64 arm64/cloudabi32 arm64/cloudabi64 arm64/linux comp... X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 amd64/cloudabi32 amd64/cloudabi64 amd64/linux amd64/linux32 arm/arm arm/cloudabi32 arm64/arm64 arm64/cloudabi32 arm64/cloudabi64 arm64/linux compat/ia32 i386/cloudabi32 i... X-SVN-Commit-Revision: 347571 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0083B81E03 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 19:52:24 -0000 Author: trasz Date: Tue May 14 19:52:18 2019 New Revision: 347571 URL: https://svnweb.freebsd.org/changeset/base/347571 Log: MFC r344705: Remove sv_pagesize, originally introduced with r100384. In all of the architectures we have today, we always use PAGE_SIZE. While in theory one could define different things, none of the current architectures do, even the ones that have transitioned from 32-bit to 64-bit like i386 and arm. Some ancient mips binaries on other systems used 8k instead of 4k, but we don't support running those and likely never will due to their age and obscurity. Differently from the original commit, the merge leaves the struct member in place to preserve the ABI. Sponsored by: DARPA, AFRL Modified: stable/12/sys/amd64/amd64/elf_machdep.c stable/12/sys/amd64/cloudabi32/cloudabi32_sysvec.c stable/12/sys/amd64/cloudabi64/cloudabi64_sysvec.c stable/12/sys/amd64/linux/linux_sysvec.c stable/12/sys/amd64/linux32/linux32_sysvec.c stable/12/sys/arm/arm/elf_machdep.c stable/12/sys/arm/cloudabi32/cloudabi32_sysvec.c stable/12/sys/arm64/arm64/elf_machdep.c stable/12/sys/arm64/cloudabi32/cloudabi32_sysvec.c stable/12/sys/arm64/cloudabi64/cloudabi64_sysvec.c stable/12/sys/arm64/linux/linux_sysvec.c stable/12/sys/compat/ia32/ia32_sysvec.c stable/12/sys/i386/cloudabi32/cloudabi32_sysvec.c stable/12/sys/i386/i386/elf_machdep.c stable/12/sys/i386/linux/linux_sysvec.c stable/12/sys/kern/imgact_aout.c stable/12/sys/kern/imgact_elf.c stable/12/sys/kern/init_main.c stable/12/sys/mips/mips/elf_machdep.c stable/12/sys/mips/mips/freebsd32_machdep.c stable/12/sys/powerpc/powerpc/elf32_machdep.c stable/12/sys/powerpc/powerpc/elf64_machdep.c stable/12/sys/riscv/riscv/elf_machdep.c stable/12/sys/sparc64/sparc64/elf_machdep.c stable/12/sys/sys/sysent.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/amd64/amd64/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -64,7 +64,6 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/amd64/cloudabi32/cloudabi32_sysvec.c ============================================================================== --- stable/12/sys/amd64/cloudabi32/cloudabi32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/amd64/cloudabi32/cloudabi32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -210,7 +210,6 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fixup = cloudabi32_fixup_tcb, .sv_name = "CloudABI ELF32", .sv_coredump = elf32_coredump, - .sv_pagesize = IA32_PAGE_SIZE, .sv_minuser = FREEBSD32_MINUSER, .sv_maxuser = FREEBSD32_MAXUSER, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, Modified: stable/12/sys/amd64/cloudabi64/cloudabi64_sysvec.c ============================================================================== --- stable/12/sys/amd64/cloudabi64/cloudabi64_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/amd64/cloudabi64/cloudabi64_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -197,7 +197,6 @@ static struct sysentvec cloudabi64_elf_sysvec = { .sv_fixup = cloudabi64_fixup_tcb, .sv_name = "CloudABI ELF64", .sv_coredump = elf64_coredump, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, /* Keep top page reserved to work around AMD Ryzen stability issues. */ .sv_maxuser = VM_MAXUSER_ADDRESS - PAGE_SIZE, Modified: stable/12/sys/amd64/linux/linux_sysvec.c ============================================================================== --- stable/12/sys/amd64/linux/linux_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/amd64/linux/linux_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -723,7 +723,6 @@ struct sysentvec elf_linux_sysvec = { .sv_coredump = elf64_coredump, .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/amd64/linux32/linux32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -921,7 +921,6 @@ struct sysentvec elf_linux_sysvec = { .sv_coredump = elf32_coredump, .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = LINUX32_MAXUSER, .sv_usrstack = LINUX32_USRSTACK, Modified: stable/12/sys/arm/arm/elf_machdep.c ============================================================================== --- stable/12/sys/arm/arm/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm/arm/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -71,7 +71,6 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/arm/cloudabi32/cloudabi32_sysvec.c ============================================================================== --- stable/12/sys/arm/cloudabi32/cloudabi32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm/cloudabi32/cloudabi32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -174,7 +174,6 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fixup = cloudabi32_fixup, .sv_name = "CloudABI ELF32", .sv_coredump = elf32_coredump, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, Modified: stable/12/sys/arm64/arm64/elf_machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm64/arm64/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -70,7 +70,6 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/arm64/cloudabi32/cloudabi32_sysvec.c ============================================================================== --- stable/12/sys/arm64/cloudabi32/cloudabi32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm64/cloudabi32/cloudabi32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -182,7 +182,6 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fixup = cloudabi32_fixup, .sv_name = "CloudABI ELF32", .sv_coredump = elf32_coredump, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = (uintmax_t)1 << 32, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, Modified: stable/12/sys/arm64/cloudabi64/cloudabi64_sysvec.c ============================================================================== --- stable/12/sys/arm64/cloudabi64/cloudabi64_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm64/cloudabi64/cloudabi64_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -166,7 +166,6 @@ static struct sysentvec cloudabi64_elf_sysvec = { .sv_fixup = cloudabi64_fixup, .sv_name = "CloudABI ELF64", .sv_coredump = elf64_coredump, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, Modified: stable/12/sys/arm64/linux/linux_sysvec.c ============================================================================== --- stable/12/sys/arm64/linux/linux_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/arm64/linux/linux_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -376,7 +376,6 @@ struct sysentvec elf_linux_sysvec = { .sv_coredump = elf64_coredump, .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/12/sys/compat/ia32/ia32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/compat/ia32/ia32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -110,7 +110,6 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_coredump = elf32_coredump, .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = IA32_PAGE_SIZE, .sv_minuser = FREEBSD32_MINUSER, .sv_maxuser = FREEBSD32_MAXUSER, .sv_usrstack = FREEBSD32_USRSTACK, Modified: stable/12/sys/i386/cloudabi32/cloudabi32_sysvec.c ============================================================================== --- stable/12/sys/i386/cloudabi32/cloudabi32_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/i386/cloudabi32/cloudabi32_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -185,7 +185,6 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fixup = cloudabi32_fixup_tcb, .sv_name = "CloudABI ELF32", .sv_coredump = elf32_coredump, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, Modified: stable/12/sys/i386/i386/elf_machdep.c ============================================================================== --- stable/12/sys/i386/i386/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/i386/i386/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -66,7 +66,6 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/i386/linux/linux_sysvec.c ============================================================================== --- stable/12/sys/i386/linux/linux_sysvec.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/i386/linux/linux_sysvec.c Tue May 14 19:52:18 2019 (r347571) @@ -862,7 +862,6 @@ struct sysentvec linux_sysvec = { .sv_coredump = NULL, .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = LINUX_USRSTACK, @@ -899,7 +898,6 @@ struct sysentvec elf_linux_sysvec = { .sv_coredump = elf32_coredump, .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = LINUX_USRSTACK, Modified: stable/12/sys/kern/imgact_aout.c ============================================================================== --- stable/12/sys/kern/imgact_aout.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/kern/imgact_aout.c Tue May 14 19:52:18 2019 (r347571) @@ -88,7 +88,6 @@ struct sysentvec aout_sysvec = { .sv_coredump = NULL, .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = AOUT32_USRSTACK, .sv_usrstack = AOUT32_USRSTACK, @@ -131,7 +130,6 @@ struct sysentvec aout_sysvec = { .sv_coredump = NULL, .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = IA32_PAGE_SIZE, .sv_minuser = AOUT32_MINUSER, .sv_maxuser = AOUT32_USRSTACK, .sv_usrstack = AOUT32_USRSTACK, Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 19:52:18 2019 (r347571) @@ -90,10 +90,9 @@ static int __elfN(check_header)(const Elf_Ehdr *hdr); static Elf_Brandinfo *__elfN(get_brandinfo)(struct image_params *imgp, const char *interp, int interp_name_len, int32_t *osrel, uint32_t *fctl0); static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr, - u_long *entry, size_t pagesize); + u_long *entry); static int __elfN(load_section)(struct image_params *imgp, vm_ooffset_t offset, - caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, - size_t pagesize); + caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot); static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp); static bool __elfN(freebsd_trans_osrel)(const Elf_Note *note, int32_t *osrel); @@ -542,8 +541,7 @@ __elfN(map_insert)(struct image_params *imgp, vm_map_t static int __elfN(load_section)(struct image_params *imgp, vm_ooffset_t offset, - caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, - size_t pagesize) + caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot) { struct sf_buf *sf; size_t map_len; @@ -571,8 +569,8 @@ __elfN(load_section)(struct image_params *imgp, vm_oof object = imgp->object; map = &imgp->proc->p_vmspace->vm_map; - map_addr = trunc_page_ps((vm_offset_t)vmaddr, pagesize); - file_addr = trunc_page_ps(offset, pagesize); + map_addr = trunc_page_ps((vm_offset_t)vmaddr, PAGE_SIZE); + file_addr = trunc_page_ps(offset, PAGE_SIZE); /* * We have two choices. We can either clear the data in the last page @@ -583,9 +581,9 @@ __elfN(load_section)(struct image_params *imgp, vm_oof if (filsz == 0) map_len = 0; else if (memsz > filsz) - map_len = trunc_page_ps(offset + filsz, pagesize) - file_addr; + map_len = trunc_page_ps(offset + filsz, PAGE_SIZE) - file_addr; else - map_len = round_page_ps(offset + filsz, pagesize) - file_addr; + map_len = round_page_ps(offset + filsz, PAGE_SIZE) - file_addr; if (map_len != 0) { /* cow flags: don't dump readonly sections in core */ @@ -615,9 +613,9 @@ __elfN(load_section)(struct image_params *imgp, vm_oof * to try and save a page, but it's a pain in the behind to implement. */ copy_len = filsz == 0 ? 0 : (offset + filsz) - trunc_page_ps(offset + - filsz, pagesize); - map_addr = trunc_page_ps((vm_offset_t)vmaddr + filsz, pagesize); - map_len = round_page_ps((vm_offset_t)vmaddr + memsz, pagesize) - + filsz, PAGE_SIZE); + map_addr = trunc_page_ps((vm_offset_t)vmaddr + filsz, PAGE_SIZE); + map_len = round_page_ps((vm_offset_t)vmaddr + memsz, PAGE_SIZE) - map_addr; /* This had damn well better be true! */ @@ -634,7 +632,7 @@ __elfN(load_section)(struct image_params *imgp, vm_oof return (EIO); /* send the page fragment to user space */ - off = trunc_page_ps(offset + filsz, pagesize) - + off = trunc_page_ps(offset + filsz, PAGE_SIZE) - trunc_page(offset + filsz); error = copyout((caddr_t)sf_buf_kva(sf) + off, (caddr_t)map_addr, copy_len); @@ -668,7 +666,7 @@ __elfN(load_section)(struct image_params *imgp, vm_oof */ static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr, - u_long *entry, size_t pagesize) + u_long *entry) { struct { struct nameidata nd; @@ -767,7 +765,7 @@ __elfN(load_file)(struct proc *p, const char *file, u_ prot = __elfN(trans_prot)(phdr[i].p_flags); error = __elfN(load_section)(imgp, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, - phdr[i].p_memsz, phdr[i].p_filesz, prot, pagesize); + phdr[i].p_memsz, phdr[i].p_filesz, prot); if (error != 0) goto fail; /* @@ -1056,8 +1054,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i prot = __elfN(trans_prot)(phdr[i].p_flags); error = __elfN(load_section)(imgp, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr + et_dyn_addr, - phdr[i].p_memsz, phdr[i].p_filesz, prot, - sv->sv_pagesize); + phdr[i].p_memsz, phdr[i].p_filesz, prot); if (error != 0) goto ret; @@ -1176,7 +1173,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i snprintf(path, MAXPATHLEN, "%s%s", brand_info->emul_path, interp); error = __elfN(load_file)(imgp->proc, path, &addr, - &imgp->entry_addr, sv->sv_pagesize); + &imgp->entry_addr); free(path, M_TEMP); if (error == 0) have_interp = TRUE; @@ -1185,13 +1182,13 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i (brand_info->interp_path == NULL || strcmp(interp, brand_info->interp_path) == 0)) { error = __elfN(load_file)(imgp->proc, newinterp, &addr, - &imgp->entry_addr, sv->sv_pagesize); + &imgp->entry_addr); if (error == 0) have_interp = TRUE; } if (!have_interp) { error = __elfN(load_file)(imgp->proc, interp, &addr, - &imgp->entry_addr, sv->sv_pagesize); + &imgp->entry_addr); } vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) { Modified: stable/12/sys/kern/init_main.c ============================================================================== --- stable/12/sys/kern/init_main.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/kern/init_main.c Tue May 14 19:52:18 2019 (r347571) @@ -411,7 +411,6 @@ struct sysentvec null_sysvec = { .sv_coredump = NULL, .sv_imgact_try = NULL, .sv_minsigstksz = 0, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/mips/mips/elf_machdep.c ============================================================================== --- stable/12/sys/mips/mips/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/mips/mips/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -67,7 +67,6 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, @@ -123,7 +122,6 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- stable/12/sys/mips/mips/freebsd32_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/mips/mips/freebsd32_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -89,7 +89,6 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = ((vm_offset_t)0x80000000), .sv_usrstack = FREEBSD32_USRSTACK, Modified: stable/12/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/elf32_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/powerpc/powerpc/elf32_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -95,7 +95,6 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_stackprot = VM_PROT_ALL, #ifdef __powerpc64__ Modified: stable/12/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/elf64_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/powerpc/powerpc/elf64_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -70,7 +70,6 @@ struct sysentvec elf64_freebsd_sysvec_v1 = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, @@ -109,7 +108,6 @@ struct sysentvec elf64_freebsd_sysvec_v2 = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/riscv/riscv/elf_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/riscv/riscv/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -73,7 +73,6 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/sparc64/sparc64/elf_machdep.c ============================================================================== --- stable/12/sys/sparc64/sparc64/elf_machdep.c Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/sparc64/sparc64/elf_machdep.c Tue May 14 19:52:18 2019 (r347571) @@ -71,7 +71,6 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, - .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, .sv_usrstack = USRSTACK, Modified: stable/12/sys/sys/sysent.h ============================================================================== --- stable/12/sys/sys/sysent.h Tue May 14 18:26:39 2019 (r347570) +++ stable/12/sys/sys/sysent.h Tue May 14 19:52:18 2019 (r347571) @@ -111,7 +111,7 @@ struct sysentvec { /* function to dump core, or NULL */ int (*sv_imgact_try)(struct image_params *); int sv_minsigstksz; /* minimum signal stack size */ - int sv_pagesize; /* pagesize */ + int sv_pagesize; /* spare / no longer used */ vm_offset_t sv_minuser; /* VM_MIN_ADDRESS */ vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS */ vm_offset_t sv_usrstack; /* USRSTACK */ From owner-svn-src-all@freebsd.org Tue May 14 20:03:21 2019 Return-Path: Delivered-To: svn-src-all@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 06DA115971D4; Tue, 14 May 2019 20:03:21 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2878823B4; Tue, 14 May 2019 20:03:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6367C25C6B; Tue, 14 May 2019 20:03:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EK3Kbb058562; Tue, 14 May 2019 20:03:20 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EK3KiL058561; Tue, 14 May 2019 20:03:20 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142003.x4EK3KiL058561@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:03:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347572 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347572 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A2878823B4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:03:21 -0000 Author: trasz Date: Tue May 14 20:03:19 2019 New Revision: 347572 URL: https://svnweb.freebsd.org/changeset/base/347572 Log: MFC r345448: Remove trunc_page_ps() and round_page_ps() macros. This completes the undoing of r100384. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 19:52:18 2019 (r347571) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:03:19 2019 (r347572) @@ -159,9 +159,7 @@ SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, honor_sbrk, CTLFLA static Elf_Brandinfo *elf_brand_list[MAX_BRANDS]; -#define trunc_page_ps(va, ps) rounddown2(va, ps) -#define round_page_ps(va, ps) roundup2(va, ps) -#define aligned(a, t) (trunc_page_ps((u_long)(a), sizeof(t)) == (u_long)(a)) +#define aligned(a, t) (rounddown2((u_long)(a), sizeof(t)) == (u_long)(a)) static const char FREEBSD_ABI_VENDOR[] = "FreeBSD"; @@ -569,8 +567,8 @@ __elfN(load_section)(struct image_params *imgp, vm_oof object = imgp->object; map = &imgp->proc->p_vmspace->vm_map; - map_addr = trunc_page_ps((vm_offset_t)vmaddr, PAGE_SIZE); - file_addr = trunc_page_ps(offset, PAGE_SIZE); + map_addr = trunc_page((vm_offset_t)vmaddr); + file_addr = trunc_page(offset); /* * We have two choices. We can either clear the data in the last page @@ -581,9 +579,9 @@ __elfN(load_section)(struct image_params *imgp, vm_oof if (filsz == 0) map_len = 0; else if (memsz > filsz) - map_len = trunc_page_ps(offset + filsz, PAGE_SIZE) - file_addr; + map_len = trunc_page(offset + filsz) - file_addr; else - map_len = round_page_ps(offset + filsz, PAGE_SIZE) - file_addr; + map_len = round_page(offset + filsz) - file_addr; if (map_len != 0) { /* cow flags: don't dump readonly sections in core */ @@ -612,11 +610,10 @@ __elfN(load_section)(struct image_params *imgp, vm_oof * segment in the file is extended to provide bss. It's a neat idea * to try and save a page, but it's a pain in the behind to implement. */ - copy_len = filsz == 0 ? 0 : (offset + filsz) - trunc_page_ps(offset + - filsz, PAGE_SIZE); - map_addr = trunc_page_ps((vm_offset_t)vmaddr + filsz, PAGE_SIZE); - map_len = round_page_ps((vm_offset_t)vmaddr + memsz, PAGE_SIZE) - - map_addr; + copy_len = filsz == 0 ? 0 : (offset + filsz) - trunc_page(offset + + filsz); + map_addr = trunc_page((vm_offset_t)vmaddr + filsz); + map_len = round_page((vm_offset_t)vmaddr + memsz) - map_addr; /* This had damn well better be true! */ if (map_len != 0) { @@ -632,8 +629,7 @@ __elfN(load_section)(struct image_params *imgp, vm_oof return (EIO); /* send the page fragment to user space */ - off = trunc_page_ps(offset + filsz, PAGE_SIZE) - - trunc_page(offset + filsz); + off = trunc_page(offset + filsz) - trunc_page(offset + filsz); error = copyout((caddr_t)sf_buf_kva(sf) + off, (caddr_t)map_addr, copy_len); vm_imgact_unmap_page(sf); From owner-svn-src-all@freebsd.org Tue May 14 20:19:30 2019 Return-Path: Delivered-To: svn-src-all@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 162C6159771C; Tue, 14 May 2019 20:19:30 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B046D82A4E; Tue, 14 May 2019 20:19:29 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 86D6B25E16; Tue, 14 May 2019 20:19:29 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKJT2r063792; Tue, 14 May 2019 20:19:29 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKJTlV063791; Tue, 14 May 2019 20:19:29 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142019.x4EKJTlV063791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:19:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347573 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347573 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B046D82A4E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:19:30 -0000 Author: trasz Date: Tue May 14 20:19:29 2019 New Revision: 347573 URL: https://svnweb.freebsd.org/changeset/base/347573 Log: MFC r345547: Factor out resource limit enforcement code in the ELF loader. It makes the code slightly easier to follow, and might make it easier to fix the resouce accounting to also account for the interpreter. The PROC_UNLOCK() is moved earlier - I don't see anything it should protect; the lim_max() is a wrapper around lim_rlimit(), and that, differently from lim_rlimit_proc(), doesn't require the proc lock to be held. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:03:19 2019 (r347572) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:19:29 2019 (r347573) @@ -813,6 +813,83 @@ __CONCAT(rnd_, __elfN(base))(vm_map_t map __unused, u_ return (res); } +static int +__elfN(enforce_limits)(struct image_params *imgp, const Elf_Ehdr *hdr, + const Elf_Phdr *phdr, u_long et_dyn_addr) +{ + struct vmspace *vmspace; + const char *err_str; + u_long text_size, data_size, total_size, text_addr, data_addr; + u_long seg_size, seg_addr; + int i; + + err_str = NULL; + text_size = data_size = total_size = text_addr = data_addr = 0; + + for (i = 0; i < hdr->e_phnum; i++) { + if (phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0) + continue; + + seg_addr = trunc_page(phdr[i].p_vaddr + et_dyn_addr); + seg_size = round_page(phdr[i].p_memsz + + phdr[i].p_vaddr + et_dyn_addr - seg_addr); + + /* + * Make the largest executable segment the official + * text segment and all others data. + * + * Note that obreak() assumes that data_addr + data_size == end + * of data load area, and the ELF file format expects segments + * to be sorted by address. If multiple data segments exist, + * the last one will be used. + */ + + if ((phdr[i].p_flags & PF_X) != 0 && text_size < seg_size) { + text_size = seg_size; + text_addr = seg_addr; + } else { + data_size = seg_size; + data_addr = seg_addr; + } + total_size += seg_size; + } + + if (data_addr == 0 && data_size == 0) { + data_addr = text_addr; + data_size = text_size; + } + + /* + * Check limits. It should be safe to check the + * limits after loading the segments since we do + * not actually fault in all the segments pages. + */ + PROC_LOCK(imgp->proc); + if (data_size > lim_cur_proc(imgp->proc, RLIMIT_DATA)) + err_str = "Data segment size exceeds process limit"; + else if (text_size > maxtsiz) + err_str = "Text segment size exceeds system limit"; + else if (total_size > lim_cur_proc(imgp->proc, RLIMIT_VMEM)) + err_str = "Total segment size exceeds process limit"; + else if (racct_set(imgp->proc, RACCT_DATA, data_size) != 0) + err_str = "Data segment size exceeds resource limit"; + else if (racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) + err_str = "Total segment size exceeds resource limit"; + PROC_UNLOCK(imgp->proc); + if (err_str != NULL) { + uprintf("%s\n", err_str); + return (ENOMEM); + } + + vmspace = imgp->proc->p_vmspace; + vmspace->vm_tsize = text_size >> PAGE_SHIFT; + vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; + vmspace->vm_dsize = data_size >> PAGE_SHIFT; + vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr; + + return (0); +} + /* * Impossible et_dyn_addr initial value indicating that the real base * must be calculated later with some randomization applied. @@ -828,13 +905,12 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i Elf_Auxargs *elf_auxargs; struct vmspace *vmspace; vm_map_t map; - const char *err_str, *newinterp; + const char *newinterp; char *interp, *interp_buf, *path; Elf_Brandinfo *brand_info; struct sysentvec *sv; vm_prot_t prot; - u_long text_size, data_size, total_size, text_addr, data_addr; - u_long seg_size, seg_addr, addr, baddr, et_dyn_addr, entry, proghdr; + u_long addr, baddr, et_dyn_addr, entry, proghdr; u_long maxalign, mapsz, maxv, maxv1; uint32_t fctl0; int32_t osrel; @@ -873,10 +949,9 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i baddr = 0; osrel = 0; fctl0 = 0; - text_size = data_size = total_size = text_addr = data_addr = 0; entry = proghdr = 0; interp_name_len = 0; - err_str = newinterp = NULL; + newinterp = NULL; interp = interp_buf = NULL; td = curthread; maxalign = PAGE_SIZE; @@ -1065,30 +1140,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i <= phdr[i].p_filesz) proghdr = phdr[i].p_vaddr + hdr->e_phoff + et_dyn_addr; - - seg_addr = trunc_page(phdr[i].p_vaddr + et_dyn_addr); - seg_size = round_page(phdr[i].p_memsz + - phdr[i].p_vaddr + et_dyn_addr - seg_addr); - - /* - * Make the largest executable segment the official - * text segment and all others data. - * - * Note that obreak() assumes that data_addr + - * data_size == end of data load area, and the ELF - * file format expects segments to be sorted by - * address. If multiple data segments exist, the - * last one will be used. - */ - - if (phdr[i].p_flags & PF_X && text_size < seg_size) { - text_size = seg_size; - text_addr = seg_addr; - } else { - data_size = seg_size; - data_addr = seg_addr; - } - total_size += seg_size; break; case PT_PHDR: /* Program header table info */ proghdr = phdr[i].p_vaddr + et_dyn_addr; @@ -1097,41 +1148,12 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i break; } } - - if (data_addr == 0 && data_size == 0) { - data_addr = text_addr; - data_size = text_size; - } - entry = (u_long)hdr->e_entry + et_dyn_addr; - - /* - * Check limits. It should be safe to check the - * limits after loading the segments since we do - * not actually fault in all the segments pages. - */ - PROC_LOCK(imgp->proc); - if (data_size > lim_cur_proc(imgp->proc, RLIMIT_DATA)) - err_str = "Data segment size exceeds process limit"; - else if (text_size > maxtsiz) - err_str = "Text segment size exceeds system limit"; - else if (total_size > lim_cur_proc(imgp->proc, RLIMIT_VMEM)) - err_str = "Total segment size exceeds process limit"; - else if (racct_set(imgp->proc, RACCT_DATA, data_size) != 0) - err_str = "Data segment size exceeds resource limit"; - else if (racct_set(imgp->proc, RACCT_VMEM, total_size) != 0) - err_str = "Total segment size exceeds resource limit"; - if (err_str != NULL) { - PROC_UNLOCK(imgp->proc); - uprintf("%s\n", err_str); - error = ENOMEM; + error = __elfN(enforce_limits)(imgp, hdr, phdr, et_dyn_addr); + if (error != 0) goto ret; - } - vmspace->vm_tsize = text_size >> PAGE_SHIFT; - vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; - vmspace->vm_dsize = data_size >> PAGE_SHIFT; - vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr; + entry = (u_long)hdr->e_entry + et_dyn_addr; /* * We load the dynamic linker where a userland call @@ -1149,7 +1171,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i } else { map->anon_loc = addr; } - PROC_UNLOCK(imgp->proc); imgp->entry_addr = entry; From owner-svn-src-all@freebsd.org Tue May 14 20:26:06 2019 Return-Path: Delivered-To: svn-src-all@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 9D55115979C4; Tue, 14 May 2019 20:26:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4360582EB6; Tue, 14 May 2019 20:26:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F7E625FE0; Tue, 14 May 2019 20:26:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKQ5Qp069024; Tue, 14 May 2019 20:26:05 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKQ5Ud069023; Tue, 14 May 2019 20:26:05 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142026.x4EKQ5Ud069023@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:26:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347574 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347574 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4360582EB6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:26:06 -0000 Author: trasz Date: Tue May 14 20:26:05 2019 New Revision: 347574 URL: https://svnweb.freebsd.org/changeset/base/347574 Log: MFC r345661: Factor out retrieving the interpreter path from the main ELF loader routine. MFC r345734 by kib: Fix branding after r345661. In particular, elf32 FreeBSD binaries were not executed on LP64 hosts. The interp_name_len value should account for the nul terminator. This is needed for strncmp()s in brand checking code to work. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:19:29 2019 (r347573) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:26:05 2019 (r347574) @@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$"); static int __elfN(check_header)(const Elf_Ehdr *hdr); static Elf_Brandinfo *__elfN(get_brandinfo)(struct image_params *imgp, - const char *interp, int interp_name_len, int32_t *osrel, uint32_t *fctl0); + const char *interp, int32_t *osrel, uint32_t *fctl0); static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr, u_long *entry); static int __elfN(load_section)(struct image_params *imgp, vm_ooffset_t offset, @@ -273,13 +273,15 @@ __elfN(brand_inuse)(Elf_Brandinfo *entry) static Elf_Brandinfo * __elfN(get_brandinfo)(struct image_params *imgp, const char *interp, - int interp_name_len, int32_t *osrel, uint32_t *fctl0) + int32_t *osrel, uint32_t *fctl0) { const Elf_Ehdr *hdr = (const Elf_Ehdr *)imgp->image_header; Elf_Brandinfo *bi, *bi_m; boolean_t ret; - int i; + int i, interp_name_len; + interp_name_len = interp != NULL ? strlen(interp) + 1 : 0; + /* * We support four types of branding -- (1) the ELF EI_OSABI field * that SCO added to the ELF spec, (2) FreeBSD 3.x's traditional string @@ -890,6 +892,60 @@ __elfN(enforce_limits)(struct image_params *imgp, cons return (0); } +static int +__elfN(get_interp)(struct image_params *imgp, const Elf_Phdr *phdr, + char **interpp, bool *free_interpp) +{ + struct thread *td; + char *interp; + int error, interp_name_len; + + KASSERT(phdr->p_type == PT_INTERP, + ("%s: p_type %u != PT_INTERP", __func__, phdr->p_type)); + KASSERT(VOP_ISLOCKED(imgp->vp), + ("%s: vp %p is not locked", __func__, imgp->vp)); + + td = curthread; + + /* Path to interpreter */ + if (phdr->p_filesz < 2 || phdr->p_filesz > MAXPATHLEN) { + uprintf("Invalid PT_INTERP\n"); + return (ENOEXEC); + } + + interp_name_len = phdr->p_filesz; + if (phdr->p_offset > PAGE_SIZE || + interp_name_len > PAGE_SIZE - phdr->p_offset) { + VOP_UNLOCK(imgp->vp, 0); + interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + error = vn_rdwr(UIO_READ, imgp->vp, interp, + interp_name_len, phdr->p_offset, + UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, + NOCRED, NULL, td); + if (error != 0) { + free(interp, M_TEMP); + uprintf("i/o error PT_INTERP %d\n", error); + return (error); + } + interp[interp_name_len] = '\0'; + + *interpp = interp; + *free_interpp = true; + return (0); + } + + interp = __DECONST(char *, imgp->image_header) + phdr->p_offset; + if (interp[interp_name_len - 1] != '\0') { + uprintf("Invalid PT_INTERP\n"); + return (ENOEXEC); + } + + *interpp = interp; + *free_interpp = false; + return (0); +} + /* * Impossible et_dyn_addr initial value indicating that the real base * must be calculated later with some randomization applied. @@ -906,7 +962,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i struct vmspace *vmspace; vm_map_t map; const char *newinterp; - char *interp, *interp_buf, *path; + char *interp, *path; Elf_Brandinfo *brand_info; struct sysentvec *sv; vm_prot_t prot; @@ -914,7 +970,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i u_long maxalign, mapsz, maxv, maxv1; uint32_t fctl0; int32_t osrel; - int error, i, n, interp_name_len, have_interp; + bool free_interp; + int error, i, n, have_interp; hdr = (const Elf_Ehdr *)imgp->image_header; @@ -950,9 +1007,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i osrel = 0; fctl0 = 0; entry = proghdr = 0; - interp_name_len = 0; - newinterp = NULL; - interp = interp_buf = NULL; + newinterp = interp = NULL; + free_interp = false; td = curthread; maxalign = PAGE_SIZE; mapsz = 0; @@ -969,44 +1025,15 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i break; case PT_INTERP: /* Path to interpreter */ - if (phdr[i].p_filesz < 2 || - phdr[i].p_filesz > MAXPATHLEN) { - uprintf("Invalid PT_INTERP\n"); - error = ENOEXEC; - goto ret; - } if (interp != NULL) { uprintf("Multiple PT_INTERP headers\n"); error = ENOEXEC; goto ret; } - interp_name_len = phdr[i].p_filesz; - if (phdr[i].p_offset > PAGE_SIZE || - interp_name_len > PAGE_SIZE - phdr[i].p_offset) { - VOP_UNLOCK(imgp->vp, 0); - interp_buf = malloc(interp_name_len + 1, M_TEMP, - M_WAITOK); - vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); - error = vn_rdwr(UIO_READ, imgp->vp, interp_buf, - interp_name_len, phdr[i].p_offset, - UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, - NOCRED, NULL, td); - if (error != 0) { - uprintf("i/o error PT_INTERP %d\n", - error); - goto ret; - } - interp_buf[interp_name_len] = '\0'; - interp = interp_buf; - } else { - interp = __DECONST(char *, imgp->image_header) + - phdr[i].p_offset; - if (interp[interp_name_len - 1] != '\0') { - uprintf("Invalid PT_INTERP\n"); - error = ENOEXEC; - goto ret; - } - } + error = __elfN(get_interp)(imgp, &phdr[i], &interp, + &free_interp); + if (error != 0) + goto ret; break; case PT_GNU_STACK: if (__elfN(nxstack)) @@ -1017,8 +1044,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i } } - brand_info = __elfN(get_brandinfo)(imgp, interp, interp_name_len, - &osrel, &fctl0); + brand_info = __elfN(get_brandinfo)(imgp, interp, &osrel, &fctl0); if (brand_info == NULL) { uprintf("ELF binary type \"%u\" not known.\n", hdr->e_ident[EI_OSABI]); @@ -1239,7 +1265,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i imgp->proc->p_elf_flags = hdr->e_flags; ret: - free(interp_buf, M_TEMP); + if (free_interp) + free(interp, M_TEMP); return (error); } From owner-svn-src-all@freebsd.org Tue May 14 20:27:47 2019 Return-Path: Delivered-To: svn-src-all@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 3E8031597AAA; Tue, 14 May 2019 20:27:47 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D366C8307B; Tue, 14 May 2019 20:27:46 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 69E3525FE1; Tue, 14 May 2019 20:27:46 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKRkmM069145; Tue, 14 May 2019 20:27:46 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKRkY1069144; Tue, 14 May 2019 20:27:46 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142027.x4EKRkY1069144@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:27:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347575 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347575 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D366C8307B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:27:47 -0000 Author: trasz Date: Tue May 14 20:27:45 2019 New Revision: 347575 URL: https://svnweb.freebsd.org/changeset/base/347575 Log: MFC r346030: Refactor ELF interpreter loading into a separate function. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:26:05 2019 (r347574) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:27:45 2019 (r347575) @@ -946,6 +946,41 @@ __elfN(get_interp)(struct image_params *imgp, const El return (0); } +static int +__elfN(load_interp)(struct image_params *imgp, const Elf_Brandinfo *brand_info, + const char *interp, u_long *addr, u_long *entry) +{ + char *path; + int error; + + if (brand_info->emul_path != NULL && + brand_info->emul_path[0] != '\0') { + path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + snprintf(path, MAXPATHLEN, "%s%s", + brand_info->emul_path, interp); + error = __elfN(load_file)(imgp->proc, path, addr, entry); + free(path, M_TEMP); + if (error == 0) + return (0); + } + + if (brand_info->interp_newpath != NULL && + (brand_info->interp_path == NULL || + strcmp(interp, brand_info->interp_path) == 0)) { + error = __elfN(load_file)(imgp->proc, + brand_info->interp_newpath, addr, entry); + if (error == 0) + return (0); + } + + error = __elfN(load_file)(imgp->proc, interp, addr, entry); + if (error == 0) + return (0); + + uprintf("ELF interpreter %s not found, error %d\n", interp, error); + return (error); +} + /* * Impossible et_dyn_addr initial value indicating that the real base * must be calculated later with some randomization applied. @@ -961,8 +996,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i Elf_Auxargs *elf_auxargs; struct vmspace *vmspace; vm_map_t map; - const char *newinterp; - char *interp, *path; + char *interp; Elf_Brandinfo *brand_info; struct sysentvec *sv; vm_prot_t prot; @@ -971,7 +1005,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i uint32_t fctl0; int32_t osrel; bool free_interp; - int error, i, n, have_interp; + int error, i, n; hdr = (const Elf_Ehdr *)imgp->image_header; @@ -1007,7 +1041,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i osrel = 0; fctl0 = 0; entry = proghdr = 0; - newinterp = interp = NULL; + interp = NULL; free_interp = false; td = curthread; maxalign = PAGE_SIZE; @@ -1075,8 +1109,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i et_dyn_addr = ET_DYN_LOAD_ADDR; } } - if (interp != NULL && brand_info->interp_newpath != NULL) - newinterp = brand_info->interp_newpath; /* * Avoid a possible deadlock if the current address space is destroyed @@ -1201,7 +1233,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i imgp->entry_addr = entry; if (interp != NULL) { - have_interp = FALSE; VOP_UNLOCK(imgp->vp, 0); if ((map->flags & MAP_ASLR) != 0) { /* Assume that interpeter fits into 1/4 of AS */ @@ -1210,35 +1241,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i addr = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1, PAGE_SIZE); } - if (brand_info->emul_path != NULL && - brand_info->emul_path[0] != '\0') { - path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); - snprintf(path, MAXPATHLEN, "%s%s", - brand_info->emul_path, interp); - error = __elfN(load_file)(imgp->proc, path, &addr, - &imgp->entry_addr); - free(path, M_TEMP); - if (error == 0) - have_interp = TRUE; - } - if (!have_interp && newinterp != NULL && - (brand_info->interp_path == NULL || - strcmp(interp, brand_info->interp_path) == 0)) { - error = __elfN(load_file)(imgp->proc, newinterp, &addr, - &imgp->entry_addr); - if (error == 0) - have_interp = TRUE; - } - if (!have_interp) { - error = __elfN(load_file)(imgp->proc, interp, &addr, - &imgp->entry_addr); - } + error = __elfN(load_interp)(imgp, brand_info, interp, &addr, + &imgp->entry_addr); vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); - if (error != 0) { - uprintf("ELF interpreter %s not found, error %d\n", - interp, error); + if (error != 0) goto ret; - } } else addr = et_dyn_addr; From owner-svn-src-all@freebsd.org Tue May 14 20:29:13 2019 Return-Path: Delivered-To: svn-src-all@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 6D6301597BAE; Tue, 14 May 2019 20:29:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 113BD8324E; Tue, 14 May 2019 20:29:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5EAC25FE2; Tue, 14 May 2019 20:29:12 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKTCjW069257; Tue, 14 May 2019 20:29:12 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKTCDW069256; Tue, 14 May 2019 20:29:12 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142029.x4EKTCDW069256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:29:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347576 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347576 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 113BD8324E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:29:13 -0000 Author: trasz Date: Tue May 14 20:29:12 2019 New Revision: 347576 URL: https://svnweb.freebsd.org/changeset/base/347576 Log: MFC r346053: Factor out section loading into a separate function. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:27:45 2019 (r347575) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:29:12 2019 (r347576) @@ -650,6 +650,45 @@ __elfN(load_section)(struct image_params *imgp, vm_oof return (0); } +static int +__elfN(load_sections)(struct image_params *imgp, const Elf_Ehdr *hdr, + const Elf_Phdr *phdr, u_long rbase, u_long *base_addrp) +{ + vm_prot_t prot; + u_long base_addr; + bool first; + int error, i; + + base_addr = 0; + first = true; + + for (i = 0; i < hdr->e_phnum; i++) { + if (phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0) + continue; + + /* Loadable segment */ + prot = __elfN(trans_prot)(phdr[i].p_flags); + error = __elfN(load_section)(imgp, phdr[i].p_offset, + (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, + phdr[i].p_memsz, phdr[i].p_filesz, prot); + if (error != 0) + return (error); + + /* + * Establish the base address if this is the first segment. + */ + if (first) { + base_addr = trunc_page(phdr[i].p_vaddr + rbase); + first = false; + } + } + + if (base_addrp != NULL) + *base_addrp = base_addr; + + return (0); +} + /* * Load the file "file" into memory. It may be either a shared object * or an executable. @@ -676,10 +715,9 @@ __elfN(load_file)(struct proc *p, const char *file, u_ struct nameidata *nd; struct vattr *attr; struct image_params *imgp; - vm_prot_t prot; u_long rbase; u_long base_addr = 0; - int error, i, numsegs; + int error; #ifdef CAPABILITY_MODE /* @@ -757,25 +795,10 @@ __elfN(load_file)(struct proc *p, const char *file, u_ goto fail; } - for (i = 0, numsegs = 0; i < hdr->e_phnum; i++) { - if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0) { - /* Loadable segment */ - prot = __elfN(trans_prot)(phdr[i].p_flags); - error = __elfN(load_section)(imgp, phdr[i].p_offset, - (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, - phdr[i].p_memsz, phdr[i].p_filesz, prot); - if (error != 0) - goto fail; - /* - * Establish the base address if this is the - * first segment. - */ - if (numsegs == 0) - base_addr = trunc_page(phdr[i].p_vaddr + - rbase); - numsegs++; - } - } + error = __elfN(load_sections)(imgp, hdr, phdr, rbase, &base_addr); + if (error != 0) + goto fail; + *addr = base_addr; *entry = (unsigned long)hdr->e_entry + rbase; @@ -999,7 +1022,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i char *interp; Elf_Brandinfo *brand_info; struct sysentvec *sv; - vm_prot_t prot; u_long addr, baddr, et_dyn_addr, entry, proghdr; u_long maxalign, mapsz, maxv, maxv1; uint32_t fctl0; @@ -1056,6 +1078,17 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i maxalign = phdr[i].p_align; mapsz += phdr[i].p_memsz; n++; + + /* + * If this segment contains the program headers, + * remember their virtual address for the AT_PHDR + * aux entry. Static binaries don't usually include + * a PT_PHDR entry. + */ + if (phdr[i].p_offset == 0 && + hdr->e_phoff + hdr->e_phnum * hdr->e_phentsize + <= phdr[i].p_filesz) + proghdr = phdr[i].p_vaddr + hdr->e_phoff; break; case PT_INTERP: /* Path to interpreter */ @@ -1075,6 +1108,9 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i __elfN(trans_prot)(phdr[i].p_flags); imgp->stack_sz = phdr[i].p_memsz; break; + case PT_PHDR: /* Program header table info */ + proghdr = phdr[i].p_vaddr; + break; } } @@ -1175,38 +1211,10 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i if (error != 0) goto ret; - for (i = 0; i < hdr->e_phnum; i++) { - switch (phdr[i].p_type) { - case PT_LOAD: /* Loadable segment */ - if (phdr[i].p_memsz == 0) - break; - prot = __elfN(trans_prot)(phdr[i].p_flags); - error = __elfN(load_section)(imgp, phdr[i].p_offset, - (caddr_t)(uintptr_t)phdr[i].p_vaddr + et_dyn_addr, - phdr[i].p_memsz, phdr[i].p_filesz, prot); - if (error != 0) - goto ret; + error = __elfN(load_sections)(imgp, hdr, phdr, et_dyn_addr, NULL); + if (error != 0) + goto ret; - /* - * If this segment contains the program headers, - * remember their virtual address for the AT_PHDR - * aux entry. Static binaries don't usually include - * a PT_PHDR entry. - */ - if (phdr[i].p_offset == 0 && - hdr->e_phoff + hdr->e_phnum * hdr->e_phentsize - <= phdr[i].p_filesz) - proghdr = phdr[i].p_vaddr + hdr->e_phoff + - et_dyn_addr; - break; - case PT_PHDR: /* Program header table info */ - proghdr = phdr[i].p_vaddr + et_dyn_addr; - break; - default: - break; - } - } - error = __elfN(enforce_limits)(imgp, hdr, phdr, et_dyn_addr); if (error != 0) goto ret; @@ -1254,7 +1262,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i */ elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK); elf_auxargs->execfd = -1; - elf_auxargs->phdr = proghdr; + elf_auxargs->phdr = proghdr + et_dyn_addr; elf_auxargs->phent = hdr->e_phentsize; elf_auxargs->phnum = hdr->e_phnum; elf_auxargs->pagesz = PAGE_SIZE; From owner-svn-src-all@freebsd.org Tue May 14 20:31:07 2019 Return-Path: Delivered-To: svn-src-all@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 3C2081597DCE; Tue, 14 May 2019 20:31:07 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D56628353C; Tue, 14 May 2019 20:31:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B05F42601F; Tue, 14 May 2019 20:31:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKV6c9073413; Tue, 14 May 2019 20:31:06 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKV6eO073412; Tue, 14 May 2019 20:31:06 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142031.x4EKV6eO073412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:31:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347577 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D56628353C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:31:07 -0000 Author: trasz Date: Tue May 14 20:31:06 2019 New Revision: 347577 URL: https://svnweb.freebsd.org/changeset/base/347577 Log: MFC r346076: Improve vnode lock assertions. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:29:12 2019 (r347576) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:31:06 2019 (r347577) @@ -659,6 +659,8 @@ __elfN(load_sections)(struct image_params *imgp, const bool first; int error, i; + ASSERT_VOP_LOCKED(imgp->vp, __func__); + base_addr = 0; first = true; @@ -925,8 +927,7 @@ __elfN(get_interp)(struct image_params *imgp, const El KASSERT(phdr->p_type == PT_INTERP, ("%s: p_type %u != PT_INTERP", __func__, phdr->p_type)); - KASSERT(VOP_ISLOCKED(imgp->vp), - ("%s: vp %p is not locked", __func__, imgp->vp)); + ASSERT_VOP_LOCKED(imgp->vp, __func__); td = curthread; From owner-svn-src-all@freebsd.org Tue May 14 20:32:30 2019 Return-Path: Delivered-To: svn-src-all@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 1E7F51597EB1; Tue, 14 May 2019 20:32:30 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B6D0A837D0; Tue, 14 May 2019 20:32:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90A6A26184; Tue, 14 May 2019 20:32:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKWTYt074474; Tue, 14 May 2019 20:32:29 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKWTpt074473; Tue, 14 May 2019 20:32:29 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201905142032.x4EKWTpt074473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 14 May 2019 20:32:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347578 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 347578 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B6D0A837D0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:32:30 -0000 Author: kevans Date: Tue May 14 20:32:29 2019 New Revision: 347578 URL: https://svnweb.freebsd.org/changeset/base/347578 Log: tuntap: Defer clearing if_softc until after if_detach r346670 added an sx to close a race between the ifioctl handler and interface destruction. Unfortunately, it clears if_softc immediately after the interface is closed, but before if_detach has been invoked. Any time before detachment, an interface that's part of a bridge may still receive traffic that's pushed through tunstart/tunstart_l2 and promptly lead to a panic because if_softc is now NULL. Fix it by deferring the clearing of if_softc until after the interface has detached and thus been removed from the bridge. if_softc still gets cleared in case another thread has already entered the ioctl handler before it's replaced with ifdead_ioctl. Reported by: markj MFC after: 3 days Modified: head/sys/net/if_tuntap.c Modified: head/sys/net/if_tuntap.c ============================================================================== --- head/sys/net/if_tuntap.c Tue May 14 20:31:06 2019 (r347577) +++ head/sys/net/if_tuntap.c Tue May 14 20:32:29 2019 (r347578) @@ -537,9 +537,6 @@ tun_destroy(struct tuntap_softc *tp) TUN_UNLOCK(tp); CURVNET_SET(TUN2IFP(tp)->if_vnet); - sx_xlock(&tun_ioctl_sx); - TUN2IFP(tp)->if_softc = NULL; - sx_xunlock(&tun_ioctl_sx); destroy_dev(tp->tun_dev); seldrain(&tp->tun_rsel); @@ -551,6 +548,9 @@ tun_destroy(struct tuntap_softc *tp) bpfdetach(TUN2IFP(tp)); if_detach(TUN2IFP(tp)); } + sx_xlock(&tun_ioctl_sx); + TUN2IFP(tp)->if_softc = NULL; + sx_xunlock(&tun_ioctl_sx); free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit); if_free(TUN2IFP(tp)); mtx_destroy(&tp->tun_mtx); From owner-svn-src-all@freebsd.org Tue May 14 20:41:25 2019 Return-Path: Delivered-To: svn-src-all@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 4FDB115984F0; Tue, 14 May 2019 20:41:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB8C783DB3; Tue, 14 May 2019 20:41:24 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5876262D8; Tue, 14 May 2019 20:41:24 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKfOEJ078704; Tue, 14 May 2019 20:41:24 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKfO7v078703; Tue, 14 May 2019 20:41:24 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142041.x4EKfO7v078703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347579 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EB8C783DB3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:41:25 -0000 Author: trasz Date: Tue May 14 20:41:24 2019 New Revision: 347579 URL: https://svnweb.freebsd.org/changeset/base/347579 Log: MFC r346120: Use shared vnode locks for the ELF interpreter. Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:32:29 2019 (r347578) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 20:41:24 2019 (r347579) @@ -717,7 +717,7 @@ __elfN(load_file)(struct proc *p, const char *file, u_ struct nameidata *nd; struct vattr *attr; struct image_params *imgp; - u_long rbase; + u_long flags, rbase; u_long base_addr = 0; int error; @@ -745,7 +745,10 @@ __elfN(load_file)(struct proc *p, const char *file, u_ imgp->object = NULL; imgp->execlabel = NULL; - NDINIT(nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, file, curthread); + flags = FOLLOW | LOCKSHARED | LOCKLEAF; + +again: + NDINIT(nd, LOOKUP, flags, UIO_SYSSPACE, file, curthread); if ((error = namei(nd)) != 0) { nd->ni_vp = NULL; goto fail; @@ -760,15 +763,30 @@ __elfN(load_file)(struct proc *p, const char *file, u_ if (error) goto fail; + /* + * Also make certain that the interpreter stays the same, + * so set its VV_TEXT flag, too. Since this function is only + * used to load the interpreter, the VV_TEXT is almost always + * already set. + */ + if (VOP_IS_TEXT(nd->ni_vp) == 0) { + if (VOP_ISLOCKED(nd->ni_vp) != LK_EXCLUSIVE) { + /* + * LK_UPGRADE could have resulted in dropping + * the lock. Just try again from the start, + * this time with exclusive vnode lock. + */ + vput(nd->ni_vp); + flags &= ~LOCKSHARED; + goto again; + } + + VOP_SET_TEXT(nd->ni_vp); + } + error = exec_map_first_page(imgp); if (error) goto fail; - - /* - * Also make certain that the interpreter stays the same, so set - * its VV_TEXT flag, too. - */ - VOP_SET_TEXT(nd->ni_vp); imgp->object = nd->ni_vp->v_object; From owner-svn-src-all@freebsd.org Tue May 14 20:59:45 2019 Return-Path: Delivered-To: svn-src-all@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 7D16515989DD; Tue, 14 May 2019 20:59:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2411F84565; Tue, 14 May 2019 20:59:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EEEAF2650C; Tue, 14 May 2019 20:59:44 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EKxi4O084787; Tue, 14 May 2019 20:59:44 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EKxieO084786; Tue, 14 May 2019 20:59:44 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201905142059.x4EKxieO084786@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 14 May 2019 20:59:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347580 - head/sys/amd64/linux X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/sys/amd64/linux X-SVN-Commit-Revision: 347580 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2411F84565 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.956,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 20:59:45 -0000 Author: trasz Date: Tue May 14 20:59:44 2019 New Revision: 347580 URL: https://svnweb.freebsd.org/changeset/base/347580 Log: Fix handling of r10 in Linux ptrace(2). This fixes decoding of the 'flags' argument to mmap(2) with Linux strace(1). Reviewed by: dchagin MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20223 Modified: head/sys/amd64/linux/linux_ptrace.c Modified: head/sys/amd64/linux/linux_ptrace.c ============================================================================== --- head/sys/amd64/linux/linux_ptrace.c Tue May 14 20:41:24 2019 (r347579) +++ head/sys/amd64/linux/linux_ptrace.c Tue May 14 20:59:44 2019 (r347580) @@ -338,18 +338,27 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, voi map_regs_to_linux(&b_reg, &l_reg); - /* - * The strace(1) utility depends on RAX being set to -ENOSYS - * on syscall entry. - */ error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { printf("%s: PT_LWPINFO failed with error %d\n", __func__, error); return (error); } - if (lwpinfo.pl_flags & PL_FLAG_SCE) - l_reg.rax = -38; // XXX: Don't hardcode? + if (lwpinfo.pl_flags & PL_FLAG_SCE) { + /* + * The strace(1) utility depends on RAX being set to -ENOSYS + * on syscall entry; otherwise it loops printing those: + * + * [ Process PID=928 runs in 64 bit mode. ] + * [ Process PID=928 runs in x32 mode. ] + */ + l_reg.rax = -38; /* -ENOSYS */ + /* + * Undo the mangling done in exception.S:fast_syscall_common(). + */ + l_reg.r10 = l_reg.rcx; + } + error = copyout(&l_reg, (void *)data, sizeof(l_reg)); return (error); } @@ -399,21 +408,27 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid map_regs_to_linux_regset(&b_reg, fsbase, gsbase, &l_regset); - /* - * The strace(1) utility depends on RAX being set to -ENOSYS - * on syscall entry; otherwise it loops printing those: - * - * [ Process PID=928 runs in 64 bit mode. ] - * [ Process PID=928 runs in x32 mode. ] - */ error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { printf("%s: PT_LWPINFO failed with error %d\n", __func__, error); return (error); } - if (lwpinfo.pl_flags & PL_FLAG_SCE) - l_regset.rax = -38; // XXX: Don't hardcode? + if (lwpinfo.pl_flags & PL_FLAG_SCE) { + /* + * The strace(1) utility depends on RAX being set to -ENOSYS + * on syscall entry; otherwise it loops printing those: + * + * [ Process PID=928 runs in 64 bit mode. ] + * [ Process PID=928 runs in x32 mode. ] + */ + l_regset.rax = -38; /* -ENOSYS */ + + /* + * Undo the mangling done in exception.S:fast_syscall_common(). + */ + l_regset.r10 = l_regset.rcx; + } len = MIN(iov.iov_len, sizeof(l_regset)); error = copyout(&l_regset, (void *)iov.iov_base, len); From owner-svn-src-all@freebsd.org Tue May 14 21:11:16 2019 Return-Path: Delivered-To: svn-src-all@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 3D5021598DBD; Tue, 14 May 2019 21:11:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D7AF284D18; Tue, 14 May 2019 21:11:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7626926809; Tue, 14 May 2019 21:11:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4ELBFUt091372; Tue, 14 May 2019 21:11:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4ELBFsZ091371; Tue, 14 May 2019 21:11:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201905142111.x4ELBFsZ091371@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 14 May 2019 21:11:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347581 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 347581 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D7AF284D18 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.95)[-0.953,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 21:11:16 -0000 Author: kib Date: Tue May 14 21:11:15 2019 New Revision: 347581 URL: https://svnweb.freebsd.org/changeset/base/347581 Log: MFC r347148: imgact_elf: do not relock the text vnode if possible. Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:59:44 2019 (r347580) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 21:11:15 2019 (r347581) @@ -958,9 +958,12 @@ __elfN(get_interp)(struct image_params *imgp, const El interp_name_len = phdr->p_filesz; if (phdr->p_offset > PAGE_SIZE || interp_name_len > PAGE_SIZE - phdr->p_offset) { - VOP_UNLOCK(imgp->vp, 0); - interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK); - vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + interp = malloc(interp_name_len + 1, M_TEMP, M_NOWAIT); + if (interp == NULL) { + VOP_UNLOCK(imgp->vp, 0); + interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } error = vn_rdwr(UIO_READ, imgp->vp, interp, interp_name_len, phdr->p_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, @@ -1279,7 +1282,12 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i /* * Construct auxargs table (used by the fixup routine) */ - elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK); + elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_NOWAIT); + if (elf_auxargs == NULL) { + VOP_UNLOCK(imgp->vp, 0); + elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } elf_auxargs->execfd = -1; elf_auxargs->phdr = proghdr + et_dyn_addr; elf_auxargs->phent = hdr->e_phentsize; @@ -2559,9 +2567,12 @@ __elfN(parse_notes)(struct image_params *imgp, Elf_Not ASSERT_VOP_LOCKED(imgp->vp, "parse_notes"); if (pnote->p_offset > PAGE_SIZE || pnote->p_filesz > PAGE_SIZE - pnote->p_offset) { - VOP_UNLOCK(imgp->vp, 0); - buf = malloc(pnote->p_filesz, M_TEMP, M_WAITOK); - vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + buf = malloc(pnote->p_filesz, M_TEMP, M_NOWAIT); + if (buf == NULL) { + VOP_UNLOCK(imgp->vp, 0); + buf = malloc(pnote->p_filesz, M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } error = vn_rdwr(UIO_READ, imgp->vp, buf, pnote->p_filesz, pnote->p_offset, UIO_SYSSPACE, IO_NODELOCKED, curthread->td_ucred, NOCRED, NULL, curthread); From owner-svn-src-all@freebsd.org Tue May 14 21:30:56 2019 Return-Path: Delivered-To: svn-src-all@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 C8DFB159949E; Tue, 14 May 2019 21:30:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6ADA8857EB; Tue, 14 May 2019 21:30:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4435626A32; Tue, 14 May 2019 21:30:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4ELUugu002702; Tue, 14 May 2019 21:30:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4ELUtr2002700; Tue, 14 May 2019 21:30:55 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201905142130.x4ELUtr2002700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 14 May 2019 21:30:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347582 - in head/sys: netinet netinet6 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head/sys: netinet netinet6 X-SVN-Commit-Revision: 347582 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6ADA8857EB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 21:30:57 -0000 Author: markj Date: Tue May 14 21:30:55 2019 New Revision: 347582 URL: https://svnweb.freebsd.org/changeset/base/347582 Log: Close some races in multicast socket option handling. r333175 converted the global multicast lock to a sleepable sx lock, so the lock order with respect to the (non-sleepable) inp lock changed. To handle this, r333175 and r333505 added code to drop the inp lock, but this opened races that could leave multicast group description structures in an inconsistent state. This change fixes the problem by simply acquiring the global lock sooner. Along the way, this fixes some LORs and bogus error handling introduced in r333175, and commits some related cleanup. Reported by: syzbot+ba7c4943547e0604faca@syzkaller.appspotmail.com Reported by: syzbot+1b803796ab94d11a46f9@syzkaller.appspotmail.com Reviewed by: ae MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20070 Modified: head/sys/netinet/in_mcast.c head/sys/netinet6/in6_mcast.c Modified: head/sys/netinet/in_mcast.c ============================================================================== --- head/sys/netinet/in_mcast.c Tue May 14 21:11:15 2019 (r347581) +++ head/sys/netinet/in_mcast.c Tue May 14 21:30:55 2019 (r347582) @@ -1534,6 +1534,7 @@ inp_block_unblock_source(struct inpcb *inp, struct soc /* * Check if we are actually a member of this group. */ + IN_MULTI_LOCK(); imo = inp_findmoptions(inp); idx = imo_match_group(imo, ifp, &gsa->sa); if (idx == -1 || imo->imo_mfilters == NULL) { @@ -1593,14 +1594,13 @@ inp_block_unblock_source(struct inpcb *inp, struct soc /* * Begin state merge transaction at IGMP layer. */ - IN_MULTI_LOCK(); CTR1(KTR_IGMPV3, "%s: merge inm state", __func__); IN_MULTI_LIST_LOCK(); error = inm_merge(inm, imf); if (error) { CTR1(KTR_IGMPV3, "%s: failed to merge inm state", __func__); IN_MULTI_LIST_UNLOCK(); - goto out_in_multi_locked; + goto out_imf_rollback; } CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__); @@ -1609,9 +1609,6 @@ inp_block_unblock_source(struct inpcb *inp, struct soc if (error) CTR1(KTR_IGMPV3, "%s: failed igmp downcall", __func__); -out_in_multi_locked: - - IN_MULTI_UNLOCK(); out_imf_rollback: if (error) imf_rollback(imf); @@ -1622,6 +1619,7 @@ out_imf_rollback: out_inp_locked: INP_WUNLOCK(inp); + IN_MULTI_UNLOCK(); return (error); } @@ -1680,10 +1678,10 @@ inp_findmoptions(struct inpcb *inp) static void inp_gcmoptions(struct ip_moptions *imo) { - struct in_mfilter *imf; + struct in_mfilter *imf; struct in_multi *inm; struct ifnet *ifp; - size_t idx, nmships; + size_t idx, nmships; nmships = imo->imo_num_memberships; for (idx = 0; idx < nmships; ++idx) { @@ -2142,12 +2140,12 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt CTR2(KTR_IGMPV3, "%s: unknown sopt_name %d", __func__, sopt->sopt_name); return (EOPNOTSUPP); - break; } if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0) return (EADDRNOTAVAIL); + IN_MULTI_LOCK(); imo = inp_findmoptions(inp); idx = imo_match_group(imo, ifp, &gsa->sa); if (idx == -1) { @@ -2272,10 +2270,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt /* * Begin state merge transaction at IGMP layer. */ - in_pcbref(inp); - INP_WUNLOCK(inp); - IN_MULTI_LOCK(); - if (is_new) { error = in_joingroup_locked(ifp, &gsa->sin.sin_addr, imf, &inm); @@ -2286,6 +2280,8 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt goto out_imo_free; } inm_acquire(inm); + KASSERT(imo->imo_membership[idx] == NULL, + ("%s: imo_membership already allocated", __func__)); imo->imo_membership[idx] = inm; } else { CTR1(KTR_IGMPV3, "%s: merge inm state", __func__); @@ -2295,7 +2291,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt CTR1(KTR_IGMPV3, "%s: failed to merge inm state", __func__); IN_MULTI_LIST_UNLOCK(); - goto out_in_multi_locked; + goto out_imf_rollback; } CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__); error = igmp_change_state(inm); @@ -2303,16 +2299,11 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt if (error) { CTR1(KTR_IGMPV3, "%s: failed igmp downcall", __func__); - goto out_in_multi_locked; + goto out_imf_rollback; } } -out_in_multi_locked: - - IN_MULTI_UNLOCK(); - INP_WLOCK(inp); - if (in_pcbrele_wlocked(inp)) - return (ENXIO); +out_imf_rollback: if (error) { imf_rollback(imf); if (is_new) @@ -2337,6 +2328,7 @@ out_imo_free: out_inp_locked: INP_WUNLOCK(inp); + IN_MULTI_UNLOCK(); return (error); } @@ -2463,6 +2455,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop /* * Find the membership in the membership array. */ + IN_MULTI_LOCK(); imo = inp_findmoptions(inp); idx = imo_match_group(imo, ifp, &gsa->sa); if (idx == -1) { @@ -2510,9 +2503,6 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop /* * Begin state merge transaction at IGMP layer. */ - in_pcbref(inp); - INP_WUNLOCK(inp); - IN_MULTI_LOCK(); if (is_final) { /* @@ -2528,7 +2518,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop CTR1(KTR_IGMPV3, "%s: failed to merge inm state", __func__); IN_MULTI_LIST_UNLOCK(); - goto out_in_multi_locked; + goto out_imf_rollback; } CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__); @@ -2540,13 +2530,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop } } -out_in_multi_locked: - - IN_MULTI_UNLOCK(); - INP_WLOCK(inp); - if (in_pcbrele_wlocked(inp)) - return (ENXIO); - +out_imf_rollback: if (error) imf_rollback(imf); else @@ -2557,7 +2541,7 @@ out_in_multi_locked: if (is_final) { /* Remove the gap in the membership and filter array. */ KASSERT(RB_EMPTY(&imf->imf_sources), - ("%s: imf_sources not empty", __func__)); + ("%s: imf_sources (%p %p %zu) not empty", __func__, imf, imo, idx)); for (++idx; idx < imo->imo_num_memberships; ++idx) { imo->imo_membership[idx - 1] = imo->imo_membership[idx]; imo->imo_mfilters[idx - 1] = imo->imo_mfilters[idx]; @@ -2569,6 +2553,7 @@ out_in_multi_locked: out_inp_locked: INP_WUNLOCK(inp); + IN_MULTI_UNLOCK(); return (error); } @@ -2646,8 +2631,6 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt /* * Atomically set source filters on a socket for an IPv4 multicast group. - * - * SMPng: NOTE: Potentially calls malloc(M_WAITOK) with Giant held. */ static int inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt) @@ -2694,6 +2677,7 @@ inp_set_source_filters(struct inpcb *inp, struct socko * Take the INP write lock. * Check if this socket is a member of this group. */ + IN_MULTI_LOCK(); imo = inp_findmoptions(inp); idx = imo_match_group(imo, ifp, &gsa->sa); if (idx == -1 || imo->imo_mfilters == NULL) { @@ -2778,7 +2762,6 @@ inp_set_source_filters(struct inpcb *inp, struct socko goto out_imf_rollback; INP_WLOCK_ASSERT(inp); - IN_MULTI_LOCK(); /* * Begin state merge transaction at IGMP layer. @@ -2789,7 +2772,7 @@ inp_set_source_filters(struct inpcb *inp, struct socko if (error) { CTR1(KTR_IGMPV3, "%s: failed to merge inm state", __func__); IN_MULTI_LIST_UNLOCK(); - goto out_in_multi_locked; + goto out_imf_rollback; } CTR1(KTR_IGMPV3, "%s: doing igmp downcall", __func__); @@ -2798,10 +2781,6 @@ inp_set_source_filters(struct inpcb *inp, struct socko if (error) CTR1(KTR_IGMPV3, "%s: failed igmp downcall", __func__); -out_in_multi_locked: - - IN_MULTI_UNLOCK(); - out_imf_rollback: if (error) imf_rollback(imf); @@ -2812,6 +2791,7 @@ out_imf_rollback: out_inp_locked: INP_WUNLOCK(inp); + IN_MULTI_UNLOCK(); return (error); } Modified: head/sys/netinet6/in6_mcast.c ============================================================================== --- head/sys/netinet6/in6_mcast.c Tue May 14 21:11:15 2019 (r347581) +++ head/sys/netinet6/in6_mcast.c Tue May 14 21:30:55 2019 (r347582) @@ -2052,6 +2052,7 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sop */ (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); + IN6_MULTI_LOCK(); imo = in6p_findmoptions(inp); idx = im6o_match_group(imo, ifp, &gsa->sa); if (idx == -1) { @@ -2171,10 +2172,6 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sop /* * Begin state merge transaction at MLD layer. */ - in_pcbref(inp); - INP_WUNLOCK(inp); - IN6_MULTI_LOCK(); - if (is_new) { error = in6_joingroup_locked(ifp, &gsa->sin6.sin6_addr, imf, &inm, 0); @@ -2204,10 +2201,6 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sop IN6_MULTI_LIST_UNLOCK(); } - IN6_MULTI_UNLOCK(); - INP_WLOCK(inp); - if (in_pcbrele_wlocked(inp)) - return (ENXIO); if (error) { im6f_rollback(imf); if (is_new) @@ -2232,6 +2225,7 @@ out_im6o_free: out_in6p_locked: INP_WUNLOCK(inp); + IN6_MULTI_UNLOCK(); in6m_release_list_deferred(&inmh); return (error); } @@ -2381,6 +2375,7 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so /* * Find the membership in the membership array. */ + IN6_MULTI_LOCK(); imo = in6p_findmoptions(inp); idx = im6o_match_group(imo, ifp, &gsa->sa); if (idx == -1) { @@ -2429,10 +2424,6 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so /* * Begin state merge transaction at MLD layer. */ - in_pcbref(inp); - INP_WUNLOCK(inp); - IN6_MULTI_LOCK(); - if (is_final) { /* * Give up the multicast address record to which @@ -2456,11 +2447,6 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so IN6_MULTI_LIST_UNLOCK(); } - IN6_MULTI_UNLOCK(); - INP_WLOCK(inp); - if (in_pcbrele_wlocked(inp)) - return (ENXIO); - if (error) im6f_rollback(imf); else @@ -2483,6 +2469,7 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so out_in6p_locked: INP_WUNLOCK(inp); + IN6_MULTI_UNLOCK(); return (error); } @@ -2528,8 +2515,6 @@ in6p_set_multicast_if(struct inpcb *inp, struct sockop /* * Atomically set source filters on a socket for an IPv6 multicast group. - * - * SMPng: NOTE: Potentially calls malloc(M_WAITOK) with Giant held. */ static int in6p_set_source_filters(struct inpcb *inp, struct sockopt *sopt) From owner-svn-src-all@freebsd.org Tue May 14 22:00:48 2019 Return-Path: Delivered-To: svn-src-all@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 B4F901599F19; Tue, 14 May 2019 22:00:48 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5751886826; Tue, 14 May 2019 22:00:48 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 330D726F74; Tue, 14 May 2019 22:00:48 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EM0mYf016867; Tue, 14 May 2019 22:00:48 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EM0mdh016866; Tue, 14 May 2019 22:00:48 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201905142200.x4EM0mdh016866@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 14 May 2019 22:00:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347583 - head/usr.sbin/mountd X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/usr.sbin/mountd X-SVN-Commit-Revision: 347583 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5751886826 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.956,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 22:00:48 -0000 Author: rmacklem Date: Tue May 14 22:00:47 2019 New Revision: 347583 URL: https://svnweb.freebsd.org/changeset/base/347583 Log: Replace global list for grouplist with list(s) for each exportlist element. In mountd.c, the grouplist structures are linked into a single global linked list headed by "grphead". The only use of this linked list is to free all list elements when the exportlist elements are also all being free'd at the time the exports are being reloaded. This patch replaces this one global linked list head with a list head in each exportlist structure, where the grouplist elements for that exported file system are linked. The only change is that now the grouplist elements are free'd with the associated exportlist element as they are free'd instead of all grouplist elements being free'd after the exportlist elements are free'd. This change should have no effect in practice. This is being done, since a future patch that will add a "-I" option for incrementally updating the exports in the kernel needs to know which grouplist elements are associated with each exported file system and having them linked into a list headed by the exportlist element does that. MFC after: 1 month Modified: head/usr.sbin/mountd/mountd.c Modified: head/usr.sbin/mountd/mountd.c ============================================================================== --- head/usr.sbin/mountd/mountd.c Tue May 14 21:30:55 2019 (r347582) +++ head/usr.sbin/mountd/mountd.c Tue May 14 22:00:47 2019 (r347583) @@ -114,6 +114,7 @@ struct dirlist { struct exportlist { struct dirlist *ex_dirl; struct dirlist *ex_defdir; + struct grouplist *ex_grphead; int ex_flag; fsid_t ex_fs; char *ex_fsdir; @@ -235,7 +236,6 @@ static void terminate(int); static struct exportlisthead exphead = SLIST_HEAD_INITIALIZER(&exphead); static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(&mlhead); -static struct grouplist *grphead; static char *exnames_default[2] = { _PATH_EXPORTS, NULL }; static char **exnames; static char **hosts = NULL; @@ -455,7 +455,6 @@ main(int argc, char **argv) argc -= optind; argv += optind; - grphead = (struct grouplist *)NULL; if (argc > 0) exnames = argv; else @@ -1692,8 +1691,8 @@ get_exportlist_one(void) */ if (has_host) { hang_dirp(dirhead, tgrp, ep, opt_flags); - grp->gr_next = grphead; - grphead = tgrp; + grp->gr_next = ep->ex_grphead; + ep->ex_grphead = tgrp; } else { hang_dirp(dirhead, (struct grouplist *)NULL, ep, opt_flags); @@ -1720,7 +1719,6 @@ nextline: static void get_exportlist(void) { - struct grouplist *grp, *tgrp; struct export_args export; struct iovec *iov; struct statfs *mntbufp; @@ -1743,14 +1741,6 @@ get_exportlist(void) */ free_exports(&exphead); - grp = grphead; - while (grp) { - tgrp = grp; - grp = grp->gr_next; - free_grp(tgrp); - } - grphead = (struct grouplist *)NULL; - /* * and the old V4 root dir. */ @@ -2448,6 +2438,7 @@ get_host(char *cp, struct grouplist *grp, struct group static void free_exp(struct exportlist *ep) { + struct grouplist *grp, *tgrp; if (ep->ex_defdir) { free_host(ep->ex_defdir->dp_hosts); @@ -2458,6 +2449,12 @@ free_exp(struct exportlist *ep) if (ep->ex_indexfile) free(ep->ex_indexfile); free_dir(ep->ex_dirl); + grp = ep->ex_grphead; + while (grp) { + tgrp = grp; + grp = grp->gr_next; + free_grp(tgrp); + } free((caddr_t)ep); } From owner-svn-src-all@freebsd.org Tue May 14 22:48:42 2019 Return-Path: Delivered-To: svn-src-all@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 5BFED159AF42; Tue, 14 May 2019 22:48:42 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0470E88133; Tue, 14 May 2019 22:48:42 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E7D03277D8; Tue, 14 May 2019 22:48:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4EMmfjI042359; Tue, 14 May 2019 22:48:41 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4EMmbFR042330; Tue, 14 May 2019 22:48:37 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <201905142248.x4EMmbFR042330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Tue, 14 May 2019 22:48:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r347584 - in releng: 11.2/contrib/tzdata 12.0/contrib/tzdata X-SVN-Group: releng X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: in releng: 11.2/contrib/tzdata 12.0/contrib/tzdata X-SVN-Commit-Revision: 347584 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0470E88133 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 14 May 2019 22:48:42 -0000 Author: gordon Date: Tue May 14 22:48:36 2019 New Revision: 347584 URL: https://svnweb.freebsd.org/changeset/base/347584 Log: Import tzdata 2019a. Approved by: so Security: FreeBSD-EN-19:08.tzdata Modified: releng/11.2/contrib/tzdata/Makefile releng/11.2/contrib/tzdata/NEWS releng/11.2/contrib/tzdata/README releng/11.2/contrib/tzdata/africa releng/11.2/contrib/tzdata/asia releng/11.2/contrib/tzdata/backward releng/11.2/contrib/tzdata/backzone releng/11.2/contrib/tzdata/etcetera releng/11.2/contrib/tzdata/europe releng/11.2/contrib/tzdata/leap-seconds.list releng/11.2/contrib/tzdata/leapseconds releng/11.2/contrib/tzdata/northamerica releng/11.2/contrib/tzdata/theory.html releng/11.2/contrib/tzdata/version releng/12.0/contrib/tzdata/Makefile releng/12.0/contrib/tzdata/NEWS releng/12.0/contrib/tzdata/README releng/12.0/contrib/tzdata/africa releng/12.0/contrib/tzdata/asia releng/12.0/contrib/tzdata/backward releng/12.0/contrib/tzdata/backzone releng/12.0/contrib/tzdata/etcetera releng/12.0/contrib/tzdata/europe releng/12.0/contrib/tzdata/leap-seconds.list releng/12.0/contrib/tzdata/leapseconds releng/12.0/contrib/tzdata/northamerica releng/12.0/contrib/tzdata/theory.html releng/12.0/contrib/tzdata/version Modified: releng/11.2/contrib/tzdata/Makefile ============================================================================== --- releng/11.2/contrib/tzdata/Makefile Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/Makefile Tue May 14 22:48:36 2019 (r347584) @@ -12,7 +12,10 @@ VERSION= unknown # Email address for bug reports. BUGEMAIL= tz@iana.org -# Choose source data features. To get new features right away, use: +# DATAFORM selects the data format. +# Available formats represent essentially the same data, albeit +# possibly with minor discrepancies that users are not likely to notice. +# To get new features and the best data right away, use: # DATAFORM= vanguard # To wait a while before using new features, to give downstream users # time to upgrade zic (the default), use: @@ -33,11 +36,11 @@ DATAFORM= main LOCALTIME= GMT # If you want something other than Eastern United States time as a template -# for handling POSIX-style timezone environment variables, +# for handling ruleless POSIX-style timezone environment variables, # change the line below (after finding the timezone you want in the # one of the $(TDATA) source files, or adding it to a source file). -# When a POSIX-style environment variable is handled, the rules in the -# template file are used to determine "spring forward" and "fall back" days and +# A ruleless environment setting like TZ='CST6CDT' uses the rules in the +# template file to determine "spring forward" and "fall back" days and # times; the environment variable itself specifies UT offsets of standard and # daylight saving time. # Alternatively, if you discover you've got the wrong timezone, you can just @@ -46,7 +49,6 @@ LOCALTIME= GMT # Use the command # make zonenames # to get a list of the values you can use for POSIXRULES. -# If you want POSIX compatibility, use "America/New_York". POSIXRULES= America/New_York @@ -113,8 +115,8 @@ TIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TI TIME_T_ALTERNATIVES_HEAD = int64_t TIME_T_ALTERNATIVES_TAIL = int32_t uint32_t uint64_t -# What kind of TZif data files to generate. -# (TZif is the binary time zone data format that zic generates.) +# What kind of TZif data files to generate. (TZif is the binary time +# zone data format that zic generates; see Internet RFC 8536.) # If you want only POSIX time, with time values interpreted as # seconds since the epoch (not counting leap seconds), use # REDO= posix_only @@ -360,6 +362,9 @@ LEAPSECONDS= zic= ./zic ZIC= $(zic) $(ZFLAGS) +# To shrink the size of installed TZif files, +# append "-r @N" to omit data before N-seconds-after-the-Epoch. +# See the zic man page for more about -r. ZFLAGS= # How to use zic to install TZif files. @@ -491,7 +496,8 @@ MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.t COMMON= calendars CONTRIBUTING LICENSE Makefile \ NEWS README theory.html version WEB_PAGES= tz-art.html tz-how-to.html tz-link.html -CHECK_WEB_PAGES=check_tz-art.html check_tz-how-to.html check_tz-link.html +CHECK_WEB_PAGES=check_theory.html check_tz-art.html \ + check_tz-how-to.html check_tz-link.html DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES) PRIMARY_YDATA= africa antarctica asia australasia \ europe northamerica southamerica @@ -804,9 +810,10 @@ check_tzs: $(TZS) $(TZS_NEW) touch $@ check_web: $(CHECK_WEB_PAGES) +check_theory.html: theory.html check_tz-art.html: tz-art.html check_tz-link.html: tz-link.html -check_tz-art.html check_tz-link.html: +check_theory.html check_tz-art.html check_tz-link.html: $(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \ -F file=@$$(expr $@ : 'check_\(.*\)') -o $@.out && \ test ! -s $@.out || { cat $@.out; exit 1; } @@ -840,11 +847,13 @@ check_zishrink_posix check_zishrink_right: \ touch $@ clean_misc: + rm -fr check_*.dir rm -f *.o *.out $(TIME_T_ALTERNATIVES) \ check_* core typecheck_* \ date tzselect version.h zdump zic yearistype libtz.a clean: clean_misc - rm -fr *.dir *.zi tzdb-*/ $(TZS_NEW) + rm -fr *.dir tzdb-*/ + rm -f *.zi $(TZS_NEW) maintainer-clean: clean @echo 'This command is intended for maintainers to use; it' Modified: releng/11.2/contrib/tzdata/NEWS ============================================================================== --- releng/11.2/contrib/tzdata/NEWS Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/NEWS Tue May 14 22:48:36 2019 (r347584) @@ -1,5 +1,53 @@ News for the tz database +Release 20198 - 2019-03-25 22:01:33 -0700 + + Briefly: + Palestine "springs forward" on 2019-03-30 instead of 2019-03-23. + Metlakatla "fell back" to rejoin Alaska Time on 2019-01-20 at 02:00. + + Changes to past and future timestamps + + Palestine will not start DST until 2019-03-30, instead of 2019-03-23 as + previously predicted. Adjust our prediction by guessing that spring + transitions will be between 24 and 30 March, which matches recent practice + since 2016. (Thanks to Even Scharning and Tim Parenti.) + + Metlakatla ended its observance of Pacific standard time, + rejoining Alaska Time, on 2019-01-20 at 02:00. (Thanks to Ryan + Stanley and Tim Parenti.) + + Changes to past timestamps + + Israel observed DST in 1980 (08-02/09-13) and 1984 (05-05/08-25). + (Thanks to Alois Treindl and Isaac Starkman.) + + Changes to time zone abbreviations + + Etc/UCT is now a backward-compatibility link to Etc/UTC, instead + of being a separate zone that generates the abbreviation "UCT", + which nowadays is typically a typo. (Problem reported by Isiah + Meadows.) + + Changes to code + + zic now has an -r option to limit the time range of output data. + For example, 'zic -r @1000000000' limits the output data to + timestamps starting 1000000000 seconds after the Epoch. + This helps shrink output size and can be useful for applications + not needing the full timestamp history, such as TZDIST truncation; + see Internet RFC 8536 section 5.1. (Inspired by a feature request + from Christopher Wong, helped along by bug reports from Wong and + from Tim Parenti.) + + Changes to documentation + + Mention Internet RFC 8536 (February 2019), which documents TZif. + + tz-link.html now cites tzdata-meta + . + + Release 2018i - 2018-12-30 11:05:43 -0800 Briefly: @@ -400,8 +448,9 @@ Release 2018d - 2018-03-22 07:05:46 -0700 downstream parsers do not support it. * The build procedure constructs three files vanguard.zi, main.zi, - and rearguard.zi, one for each format. The files represent the - same data as closely as the formats allow. These three files + and rearguard.zi, one for each format. Although the files + represent essentially the same data, they may have minor + discrepancies that users are not likely to notice. The files are intended for downstream data consumers and are not installed. Zoneinfo parsers that do not support negative SAVE values should start using rearguard.zi, so that they will be unaffected Modified: releng/11.2/contrib/tzdata/README ============================================================================== --- releng/11.2/contrib/tzdata/README Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/README Tue May 14 22:48:36 2019 (r347584) @@ -1,7 +1,7 @@ README for the tz distribution -"What time is it?" -- Richard Deacon as The King -"Any time you want it to be." -- Frank Baxter as The Scientist +"Where do I set the hands of the clock?" -- Les Tremayne as The King +"Oh that--you can set them any place you want." -- Frank Baxter as The Scientist (from the Bell System film "About Time") The Time Zone Database (called tz, tzdb or zoneinfo) contains code and Modified: releng/11.2/contrib/tzdata/africa ============================================================================== --- releng/11.2/contrib/tzdata/africa Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/africa Tue May 14 22:48:36 2019 (r347584) @@ -364,6 +364,11 @@ Zone Africa/Cairo 2:05:09 - LMT 1900 Oct # See Africa/Lagos. # Eritrea +# See Africa/Nairobi. + +# Eswatini (formerly Swaziland) +# See Africa/Johannesburg. + # Ethiopia # See Africa/Nairobi. # @@ -1188,7 +1193,7 @@ Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8 1:30 - SAST 1903 Mar 2:00 SA SAST Link Africa/Johannesburg Africa/Maseru # Lesotho -Link Africa/Johannesburg Africa/Mbabane # Swaziland +Link Africa/Johannesburg Africa/Mbabane # Eswatini # # Marion and Prince Edward Is # scientific station since 1947 @@ -1229,9 +1234,6 @@ Zone Africa/Khartoum 2:10:08 - LMT 1931 Zone Africa/Juba 2:06:28 - LMT 1931 2:00 Sudan CA%sT 2000 Jan 15 12:00 3:00 - EAT - -# Swaziland -# See Africa/Johannesburg. # Tanzania # See Africa/Nairobi. Modified: releng/11.2/contrib/tzdata/asia ============================================================================== --- releng/11.2/contrib/tzdata/asia Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/asia Tue May 14 22:48:36 2019 (r347584) @@ -1620,6 +1620,24 @@ Rule Zion 1974 only - Jul 7 0:00 1:00 D Rule Zion 1974 only - Oct 13 0:00 0 S Rule Zion 1975 only - Apr 20 0:00 1:00 D Rule Zion 1975 only - Aug 31 0:00 0 S + +# From Alois Treindl (2019-03-06): +# http://www.moin.gov.il/Documents/שעון קיץ/clock-50-years-7-2014.pdf +# From Isaac Starkman (2019-03-06): +# Summer time was in that period in 1980 and 1984, see +# https://www.ynet.co.il/articles/0,7340,L-3951073,00.html +# You can of course read it in translation. +# I checked the local newspapers for that years. +# It started on midnight and end at 01.00 am. +# From Paul Eggert (2019-03-06): +# Also see this thread about the moin.gov.il URL: +# https://mm.icann.org/pipermail/tz/2018-November/027194.html +Rule Zion 1980 only - Aug 2 0:00 1:00 D +Rule Zion 1980 only - Sep 13 1:00 0 S +Rule Zion 1984 only - May 5 0:00 1:00 D +Rule Zion 1984 only - Aug 25 1:00 0 S + +# From Shanks & Pottenger: Rule Zion 1985 only - Apr 14 0:00 1:00 D Rule Zion 1985 only - Sep 15 0:00 0 S Rule Zion 1986 only - May 18 0:00 1:00 D @@ -3071,9 +3089,15 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # the official website, though the decree did not specify the exact # time of the time shift. # http://www.palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e7a42ab7-ee23-435a-b9c8-a4f7e81f3817 + +# From Even Scharning (2019-03-23): +# DST in Palestine will start on 30 March this year, not 23 March as the time +# zone database predicted. +# https://ramallah.news/post/123610 # -# From Paul Eggert (2018-03-16): -# For 2016 on, predict spring transitions on March's fourth Saturday at 01:00. +# From Tim Parenti (2019-03-23): +# Combining this with the rules observed since 2016, adjust our spring +# transition guess to Mar Sat>=24. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S @@ -3104,7 +3128,7 @@ Rule Palestine 2012 only - Sep 21 1:00 0 - Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - Rule Palestine 2014 2015 - Oct Fri>=21 0:00 0 - Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S -Rule Palestine 2016 max - Mar Sat>=22 1:00 1:00 S +Rule Palestine 2016 max - Mar Sat>=24 1:00 1:00 S Rule Palestine 2016 max - Oct lastSat 1:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -3595,6 +3619,18 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 7:00 - +07 1959 Dec 31 23:00 8:00 - +08 1975 Jun 13 7:00 - +07 + +# From Paul Eggert (2019-02-19): +# +# The Ho Chi Minh entry suffices for most purposes as it agrees with all of +# Vietnam since 1975-06-13. Presumably clocks often changed in south Vietnam +# in the early 1970s as locations changed hands during the war; however the +# details are unknown and would likely be too voluminous for this database. +# +# For timestamps in north Vietnam back to 1970 (the tzdb cutoff), +# use Asia/Bangkok; see the VN entries in the file zone1970.tab. +# For timestamps before 1970, see Asia/Hanoi in the file 'backzone'. + # Yemen # See Asia/Riyadh. Modified: releng/11.2/contrib/tzdata/backward ============================================================================== --- releng/11.2/contrib/tzdata/backward Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/backward Tue May 14 22:48:36 2019 (r347584) @@ -77,6 +77,7 @@ Link Pacific/Easter Chile/EasterIsland Link America/Havana Cuba Link Africa/Cairo Egypt Link Europe/Dublin Eire +Link Etc/UTC Etc/UCT Link Europe/London Europe/Belfast Link Europe/Chisinau Europe/Tiraspol Link Europe/London GB @@ -111,7 +112,7 @@ Link Asia/Taipei ROC Link Asia/Seoul ROK Link Asia/Singapore Singapore Link Europe/Istanbul Turkey -Link Etc/UCT UCT +Link Etc/UTC UCT Link America/Anchorage US/Alaska Link America/Adak US/Aleutian Link America/Phoenix US/Arizona Modified: releng/11.2/contrib/tzdata/backzone ============================================================================== --- releng/11.2/contrib/tzdata/backzone Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/backzone Tue May 14 22:48:36 2019 (r347584) @@ -204,7 +204,7 @@ Zone Africa/Maseru 1:50:00 - LMT 1903 Mar 2:00 1:00 SAST 1944 Mar 19 2:00 2:00 - SAST -# Swaziland +# Eswatini (formerly Swaziland) Zone Africa/Mbabane 2:04:24 - LMT 1903 Mar 2:00 - SAST @@ -625,7 +625,7 @@ Zone Europe/Sarajevo 1:13:40 - LMT 1884 1:00 - CET 1982 Nov 27 1:00 EU CE%sT -# Macedonia +# North Macedonia Zone Europe/Skopje 1:25:44 - LMT 1884 1:00 - CET 1941 Apr 18 23:00 1:00 C-Eur CE%sT 1945 May 8 2:00s Modified: releng/11.2/contrib/tzdata/etcetera ============================================================================== --- releng/11.2/contrib/tzdata/etcetera Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/etcetera Tue May 14 22:48:36 2019 (r347584) @@ -19,7 +19,6 @@ Zone Etc/GMT 0 - GMT Zone Etc/UTC 0 - UTC -Zone Etc/UCT 0 - UCT # The following link uses older naming conventions, # but it belongs here, not in the file 'backward', Modified: releng/11.2/contrib/tzdata/europe ============================================================================== --- releng/11.2/contrib/tzdata/europe Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/europe Tue May 14 22:48:36 2019 (r347584) @@ -1855,7 +1855,7 @@ Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun 1:00 Belgium CE%sT 1977 1:00 EU CE%sT -# Macedonia +# North Macedonia # See Europe/Belgrade. # Malta @@ -3359,7 +3359,7 @@ Zone Europe/Belgrade 1:22:00 - LMT 1884 Link Europe/Belgrade Europe/Ljubljana # Slovenia Link Europe/Belgrade Europe/Podgorica # Montenegro Link Europe/Belgrade Europe/Sarajevo # Bosnia and Herzegovina -Link Europe/Belgrade Europe/Skopje # Macedonia +Link Europe/Belgrade Europe/Skopje # North Macedonia Link Europe/Belgrade Europe/Zagreb # Croatia # Slovakia Modified: releng/11.2/contrib/tzdata/leap-seconds.list ============================================================================== --- releng/11.2/contrib/tzdata/leap-seconds.list Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/leap-seconds.list Tue May 14 22:48:36 2019 (r347584) @@ -204,10 +204,10 @@ # current -- the update time stamp, the data and the name of the file # will not change. # -# Updated through IERS Bulletin C56 -# File expires on: 28 June 2019 +# Updated through IERS Bulletin C57 +# File expires on: 28 December 2019 # -#@ 3770668800 +#@ 3786480000 # 2272060800 10 # 1 Jan 1972 2287785600 11 # 1 Jul 1972 @@ -252,4 +252,4 @@ # the hash line is also ignored in the # computation. # -#h 62ca19f6 96a4ae0a 3708451c 9f8693f4 016604eb +#h 83c68138 d3650221 07dbbbcd 11fcc859 ced1106a Modified: releng/11.2/contrib/tzdata/leapseconds ============================================================================== --- releng/11.2/contrib/tzdata/leapseconds Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/leapseconds Tue May 14 22:48:36 2019 (r347584) @@ -63,7 +63,7 @@ Leap 2016 Dec 31 23:59:60 + S # POSIX timestamps for the data in this file: #updated 1467936000 -#expires 1561680000 +#expires 1577491200 -# Updated through IERS Bulletin C56 -# File expires on: 28 June 2019 +# Updated through IERS Bulletin C57 +# File expires on: 28 December 2019 Modified: releng/11.2/contrib/tzdata/northamerica ============================================================================== --- releng/11.2/contrib/tzdata/northamerica Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/northamerica Tue May 14 22:48:36 2019 (r347584) @@ -609,6 +609,15 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12 # In a 2018-12-11 special election, Metlakatla voted to go back to # Alaska time (including daylight saving time) starting next year. # https://www.krbd.org/2018/12/12/metlakatla-to-follow-alaska-standard-time-allow-liquor-sales/ +# +# From Ryan Stanley (2019-01-11): +# The community will be changing back on the 20th of this month... +# From Tim Parenti (2019-01-11): +# Per an announcement on the Metlakatla community's official Facebook page, the +# "fall back" will be on Sunday 2019-01-20 at 02:00: +# https://www.facebook.com/141055983004923/photos/607150969728753/ +# So they won't be waiting for Alaska to join them on 2019-03-10, but will +# rather change their clocks twice in seven weeks. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Juneau 15:02:19 - LMT 1867 Oct 19 15:33:32 @@ -637,7 +646,7 @@ Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 19 15 -8:00 US P%sT 1983 Oct 30 2:00 -8:00 - PST 2015 Nov 1 2:00 -9:00 US AK%sT 2018 Nov 4 2:00 - -8:00 - PST 2019 Mar Sun>=8 3:00 + -8:00 - PST 2019 Jan 20 2:00 -9:00 US AK%sT Zone America/Yakutat 14:41:05 - LMT 1867 Oct 19 15:12:18 -9:18:55 - LMT 1900 Aug 20 12:00 Modified: releng/11.2/contrib/tzdata/theory.html ============================================================================== --- releng/11.2/contrib/tzdata/theory.html Tue May 14 22:00:47 2019 (r347583) +++ releng/11.2/contrib/tzdata/theory.html Tue May 14 22:48:36 2019 (r347584) @@ -15,7 +15,7 @@
  • Scope of the tz database
  • -
  • Names of timezones
  • +
  • Timezone identifiers
  • Time zone abbreviations
  • Accuracy of the tz database
  • @@ -107,9 +107,9 @@ It does not always make sense to talk about a timezone
    -

    Names of timezones

    +

    Timezone identifiers

    -Each timezone has a unique name. +Each timezone has a name that uniquely identifies the timezone. Inexperienced users are not expected to select these names unaided. Distributors should provide documentation and/or a simple selection interface that explains each name via a map or via descriptive text like @@ -142,10 +142,12 @@ among the following goals:

  • Be robust in the presence of political changes. - For example, names of countries are ordinarily not used, to avoid + For example, names are typically not tied to countries, to avoid incompatibilities when countries change their name (e.g., - Zaire→Congo) or when locations change countries (e.g., Hong + Swaziland→Eswatini) or when locations change countries (e.g., Hong Kong from UK colony to China). + There is no requirement that every country or national + capital must have a timezone name.
  • Be portable to a wide variety of implementations. @@ -215,19 +217,18 @@ in decreasing order of importance: do not need locations, since local time is not defined there.
  • - There should typically be at least one name for each ISO - 3166-1 officially assigned two-letter code for an inhabited - country or territory. -
  • -
  • If all the clocks in a timezone have agreed since 1970, do not bother to include more than one timezone even if some of the clocks disagreed before 1970. Otherwise these tables would become annoyingly large.
  • + If boundaries between regions are fluid, such as during a war or + insurrection, do not bother to create a new timezone merely + because of yet another boundary change. This helps prevent table + bloat and simplifies maintenance. +
  • +
  • If a name is ambiguous, use a less ambiguous alternative; e.g., many cities are named San José and Georgetown, so prefer America/Costa_Rica to @@ -299,29 +300,23 @@ in decreasing order of importance:

-The file 'zone1970.tab' lists geographical locations used -to name timezones. -It is intended to be an exhaustive list of names for geographic -regions as described above; this is a subset of the timezones in the data. -Although a 'zone1970.tab' location's -longitude -corresponds to -its local mean -time (LMT) offset with one hour for every 15° -east longitude, this relationship is not exact. +Guidelines have evolved with time, and names following old versions of +this guideline might not follow the current version. When guidelines +have changed, old names continue to be supported. Guideline changes +have included the following:

-

-Older versions of this package used a different naming scheme, -and these older names are still supported. +

    +
  • +Older versions of this package used a different naming scheme. See the file 'backward' for most of these older names (e.g., 'US/Eastern' instead of 'America/New_York'). The other old-fashioned names still supported are 'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). -

    +
  • -

    +

  • Older versions of this package defined legacy names that are incompatible with the first guideline of location names, but which are still supported. @@ -332,6 +327,31 @@ Also, the file 'backward' defines the leg and the file 'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', 'MST7MDT', and 'PST8PDT'. +
  • + +
  • +Older versions of this guideline said that +there should typically be at least one name for each ISO +3166-1 officially assigned two-letter code for an inhabited +country or territory. +This old guideline has been dropped, as it was not needed to handle +timestamps correctly and it increased maintenance burden. +
  • +
+ +

+The file 'zone1970.tab' lists geographical locations used +to name timezones. +It is intended to be an exhaustive list of names for geographic +regions as described above; this is a subset of the timezones in the data. +Although a 'zone1970.tab' location's +longitude +corresponds to +its local mean +time (LMT) offset with one hour for every 15° +east longitude, this relationship is not exact.

@@ -983,7 +1003,9 @@ an older zic. constrained to be a string containing abbreviations and numeric data as described above. The file's format is TZif, - a timezone information format that contains binary data. + a timezone information format that contains binary data; see + Internet + RFC 8536. The daylight saving time rules to be used for a particular timezone are encoded in the TZif file; the format of the file allows US, @@ -1166,7 +1188,7 @@ The tz code and data supply