From: Brandon Schaefer <bschaef14@gmail.com>
To: linux-mmc@vger.kernel.org
Cc: Brandon Schaefer <brandon.schaefer@flukenetworks.com>
Subject: [PATCH] mmc ioctl: Notify mmc core of ext_csd change
Date: Wed, 24 May 2017 15:02:30 -0700 [thread overview]
Message-ID: <1495663350-93076-1-git-send-email-brandon.schaefer@flukenetworks.com> (raw)
Let mmc core know of ext_csd change when userspace utilizes ioctl to
change PARTITION_CONFIG (previously BOOT_CONFIG). Otherwise changing
boot partitions from userspace can be trampled on.
Signed-off-by: Brandon Schaefer <brandon.schaefer@flukenetworks.com>
---
drivers/mmc/core/block.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 64f9fda..d5b0085 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -63,7 +63,9 @@ MODULE_ALIAS("mmc:block");
#define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
#define MMC_SANITIZE_REQ_TIMEOUT 240000
-#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
+#define MMC_EXTRACT_SWITCH_MODE_FROM_ARG(x) (((x) & 0x030F0000) >> 24)
+#define MMC_EXTRACT_INDEX_FROM_ARG(x) (((x) & 0x00FF0000) >> 16)
+#define MMC_EXTRACT_VALUE_FROM_ARG(x) (((x) & 0x00000FF0) >> 8)
#define mmc_req_rel_wr(req) ((req->cmd_flags & REQ_FUA) && \
(rq_data_dir(req) == WRITE))
@@ -517,6 +519,24 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
return err;
}
+ if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_PART_CONFIG) &&
+ (cmd.opcode == MMC_SWITCH)) {
+ u8 mode = MMC_EXTRACT_SWITCH_MODE_FROM_ARG(cmd.arg);
+ u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg);
+
+ switch (mode) {
+ case MMC_SWITCH_MODE_SET_BITS:
+ card->ext_csd.part_config |= value;
+ break;
+ case MMC_SWITCH_MODE_CLEAR_BITS:
+ card->ext_csd.part_config &= ~value;
+ break;
+ case MMC_SWITCH_MODE_WRITE_BYTE:
+ card->ext_csd.part_config = value;
+ break;
+ }
+ }
+
mmc_wait_for_req(card->host, &mrq);
if (cmd.error) {
--
2.7.4
reply other threads:[~2017-05-24 22:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495663350-93076-1-git-send-email-brandon.schaefer@flukenetworks.com \
--to=bschaef14@gmail.com \
--cc=brandon.schaefer@flukenetworks.com \
--cc=linux-mmc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).