1

So I want to have a buffer in my kernel module that I created like that:

static char buf[BUF_LEN];

My problem is that the start address of this buffer is not necessarily page aligned. To give a bit of context: I want to extract the physical address (I currently do so using virt_to_phys, although I have read somewhere that it is not appliccable to variable addresses in kernel modules; is there a better way?). Then I change execution environment with a hypervisor call to execute svsm; the specifics don't really matter here. This new execution environment has the same (emulated) physical address space and the process there will read the physical address of buf. The problem is: it expects it to be page aligned!

Is there a good way to create a page aligned buffer and its physical address within a kernel module?

2
  • 1
    Why not simply obtain a page at runtime with alloc_pages(0)? Is there a particular reason you need it statically defined in you rmodule? Commented Jul 14, 2024 at 23:07
  • 1
    You could align it with static char buf[BUF_LEN] __aligned(PAGE_SIZE);. Commented Jul 16, 2024 at 15:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.