public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Alexander Altman <alexanderaltman@me.com>
To: Borislav Petkov <bp@alien8.de>
Cc: kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	rust-for-linux@vger.kernel.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [bp:tip-x86-alternatives 1/1] error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
Date: Tue, 27 Dec 2022 12:31:17 -0800	[thread overview]
Message-ID: <76353487-736A-4470-AD31-77F47F8C08F6@me.com> (raw)
In-Reply-To: <Y6r+UbfkXruwHU2v@zn.tnic>

> On Dec 27, 2022, at 6:16 AM, Borislav Petkov <bp@alien8.de> wrote:
> 
> Resending because rust ML doesn't like big messages:
> 
> From: rust-for-linux-owner@vger.kernel.org
> To: rust-for-linux-approval@vger.kernel.org, bp@alien8.de
> Subject: BOUNCE rust-for-linux@vger.kernel.org:     Message too long (>100000 chars)
> 
> Rust folks, you can check out the whole thing here:
> 
> https://lore.kernel.org/all/202212272003.rgQDX8DQ-lkp@intel.com/
> 
> (and maybe raise the limit on that ML of yours :))
> 
> Thx.
> 
> On Tue, Dec 27, 2022 at 02:52:25PM +0100, Borislav Petkov wrote:
>> On Tue, Dec 27, 2022 at 08:36:11PM +0800, kernel test robot wrote:
>>> Hi Borislav,
>>> 
>>> FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
>>> 
>>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git tip-x86-alternatives
>>> head:   82db736201e76889825efe8899ad55976111691a
>>> commit: 82db736201e76889825efe8899ad55976111691a [1/1] x86/alternatives: Add alt_instr.flags
>>> config: x86_64-rhel-8.3-rust
>>> compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
>>> reproduce (this is a W=1 build):
>>>        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>>        chmod +x ~/bin/make.cross
>>>        # https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/commit/?id=82db736201e76889825efe8899ad55976111691a
>>>        git remote add bp https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git
>>>        git fetch --no-tags bp tip-x86-alternatives
>>>        git checkout 82db736201e76889825efe8899ad55976111691a
>>>        # save the config file
>>>        mkdir build_dir && cp config build_dir/.config
>>>        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
>>>        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 prepare
>> 
>> These reproduction instructions look insufficient to me. The env needs a
>> rust compiler installed. Which I don't have:
>> 
>> ./scripts/rust_is_available.sh -v
>> ***
>> *** Rust compiler '' could not be found.
>> ***
>> 
>> Or does some of that make.cross magic install one? I don't see a "rustc"
>> mentioned there at all but I see
>> 
>> CONFIG_RUSTC_VERSION_TEXT="rustc 1.62.0 (a8314ef7d 2022-06-27)"
>> 
>> in the .config so apparently that rustc thing has come from somewhere...
>> 
>>> If you fix the issue, kindly add following tag where applicable
>>> | Reported-by: kernel test robot <lkp@intel.com>
>>> 
>>> All errors (new ones prefixed by >>):
>>> 
>>>>> error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type


This is indeed directly because of your change, although fixing it beyond my
skill.  Explanation:

You made the following change:
> - u16 cpuid; /* cpuid bit set for replacement */
> +
> + union {
> + struct {
> + u32 cpuid: 16; /* CPUID bit set for replacement */
> + u32 flags: 16; /* patching control flags */
> + };
> + u32 ft_flgs;
> + };

That caused Rust’s bindgen (bindings generator) to generate a type for the
altered field that indirectly included a representation of the
bitfields...which have a greater-than-natural alignment because of their
encoding (they’re represented as an array of 4 8-bit unsigned integers, but
aligned as if they’re a single 16-bit unsigned integer).  This interacts
badly with the top-level command to make the alt_instr struct packed, which
bindgen faithfully translates from C __packed to Rust #[repr(packed)].

One way to resolve this temporarily would be to add the following line above
the offending struct:
/// <div rustbindgen hide></div>
This will cause bindgen to ignore the struct entirely and not translate it.  If it’s
actually needed for Rust code, now or later, then we can’t do that and need
to actually replace it with something translatable, or else leave it hidden and
manually create its translation on the Rust side.  For the latter, just using a
u32 for the entire bitfield-containing union would be sufficient.

>> 
>> -ENOPARSE this error.
>> 
>> Lemme add rust and toolchain MLs to Cc and leave the rest for them with
>> the hope that they can translate this linenoise for me.
> 
> Well, not leaving it because rust ML can't take such big emails.
> 
> -- 
> Regards/Gruss,
>    Boris.
> 
> https://people.kernel.org/tglx/notes-about-netiquette
> 


Thanks,
     Laine Taffin Altman 

  reply	other threads:[~2022-12-27 20:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 12:36 [bp:tip-x86-alternatives 1/1] error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type kernel test robot
2022-12-27 13:52 ` Borislav Petkov
2022-12-27 14:16   ` Borislav Petkov
2022-12-27 20:31     ` Alexander Altman [this message]
2022-12-27 21:14       ` Borislav Petkov
2023-01-06 23:26       ` Miguel Ojeda
2023-01-07  0:42     ` Miguel Ojeda
2023-01-06 23:25   ` Miguel Ojeda
2023-01-06 23:57     ` Borislav Petkov
2023-01-07  0:38       ` Miguel Ojeda
2023-01-12 16:14         ` Borislav Petkov
2023-01-14  2:18           ` Gary Guo
2023-01-14 12:29             ` Miguel Ojeda
2023-01-14 11:54           ` Miguel Ojeda
2023-01-14 15:35           ` David Laight

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=76353487-736A-4470-AD31-77F47F8C08F6@me.com \
    --to=alexanderaltman@me.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rust-for-linux@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