Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jun 2018 11:13:16 -0700
From:      Ben Widawsky <ben@bwidawsk.net>
To:        Brooks Davis <brooks@freebsd.org>
Cc:        Warner Losh <imp@bsdimp.com>, "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, Mark Johnston <markj@freebsd.org>
Subject:   Re: specifying alignment of loader files
Message-ID:  <20180612181316.e67bv44exkvhmtyv@mail.bwidawsk.net>
In-Reply-To: <20180612181009.GA11238@spindle.one-eyed-alien.net>
References:  <20180612170420.GD56138@raichu> <CANCZdfofkgg4NyGtVucn7O6r44q7JBqf1fHf0qqMbPT-sTui6A@mail.gmail.com> <20180612171649.GE56138@raichu> <CANCZdfqWyf2MoiS-KrZQZOV0LH4qg64vrcrdisLMBTDpeamMPw@mail.gmail.com> <20180612175130.GF56138@raichu> <CANCZdfpDy44BSbs7n3HAyMSOTsrOQAAXrNfxsUrtAEOq5ACq4g@mail.gmail.com> <20180612181009.GA11238@spindle.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 18-06-12 18:10:09, Brooks Davis wrote:
> On Tue, Jun 12, 2018 at 11:55:27AM -0600, Warner Losh wrote:
> > On Tue, Jun 12, 2018 at 11:51 AM, Mark Johnston <markj@freebsd.org> 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 <markj@freebsd.org>
> > > 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 <markj@freebsd.org>
> > > > > 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?
> 
> Page boundaries might be too much on very small systems, but there's
> a principled argument for 8-bytes just based on the aligment of
> primative types so 16 (or even 64) isn't much of a stretch.  16-bytes
> would future-proof for the CHERI variants that are likely to make
> it to silicon.
> 
> -- Brooks

I think native cacheline size is a pretty safe yet more conservative than page
size bet ie. me too for 64.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180612181316.e67bv44exkvhmtyv>