From owner-freebsd-hackers@freebsd.org Tue Jun 12 17:55:29 2018 Return-Path: Delivered-To: freebsd-hackers@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 10B05100D161 for ; Tue, 12 Jun 2018 17:55:29 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x232.google.com (mail-it0-x232.google.com [IPv6:2607:f8b0:4001:c0b::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 94175718A4 for ; Tue, 12 Jun 2018 17:55:28 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x232.google.com with SMTP id a3-v6so475959itd.0 for ; Tue, 12 Jun 2018 10:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=3GAgAkO0lm7PsXM70MvNI1yjrR2bAgaa6pWfJaIen4U=; b=euLI2cx4/i2UKk8sC93MKYeAGqqWX0JxSbIHMGTgvSHKVVhugEyxKXDCbmfp3+8ViJ 2FePqZUpCgo4j6IcB9yVNXsn+cyx9hMs0H8/KlhibJQ9JdOz9qYBvOGdKNNl6ymltq97 35M6R1GAFVbKVpCYE7uaOUZAEenZRXgSDO/vJ3G4wfmf5VDp+PXgINXMGED6pUk1QY7y 2YlCYBiQqQEjRFpqPg2qzy82N+kjj46vByPqW0eW7KQ3JRlzlClCiZ6hlOYTlfwr1FDb j2F8NLdlUTn/6Cn+MY3uT3l4h3D4y9VKEQ8aPsH6prE2NrLkbAlyclu3jrg4fi8yqNS9 SIIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=3GAgAkO0lm7PsXM70MvNI1yjrR2bAgaa6pWfJaIen4U=; b=DyOm1dRFcicHjtLeGorC1mF9IPb2EC+T9ooPF3FLC5vs2oIRr3+bus6yzRBefj073H Y98jkaGyF24kx9MIvPaDb26F9LTm7/kMag8ES9I1f9Anci/PraDCZUXp2NqgQe5PdtqO 32uDZXde9b/J+hrstfiAwpOugD2ZMHa4Ftu8fjR0UpaLIRisk/9zEzv0nMygRzZaPKsv PyN6Uqijq1YV5CtmjDRgxuwhcyl+hJUWxXfe4UMTvIQS/HV1700RgUWY7GrXN20AUW7E dGXGXYEJP14G0G7JbuLOaEnLdJP02Z5Idy1qcXvOTxYZlOhxnYEbntSzZphZ3S9B4hZS c9nA== X-Gm-Message-State: APt69E08Lpr6xo2Fj0kjBgJg6npLD7pklWN8AZZ3kxL+b9Ogu4rWVKpd EbXvHGNLMGixODWWOIrPSRJ/LGdNMHJyKJaPOkChkQ== X-Google-Smtp-Source: ADUXVKJHLcuUH5yVioSeNeG8887k4wZJ0EaZ41gPVyIHr9lQ0U0Inw2u/8uZ5XgofQkcPGBshJk8WixU5gXTdOLKMgc= X-Received: by 2002:a24:5b81:: with SMTP id g123-v6mr1426991itb.1.1528826127927; Tue, 12 Jun 2018 10:55:27 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:d028:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 10:55:27 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <20180612175130.GF56138@raichu> References: <20180612170420.GD56138@raichu> <20180612171649.GE56138@raichu> <20180612175130.GF56138@raichu> From: Warner Losh Date: Tue, 12 Jun 2018 11:55:27 -0600 X-Google-Sender-Auth: ho6RJA7pB8eLGDwyKLuY2pomoaM Message-ID: Subject: Re: specifying alignment of loader files To: Mark Johnston Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2018 17:55:29 -0000 On Tue, Jun 12, 2018 at 11:51 AM, Mark Johnston wrote: > On Tue, Jun 12, 2018 at 11:45:01AM -0600, Warner Losh wrote: > > On Tue, Jun 12, 2018 at 11:16 AM, Mark Johnston > wrote: > > > > > On Tue, Jun 12, 2018 at 11:11:25AM -0600, Warner Losh wrote: > > > > On Tue, Jun 12, 2018 at 11:04 AM, Mark Johnston > > > wrote: > > > > > > > > > Hi, > > > > > > > > > > I'm writing some code which processes a file loaded by the > loader. I > > > > > want the file's contents to be available at a certain alignment in > > > > > memory, and as far as I can see, the loader provides no alignment > > > > > guarantees today. The access will happen early enough during boot > that > > > > > making an aligned copy of the data will be awkward, so I'd like the > > > > > loader to provide the desired alignment. > > > > > > > > > > I'm considering adding a new "module_align" variable that would > specify > > > > > the alignment for a given file type, and plumb that through to > > > > > command_load(). Does anyone have an alternate suggestion, or an > > > > > objection to my proposal? > > > > > > > > > > > > > I thought the loader already did that for ELF sections... Why not > wrap > > > your > > > > file in such a segment? > > > > > > In this case it's a raw binary file (CPU microcode), and I want to be > > > able to load it without any modifications or wrappers. > > > > > > > How do you identify the type then? I'm ok in theory with this (though a > > variable is more flexible than needed), but that's my main concern. > What's > > the alignment required btw? > > It'd be a property of the type, e.g., > > cpu_ucode_name=/boot/firmware/... > cpu_ucode_align=16 > > I do feel like having a separate variable is overkill, but I can't see > a less invasive solution that isn't hacky. > > The required alignment for Intel is 16 bytes; I'm not yet sure whether > AMD has a required alignment. > OK. That seems sane. I was thinking it was more general than this, but I'm cool with what you've outlined. OTOH, wouldn't just loading all files on page boundaries suffice? Warner