From owner-freebsd-hackers@freebsd.org Tue Jun 12 17:51:35 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 7B36B100C855 for ; Tue, 12 Jun 2018 17:51:35 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pg0-x236.google.com (mail-pg0-x236.google.com [IPv6:2607:f8b0:400e:c05::236]) (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 F2BE471389 for ; Tue, 12 Jun 2018 17:51:34 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pg0-x236.google.com with SMTP id d2-v6so11805700pga.13 for ; Tue, 12 Jun 2018 10:51:34 -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=bSPn5P++O/94TUXs+seoA2hU69qHc4tX2CW7pj4aVZ0=; b=N6s1RHGZTqIovvH0ZUpNZlC8kt370tT5X6+BlCmvadv7DERMcIdUgz4qXMC2Kg2GC5 FXsUNCZGm0URWC1sdKaoF7xxcLe/j55zsJMTE4d/UfTZfV31OQ/rrCK9KUikNqCXc1RB W1EaOPsngMukfLjdQlCKUVYOXrRXf/oa2oSb7YOOw00GzHTt82o3QKnrq1Pl8736x7kj mFD0aU30E+erx903l260LJ0WMB+RA+3QVbP0h4vbj7brojF+R3KeCkoeqti+7fySUk28 VV+MwJu8aMR+oOCvfmFIlm9y838WEj0A+r7S9oYVM1aM3w+I9DTpNh2cs8V9SacXuNkt cehw== 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=bSPn5P++O/94TUXs+seoA2hU69qHc4tX2CW7pj4aVZ0=; b=C0Ic83vZAn6mSoWv1HIZ4/qnEZO/6yovP6WWDB0eOh4HoQcjjJnHqN2xC36dzfsa/C Lp4K6BoDSaMo5FVvn+fkp1rYQRzi1B2/pDK219QX+yxX9ZDKXbpyyY81DZ+XHajX1Q2m 6FLGB0Vyia4YD2ENZ1zFORM60PPVf4+3UHPHAJDPT8Fwz7KiTth0uQdSCgjTSjKyZRFn A4t5/+1eO4nEB4vKAXcLJFFmbigN2hv6UPBukQESeQem1hWXhiFRu/0M6M1W1Uh8FZ/G ZziBaFBrjdzMAh8GveIESQUuotEwFOsBViMGzWkUysZL8qaSP/j3/4DG0hxIbqVGmSjg ezaw== X-Gm-Message-State: APt69E2KCBxMv4qsfR25M2iwks7FNgCpMBRU78LTESy2C7EBYcLMu7u4 +3edkiGLWRf6jbPUJEhE1Wg= X-Google-Smtp-Source: ADUXVKLh4mm+n8HsDPT856sPBbz8o52eLhVNM4SB54jmxlYFsZ+G2XoClWazuRsBSwbOuQfPLP1T3g== X-Received: by 2002:a63:8c10:: with SMTP id m16-v6mr1230569pgd.120.1528825894110; Tue, 12 Jun 2018 10:51:34 -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 w18-v6sm728921pgq.1.2018.06.12.10.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 10:51:33 -0700 (PDT) Sender: Mark Johnston Date: Tue, 12 Jun 2018 13:51:30 -0400 From: Mark Johnston To: Warner Losh Cc: "freebsd-hackers@freebsd.org" Subject: Re: specifying alignment of loader files Message-ID: <20180612175130.GF56138@raichu> References: <20180612170420.GD56138@raichu> <20180612171649.GE56138@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 17:51:35 -0000 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.