From patchwork Mon Sep 30 11:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 831762 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5DFC18E75F; Mon, 30 Sep 2024 11:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695891; cv=none; b=P9v+zcubvCk4kvhLq2ZiGPhZ+pu7Eg7n+6hueetMP6iDe/7n2dI8Vn94SKYIoAbVRQ/6rspKgtRU8UAUGlr9zsqY0Glw4U9eUY8eUJNy5bd8Wtd6gyOde3x5leBeO3PxlWt43RpltEfSXU1Cf4BqRT0/RU5Yvdrai4ZXYFy47MM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695891; c=relaxed/simple; bh=vIZUmOhkctrpxNjE/bq31Se+xRGgI8VKyz9uNEv0GsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ibgvoj8/E5Od4nNaSvj94T/SDh854Awhg6ZZZv6uvEzgeLpdkJrj5avK8weLVhZsDjXu0NqwrpjmQSwSJ8YkAZc5vIEXWUezKBoO+fEO7SoYz6uOTYgfJAfKbS9HiRXQ2mSrwREq96eZv2C9FU1nNpSukuMYuMiMj6MWplgnysA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kMFhT0Dj; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kMFhT0Dj" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37ccfada422so2182403f8f.2; Mon, 30 Sep 2024 04:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727695888; x=1728300688; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4T9c6jNuxQUPP/Rbzo55YkzEPcrdsPIICvkg9bn4/tM=; b=kMFhT0DjXKwlwSbR/Azjgv4oU26ytUskdfREhpyzdOLM8HzGCk123Ztqm1wgZYzjft /ndOYUPBJj8sDxDct2qiUkiAbK4yVqBbPpx6yyyoIVNpqw7SX+AuPL4Eax7gC1NRdHDt FMq0QlZTFiycnTTW6jdRb0blOO58SqZeVBTdgyg4GmRHqn4zieUGABR9ZGg2N8UUJDGq KKfb+CJT84CwM+b+b2LfXvK5AxBrawDhSeUEExC7dEJwRxg6XQGjt8n1ghNFt1tu/9Ny TXlaU0LmMUXbZo29bozLftiL1rFEFK3oB1zMRMhkMX4zN7SDp76uY0EpYNx1qALb84Gg krtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727695888; x=1728300688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4T9c6jNuxQUPP/Rbzo55YkzEPcrdsPIICvkg9bn4/tM=; b=r8dbXECdZoHgWaSpQ6mvue3FZdTH+m9F2PT8LMQORO2j38yjCqImKPgFlipn2REHs2 Az/NHd4qUCamvD3uHmBEs5jCPw/CXaC+g89/dUA81uIGAAjiqFxhsUut/765Mq7BCAhw idE9xaR+j1ZZy3nS6vkAL5mkxHYME3BiQB5bpQyuagIJ7Hv+YHJ6hK74H6O43JOazhAG eVTgNxWtQlV1Brw5uJAr4jtVwtsJfZFCxpXVvghpD+7YXIa0MNLn3AR+7TjpfW+B+PUo BVY5UrQ9XZMYNVAj4DfbGMX160VCuXwy7bKUdnBJsbbyF7DCbUSesrcP1QmDM/RGN6w5 ZVkw== X-Forwarded-Encrypted: i=1; AJvYcCUOQ/YOqAXbrzAlCvFpsmDMSvUNoyJX3XkMjO4apWwZXv6QGHDUoZYfa4OXNnOS14pv+h4ORKqTMzQG@vger.kernel.org, AJvYcCUUG4ifDISd+83ZXodkabcfY8/R7srSw9zlT2aYTGMjWJLBP7a474hnTieaYKtTsf3YxAPFpyN1VEt3@vger.kernel.org, AJvYcCUXRE4jM7moSQ30gOwsPFFxkLm766EwjaSLf0p2DYXmZ+Vk8BtqxPKkIfkyi+wPFdEa8y8OA4PLBh29@vger.kernel.org, AJvYcCWuGiOwP3cHg0vxA0LTHs4wv1oc6zvc4tzUgW9LFMa19kl1adCQC32jCvJI54MVVXBwS/SFBQqwZe5lOng=@vger.kernel.org, AJvYcCXO7RUY04RdHBUaL4XDo4K8Vz+NWAQZxrZc/cJmFTXjn9ObFHHmwvx45Y5RhTRtdBSVpSY5iuup88Z/eqXQ@vger.kernel.org, AJvYcCXWdYJaMrFBEtfSnz3PBYeq0QAB+KnZkpr4a3V1/F9ltOUdMde8HnFWdY9gB7cHeqgmmRMcCpZmTXJvTyCQIaB5@vger.kernel.org X-Gm-Message-State: AOJu0YxqV5UeuESpw4Llh/wNYpiDy9Uzh36XPJUx8PDpyIBp6icJVEqu VwoVsisT1aTsIM8vvJjO/toZZyCgikHLIvuuTGs0ESNZQ7JpeDn5 X-Google-Smtp-Source: AGHT+IF9WsH8NhMVUflWW6Q3l/hIjgZVoJvdNgq/QcLbG4GjJGrw9atHk9fPnPJRYuLBLHD7vOmpNg== X-Received: by 2002:a5d:5052:0:b0:37c:d537:9dc0 with SMTP id ffacd0b85a97d-37cd5a6bf42mr7699742f8f.12.1727695887712; Mon, 30 Sep 2024 04:31:27 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37cd57427c6sm8889363f8f.96.2024.09.30.04.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 04:31:26 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , Andy Shevchenko , Christian Marangi , Daniel Golle , INAGAKI Hiroshi , Christian Brauner , Al Viro , Li Lingfeng , Ming Lei , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-hardening@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi , upstream@airoha.com Cc: Christoph Hellwig Subject: [PATCH v4 1/5] block: add support for defining read-only partitions Date: Mon, 30 Sep 2024 13:30:08 +0200 Message-ID: <20240930113045.28616-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930113045.28616-1-ansuelsmth@gmail.com> References: <20240930113045.28616-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for defining read-only partitions and complete support for it in the cmdline partition parser as the additional "ro" after a partition is scanned but never actually applied. Signed-off-by: Christian Marangi Reviewed-by: Christoph Hellwig --- block/blk.h | 1 + block/partitions/cmdline.c | 3 +++ block/partitions/core.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/block/blk.h b/block/blk.h index c718e4291db0..f300212d3e98 100644 --- a/block/blk.h +++ b/block/blk.h @@ -558,6 +558,7 @@ void blk_free_ext_minor(unsigned int minor); #define ADDPART_FLAG_NONE 0 #define ADDPART_FLAG_RAID 1 #define ADDPART_FLAG_WHOLEDISK 2 +#define ADDPART_FLAG_READONLY 4 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, sector_t length); int bdev_del_partition(struct gendisk *disk, int partno); diff --git a/block/partitions/cmdline.c b/block/partitions/cmdline.c index 152c85df92b2..da3e719d8e51 100644 --- a/block/partitions/cmdline.c +++ b/block/partitions/cmdline.c @@ -237,6 +237,9 @@ static int add_part(int slot, struct cmdline_subpart *subpart, put_partition(state, slot, subpart->from >> 9, subpart->size >> 9); + if (subpart->flags & PF_RDONLY) + state->parts[slot].flags |= ADDPART_FLAG_READONLY; + info = &state->parts[slot].info; strscpy(info->volname, subpart->name, sizeof(info->volname)); diff --git a/block/partitions/core.c b/block/partitions/core.c index ab76e64f0f6c..abad6c83db8f 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -373,6 +373,9 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, goto out_del; } + if (flags & ADDPART_FLAG_READONLY) + bdev_set_flag(bdev, BD_READ_ONLY); + /* everything is up and running, commence */ err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); if (err) From patchwork Mon Sep 30 11:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 831761 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04C68191F73; Mon, 30 Sep 2024 11:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695894; cv=none; b=XTzLTC1tQbs/vNVaf8QMRF5muPeEUjs2HVh+e191dQdL6qGZeBfNiSEpjm+jVhSjCVKNWiLNa+igvz1xLC6KVW1mEtzvC+4g6gLJQ3FB/isNGYBva8VZ9apletp6nDnf3P/EEnzUpCI/xfscsXK+wLZoai2vUpMeD/QEiB5ijsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695894; c=relaxed/simple; bh=Fdg5b8SVAH5j0Qu176AA7my/fJNS0PCGFYU3JPPLVLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hbarnkSuatvcZo0nB4/OS72KoSkn7iIY09egXiglmheUAC85F8o+UuFimivfPP4VvFtBWHfp0EGbGFtxEvKvbhTDMmRdSnIgXCdQKtHD98Tz6a4kGU1SKr/hq2jVrPqrvmGN1hB92dPIpQZELMTTjok3GNkyoxbehKXLH6+NCb4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R8tTLz2d; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R8tTLz2d" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42e5e758093so33658345e9.1; Mon, 30 Sep 2024 04:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727695891; x=1728300691; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pdWET63vJ0wHHaPGfNh/Rl/SDLzGR4oHq+JYF3SYx8c=; b=R8tTLz2d3pRXzh16tJIYid+/XQKfJh5JxPGGHBufur/xOYw7BvdxKThkvqHKDmyd5T cBSlThWyNKC2uq/UA6skcEuVYEuc952QVMvNppNqiq4pmoNIEtU6b1/w/9JMrYSBzi6R eN/PbXnq05SrNq0S7m2N7rkf9VBe2KBoWVYSQlIdo+YpqMPvKG4WlnHh6u0F70L4kOAk UnZDLI7bYCPyF7aNS+7+XIya1dPVA0jo8kSnKzYcuytBfmHeDmWq/LdyG/Db2c3yhPnX BCKb6Lx7hUzqoo1Wa+WueA7y3tmi64mbUsaFL80EKcou2Kl+H6fn1w9F+yo1P1FC95Wh 2R9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727695891; x=1728300691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pdWET63vJ0wHHaPGfNh/Rl/SDLzGR4oHq+JYF3SYx8c=; b=U00kNU2S7I1NZbWjZ+ptBLPMDxmDhiPN4RbwCfub1pX9ttIe3BahCiw3ofDQQKnCyr 1nIHrxoMwNgiAbpTUgDXGd35vyUH0AMPk76bYED+HsSVKbrakxNphWPZg71RstT9NM6K ceuT8baIdUTjrRrS8yKXs+aLiPAEPARo94/MS2bRP8B5kM3sHeDuenPQxxiDWWprwAGk CRINEdsX1U9vNiflgB/zT8/NRg81VdneHO5nbbPjSJ6wPM0PMhbu1G0skKI1AMk6MV5u J/z3qc8FtxrgcTv1rLxJ6WF86kHkRJqTY0XZ/S8JQF/dY/F/HD4ZZXl5VflNXXpJ/oWO pjrg== X-Forwarded-Encrypted: i=1; AJvYcCUasyVdqDZsC08/n+vszvPAkBI7JfSQ/mqBlD8+IcWablZvLfkfAP2z7nPxXIYud0i5g/W/OE+puqLu@vger.kernel.org, AJvYcCUiFOQV3skpAVix7PmqaAdRBD/mTQdHayF2sJU+fjxguwhPNsECDeZadH+Kp1EH5Q2TOjU7QH7FLpPAxf0U@vger.kernel.org, AJvYcCVUsLLVWh6Nrd6IBzh3s8dkMJAPacjr5KR+F6QI7elTryE2CXkbCuT0DmK4RZX7BURykxnjQ1uhQ/wr@vger.kernel.org, AJvYcCVy+M0dtXpo5qznltnMwaeO3md9s5qA5ySPwjqjgSNUhQ7Y2HL4ISNMe6IUZWP5K2RMDY6bVrwVC1WnxXY=@vger.kernel.org, AJvYcCWKtPJiTIVN2uxqnUCmEq8UUhSK5Yi+MSa+G/etXOgkBQNP0DxbWCc/Ng8tqRaGzQdiadoPGT4VmSeNMJlwVUVl@vger.kernel.org, AJvYcCWUT8j/uBGa5k5yBCrR6AqlffBrghg8zO2RpNPoVRARZUm6/zarD0Y6URTNVyN7btNWUPWX22WVaV7u@vger.kernel.org X-Gm-Message-State: AOJu0YwVLhVWknp0BfyqFWhPDqhCdMOPFxGiCYRpkLt9idXRGtA6zTDN lXTOJ+v++lo3SoyoMuVoQKNNQXgndDd9Qjk10LOiLKYVeLblLBFM X-Google-Smtp-Source: AGHT+IG+FX7wQbiPTrV+FZ9bKUhqJKnd538V9esFrVT+ydwCqe9J1R6Rzi20PJszdP50SknlXHumOw== X-Received: by 2002:a05:600c:1d25:b0:42c:bde5:9082 with SMTP id 5b1f17b1804b1-42f584481cfmr82686035e9.17.1727695891212; Mon, 30 Sep 2024 04:31:31 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37cd57427c6sm8889363f8f.96.2024.09.30.04.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 04:31:30 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , Andy Shevchenko , Christian Marangi , Daniel Golle , INAGAKI Hiroshi , Christian Brauner , Al Viro , Li Lingfeng , Ming Lei , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-hardening@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi , upstream@airoha.com Cc: Rasmus Villemoes Subject: [PATCH v4 3/5] string: add strends() helper to check if a string ends with a suffix Date: Mon, 30 Sep 2024 13:30:10 +0200 Message-ID: <20240930113045.28616-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930113045.28616-1-ansuelsmth@gmail.com> References: <20240930113045.28616-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add strends() helper to check if a string ends with a suffix. The unreadable strends is chosen to keep consistency with the parallel strstarts helper used to check if a string starts with a prefix. To prevent out-of-bounds read, len of string is checked against the prefix length before comparing the 2 string at the offset. Suggested-by: Rasmus Villemoes Signed-off-by: Christian Marangi --- include/linux/string.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 0dd27afcfaf7..2c3df6ffb326 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -353,6 +353,19 @@ static inline bool strstarts(const char *str, const char *prefix) return strncmp(str, prefix, strlen(prefix)) == 0; } +/** + * strends - does @str end with @suffix? + * @str: string to examine + * @suffix: suffix to look for. + */ +static inline bool strends(const char *str, const char *suffix) +{ + size_t n = strlen(str); + size_t m = strlen(suffix); + + return n >= m && !memcmp(str + n - m, suffix, m); +} + size_t memweight(const void *ptr, size_t bytes); /** From patchwork Mon Sep 30 11:30:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 831760 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D65F18EFEC; Mon, 30 Sep 2024 11:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695898; cv=none; b=G7RCb659i0pl6xONYYGn+vx2DK+6jUlSI1XzmJA74jivcqSMFWuEcpKnmjmVBgJlfb8Z45GdaYovP4BYhN1HKStHfCy51yHCrbxHufB53HwaM4omAK+Bz5XDThPKR+OjuVEoiayrHR4ETuVXfgEr5P1Md7JLAx/GoyWDMBADxkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727695898; c=relaxed/simple; bh=XY9CIJRo4kERP1f7gzDDtLEj6FCWJeCQbDTSD4GQKRc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Adneu0dS6i6/mrWo/B5ymE35ZSBYlsStQ74p2nghr5yxFnPeo08FUjmBw/YuD2RxGZHcBbb6dhZ7umfQpnGHHZqsb5VWlDLC4BHbaqDHqVVfmZrXAqbQ7V2kout5WgxIyb9UzWE8bAEOsGVZVvjrlj6cMyYyebquiPahNbNRPr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BKZo/KvB; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BKZo/KvB" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42e5e758093so33658845e9.1; Mon, 30 Sep 2024 04:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727695895; x=1728300695; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xOC+2wly8ftj8TAYNwXd5GnLMEEgJdboLyIbx9/Qeyc=; b=BKZo/KvB4pNksTAK45cGhy9kpW79zkZnUua0Np2Jn9Tu+gv2tpsBSgwezaZoDnWJL5 nblm/0f0P2TYXqNS84ILG5Cz9Iub/wWmEeS+UhYWA2YhGaoIrlxEmXZRu2fVqFi8iGK6 3JwMWuovZrxJt/JyItLQkBcKyQB3H/ioDHpNJkX+qbwgPITEsTJvr/Mme6Suo+tuV4z1 mJfcy+/tz+abOi3CqbuFGrgFZfpzgBjhnvprYeFrOAJ5vAwwPVgxeMm4HD0VYlmJkrlb 8C7hm4i0bMrUmHZFTLlSdLxmQSqYJLBHG9MVPdtM0b51tNHne24nezEAnzuLZqF2m1F7 KqUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727695895; x=1728300695; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xOC+2wly8ftj8TAYNwXd5GnLMEEgJdboLyIbx9/Qeyc=; b=FL6SEbqFc/d2hP8QuZMDRb2gcBfrKpjWwrBm1gZX/WOEnWHsj50HI4A9wvAvd8mPoZ 4+jHxbSnj05YbM9IcP5TXKKDzucYrCoNl4w85BYGM/265zCRUUs3gE1cmXBmyKssCHa8 DCPXXhBrZtGiOQZrLyA8CQOX0bSEfpLVCjRFu4HZgJqalLSPpHk+GBn0BQVVzrgXoejD XiQx0XBKRAMaxxgn69ttAt0nl4qTUHAdFdO17iwc41s02S0UXqXkqZJXyAbXs2UlFziC TwjUItfBx25LqYc4IST5V0MvB9fSc20OY9SDoCfa6PA8UoTwPcSkk0W7k5rRdq9Qj9s5 6aew== X-Forwarded-Encrypted: i=1; AJvYcCUaiT8P0Mo2MnH1CwnSVvJOcNc5TDKqeNdWBcL0PEwg7wzcWte5+Ot9I3Jm7h5TT5q5CI4SfAnyVXFz+hY=@vger.kernel.org, AJvYcCVOV0KJpVK5fKe2gv+JIs2sphL45cY3EQuIMI4xOYHIkO7fUXvE1CE3OS2Sl4o51/JlVDUqwHmbgi906yoP21Yj@vger.kernel.org, AJvYcCVRrUVrjgzSNY2BXYtks94TXJ0Edo3BcCK2EQaeFBpDA/d0eMHvl5GNeFnM4XIAxfDWm4M4WC3cSRc0pfn8@vger.kernel.org, AJvYcCW3nzLEUdaEALIYV5iNTLqsZ0T3tuCyfC5mFc23GNx8aKGpp/hKktYOQMatkw2zEGnSo+eqzlSN3jPG@vger.kernel.org, AJvYcCWLXkgYuwviC3FpO9ALZka0s9qNuqM58NlZYCjhJCluMQyqusz6dGfAfPEkMJrdNq68H2BL43WVG31x@vger.kernel.org, AJvYcCWQxaSsXOJ1p0s0oI7W99G03f0sy1RajQWdlHa8XlJxNNBuTYUnNs8BxewNo+rVQtc8uncbhpvYrdVs@vger.kernel.org X-Gm-Message-State: AOJu0Yw8jeQn228BUB9VUsAjiFJEtxvly2tqOEWbrvEenXv/ZoHSAxBd BKbBQhp29Icw787i7ltHr8Phhs6XSq4MN8GzW0BCCWvLKpwocN0p X-Google-Smtp-Source: AGHT+IFdIkatQerk+zXAxINpq/NRTF+eJHagLd98gelH27PNmGtNgyRLnetKypXvOHMMq/uLAK/OKw== X-Received: by 2002:a5d:554e:0:b0:37c:d20d:447c with SMTP id ffacd0b85a97d-37cd5ab758emr6846761f8f.29.1727695894648; Mon, 30 Sep 2024 04:31:34 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-37cd57427c6sm8889363f8f.96.2024.09.30.04.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 04:31:34 -0700 (PDT) From: Christian Marangi To: Jens Axboe , Jonathan Corbet , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , Andy Shevchenko , Christian Marangi , Daniel Golle , INAGAKI Hiroshi , Christian Brauner , Al Viro , Li Lingfeng , Ming Lei , Christian Heusel , linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-hardening@vger.kernel.org, Miquel Raynal , Lorenzo Bianconi , upstream@airoha.com Subject: [PATCH v4 5/5] dt-bindings: mmc: Document support for partition table in mmc-card Date: Mon, 30 Sep 2024 13:30:12 +0200 Message-ID: <20240930113045.28616-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930113045.28616-1-ansuelsmth@gmail.com> References: <20240930113045.28616-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document support for defining a partition table in the mmc-card node. This is needed if the eMMC doesn't have a partition table written and the bootloader of the device load data by using absolute offset of the block device. This is common on embedded device that have eMMC installed to save space and have non removable block devices. If an OF partition table is detected, any partition table written in the eMMC will be ignored and won't be parsed. eMMC provide a generic disk for user data and if supported (JEDEC 4.4+) also provide two additional disk ("boot0" and "boot1") for special usage of boot operation where normally is stored the bootloader or boot info. Signed-off-by: Christian Marangi --- .../devicetree/bindings/mmc/mmc-card.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.yaml b/Documentation/devicetree/bindings/mmc/mmc-card.yaml index fd347126449a..5f93bb77f246 100644 --- a/Documentation/devicetree/bindings/mmc/mmc-card.yaml +++ b/Documentation/devicetree/bindings/mmc/mmc-card.yaml @@ -13,6 +13,10 @@ description: | This documents describes the devicetree bindings for a mmc-host controller child node describing a mmc-card / an eMMC. + It's possible to define a fixed partition table for an eMMC for the user + partition and one of the 2 boot partition (boot0/boot1) if supported by the + eMMC. + properties: compatible: const: mmc-card @@ -26,6 +30,24 @@ properties: Use this to indicate that the mmc-card has a broken hpi implementation, and that hpi should not be used. +patternProperties: + "^partitions(-boot[01])?$": + $ref: /schemas/mtd/partitions/partitions.yaml + + patternProperties: + "^partition@[0-9a-f]+$": + $ref: /schemas/mtd/partitions/partition.yaml + + properties: + reg: + description: Must be multiple of 512 as it's converted + internally from bytes to SECTOR_SIZE (512 bytes) + + required: + - reg + + unevaluatedProperties: false + required: - compatible - reg @@ -42,6 +64,36 @@ examples: compatible = "mmc-card"; reg = <0>; broken-hpi; + + partitions { + compatible = "fixed-partitions"; + + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; /* Kernel */ + reg = <0x0 0x2000000>; /* 32 MB */ + }; + + partition@2000000 { + label = "rootfs"; + reg = <0x2000000 0x40000000>; /* 1GB */ + }; + }; + + partitions-boot0 { + compatible = "fixed-partitions"; + + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bl"; + reg = <0x0 0x2000000>; /* 32MB */ + read-only; + }; + }; }; };