From patchwork Wed Mar 3 13:54:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 392656 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp5616529jap; Wed, 3 Mar 2021 18:00:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrnIDtOGJJz4UoNi1Yy6dpu4RvEJQskM5nap26HgbPIAY34/RC3G0pTIDcvyD29SjB3IqL X-Received: by 2002:a05:6402:270e:: with SMTP id y14mr1812266edd.283.1614822838229; Wed, 03 Mar 2021 17:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614822838; cv=none; d=google.com; s=arc-20160816; b=E387isGA0+pHyVWPQKcCYPU41oMgEBLsFsFAAohHEeKlK1KdCR6nVQjdywT+Gq2TQb zy65bDpaYD9N8CjkshWet9o5+YlGrInqRJTGdwn5h+gzRxCoWoUvRmEAznz1kolw1WeB HVj4KzCCgoC7NppeGceQ5+TAr9ZGAuR1GEfxKCJZTL0lR6EtfRzNOqhrkdDv4XvL5B1m oyvgMmalKj1m1y/9rcQmzsFZOwq6SXwviwMh6MnZaeyC+50QZHldwzYGULZa6Ts798fd fOIxX4V/i7sqfFUbvzviQxVUojnNMa5Lt6g2wkb0vgi5VohBMQwLFDDfbjFWFvy24jAc 5qTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5YOg5zpUZn68sgiB7/CmxizbcXg6Inaa7h+fkuHr+NU=; b=xAghU5rk3m1dXeg0VIM5wc57OJCPV36TwLJ2hBtA33Ey9R/Qq1yNcvFHHEcf9KKK1j qRrOrOv8H548JwreLSbRYZG8fkpgrxpyehtwj3l5xqFjtAvpij1DTYZY+bD1cGWgt3EJ 85Ub/JgyOAaemnzsitS7/bZ723uzUmHovvVftiXkbDL8/eNG+rwf9LBYGe/0yTUj8Jp2 p9dop7HXLcRUdTExC67yTa8+A19XXu5X/I1y4PoJDnTE01IuqIPc46OJXvatgtTrgzDe dNXBb7XjN8tTAxWCoZbGPRJtDOSjhN1nM/Upqk90LF1RyhBhnWCEWg7DCGuiB1pawgcn R0NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q++B4VWZ; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si16189393ejd.307.2021.03.03.17.53.58; Wed, 03 Mar 2021 17:53:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q++B4VWZ; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348978AbhCDAAc (ORCPT + 3 others); Wed, 3 Mar 2021 19:00:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348510AbhCCN4R (ORCPT ); Wed, 3 Mar 2021 08:56:17 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4AB7C061794 for ; Wed, 3 Mar 2021 05:55:03 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id b18so17291866wrn.6 for ; Wed, 03 Mar 2021 05:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5YOg5zpUZn68sgiB7/CmxizbcXg6Inaa7h+fkuHr+NU=; b=Q++B4VWZxWtKiqGZOTBh7Q0d/9A0phGVBtZ6Tcdb4OivrfT3V4n0KsvoOItbwPg22B eZTQxcobUCkgxxpQhiOnUPwwsQn5nBwRoE+k3WqfxZVKFY9QUzku8hGKZrGRskpwzURk E5Ounzx8YiqKubHadqCT9jr9p3ukzspXgv7PzPpS4UDG8X4gIV+KbXQ9KHcg9IXAJw63 UCL5onsn8O1KAKUci0VzlWmxEzyBpCh0XxHnmS8yB8ldQUD1vrBPT733kTGT2Lhnk9Rg /IJLSGZaMvFGuHZpxikQ11dPtZqZQ2/uP5/kW5517eYdIOTW/PX+bPcsXFZvVm7dQK3p 9//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5YOg5zpUZn68sgiB7/CmxizbcXg6Inaa7h+fkuHr+NU=; b=ebfVuT9yyei3v5zSib4a+7z3WZdAEPm0S1w+bHFCl0Au1+GpD+/nGs55l+ujPwVRKb mQSV4rE/F+G/z0TzfuS2vGJfOoInL/v9ChEInttoUupYxRiokxYYxCvtde4pT7c9VBgV QrPtOkZrY4h3lrcpN+95BYz4zwjIy3AXrRoTp7dVD7qQYB7nMd3VWzGh8hG2dHzXPB91 qDqkkdK/ztYFf4LctnFVHtcR9v1xz3oWWtB6DEsEVwQrwX7C0V6JOIx/YYbM7mrm1Ced VBPiJWbQA/u/z4r8dOKPHaC3FeG6hpCTJSMuUM0977n6fD+Hyw5KnAWP6hk+IIerdn7p fQAA== X-Gm-Message-State: AOAM530hfnQLtanEG3JLgOAmRLDYyX4PwTxIDj87r8S14MeLJcVoZZyn llRibZ1t3P/H+fEupOWqF18ayQ== X-Received: by 2002:adf:c752:: with SMTP id b18mr4774484wrh.233.1614779702514; Wed, 03 Mar 2021 05:55:02 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p10sm18581441wrw.33.2021.03.03.05.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 05:55:01 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 901401FF7E; Wed, 3 Mar 2021 13:55:00 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: linux-kernel@vger.kernel.org Cc: maxim.uvarov@linaro.org, joakim.bech@linaro.org, ilias.apalodimas@linaro.org, arnd@linaro.org, ruchika.gupta@linaro.org, tomas.winkler@intel.com, yang.huang@intel.com, bing.zhu@intel.com, Matti.Moell@opensynergy.com, hmo@opensynergy.com, linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-nvme@vger.kernel.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [RFC PATCH 0/5] RPMB internal and user-space API + WIP virtio-rpmb frontend Date: Wed, 3 Mar 2021 13:54:55 +0000 Message-Id: <20210303135500.24673-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Hi, This is a follow-up to the email I sent last month: Subject: RPMB user space ABI Date: Thu, 11 Feb 2021 14:07:00 +0000 Message-ID: <87mtwashi4.fsf@linaro.org> which attempts to put some concrete flesh on the bones of the proposal for a new internal kernel API for dealing with RPMB partitions and the resultant exposed user-space character device API. It became apparent while implementing a virtio-rpmb backend that the initial proposed API didn't sit well with a device like virtio-rpmb which isn't part of a greater device (like eMMC or UFS). It also exposed the gritty details of the frame format to userspace leaving it to deal with the complications of creating JDEC frames and calculating MACs. The series is based on Thomas' last posting with a bunch of functionality dropped: - no FS/RPMB integration - dropped the simulator - dropped the sysfs patches There is a start of a WIP virtio-rpmb front-end however as the initial discussion should be focused on the proposed APIs I thought it would be worth posting as an RFC before getting too deep into the weeds of implementation. The principle changes to the original proposal: - frame construction left to device driver The differences between UFS/JEDEC/VirtioRPMB are left for the driver itself to deal with. This means things like MAC calculation and validation also remain the preserve of the low level implementation details. This doesn't mean there can't be shared code where implementation details are common across several device types. - key management uses keyctl() This means in theory userspace could interact with the RPMB device without having to manage the key itself. This also means you don't need to pass as much data about as the kernel internals can just use the keyring id with the API to fetch the key when required. - user-space interface split across several ioctls Now we no longer have multiple command frames going back and forth we can have a single structure per ioctl which just contains what is needed for the operation in question. So what do people think? Is it worth pursuing this approach? I'm certainly intended to complete the virtio-rpmb driver and test it with my QEMU based vhost-user backend. However I've no direct interest in implementing the interfaces to real hardware. I leave that to people who have access to such things and are willing to take up the maintainer burden if this is merged. Alex Bennée (5): rpmb: add Replay Protected Memory Block (RPMB) subsystem char: rpmb: provide a user space interface tools rpmb: add RPBM access tool rpmb: create virtio rpmb frontend driver [WIP] tools/rpmb: simple test sequence .../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 9 + drivers/char/Kconfig | 2 + drivers/char/Makefile | 1 + drivers/char/rpmb/Kconfig | 28 + drivers/char/rpmb/Makefile | 9 + drivers/char/rpmb/cdev.c | 246 +++++++ drivers/char/rpmb/core.c | 431 ++++++++++++ drivers/char/rpmb/rpmb-cdev.h | 17 + drivers/char/rpmb/virtio_rpmb.c | 366 ++++++++++ include/linux/rpmb.h | 173 +++++ include/uapi/linux/rpmb.h | 68 ++ include/uapi/linux/virtio_ids.h | 1 + include/uapi/linux/virtio_rpmb.h | 54 ++ tools/Makefile | 14 +- tools/rpmb/.gitignore | 2 + tools/rpmb/Makefile | 41 ++ tools/rpmb/key | 1 + tools/rpmb/rpmb.c | 649 ++++++++++++++++++ tools/rpmb/test.sh | 13 + 20 files changed, 2121 insertions(+), 5 deletions(-) create mode 100644 drivers/char/rpmb/Kconfig create mode 100644 drivers/char/rpmb/Makefile create mode 100644 drivers/char/rpmb/cdev.c create mode 100644 drivers/char/rpmb/core.c create mode 100644 drivers/char/rpmb/rpmb-cdev.h create mode 100644 drivers/char/rpmb/virtio_rpmb.c create mode 100644 include/linux/rpmb.h create mode 100644 include/uapi/linux/rpmb.h create mode 100644 include/uapi/linux/virtio_rpmb.h create mode 100644 tools/rpmb/.gitignore create mode 100644 tools/rpmb/Makefile create mode 100644 tools/rpmb/key create mode 100644 tools/rpmb/rpmb.c create mode 100755 tools/rpmb/test.sh -- 2.20.1