From nobody Mon Jan 10 07:22:09 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3808119469B4; Mon, 10 Jan 2022 07:22:10 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JXQJ16lDZz4rJ7; Mon, 10 Jan 2022 07:22:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C896A2123C; Mon, 10 Jan 2022 07:22:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20A7M9KV003195; Mon, 10 Jan 2022 07:22:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20A7M9DM003194; Mon, 10 Jan 2022 07:22:09 GMT (envelope-from git) Date: Mon, 10 Jan 2022 07:22:09 GMT Message-Id: <202201100722.20A7M9DM003194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: ae13829ddce0 - main - vm_addr_ok: add power2 invariant check List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae13829ddce0b5fbf12f2b240a26414b41def8ba Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641799330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m/NQ3PejwpRFG4mOU3sv0fTqk7AYg3o0ph0fwoIHvAg=; b=I4RAyX3x/fhnyGOta6xeleFqOr7utE2Zycmop7PR5gPDdv5FXHxb501CImxMxYuUSlvbqH Ws3ijLUGFefiaioWDGAmY3tT8iL9n16F+Yj+/jFtpbmREA26SYi06pB6QvXwc50M1xfVyX 1JuxuTuLRqJ57LAZ/ExIkw+HbcDN+Za8xz+zMegoAWwhfJY8S/bt+doIa68aCmmqD6l8k5 mxJAwxCg20diimHKZO3ua7+a8baUjDoDZB+nyt26nxZb7qk0w5zQX2Sz5zuhHmWvV8EPqr sxE85irgjtpGTEygq/21g23JQQuT6g8b5aVeK+bTkWRyovQph+CFwCGOlhFcKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641799330; a=rsa-sha256; cv=none; b=OXdTmBFvlRY5rQBMGkg2tklJ0x3XyuJsdeVTPudSvk7tzPjZb6K2lp7oJVaAC7/gS/fy/g BiyZQw79UWR+MjkeJ+Nn0/St6PMymM3ZytGvBRRfjnZbvz1wUckIFs2uzhoRm/rfdUdfL0 IfYHnTlJwrQqPakOWn/QSoi8wzG3NJTVo9msh73EnO2gXjRfZo+pmoGAPQliLauMXMeV4X 61FxfGS2Qbcy4ckqgxq9aOY4yCFYfK7fAyKJoCw4k+5BlW2gb2aHl1IoyAfr4llTQDWjtz wEPZNYx2OhVKGpbJ08to0TFtWyw6iPSgPQZkA0c1H5HRTWyK6+umoIpTyrPfTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=ae13829ddce0b5fbf12f2b240a26414b41def8ba commit ae13829ddce0b5fbf12f2b240a26414b41def8ba Author: Doug Moore AuthorDate: 2022-01-10 07:17:25 +0000 Commit: Doug Moore CommitDate: 2022-01-10 07:17:25 +0000 vm_addr_ok: add power2 invariant check With INVARIANTS defined, have vm_addr_align_ok and vm_addr_bound_ok panic when passed an alignment/boundary parameter that is not a power of two. Reviewed by: alc Suggested by: kib, se Differential Revision: https://reviews.freebsd.org/D33725 --- sys/vm/vm_extern.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 4e03bba66eeb..9fac3403f787 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -140,6 +140,11 @@ u_int vm_wait_count(void); static inline bool vm_addr_align_ok(vm_paddr_t pa, u_long alignment) { +#ifdef INVARIANTS + if (!powerof2(alignment)) + panic("%s: alignment is not a power of 2: %#lx", + __func__, alignment); +#endif return ((pa & (alignment - 1)) == 0); } @@ -150,6 +155,11 @@ vm_addr_align_ok(vm_paddr_t pa, u_long alignment) static inline bool vm_addr_bound_ok(vm_paddr_t pa, vm_paddr_t size, vm_paddr_t boundary) { +#ifdef INVARIANTS + if (!powerof2(boundary)) + panic("%s: boundary is not a power of 2: %#jx", + __func__, (uintmax_t)boundary); +#endif return (((pa ^ (pa + size - 1)) & -boundary) == 0); }