Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nWtqi-0002Zw-UD for mharc-grub-devel@gnu.org; Wed, 23 Mar 2022 01:48:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWtqh-0002Zn-6N for grub-devel@gnu.org; Wed, 23 Mar 2022 01:47:59 -0400 Received: from [2607:f8b0:4864:20::632] (port=46793 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWtqf-0007Sd-Bb for grub-devel@gnu.org; Wed, 23 Mar 2022 01:47:58 -0400 Received: by mail-pl1-x632.google.com with SMTP id w4so549487ply.13 for ; Tue, 22 Mar 2022 22:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=6HSLHlK9z5rRDDWnx82kvu1AkGpS3SexuLgfQBaQC7s=; b=ZjHq4hChsTY7Rtmycc/T94WQP7g4SmPn3rwQN5YqXybxixpAYN7PF5W0Mr8XLasYuu mTiKY+bTRhISRdJ1GhTIX34jyU5psPN3jX7/vVMh5MlQy7tscFnxTSRQsQUspbqbF5dE PDrwPi368Zdq2D6MCz9w/5WlipwraKM1Jr5rY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=6HSLHlK9z5rRDDWnx82kvu1AkGpS3SexuLgfQBaQC7s=; b=7Ii+254wYm9CxwNCWeNVd4A4zijzE69CwgIsyZnkIFpEnhAi82CZsVFKjgLgPmRpOX Hnfpec7uQrj6Mg21yjwrYnHjAv3SZX96p7eiOUYxWRZY3RLW/Y+Ix1MVNLWqTlqI6U0g dMsiapikDNNuORnfsRBwqSMGNP1vik984jf0JZWuxmsoX9hnmE65KFLSpR3SrP558lSX y3IMdd7KWpYQmptUcheAaMervsVQOfnTKCsSR2Rk9fO29aAQhCVGHG7mLxBkez5i5aYS qMZgRixGQPFbKXvqMHJmM7mABFrxoeBkezIdyQRdjDH9s34nS/F/YC6+V7EyW764rv3G QyKg== X-Gm-Message-State: AOAM532V+m4P2zkHO12pBSGa4gWzZb6v605mUjkIZzWcaqOFx/XQl7kt OY5TIRUgpXK6c+iLtMiMYBzwEQ== X-Google-Smtp-Source: ABdhPJwMC9DeJ9Uv6MLcN1O6uOapkB3DWNZWm7IQAupSBPf52OOsnh8uWjTW4/6xTkRsU57ht4Mtxg== X-Received: by 2002:a17:902:8605:b0:151:b6a2:8a1 with SMTP id f5-20020a170902860500b00151b6a208a1mr22046037plo.64.1648014475380; Tue, 22 Mar 2022 22:47:55 -0700 (PDT) Received: from localhost ([2001:4479:e000:e400:1221:acdf:6ee0:52b]) by smtp.gmail.com with ESMTPSA id c63-20020a624e42000000b004fa9ee41b7bsm9402549pfb.217.2022.03.22.22.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 22:47:54 -0700 (PDT) From: Daniel Axtens To: Daniel Kiper Cc: grub-devel@gnu.org, leif@nuviainc.com, stefanb@linux.ibm.com, ps@pks.im Subject: Re: [PATCH 04/19] mm: assert that we preserve header vs region alignment In-Reply-To: <20211020174313.nxw5kaaj2l6mhkqq@tomti.i.net-space.pl> References: <20211012073008.4059133-1-dja@axtens.net> <20211012073008.4059133-5-dja@axtens.net> <20211020174313.nxw5kaaj2l6mhkqq@tomti.i.net-space.pl> Date: Wed, 23 Mar 2022 16:47:51 +1100 Message-ID: <87pmmd8bjs.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::632 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=dja@axtens.net; helo=mail-pl1-x632.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 05:47:59 -0000 > s/struct grub_mm_region/grub_mm_region_t/ > s/struct grub_mm_header/grub_mm_header_t/ The problem is that grub_mm_{region,header}_t is a pointer type, not a struct type. So sizeof (grub_mm_region_t) == sizeof(void *). You also can't do sizeof (*grub_mm_region_t), because you can't dereference a type. If there's a better way to express this I am open to it, but for now I will stick with the struct type... > >> + sizeof(struct grub_mm_header)) == 0); > > I think this check is insufficient. The GRUB_MM_ALIGN should be checked > somehow too. E.g. if sizeof(struct grub_mm_region) == 16, > sizeof(struct grub_mm_header) == 8 and GRUB_MM_ALIGN == 32 then assert > above will pass but the GRUB will blow up later. Of course numbers are not > real but I chose them to show the problem. Hmmm... If we could choose > grub_mm_region_t and grub_mm_header_t sizes properly then probably we > could drop GRUB_MM_ALIGN... > I have added that sizeof(struct header) == GRUB_MM_ALIGN. GRUB_MM_ALIGN is supposed to align you to a cell, and a header is supposed to be 1 cell. We probably _could_ do away with the constant but I think that requires a bit more close thought. Kind regards, Daniel