From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 271AE1D54E0 for ; Mon, 19 Aug 2024 19:38:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096337; cv=none; b=bM7LzPEQp+w+yBep8I38Bdl1x1B2qFAYIVasKTquQxWnjbYVxMxT5ibSh0sl4XTG4n+qqv68q2BLxUewgD1oCOjSnOyQky/EC+N3SQ2aHrPZAhGzwrtrx+c1uEhWDlbzhb2y8+tdtSIroePOZEHkcP8Atuf0DTLIb9RLNWOjcHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724096337; c=relaxed/simple; bh=F7wkcHJPXIPuDfH/klr4thKavbEnJmwxdbEiZYRhu1E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cKJqq1MmwYfwIn7L9Q7w28yXKfEtpjxWE3CLNCeEA8wRYJGZ+iDBYSpiWHwJpqIOy/n4LNv+LhztCh9wY6meyON3doZj+iLxNJEQy9s6XSms5ZDdqz3Q2mlwZFpZ/h7lfO0DoqUJzA9P12sb8BZvZoRcQNKTUUpB6IR2nE30Heo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Jqy44aHK; arc=none smtp.client-ip=209.85.214.179 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jqy44aHK" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-201fba05363so29186955ad.3 for ; Mon, 19 Aug 2024 12:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724096335; x=1724701135; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YeS++fCKemkXhDJMjat3ElWefP5AW5Wy1oKzA28CFNw=; b=Jqy44aHKfCucjW6dSdgDbzaqx2bnXrzPEbfetshLmrEaw/8xyi0TxC5h7b8LHg8N/t kouRMUJCIINWGrPLvd4Sca5u2B86Qpu1OApbkfFi9jPE4QPO7YgUqf48/pp/avbE7M1F lXJKrVlyu8na4SVtkpsonw//DihGztrsDcWO8orF6NQltKwhUgETN4S6mzahBatvl4yK UMKc7DJodi8BjCyDHN1sSBeQM4hD1rgsoVbAMCZPZst7QDHwCBS9MNExih6UbG4Uzp3E K7W7VpffRMkE0tER85oamhTkLH2AFLpW0FSWfqnMxWZ7uyCW3dVhQkwozOJ+vYV/wb0k fn4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724096335; x=1724701135; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YeS++fCKemkXhDJMjat3ElWefP5AW5Wy1oKzA28CFNw=; b=u9FL8nDMbLgMcN0AVlvfaa9S54Gv1j2si14fXOIWNiAiKtV56o+/t2Y5FHnjzgEjY6 AqDugGyU22xfsmkOtEp4l1ZBKUEbxSDrGldIdqcx1ukwGB2W11f28OFGJOIUdyEEcrdB S0cC8BcGmRWAkFpPFYY/Gf79kOglfFi8GqDkFoLXrsZfSTHAaMUBgTqTTE6VMjqIv+aY Zj3MCNpO3V5+cjpN0U0oRrh7/hOIewlxo4dFy79zZrMeMigT4cXrHYJHUka3Xh74pFg7 rjSmEdgNoVs35rOf6VgnGVQ7NvT686Z5wypjf+MHOPLuuld9J2KnCw8jHtzaCw0dCCGV keAg== X-Forwarded-Encrypted: i=1; AJvYcCWzXb9zKMX60sKJ9Uf/r5rWGK7B7PV/ie7I4Ya5kQ5Zo1zjHu7LvNGJpo1T0qhe3k2fpa8X8p75XOJLAjg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/K824o5ZVe/8RTsNQGvYuHF6td3TN3DobSrErUn3MtnMk/454 6pGnoS3oe5ea9TGXHcdDmG7KVAzny66ZHVePBML18wFC/NOlCul0q0x5bVYa8A== X-Google-Smtp-Source: AGHT+IG8oRBHqBpvRvU+j9ijDv76wPfUzxrx1g+I09GD1WWcWllKaTLicpQtA41S0/MWaq3kkTtGZA== X-Received: by 2002:a17:903:188:b0:202:4d05:a24a with SMTP id d9443c01a7336-2024d05a587mr34136775ad.16.1724096334977; Mon, 19 Aug 2024 12:38:54 -0700 (PDT) Received: from google.com (226.75.127.34.bc.googleusercontent.com. [34.127.75.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f03197b6sm65427305ad.69.2024.08.19.12.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 12:38:54 -0700 (PDT) Date: Mon, 19 Aug 2024 19:38:51 +0000 From: Sami Tolvanen To: Benno Lossin Cc: Greg Kroah-Hartman , Masahiro Yamada , Luis Chamberlain , Miguel Ojeda , Matthew Maurer , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Petr Pavlu , Neal Gompa , Hector Martin , Janne Grunau , Asahi Linux , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH v2 16/19] gendwarfksyms: Add support for reserved structure fields Message-ID: <20240819193851.GA4809@google.com> References: <20240815173903.4172139-21-samitolvanen@google.com> <20240815173903.4172139-37-samitolvanen@google.com> <2024081600-grub-deskwork-4bae@gregkh> <2024081705-overarch-deceptive-6689@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Benno, On Sat, Aug 17, 2024 at 01:19:55PM +0000, Benno Lossin wrote: > > For this use-case (the one in the patch), I don't really know if we want > to copy the approach from C. Do we even support exporting kABI from > Rust? If yes, then we I would recommend we tag it in the source code > instead of using a union. Here the example from the patch adapted: > > #[repr(C)] // needed for layout stability > pub struct Struct1 { > a: u64, > #[kabi_reserved(u64)] // this marker is new > _reserved: u64, > } > > And then to use the reserved field, you would do this: > > #[repr(C)] > pub struct Struct1 { > a: u64, > #[kabi_reserved(u64)] > b: Struct2, > } > > #[repr(C)] > pub struct Struct2 { > b: i32, > v: i32, > } > > The attribute would check that the size of the two types match and > gendwarfksyms would use the type given in "()" instead of the actual > type. This definitely looks cleaner than unions in Rust, but how would this scheme be visible in DWARF? You might also need to expand the annotation to allow replacing one reserved field with multiple smaller ones without using structs. Sami