https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103241

            Bug ID: 103241
           Summary: Odd 0 length entries in location lists
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wcohen at redhat dot com
  Target Milestone: ---

I wrote a dwgrep (https://pmachata.github.io/dwgrep/) script to examine the
location lists of function parameters of the kernel and print out each function
and parameter that had zero length entries in the location lists:

  dwgrep /usr/lib/debug/lib/modules/5.14.15-200.fc34.x86_64/vmlinux -e '
let A := entry (?TAG_subprogram) (?AT_ranges || ?AT_low_pc);
let FSTART := (A ?AT_ranges @AT_ranges low) || ( A low);
let PARM := A child ?TAG_formal_parameter;
(PARM ?AT_location @AT_location address length==0) ([A name, FSTART, PARM
name])' | grep \\[ | more

Some of the functions in the kernel that were flagged may have been confused by
the constant propagation, irsa, or partial inlining optimization.  However,
There were some functions parameters that included entries with 0 length
entries in the location list for the parameter.  Focusing on one function,
static_protections:

["static_protections", 0xffffffff8107a540, "prot"]
["static_protections", 0xffffffff8107a540, "start"]
["static_protections", 0xffffffff8107a540, "pfn"]
["static_protections", 0xffffffff8107a540, "npg"]
["static_protections", 0xffffffff8107a540, "warnlvl"]


Using The following to look at the section of the debuginfo associated with the
function:

llvm-dwarfdump -c --name="static_protection"
/usr/lib/debug/lib/modules/5.14.15-200.fc34.x86_64/vmlinux | more

See the following for static_protection where first entry for "prot" parameter
is 0 length and overlaps the next entry:

0x00e44d5c:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fb6d "prot")
                DW_AT_location  (0x002c83db: 
                   [0xffffffff8107a540, 0xffffffff8107a540): DW_OP_reg5 RDI
                   [0xffffffff8107a540, 0xffffffff8107a569): DW_OP_reg5 RDI,
DW_OP_piece 0x8
                   [0xffffffff8107a5a0, 0xffffffff8107a5f3): DW_OP_reg5 RDI
                   [0xffffffff8107a617, 0xffffffff8107a65b): DW_OP_reg3 RBX
                   [0xffffffff8107a66a, 0xffffffff8107a67e): DW_OP_reg3 RBX,
DW_OP_piece 0x8
                   [0xffffffff8107a67e, 0xffffffff8107a68c): DW_OP_reg5 RDI
                   [0xffffffff8107a68c, 0xffffffff8107a6a1): DW_OP_reg3 RBX,
DW_OP_piece 0x8
                   [0xffffffff8107a6a1, 0xffffffff8107a6a1): DW_OP_reg3 RBX,
DW_OP_piece 0x8
                   [0xffffffff8107a6a1, 0xffffffff8107a6cb): DW_OP_reg3 RBX
                   [0xffffffff8107a6cb, 0xffffffff8107a6cb): DW_OP_reg3 RBX,
DW_OP_piece 0x8
                   [0xffffffff81bc6967, 0xffffffff81bc6994): DW_OP_reg3 RBX,
DW_OP_piece 0x8
                   [0xffffffff81bc69b5, 0xffffffff81bc6a24): DW_OP_reg3 RBX,
DW_OP_piece 0x8)
                DW_AT_unknown_2137      (0x002c83c3)

0x00e44d69:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fb7a "start")
                DW_AT_location  (0x002c84ed: 
                   [0xffffffff8107a540, 0xffffffff8107a5a0): DW_OP_reg4 RSI
                   [0xffffffff8107a5a0, 0xffffffff8107a65b): DW_OP_reg12 R12
                   [0xffffffff8107a65b, 0xffffffff8107a66a):
DW_OP_GNU_entry_value(DW_OP_reg4 RSI), DW_OP_s
tack_value
                   [0xffffffff8107a66a, 0xffffffff8107a68c): DW_OP_reg4 RSI
                   [0xffffffff8107a68c, 0xffffffff8107a6cb): DW_OP_reg12 R12
                   [0xffffffff8107a6cb, 0xffffffff8107a6cb): DW_OP_reg4 RSI
                   [0xffffffff81bc6967, 0xffffffff81bc698c): DW_OP_reg4 RSI
                   [0xffffffff81bc698c, 0xffffffff81bc6a24): DW_OP_reg12 R12)
                DW_AT_unknown_2137      (0x002c84dd)

0x00e44d76:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fb87 "pfn")
                DW_AT_location  (0x002c85a8: 
                   [0xffffffff8107a540, 0xffffffff8107a5a0): DW_OP_reg1 RDX
                   [0xffffffff8107a5a0, 0xffffffff8107a65b): DW_OP_reg15 R15
                   [0xffffffff8107a65b, 0xffffffff8107a66a):
DW_OP_GNU_entry_value(DW_OP_reg1 RDX), DW_OP_s
tack_value
                   [0xffffffff8107a66a, 0xffffffff8107a68c): DW_OP_reg1 RDX
                   [0xffffffff8107a68c, 0xffffffff8107a6cb): DW_OP_reg15 R15
                   [0xffffffff8107a6cb, 0xffffffff8107a6cb): DW_OP_reg1 RDX
                   [0xffffffff81bc6967, 0xffffffff81bc6983): DW_OP_reg1 RDX
                   [0xffffffff81bc6983, 0xffffffff81bc6a24): DW_OP_reg15 R15)
                DW_AT_unknown_2137      (0x002c8598)

0x00e44d83:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fb94 "npg")
                DW_AT_location  (0x002c8663: 
                   [0xffffffff8107a540, 0xffffffff8107a5a0): DW_OP_reg2 RCX
                   [0xffffffff8107a5a0, 0xffffffff8107a65b): DW_OP_reg13 R13
                   [0xffffffff8107a65b, 0xffffffff8107a66a):
DW_OP_GNU_entry_value(DW_OP_reg2 RCX), DW_OP_s
tack_value
                   [0xffffffff8107a66a, 0xffffffff8107a68c): DW_OP_reg2 RCX
                   [0xffffffff8107a68c, 0xffffffff8107a6cb): DW_OP_reg13 R13
                   [0xffffffff8107a6cb, 0xffffffff8107a6cb): DW_OP_reg2 RCX
                   [0xffffffff81bc6967, 0xffffffff81bc6977): DW_OP_reg2 RCX
                   [0xffffffff81bc6977, 0xffffffff81bc6a24): DW_OP_reg13 R13)
                DW_AT_unknown_2137      (0x002c8653)

0x00e44d90:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fba1 "lpsize")
                DW_AT_location  (0x002c8718: 
                   [0xffffffff8107a540, 0xffffffff8107a585): DW_OP_reg8 R8
                   [0xffffffff8107a585, 0xffffffff8107a65b): DW_OP_reg14 R14
                   [0xffffffff8107a65b, 0xffffffff8107a66a):
DW_OP_GNU_entry_value(DW_OP_reg8 R8), DW_OP_st
ack_value
                   [0xffffffff8107a66a, 0xffffffff8107a6cb): DW_OP_reg14 R14
                   [0xffffffff81bc6967, 0xffffffff81bc6a24): DW_OP_reg14 R14)
                DW_AT_unknown_2137      (0x002c870e)

0x00e44d9d:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00e3fbae "warnlvl")
                DW_AT_location  (0x002c8798: 
                   [0xffffffff8107a540, 0xffffffff8107a5a0): DW_OP_reg9 R9
                   [0xffffffff8107a5a0, 0xffffffff8107a66a): DW_OP_fbreg -72
                   [0xffffffff8107a66a, 0xffffffff8107a68c): DW_OP_reg9 R9
                   [0xffffffff8107a68c, 0xffffffff8107a6cb): DW_OP_fbreg -72
                   [0xffffffff8107a6cb, 0xffffffff8107a6cb): DW_OP_reg9 R9
                   [0xffffffff81bc6967, 0xffffffff81bc6974): DW_OP_reg9 R9
                   [0xffffffff81bc6974, 0xffffffff81bc6a24): DW_OP_fbreg -72)
                DW_AT_unknown_2137      (0x002c878a)


It looks like that first "prot" entry [0xffffffff8107a540, 0xffffffff8107a540):
DW_OP_reg5 RDI isn't useful as it is 0 length and the next entry covers its
start.  The entries for [0xffffffff8107a6cb, 0xffffffff8107a6cb) for "start",
"pfn", "lpsize", and "warnlvl" look questionable as that would be an area
outside the function's first entry [0xffffffff8107a540, 0xffffffff8107a6cb).

The source code associated with with this function
https://elixir.bootlin.com/linux/v5.14.15/source/arch/x86/mm/pat/set_memory.c#L534
has a struct being passed in and the other cases seem to also have a struct as
the parameter.

Reply via email to