Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp945957imm; Wed, 26 Sep 2018 09:11:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV63l6h4avp+X+OoIvZBhKlEnkFdHiACFuPGRkOtXlJw38N08SHGXEvexkgQxCt/lyBwk+4cK X-Received: by 2002:a63:2d86:: with SMTP id t128-v6mr6451279pgt.128.1537978269960; Wed, 26 Sep 2018 09:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537978269; cv=none; d=google.com; s=arc-20160816; b=bESK3q8CvMqo7LAcbxfs8GFdlibAt2qdTNol6muJdcmuQ0m7X/M5SPfCL7JNjIsn7V iEI1JX1sY++A75l0DCa2yL7KVRR1ZlKjTCLG/XLd0nFDIWGL6o13QkQMl2p72KPVUTFF lS39kMvbV5oSRs5zbLd7ZiKjSz4VTc3hQhKz5nEUtqG9g/N4kRR6l02NLmSBAhrGHr2b brffYNNQqYSioPKHJNNw6yxaH8gc0pWcNdh6mHMiosLVCe89qRerAZt+u8kewOikju6C fXDTtElwU1MRvmEBgF5iVreLAFDYFhZqI3M3zBPgbRr27tQK56JcMBb6xH1YTWlBUa2t /NjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=wq7ISVzsJDUIsC2v5kxwtm3ZttxBOJm1KM5Ze+GtpdI=; b=NOe5HaTXHTLSgZyAFzClab6BpfKXNBmeuEm3kYlY1kpTysY47Ej7UOVP7dFcfy5Puv HZj6v2NfN4C2X+Mf2Ma6KkDLaDtmUCl1EQ6jSwmZk9vIfHOV5cAoKj2GytbQcNottLIa 5aHA5SSxeiptVDCvqJ7CQKuSn9KVYvt2briVa1VK7BQBOsWhEcJDRKJKk0X2RiALV0Lr Zv9PRLuNt1UgKg7bWKkhzXDbaXF7dWmNq56qxI16YdBeDuSwzuz6wuurKWiSJl5OIzbB vxXrTXe5dzgZTvWtKvbK5j/H/Vpa/cm+Cs0lB2+rvrR0xeTXBSBB1jLeDnrpgPRDr0dM X2xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=SaZBpcoa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24-v6si5130859pft.235.2018.09.26.09.10.54; Wed, 26 Sep 2018 09:11:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=SaZBpcoa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbeIZWX4 (ORCPT + 99 others); Wed, 26 Sep 2018 18:23:56 -0400 Received: from merlin.infradead.org ([205.233.59.134]:53924 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbeIZWXz (ORCPT ); Wed, 26 Sep 2018 18:23:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wq7ISVzsJDUIsC2v5kxwtm3ZttxBOJm1KM5Ze+GtpdI=; b=SaZBpcoan4NBHmslqQXLGQgY9G KIVovBDrhMeGPNZxlIHy5EgEEgUulRxDrwFll90q8t/ZIjYSabs0xg95nKRHz4L7yL+0rHj49WAFP /1aSWtee9fGT9UW0T9PCi9VLCbN3K8pTLmoDwXChVgEuZPAQPncPpVm21524HZUhpXPMi9bWCRVWq PxfXNg5KkN908LIdxi/+q3reaa+Zotipcpx5lkB8g+wChOVcj+ABOqTVwTxGh0Udsvkwiz+SR2Od+ ZGA2LsrEriyshJpSc9fPqgufcC2WFmuIJyqNrKgjR5VtETs/DAsuAoofP46C2pY7uZU4ky4zG+t5S 64yXXfFg==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5CNs-0001FJ-GP; Wed, 26 Sep 2018 16:10:12 +0000 Subject: Re: [PATCH 2/2] init: add support to directly boot to a mapped device To: Helen Koike , dm-devel@redhat.com Cc: agk@redhat.com, snitzer@redhat.com, linux-kernel@vger.kernel.org, enric.balletbo@collabora.com, wad@chromium.org, linux-doc@vger.kernel.org, linux-lvm@redhat.com, kernel@collabora.com References: <2c01b2a43a46fab760208d7af3a7af37eec8c41a.1537936397.git.helen.koike@collabora.com> From: Randy Dunlap Message-ID: Date: Wed, 26 Sep 2018 09:09:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <2c01b2a43a46fab760208d7af3a7af37eec8c41a.1537936397.git.helen.koike@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/25/18 10:00 PM, Helen Koike wrote: > From: Will Drewry > > Add a dm= kernel parameter modeled after the md= parameter from > do_mounts_md. It allows for device-mapper targets to be configured at > boot time for use early in the boot process (as the root device or > otherwise). > > Signed-off-by: Will Drewry > Signed-off-by: Kees Cook > [rework to use dm_ioctl calls] > Signed-off-by: Enric Balletbo i Serra > [rework to use concise format | rework for upstream] > Signed-off-by: Helen Koike Hi, A few small comments inline... > --- > .../admin-guide/kernel-parameters.rst | 1 + > .../admin-guide/kernel-parameters.txt | 3 + > Documentation/device-mapper/dm-boot.txt | 63 +++ > init/Makefile | 1 + > init/do_mounts.c | 1 + > init/do_mounts.h | 10 + > init/do_mounts_dm.c | 475 ++++++++++++++++++ > 7 files changed, 554 insertions(+) > create mode 100644 Documentation/device-mapper/dm-boot.txt > create mode 100644 init/do_mounts_dm.c > diff --git a/Documentation/device-mapper/dm-boot.txt b/Documentation/device-mapper/dm-boot.txt > new file mode 100644 > index 000000000000..f598f102c980 > --- /dev/null > +++ b/Documentation/device-mapper/dm-boot.txt > @@ -0,0 +1,63 @@ > +Boot time creation of mapped devices > +==================================== > + > +It is possible to configure a device mapper device to act as the root > +device for your system in two ways. > + > +The first is to build an initial ramdisk which boots to a minimal > +userspace which configures the device, then pivot_root(8) in to it. > + > +The second is to possible when the device-mapper and any targets are parse error: ^^^^^^^^^^^^^^ > +compiled into the kernel (not a module), one or more device-mappers may > +be created and used as the root device at boot time with the parameters > +given with the boot line dm=... > + > +The format is specified as a simple string of data separated by commas and for some definition of "simple". > +optionally semi-colons, where: > + - a comma is used to separate fields like name, uuid, flags and table (specifies > + one device) > + - a semi-colon is used to separate devices. > + > +So the format will look like this: > + > + dm=,,,,[,
+][;,,,,
[,
+]] > + > +Where, > + ::= The device name. > + ::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | "" > + ::= The device minor number. > + ::= "ro" | "rw" > +
::= > + ::= "verity" | "bootcache" | ... > + > +The dm line may be as normal when using the dmsetup tool when using the > +--concise argument. > + > +Examples > +======== > +An example of booting to a linear array made up of user-mode linux block > +devices: > + > + dm="lroot,,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" \ > + root=/dev/dm-0 > + > +This will boot to a rw dm-linear target of 8192 sectors split across two > +block devices identified by their major:minor numbers. After boot, udev > +will rename this target to /dev/mapper/lroot (depending on the rules). > +No uuid was assigned. > + > +An example of multiple device-mappers, with the dm="..." contents shown > +here split on multiple lines for readability: > + > + vboot,,ro, > + 0 1768000 bootcache > + aa55b119-2a47-8c45-946a-5ac57765011f+1 > + 76e9be054b15884a9fa85973e9cb274c93afadb6 > + 1768000 100000 23 20000; > + vroot,,ro, > + 0 1740800 verity 254:0 254:0 1740800 sha1 > + 76e9be054b15884a9fa85973e9cb274c93afadb6 > + 5b3549d54d6c7a3837b9b81ed72e49463a64c03680c47835bef94d768e5646fe; > + vram,,rw, > + 0 32768 linear 1:0 0, > + 32768 32768 linear 1:1 0 > diff --git a/init/do_mounts_dm.c b/init/do_mounts_dm.c > new file mode 100644 > index 000000000000..507ae31808ef > --- /dev/null > +++ b/init/do_mounts_dm.c > @@ -0,0 +1,475 @@ > +// SPDX-License-Identifier: > + > +/* > + * do_mounts_dm.c > + * Copyright (C) 2017 The Chromium OS Authors > + * Based on do_mounts_md.c > + * > + * This file is released under the GPLv2. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "do_mounts.h" > + > +#define DM_MAX_DEVICES 256 > +#define DM_MAX_NAME 32 > +#define DM_MAX_UUID 129 > + > +#define DM_MSG_PREFIX "init" > + > +#define is_even(a) (((a) & 1) == 0) > + > +/* See Documentation/device-mapper/dm-boot.txt for dm="..." format details. */ > + > +struct target { > + sector_t start; > + sector_t length; > + char *type; > + char *params; > + /* simple singly linked list */ > + struct target *next; > +}; > + > +struct dm_device { > + int minor; > + int ro; > + char name[DM_MAX_NAME]; > + char uuid[DM_MAX_UUID]; > + struct target *table; > + int table_count; > + /* simple singly linked list */ > + struct dm_device *next; > +}; > + > +static struct { > + unsigned long num_devices; > + char *str; > +} dm_setup_args __initdata; > + > +static int dm_early_setup __initdata; > + // @a: must be a power of 2 > +static void __init *_align(void *ptr, unsigned int a) > +{ > + register unsigned long agn = --a; > + > + return (void *) (((unsigned long) ptr + agn) & ~agn); > +} thanks. -- ~Randy