From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 245462D0A4D for ; Mon, 14 Apr 2025 14:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744639564; cv=none; b=H8TBtOIQzTFmQJxqIVGrM0jCquzyCVckEGpFdLwAiJ+o/Q8pFDt9ea6uwlxuCGCiEEQwxRqyk13avWCVj38sOw5FY1SzFzcoD6G+z7RqTh63zNklJFSqsxScBcanl4a9TlWdURfr0oKnBe8O1w0XggTjbLHUNIDpBc2QsVX/g5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744639564; c=relaxed/simple; bh=1Tpyq5xBZ9bBoXA1okFnsjXuvR0LvRO7JEf1SqZG1A0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oUZHCSUz9uKa+FitotsJcT2ogEzJ2iZe4/P8tl6Nr806Rj36sPbSQF+5tIbvys1YfXLLyHUzVEsNVIhQljnaApX8R/IR0fpkHyhf4szUOBEm2M+IJ7f7053DSjBqZCTXYs9K+qQo+dcytaMovZbAg23/ByC9GroXgPlD/e0EUmw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CP0V714z; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CP0V714z" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-399744f742bso1543945f8f.1 for ; Mon, 14 Apr 2025 07:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744639560; x=1745244360; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=pquPnA1PEeiSIlwvjcbZGrtyLxq30mwUO7DzjIyEInU=; b=CP0V714zVRvI6BPoFKJv/511uVdtY2KKjP4J5SRbnEKmAbGQGsEaCJhVwlg3DsMa+m 6se662E0q3EkwI8bI3zQx8ljO+zgXKMb4BT/3nynxDTC6qxDCjxc7XWfeZo80ny/WGDt +FJxDxAa53aQxF+hf1IBrCB7bBnzEQbT2Su06hXDjNIrLnBI5FG+mkHFxUM9PDnfPe12 EwwJbxnAxXuzxINt8s1diavKHShPAVa6ASO9XtWGZvbpoLIp41KqbqqCz5nTOLxTeoWH ToKtDrzLDczrBn1ZyzD6Y/y3ntjH7TJdGcM00nNBKYTy/54lScYYlCgkY8fyVDpWWmJi 9SkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744639560; x=1745244360; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=pquPnA1PEeiSIlwvjcbZGrtyLxq30mwUO7DzjIyEInU=; b=NicI1Da2wzBSk/TfWCuFaLVCkFlOcJstuup+yH0KBeJZGeHtayLYt/Gr7sSemnlrKk QrB6g4cs8TNA5x/vdECBSpm4dLRvyXZOf8GuZDhmmk+GV1VGqvdEJ5KH3UltMtBhCEzJ bd4tQrSPZGUc4nhEuV2d/P8Xafnj9PYxg/jSbZxD1pTw/r22yquAsHy3zLszeLEZqMyu pWMBziOE6NbbgAKo7B4TqC0GQTx80LPTv7LCXksYurgxCS77c+a/8b1safVmw8JfLwEx 39HxCnhiV5HL97OfzWtYZHP9juaTBmqrX5aTO8ARZNJH9ejKXw8Lutk8OCXKbPO1gLLV 41Gw== X-Forwarded-Encrypted: i=1; AJvYcCUAH0iTlCbHSiReTmkwY8nIuYbr6dzZcOkbNvsoTRRyygta3SWIxNjuPRQx8yb1BNb6e9uAZmrywUFMrBY=@vger.kernel.org X-Gm-Message-State: AOJu0YxVlD/cy3V59HL/c8Ft4SAxAoNUP9IWb2TJeapK0gM/2QN5ntn4 YhZKWt26M4IVqIquKCZuiYpnocI6qtl+WwscE4oBrf5B0hvt/nwIHhJBrTE/FCc8XbSLB0EXEmo 0Tne5Xn+oeVZofQ== X-Google-Smtp-Source: AGHT+IGQbHeuxbBbZFXwHsYpF9g2N88M1bkKFXroszwDXJntxCkbevVk0P6QDHTRfo+/ugItOAMd6LUWJaI08es= X-Received: from wmbev15.prod.google.com ([2002:a05:600c:800f:b0:43d:7e5:30f0]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2483:b0:39a:d32c:fb5e with SMTP id ffacd0b85a97d-39ea51f577emr9570064f8f.21.1744639560478; Mon, 14 Apr 2025 07:06:00 -0700 (PDT) Date: Mon, 14 Apr 2025 14:05:58 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250411-rust_arm_fix_fw_abstaction-v1-1-0a9e598451c6@gmail.com> Message-ID: Subject: Re: [PATCH] rust: fix building firmware abstraction on 32bit arm From: Alice Ryhl To: Benno Lossin Cc: Miguel Ojeda , Christian Schrefl , Luis Chamberlain , Russ Weight , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 12, 2025 at 10:01:22AM +0000, Benno Lossin wrote: > On Fri Apr 11, 2025 at 4:15 PM CEST, Miguel Ojeda wrote: > > On Fri, Apr 11, 2025 at 2:46=E2=80=AFPM Benno Lossin wrote: > >> > >> Ah I overlooked this, you should be using `kernel::ffi` (or > >> `crate::ffi`) instead of `core`. (for `c_char` it doesn't matter, but = we > >> shouldn't be using `core::ffi`, since we have our own mappings). > > > > In 6.6, C `char` changed to unsigned, but `core::ffi::c_char` is > > signed (in x86_64 at least). > > > > We should just never use `core::ffi` (except in `rust/ffi.rs`, of > > course) -- I think we should just add the C types to the prelude > > (which we discussed in the past) so that it is easy to avoid the > > mistake (something like the patch attached as the end result, but > > tested and across a kernel cycle or two) and mention it in the Coding > > Guidelines. Thoughts? >=20 > Yeah sounds like a good idea. >=20 > > I tried to use Clippy's `disallowed-types` too: > > > > disallowed-types =3D [ > > { path =3D "core::ffi::c_void", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_char", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_schar", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_uchar", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_short", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_ushort", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_int", reason =3D "the `kernel::ffi` ty= pes > > should be used instead" }, > > { path =3D "core::ffi::c_uint", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_long", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_ulong", reason =3D "the `kernel::ffi` > > types should be used instead" }, > > { path =3D "core::ffi::c_longlong", reason =3D "the `kernel::ff= i` > > types should be used instead" }, > > { path =3D "core::ffi::c_ulonglong", reason =3D "the `kernel::f= fi` > > types should be used instead" }, > > ] > > > > But it goes across aliases. >=20 > We could make the types in `ffi` be transparent newtypes. But not sure > if that could interfere with kCFI or other stuff. Transparent newtypes for all integers would be super inconvenient. Alice