Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls to __clear_cache() require pointer arguments #239

Closed
cmuellner opened this issue Apr 28, 2021 · 4 comments
Closed

Calls to __clear_cache() require pointer arguments #239

cmuellner opened this issue Apr 28, 2021 · 4 comments

Comments

@cmuellner
Copy link
Contributor

cmuellner commented Apr 28, 2021

When compiling with a recent version of GCC, we run into the following error:

      ../pk/pk.c: In function 'run_loaded_program.constprop':
      ../pk/pk.c:177:3: error: both arguments to '__builtin___clear_cache'
      must be pointers
        177 |   __clear_cache(0, 0);
            |   ^~~~~~~~~~~~~~~~~~~

The error comes from the fact, that we pass numeric values as arguments to the invocation of __clear_cache.

Using (void*)0 or NULL instead of 0 does not work either.

My understanding of the code is, that we know that we can only clear the complete instruction cache and therefore we don't care about the arguments. Is this assumption correct?

This error has been introduced by the GCC commit c05ece9 in Dec 2020.
I have created a GCC bug report (PR100316) as well.

@cmuellner
Copy link
Contributor Author

Ping for @aswaterman as he is the author of the affected piece of code.

@aswaterman
Copy link
Collaborator

I think we can replace this one with an asm volatile fence.i. If you make such a PR, I’ll merge it.

cmuellner added a commit to cmuellner/riscv-pk that referenced this issue Apr 28, 2021
Using recent compilers we get the following error message:

  ../pk/pk.c: In function 'run_loaded_program.constprop':
  ../pk/pk.c:177:3: error: both arguments to '__builtin___clear_cache'
  must be pointers
    177 |   __clear_cache(0, 0);
        |   ^~~~~~~~~~~~~~~~~~~

Let's use the existing function __riscv_flush_icache(),
give it a header with a prototype and use it to
emits the FENCE.I instruction directly.

See riscv-software-src#239

Suggested-by: Andrew Waterman <andrew@sifive.com>
Signed-off-by: Christoph Muellner <cmuellner@linux.com>
@cmuellner
Copy link
Contributor Author

The required code was already there. Just needed to be called.
Thanks!

aswaterman pushed a commit that referenced this issue Apr 28, 2021
Using recent compilers we get the following error message:

  ../pk/pk.c: In function 'run_loaded_program.constprop':
  ../pk/pk.c:177:3: error: both arguments to '__builtin___clear_cache'
  must be pointers
    177 |   __clear_cache(0, 0);
        |   ^~~~~~~~~~~~~~~~~~~

Let's use the existing function __riscv_flush_icache(),
give it a header with a prototype and use it to
emits the FENCE.I instruction directly.

See #239

Suggested-by: Andrew Waterman <andrew@sifive.com>
Signed-off-by: Christoph Muellner <cmuellner@linux.com>
@aswaterman
Copy link
Collaborator

Resolved by #240.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants