bpf: Handle sign-extenstin ctx member accesses
authorYonghong Song <yonghong.song@linux.dev>
Fri, 28 Jul 2023 01:12:07 +0000 (18:12 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 28 Jul 2023 01:52:33 +0000 (18:52 -0700)
commit1f1e864b65554e33fe74e3377e58b12f4302f2eb
tree9effb1a9e6dfd2f9bd97b90965f50d984612f7f5
parent8100928c881482a73ed8bd499d602bab0fe55608
bpf: Handle sign-extenstin ctx member accesses

Currently, if user accesses a ctx member with signed types,
the compiler will generate an unsigned load followed by
necessary left and right shifts.

With the introduction of sign-extension load, compiler may
just emit a ldsx insn instead. Let us do a final movsx sign
extension to the final unsigned ctx load result to
satisfy original sign extension requirement.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230728011207.3712528-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c