Conversation
|
HIR ty lowering was modified cc @fmease |
|
Thanks for the pull request, and welcome! The Rust Project has assigned @TaKO8Ki (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
Converting to draft, while it passed unit tests locally I was able to cause an issue with the validator when running against code in the wild. I will reopen once resolved. Specifically, this case fails: I'm adding it to my tests now as a regression test, and I'm going to try to figure out why this is happening. Getting this error: My original design was based on the cmse.rs impl inside of |
d5d25f0 to
4610779
Compare
This comment has been minimized.
This comment has been minimized.
|
With a fairly minimal refactor I moved it into check (I'm still not confident on where to integrate it, so advice would be welcome) and the cycle error is resolved against my tests, however, the validation no longer runs against function pointers. I'm still a bit uphappy about that, but, for now, since I after running more tests on existing code (including the x86_64 crate) I found no regressions, I'm reopening. |
17c3dd0 to
123a52d
Compare
|
A quick reference for what shapes GCC/Clang/rustc allows / rejects (pre / post changes) ChartsAssume 64-bits except if noted otherwise. Rust types used: C types used: Frame parameter
Error code parameter
Whole-signature shape
32-bit variants
NotesMost significant things I note is:
Wrong Code (Array)Basically, error code resides at [rsp + 24], we load it as a pointer into rax and then dereference it twice for accesses into c[0] and c[2]. let err_code == 2, we then dereference 0x2, causing a fault. Wrong code (ZST Code)If we installed |
123a52d to
b4510f7
Compare
|
I've implemented generics support and validated against most patterns. Not sure I got all patterns possible since the breadth of possible generic structures is quite high, but I tried to be thorough. |
This comment has been minimized.
This comment has been minimized.
b717173 to
7afa7f1
Compare
7afa7f1 to
dc244f0
Compare
|
Did some research on this (and nightly) against pointers. I assumed they were valid frame parameters because abi tests elsewhere used them as the reference and because the underlying LLVM abi itself in fact provides you a pointer, however, I don't believe this is actually the case. I believe the pointer is essentially being lowered as I've gone and updated my code to check for pointers now, and also did a retest of my build against community crates & projects. No code I tested seems to be broken by this design, which makes sense because if they used pointers as a frame param it would have broken. (Meanwhile, every single test we wrong seems to use *const u8, which is invalid and painful to update.) |
This comment has been minimized.
This comment has been minimized.
1f031f0 to
ec734ca
Compare
This comment has been minimized.
This comment has been minimized.
ec734ca to
e2695f9
Compare
This comment has been minimized.
This comment has been minimized.
Unsized parameters or zero sized parameters provided to an function with the x86-interrupt abi could emit ICE. Such parameters are conceptually invalid. This commit implements parameter validation logic for the x86-iterrupt ABI to prevent these error classes and to improve user diagnostics.
e2695f9 to
bd36627
Compare
| // Rules for input validation | ||
| // 1. 1-2 parameters (validated in AST layer) | ||
| // 2. Neither type may be unsized -> X86InterruptUnsized | ||
| // 3. Neither type may be zero-sized -> X86InterruptZeroSized | ||
| // 4. First parameter (frame) must be valid for any bit pattern -> X86InterruptInvalidFrame | ||
| // 5. First parameter (frame) must not be a pointer -> X86InterruptInvalidFrame | ||
| // 6. Second parameter (error code) must be single word-size integer, | ||
| // and valid for any bit pattern -> X86InterruptInvalidErrorCode |
There was a problem hiding this comment.
Note: I've considered adding a rule for restricting Frame size, but I chose not to because the frame size is actually variable on 32-bit, and can be between 12-36 bytes. The C abi's avoid having to care about this because they all operate on pointers, so I think we should also leave this to largely the user's discretion.
In contrast, llvm & gcc are both strict on what the code parameter may be, so that one I believe we can be strict on size requirements for.
Unsized parameters or zero sized parameters provided to an function with the x86-interrupt abi could emit ICE. Such parameters are conceptually invalid. This commit implements parameter validation logic for the x86-iterrupt ABI to prevent these error classes and to improve user diagnostics.
Relevant unstable feature: #40180
Fixes #124806
Fixes #126418
(May also close this, a reviewer's input would be optimal: #63018. It depends on what the desired resolution is, because current rules don't bound the size requirements of frame though they could be trivially added. The bug itself seems to be resolved at this point.)
LLM assistance disclosure: An LLM was used in the development of this PR, specifically for the following tasks:
There exists no LLM generated code, comments, documentation, or tests in this PR.