From owner-freebsd-hackers@freebsd.org Tue Jun 12 18:08:51 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 72A85100E72C for ; Tue, 12 Jun 2018 18:08:51 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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 E7CA07260E; Tue, 12 Jun 2018 18:08:50 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pf0-x243.google.com with SMTP id c22-v6so12102982pfi.2; Tue, 12 Jun 2018 11:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=b6A/21zxPpl3kS6lAxH6lru4Wxh6O+rcaLrnKiedIGQ=; b=MM/1RnOU2is/9q0m0cC/rnNUTuBOwV7/lZtJyuYn40s0ikCuVEwoZe91qdTpnfKKVZ Fj1klanh1Ouv2lP1gJauIvnai/z37UAXPt1tvXIQuJOuYYlFEK4jjOwa6RVF5qANbZN2 97as0TPUOhO9UNtLNPPs/pAzP/XnwsTEpN45nFjXI2BX+RWN4bBCxILhWFnovUccmAq1 yk2LnpAqNNARjtFiCBCSoAMLg4rbUyn3xSwgLSkuy+kRjchZnfsnrNOif2OutrpaY5iq 0qZWU4Pz2g+AJa+zz93bmTLWqK1uc+zMPcKfTS8b3jlhUmLJYzX+HtvPu8f2L+pd+QQL 2R+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=b6A/21zxPpl3kS6lAxH6lru4Wxh6O+rcaLrnKiedIGQ=; b=On0TpsPOYxPPYvtHaxr71Pl3At6mXviuu/xCrx0MgSiKRj1W2o2fdH70TgjVOmSDwk NBWQhqY50Tddj5+eKfsSh5YIXwhkaBIAcpQ2R90CPoHD2DuroOhsAM0jqY5L9R65cSjK 8X3OV21sIBe1N0sJ6w/MpAj7aZa3IDTsBQ5uNURYVu5q5KIBpZeTdDpqBsvjbyClYOFH Sl8rhRNHES8MV6oi1Y//ETJGE8wfN7xdJc6a+RZOMUej6TaABbC1uUocVpcS0eqW6boY yc93U09uwcp3L/4t1yvj0/VEIQ1pNuCY7HLaWyPJuU/UyC3hw9FH3UiZU1q3rMkHUaIQ wtCQ== X-Gm-Message-State: APt69E2gX8YpmsZxaz3AueQLrBw8NGIkcARov0R6Onv+o01+6uQbDPVr UIKgleMU7QXuxZcxrZ6xzeHz3Q== X-Google-Smtp-Source: ADUXVKJjFAEm2JeqpAwD9Df0iC5oWwGuvuVdjVfNKpVah/eNIsodJn6wqGBFjH7m6DlPis8xq2QT0g== X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr1254701pgv.306.1528826929703; Tue, 12 Jun 2018 11:08:49 -0700 (PDT) Received: from raichu (toroon0560w-lp140-02-70-49-169-156.dsl.bell.ca. [70.49.169.156]) by smtp.gmail.com with ESMTPSA id x17-v6sm738923pgv.15.2018.06.12.11.08.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 11:08:48 -0700 (PDT) Sender: Mark Johnston Date: Tue, 12 Jun 2018 14:08:46 -0400 From: Mark Johnston To: Kyle Evans Cc: Warner Losh , "freebsd-hackers@freebsd.org" Subject: Re: specifying alignment of loader files Message-ID: <20180612180846.GH56138@raichu> References: <20180612170420.GD56138@raichu> <20180612171649.GE56138@raichu> <20180612175130.GF56138@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) 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 18:08:51 -0000 On Tue, Jun 12, 2018 at 01:00:06PM -0500, Kyle Evans wrote: > On Tue, Jun 12, 2018 at 12:55 PM, Warner Losh wrote: > > 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? > > If the answer to the above isn't "yes," can we consider making this a > flag to `load` parsed in command_load instead of its own > ${module}_align variable? e.g. > > cpu_ucode_name=/boot/firmware/... > cpu_ucode_flags="-a 16" > > The initial recommendation isn't a bad idea, > but adding a new ${module}_flags requires changes in both interpreters > that I'm not sure are strictly necessary when this will be relatively > rarely used. Oh, I didn't realize those flags get passed straight to command_load(). I think that's a better idea than what I suggested. I started this thread when I realized that I would need to write some Forth code to implement my idea. :)