From nobody Fri Sep 16 15:53:53 2022 X-Original-To: dev-commits-src-main@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 4MTdsZ24BZz4cKqn; Fri, 16 Sep 2022 15:53:54 +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 4MTdsZ1P1Xz3hPl; Fri, 16 Sep 2022 15:53:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663343634; 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=6dsOEME1Mjepx99gWn9rVkO4XqtR7ZYxAJsY2JZNZz0=; b=H/iU8POVvcEnZ1+0yrZybge9Ph+93jcnx0h5uAppVP54KUBJ2J9NqdRkdaYAfpCfiDhuGw 2teW7pzDyQwSMwraeNPCvUsheUXJeupOsViKwIWFBgwaekNhotJ01Ec5E9TlTGjEzZiLtb L1RNLEv83hZm7ARYT3sTeCXMFL46wPtoxRY/+mok2ANuIlN43q2Hl7I4248OYCr1b3IFuj TkjKx3kO4npNG4YP9TfcyHNlgMDpH4KvFLfIl4uqZVgJw7k2WEOVN72o9lHCZk3jPSr9Zf aZC2fIfNkAle1ZJ6Y3+WyKlMpk8L41Ebu3PdMNfS3HJSpbk2iAbC+N1wiwEOXA== 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 4MTdsZ0P9tzPNj; Fri, 16 Sep 2022 15:53:54 +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 28GFrrqD086381; Fri, 16 Sep 2022 15:53:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28GFrrLl086380; Fri, 16 Sep 2022 15:53:53 GMT (envelope-from git) Date: Fri, 16 Sep 2022 15:53:53 GMT Message-Id: <202209161553.28GFrrLl086380@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8b19d28d68a3 - main - stand: Create MOD_ALIGN macro and use it everywhere List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8b19d28d68a396b0263e3c13a559a31f70eb3b1d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663343634; 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=6dsOEME1Mjepx99gWn9rVkO4XqtR7ZYxAJsY2JZNZz0=; b=x/emF7Or0unWRouZXcavXEW6Mj4FZBfmjupJPgiUz9r+5gRGZ9JtCoISJLxuD/mTj5LB9H K7FciWmxltkJkww4CmhIEbee5DhDmd9+MTYXAv5HDzs6oOkS/OJpleMaOMYmkZbct1O5RS tz23+8mjDfWIpPlJZuVGaBaWoybm3WglM4uk3H70MohVfZYc9kJzxuHpGY3ri22LctG1QN C3nmZJJ2ovtUemPugF+QtFQK4KiD20xCmX0AhocANsFNcjk4+S9c2STLUZ9UzPrx7ZuIch D8dPKemRxv+Q+UKVSUaw2wgKNsp0MM791P7ZSVGHCkJ9ctZIirR9vkmql7fehg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663343634; a=rsa-sha256; cv=none; b=BgD19govd2LUpTJxrtN+i/p/opphNZeToF47b66nDxYT2jWO+oizJLneBeHPrgUM/YvYTO c7NEDDeOxKbAtwv3HkkcR9iUs926J+8HND0dHqNlpYlxtb0XYKiFHha8zr+cQ73FveaB40 FczO8HnkT8sNK3V6jHxv+2MFiFPMqTy+F/gQ9VOpfq4XgdvQx9M68jkPaizH6fqLM10u+p iPLG1fw5WxCd+5PSKL8mQNcZWKZ9VacUBmNlFwrXQyzVI1sgfHSb+AgQ1I5SPPG3JGhrgh xvHXw9ytzP8yiCpVr6hl2RSQ8fUk+Kxlqum58vuthCVn1zewUmLp6+23GSZ1ew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8b19d28d68a396b0263e3c13a559a31f70eb3b1d commit 8b19d28d68a396b0263e3c13a559a31f70eb3b1d Author: Warner Losh AuthorDate: 2022-09-16 15:08:37 +0000 Commit: Warner Losh CommitDate: 2022-09-16 15:18:56 +0000 stand: Create MOD_ALIGN macro and use it everywhere To further reduce the differences between the different MOD_xxx macros, use MOD_ALIGN to do the proper alignment for the given use. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36570 --- stand/common/metadata.c | 7 ++++--- stand/efi/loader/bootinfo.c | 9 +++++---- stand/i386/libi386/bootinfo32.c | 7 ++++--- stand/i386/libi386/bootinfo64.c | 7 ++++--- stand/userboot/userboot/bootinfo32.c | 7 ++++--- stand/userboot/userboot/bootinfo64.c | 7 ++++--- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/stand/common/metadata.c b/stand/common/metadata.c index a9c81added02..cb92537d1ce2 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -111,6 +111,7 @@ md_copyenv(vm_offset_t addr) static int align; +#define MOD_ALIGN(l) roundup(l, align) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -123,7 +124,7 @@ static int align; COPY32(strlen(s) + 1, a, c) \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1);\ - a += roundup(strlen(s) + 1, align); \ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -135,7 +136,7 @@ static int align; COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), align); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -146,7 +147,7 @@ static int align; COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size);\ - a += roundup(mm->md_size, align); \ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \ diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 06b131aac521..c3184a1e84d5 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -180,6 +180,7 @@ bi_copyenv(vm_offset_t start) * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ +#define MOD_ALIGN(l) roundup(l, sizeof(u_long)) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -192,7 +193,7 @@ bi_copyenv(vm_offset_t start) COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(u_long)); \ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -204,7 +205,7 @@ bi_copyenv(vm_offset_t start) COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(u_long)); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -214,8 +215,8 @@ bi_copyenv(vm_offset_t start) COPY32(MODINFO_METADATA | mm->md_type, a, c); \ COPY32(mm->md_size, a, c); \ if (c) \ - archsw.arch_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(u_long)); \ + archsw.arch_copyin(mm->md_data, a, mm->md_size); \ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \ diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c index dd919d0fad93..207fe9a3fde8 100644 --- a/stand/i386/libi386/bootinfo32.c +++ b/stand/i386/libi386/bootinfo32.c @@ -59,6 +59,7 @@ static struct bootinfo bi; * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ +#define MOD_ALIGN(l) roundup(l, sizeof(u_long)) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -71,7 +72,7 @@ static struct bootinfo bi; COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(u_long));\ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -83,7 +84,7 @@ static struct bootinfo bi; COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(u_long)); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -94,7 +95,7 @@ static struct bootinfo bi; COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(u_long));\ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \ diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c index 1e06c229ec30..e088c27347be 100644 --- a/stand/i386/libi386/bootinfo64.c +++ b/stand/i386/libi386/bootinfo64.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ +#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t)) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -72,7 +73,7 @@ __FBSDID("$FreeBSD$"); COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1); \ - a += roundup(strlen(s) + 1, sizeof(uint64_t));\ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -84,7 +85,7 @@ __FBSDID("$FreeBSD$"); COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(uint64_t)); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -95,7 +96,7 @@ __FBSDID("$FreeBSD$"); COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size); \ - a += roundup(mm->md_size, sizeof(uint64_t));\ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \ diff --git a/stand/userboot/userboot/bootinfo32.c b/stand/userboot/userboot/bootinfo32.c index 26376709e899..bd2729927349 100644 --- a/stand/userboot/userboot/bootinfo32.c +++ b/stand/userboot/userboot/bootinfo32.c @@ -58,6 +58,7 @@ static struct bootinfo bi; * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ +#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t)) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -70,7 +71,7 @@ static struct bootinfo bi; COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1);\ - a += roundup(strlen(s) + 1, sizeof(uint32_t));\ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -82,7 +83,7 @@ static struct bootinfo bi; COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(uint32_t)); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -93,7 +94,7 @@ static struct bootinfo bi; COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size);\ - a += roundup(mm->md_size, sizeof(uint32_t));\ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \ diff --git a/stand/userboot/userboot/bootinfo64.c b/stand/userboot/userboot/bootinfo64.c index f2713adf5513..5fffb04d8d75 100644 --- a/stand/userboot/userboot/bootinfo64.c +++ b/stand/userboot/userboot/bootinfo64.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ +#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t)) #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ @@ -67,7 +68,7 @@ __FBSDID("$FreeBSD$"); COPY32(strlen(s) + 1, a, c); \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1);\ - a += roundup(strlen(s) + 1, sizeof(uint64_t));\ + a += MOD_ALIGN(strlen(s) + 1); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) @@ -79,7 +80,7 @@ __FBSDID("$FreeBSD$"); COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ - a += roundup(sizeof(s), sizeof(uint64_t)); \ + a += MOD_ALIGN(sizeof(s)); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) @@ -90,7 +91,7 @@ __FBSDID("$FreeBSD$"); COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size);\ - a += roundup(mm->md_size, sizeof(uint64_t));\ + a += MOD_ALIGN(mm->md_size); \ } #define MOD_END(a, c) { \