From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DB68C77B70 for ; Mon, 17 Apr 2023 07:05:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF93C85816; Mon, 17 Apr 2023 09:05:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="BycI94dT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A4958574D; Mon, 17 Apr 2023 09:05:27 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0B3008574D for ; Mon, 17 Apr 2023 09:05:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C35F661E9C; Mon, 17 Apr 2023 07:05:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE74C433EF; Mon, 17 Apr 2023 07:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681715123; bh=me7VaDfoo+9bPDfwglYtmNgzlSA9hiL62aWOavoaCTk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BycI94dTH3tbdECKzX1vmxT4lUdmz8YVJm5kLSvD7quynySGiCPzdlOnmj4MwvFOB Xsy+VccaSCTgMrcb2/MxrtZhtVI3W1vEO2d2M7vleP6hI9vf+BUUkMANTlKSo7IzY9 HQQtKE1r1Q/TNUWUNaKTebT79f4wcSy/n7JNszShT9QHDFKXwSRhQztiX5o++qIeqA T7n75uBvajX2Wecty1cImPJ/ULR6FcGxBMyT/iGXPyFKEBUIBuuTivrlj+IpWtzEcO 4daFmNRhgo0XNgjmBVoSPz36b2TT42LeEDC2URJLfAJ7tSxaKxh0hlCV4YDImuSnc1 x9BrkebBfDoKA== Received: by pali.im (Postfix) id 9F131790; Mon, 17 Apr 2023 09:05:20 +0200 (CEST) Date: Mon, 17 Apr 2023 09:05:20 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Jaehoon Chung , Peng Fan , Stefan Roese , Martin Rowe Cc: u-boot@lists.denx.de Subject: Re: [PATCH u-boot 2/4] cmd: mvebu/bubt: Validate EXT_CSD[179] eMMC register in mmc_burn_image() Message-ID: <20230417070520.3fadb77ew5c52sy5@pali> References: <20230413211057.10975-1-pali@kernel.org> <20230413211057.10975-3-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230413211057.10975-3-pali@kernel.org> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean + Martin On Thursday 13 April 2023 23:10:55 Pali Rohár wrote: > When determining eMMC boot partition for a bootloader, validate that > EXT_CSD[179] eMMC register is set to recognized value. > > This prevent situation that EXT_CSD[179] Boot Enable value is improperly > parsed and passed into EXT_CSD[179] Partition Access. > > Signed-off-by: Pali Rohár > --- > cmd/mvebu/bubt.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c > index ca24a5c1c4ba..b8fe7c7a1461 100644 > --- a/cmd/mvebu/bubt.c > +++ b/cmd/mvebu/bubt.c > @@ -223,9 +223,29 @@ static int mmc_burn_image(size_t image_size) > orig_part = mmc->block_dev.hwpart; > #endif > > - part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); > - if (part == 7) > + if (mmc->part_config == MMCPART_NOAVAILABLE) { > part = 0; > + } else { > + switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) { > + case 0: /* Booting from this eMMC device is disabled */ > + printf("Error - Booting from this eMMC device is disabled\n"); > + printf("Hint: Use 'mmc partconf' command to choose boot partition\n"); > + return -ENODEV; > + case 1: /* Boot partition 1 is used for booting */ > + part = 1; > + break; > + case 2: /* Boot partition 2 is used for booting */ > + part = 2; > + break; > + case 7: /* User area is used for booting */ > + part = 0; > + break; > + default: /* Other values are reserved / unsupported */ > + printf("Error - This eMMC device has configured Reserved boot option\n"); > + printf("Hint: Use 'mmc partconf' command to choose boot partition\n"); > + return -ENODEV; > + } > + } > > #ifdef CONFIG_BLK > err = blk_dselect_hwpart(blk_desc, part); > -- > 2.20.1 >