• Yonghong Song's avatar
    Force udst ctx->#reg load to be volatile · b0f891d1
    Yonghong Song authored
    This is related to issue #1133. Compiler sometimes
    generates code patterns likes:
         r1 = ctx + 96
         goto next
       here:
         r1 = ctx + 48
       next:
         r3 = load (r1 + 0)
    Verifier will fail for such cases as r1 is marked
    as "unknown" at the time of load.
    
    The previous workaround is to add volatile attribute
    to the store like
       *(volatile u64 *)&dest = ctx->bx
    The hope is to force ctx related load in-place since
    its value is needed for store.
    
    Unfortunately, this does not always work and compiler
    still has freedom to merge different ctx loads at the
    same time honoring the volatile &dest. In USDT generated
    code, different branches of &dest are the same.
    
    This patch directly make ctx->bx itself as a volatile load:
      *(volatile u64 *)&ctx->bx
    This seems working as compiler stops playing around
    the address pointing to a volatile data.
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    b0f891d1
usdt.cc 11.4 KB