Hello community, here is the log from the commit of package mmc-utils for openSUSE:Factory checked in at 2019-08-13 20:44:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mmc-utils (Old) and /work/SRC/openSUSE:Factory/.mmc-utils.new.9556 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mmc-utils" Tue Aug 13 20:44:52 2019 rev:12 rq:723088 version:0.1+git.20190808 Changes: -------- --- /work/SRC/openSUSE:Factory/mmc-utils/mmc-utils.changes 2018-12-18 14:57:55.678293449 +0100 +++ /work/SRC/openSUSE:Factory/.mmc-utils.new.9556/mmc-utils.changes 2019-08-13 20:44:56.651050704 +0200 @@ -1,0 +2,7 @@ +Tue Aug 13 14:02:28 UTC 2019 - Martin Pluskal <[email protected]> + +- Update to version 0.1+git.20190808: + * mmc-utils: feature spec 5.0+, add secure removal type fields to Extended CSD + * mmc-utils: use MMC_IOC_MULTI_CMD for RPMB access + +------------------------------------------------------------------- Old: ---- mmc-utils-0.1+git.20181208.tar.xz New: ---- mmc-utils-0.1+git.20190808.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mmc-utils.spec ++++++ --- /var/tmp/diff_new_pack.jvFFoY/_old 2019-08-13 20:44:57.399050489 +0200 +++ /var/tmp/diff_new_pack.jvFFoY/_new 2019-08-13 20:44:57.419050483 +0200 @@ -1,7 +1,7 @@ # # spec file for package mmc-utils # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: mmc-utils -Version: 0.1+git.20181208 +Version: 0.1+git.20190808 Release: 0 Summary: Tools for MMC/SD devices License: GPL-2.0-only ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.jvFFoY/_old 2019-08-13 20:44:57.503050459 +0200 +++ /var/tmp/diff_new_pack.jvFFoY/_new 2019-08-13 20:44:57.503050459 +0200 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git</param> - <param name="changesrevision">485b05ec40031a06077db9c84ae75a36ebd3db25</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">d40ec535b9d4e4c974e8c2fbfb422cd0348cc5e8</param></service></servicedata> \ No newline at end of file ++++++ mmc-utils-0.1+git.20181208.tar.xz -> mmc-utils-0.1+git.20190808.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mmc-utils-0.1+git.20181208/mmc.h new/mmc-utils-0.1+git.20190808/mmc.h --- old/mmc-utils-0.1+git.20181208/mmc.h 2018-12-08 06:51:37.000000000 +0100 +++ new/mmc-utils-0.1+git.20190808/mmc.h 2019-08-09 00:42:38.000000000 +0200 @@ -116,6 +116,7 @@ #define EXT_CSD_MODE_CONFIG 30 #define EXT_CSD_MODE_OPERATION_CODES 29 /* W */ #define EXT_CSD_FFU_STATUS 26 /* R */ +#define EXT_CSD_SECURE_REMOVAL_TYPE 16 /* R/W */ #define EXT_CSD_CMDQ_MODE_EN 15 /* R/W */ /* @@ -132,6 +133,8 @@ /* * EXT_CSD field definitions */ +#define EXT_CSD_CONFIG_SECRM_TYPE (0x30) +#define EXT_CSD_SUPPORTED_SECRM_TYPE (0x0f) #define EXT_CSD_FFU_INSTALL (0x01) #define EXT_CSD_FFU_MODE (0x01) #define EXT_CSD_NORMAL_MODE (0x00) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mmc-utils-0.1+git.20181208/mmc_cmds.c new/mmc-utils-0.1+git.20190808/mmc_cmds.c --- old/mmc-utils-0.1+git.20181208/mmc_cmds.c 2018-12-08 06:51:37.000000000 +0100 +++ new/mmc-utils-0.1+git.20190808/mmc_cmds.c 2019-08-09 00:42:38.000000000 +0200 @@ -1766,6 +1766,38 @@ ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]); printf("eMMC Pre EOL information [EXT_CSD_PRE_EOL_INFO]: 0x%02x\n", ext_csd[EXT_CSD_PRE_EOL_INFO]); + reg = ext_csd[EXT_CSD_SECURE_REMOVAL_TYPE]; + printf("Secure Removal Type [SECURE_REMOVAL_TYPE]: 0x%02x\n", reg); + printf(" information is configured to be removed "); + /* Bit [5:4]: Configure Secure Removal Type */ + switch ((reg & EXT_CSD_CONFIG_SECRM_TYPE) >> 4) { + case 0x0: + printf("by an erase of the physical memory\n"); + break; + case 0x1: + printf("by an overwriting the addressed locations" + " with a character followed by an erase\n"); + break; + case 0x2: + printf("by an overwriting the addressed locations" + " with a character, its complement, then a random character\n"); + break; + case 0x3: + printf("using a vendor defined\n"); + break; + } + /* Bit [3:0]: Supported Secure Removal Type */ + printf(" Supported Secure Removal Type:\n"); + if (reg & 0x01) + printf(" information removed by an erase of the physical memory\n"); + if (reg & 0x02) + printf(" information removed by an overwriting the addressed locations" + " with a character followed by an erase\n"); + if (reg & 0x04) + printf(" information removed by an overwriting the addressed locations" + " with a character, its complement, then a random character\n"); + if (reg & 0x08) + printf(" information removed using a vendor defined\n"); } if (ext_csd_rev >= 8) { @@ -1825,6 +1857,8 @@ ret; \ }) +#define RPMB_MULTI_CMD_MAX_CMDS 3 + enum rpmb_op_type { MMC_RPMB_WRITE_KEY = 0x01, MMC_RPMB_READ_CNT = 0x02, @@ -1847,6 +1881,17 @@ u_int16_t req_resp; }; +static inline void set_single_cmd(struct mmc_ioc_cmd *ioc, __u32 opcode, + int write_flag, unsigned int blocks) +{ + ioc->opcode = opcode; + ioc->write_flag = write_flag; + ioc->arg = 0x0; + ioc->blksz = 512; + ioc->blocks = blocks; + ioc->flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; +} + /* Performs RPMB operation. * * @fd: RPMB device on which we should perform ioctl command @@ -1861,22 +1906,28 @@ struct rpmb_frame *frame_out, unsigned int out_cnt) { +#ifndef MMC_IOC_MULTI_CMD + fprintf(stderr, "mmc-utils has been compiled without MMC_IOC_MULTI_CMD" + " support, needed by RPMB operation.\n"); + exit(1); +#else int err; u_int16_t rpmb_type; - - struct mmc_ioc_cmd ioc = { - .arg = 0x0, - .blksz = 512, - .blocks = 1, - .write_flag = 1, - .opcode = MMC_WRITE_MULTIPLE_BLOCK, - .flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC, - .data_ptr = (uintptr_t)frame_in - }; + struct mmc_ioc_multi_cmd *mioc; + struct mmc_ioc_cmd *ioc; + struct rpmb_frame frame_status = {0}; if (!frame_in || !frame_out || !out_cnt) return -EINVAL; + /* prepare arguments for MMC_IOC_MULTI_CMD ioctl */ + mioc = (struct mmc_ioc_multi_cmd *) + malloc(sizeof (struct mmc_ioc_multi_cmd) + + RPMB_MULTI_CMD_MAX_CMDS * sizeof (struct mmc_ioc_cmd)); + if (!mioc) { + return -ENOMEM; + } + rpmb_type = be16toh(frame_in->req_resp); switch(rpmb_type) { @@ -1887,33 +1938,23 @@ goto out; } + mioc->num_of_cmds = 3; + /* Write request */ - ioc.write_flag |= (1<<31); - err = ioctl(fd, MMC_IOC_CMD, &ioc); - if (err < 0) { - err = -errno; - goto out; - } + ioc = &mioc->cmds[0]; + set_single_cmd(ioc, MMC_WRITE_MULTIPLE_BLOCK, (1 << 31) | 1, 1); + mmc_ioc_cmd_set_data((*ioc), frame_in); /* Result request */ - memset(frame_out, 0, sizeof(*frame_out)); - frame_out->req_resp = htobe16(MMC_RPMB_READ_RESP); - ioc.write_flag = 1; - ioc.data_ptr = (uintptr_t)frame_out; - err = ioctl(fd, MMC_IOC_CMD, &ioc); - if (err < 0) { - err = -errno; - goto out; - } + ioc = &mioc->cmds[1]; + frame_status.req_resp = htobe16(MMC_RPMB_READ_RESP); + set_single_cmd(ioc, MMC_WRITE_MULTIPLE_BLOCK, 1, 1); + mmc_ioc_cmd_set_data((*ioc), &frame_status); /* Get response */ - ioc.write_flag = 0; - ioc.opcode = MMC_READ_MULTIPLE_BLOCK; - err = ioctl(fd, MMC_IOC_CMD, &ioc); - if (err < 0) { - err = -errno; - goto out; - } + ioc = &mioc->cmds[2]; + set_single_cmd(ioc, MMC_READ_MULTIPLE_BLOCK, 0, 1); + mmc_ioc_cmd_set_data((*ioc), frame_out); break; case MMC_RPMB_READ_CNT: @@ -1924,23 +1965,17 @@ /* fall through */ case MMC_RPMB_READ: - /* Request */ - err = ioctl(fd, MMC_IOC_CMD, &ioc); - if (err < 0) { - err = -errno; - goto out; - } + mioc->num_of_cmds = 2; + + /* Read request */ + ioc = &mioc->cmds[0]; + set_single_cmd(ioc, MMC_WRITE_MULTIPLE_BLOCK, 1, 1); + mmc_ioc_cmd_set_data((*ioc), frame_in); /* Get response */ - ioc.write_flag = 0; - ioc.opcode = MMC_READ_MULTIPLE_BLOCK; - ioc.blocks = out_cnt; - ioc.data_ptr = (uintptr_t)frame_out; - err = ioctl(fd, MMC_IOC_CMD, &ioc); - if (err < 0) { - err = -errno; - goto out; - } + ioc = &mioc->cmds[1]; + set_single_cmd(ioc, MMC_READ_MULTIPLE_BLOCK, 0, out_cnt); + mmc_ioc_cmd_set_data((*ioc), frame_out); break; default: @@ -1948,8 +1983,12 @@ goto out; } + err = ioctl(fd, MMC_IOC_MULTI_CMD, mioc); + out: + free(mioc); return err; +#endif /* !MMC_IOC_MULTI_CMD */ } int do_rpmb_write_key(int nargs, char **argv)
