Thread (14 messages) 14 messages, 4 authors, 2021-09-12

Re: [PATCH 3/4] parisc: Use absolute_pointer for memcmp on fixed memory location

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2021-09-12 19:12:07
Also in: lkml, netdev

On Sun, Sep 12, 2021 at 9:02 AM Guenter Roeck [off-list ref] wrote:
-       running_on_qemu = (memcmp(&PAGE0->pad0, "SeaBIOS", 8) == 0);
+       running_on_qemu = (memcmp(absolute_pointer(&PAGE0->pad0), "SeaBIOS", 8) == 0);
This seems entirely the wrong thing to do, and makes no sense. That
"&PAGE0->pad0" is a perfectly valid pointer, and that's not where the
problem is.

The problem is "PAGE0" itself:

    #define PAGE0   ((struct zeropage *)__PAGE_OFFSET)

which takes that absolute offset and creates a pointer out of it.

IOW, _that_ is what should have the "absolute_pointer()" thing, and in
that context the name of that macro and its use actually makes sense.

No?

An alternative - and possibly cleaner - approach that doesn't need
absolute_pointer() at all might be to just do

        extern struct zeropage PAGE0;

and then make that PAGE0 be defined to __PAGE_OFFSET in the parisc
vmlinux.lds.S file.

Then doing things like

        running_on_qemu = !memcmp(&PAGE0.pad0, "SeaBIOS", 8);

would JustWork(tm).

Hmm?

             Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help