asahi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Asahi Lina <lina@asahilina.net>
To: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	 asahi@lists.linux.dev, Asahi Lina <lina@asahilina.net>
Subject: [PATCH 0/2] rust: Add uapi crate
Date: Wed, 29 Mar 2023 20:40:17 +0900	[thread overview]
Message-ID: <20230329-rust-uapi-v1-0-ee78f2933726@asahilina.net> (raw)

In general, direct bindgen bindings for C kernel APIs are not intended
to be used by drivers outside of the `kernel` crate. However, some
drivers do need to interact directly with UAPI definitions to implement
userspace APIs.

Instead of making this an exception to the use of the `bindings` crate,
introduce a new `uapi` crate that will contain only these publicly
usable definitions. The build logic mirrors the `bindings` crate, but
there is no helper support since UAPIs are only intended to contain
constant and type definitions, not function prototypes.

In the future, we would like to extend this to also auto-derive and
validate certain safety properties for UAPI structure definitions, such
as that they are safely castable to/from "bag of bits" buffers.

The first patch introduces the `uapi` crate proper and stands on its own,
while the second patch modifies the ioctl crate (which I sent as a
separate series) to use the new crate. Miguel: if/once everything looks
good, feel free to merge just patch #1 and I can squash #2 into the ioctl
crate, or you can squash it yourself, or just merge both series in
sequence, whatever works ^^

Signed-off-by: Asahi Lina <lina@asahilina.net>
---
Asahi Lina (2):
      rust: uapi: Add UAPI crate
      rust: ioctl: Move to the uapi crate
 rust/.gitignore         |  1 +
 rust/Makefile           | 18 ++++++++++++++++--
 rust/kernel/ioctl.rs    | 32 ++++++++++++++++----------------
 rust/kernel/lib.rs      |  1 +
 rust/uapi/lib.rs        | 27 +++++++++++++++++++++++++++
 rust/uapi/uapi_helper.h |  9 +++++++++
 6 files changed, 70 insertions(+), 18 deletions(-)
---
base-commit: 5aa20836252a607ce5d3fa96f9807b56e9f6b1ca
change-id: 20230329-rust-uapi-894421e9a5d2

Thank you,
~~ Lina


             reply	other threads:[~2023-03-29 11:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 11:40 Asahi Lina [this message]
2023-03-29 11:40 ` [PATCH 1/2] rust: uapi: Add UAPI crate Asahi Lina
2023-03-29 15:21   ` Martin Rodriguez Reboredo
2023-03-29 20:25   ` Gary Guo
2023-03-29 11:40 ` [PATCH 2/2] rust: ioctl: Move to the uapi crate Asahi Lina
2023-03-29 15:28   ` Martin Rodriguez Reboredo
2023-03-29 20:29   ` Gary Guo

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=20230329-rust-uapi-v1-0-ee78f2933726@asahilina.net \
    --to=lina@asahilina.net \
    --cc=alex.gaynor@gmail.com \
    --cc=asahi@lists.linux.dev \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).