Skip to contentSkip to conversation

xen/riscv: fix build issue for bullseye-riscv64 container

PATCH In review Oleksii Kurochko 3 participants 4 messages Jul 31, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/riscv: fix build issue for bullseye-riscv64 container

Address compilation error on bullseye-riscv64 container:
undefined reference to guest_physmap_remove_page

Since there is no current implementation of guest_physmap_remove_page(), a stub function has been added.

---
 xen/arch/riscv/stubs.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/riscv/stubs.c +6 -0
index b67d99729f..3285d18899 100644
@@ -381,6 +381,12 @@ int arch_get_paging_mempool_size(struct domain *d, uint64_t *size)
     BUG_ON("unimplemented");
 }
 
+int guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn,
+                              unsigned int page_order)
+{
+    BUG_ON("unimplemented");
+}
+
 /* delay.c */
 
 void udelay(unsigned long usecs)
Signature · 1 line
2.45.2
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Oleksii Kurochko

Address compilation error on bullseye-riscv64 container:
undefined reference to guest_physmap_remove_page

Since there is no current implementation of guest_physmap_remove_page(), a stub function has been added.

I'll commit this with the description unchanged, just the tags switched around. But really I think sooner or later I'm simply not going to comment on patches anymore when you repeat the same patterns over and over again, despite having been given clear guidelines on how to write patch descriptions (and there are ample of good examples to pick from the list).

I'm sorry for the rant, Jan

#2 lore raw
In reply to Oleksii Kurochko
Quoted 8 lines · Oleksii Kurochko

Address compilation error on bullseye-riscv64 container:
undefined reference to guest_physmap_remove_page

Since there is no current implementation of guest_physmap_remove_page(), a stub function has been added.

Usually we do Fixes/Reported-by tags first.  (We try to do tags in chronological/logical order).

I've confirmed this fixes the issue, so Acked-by: Andrew Cooper <[email protected]>

Having tried a different approach,

user@3c393ef3b4c0:/build/xen$ make
  UPD     include/xen/compile.h
Xen 4.20-unstable
make[1]: Nothing to be done for 'include'.
make[1]: 'arch/riscv/include/asm/asm-offsets.h' is up to date.
  CC      common/version.o
  LD      common/built_in.o
  CC      arch/riscv/setup.o
  LD      arch/riscv/built_in.o
  LD      prelink.o
  LDS     arch/riscv/xen.lds
riscv64-linux-gnu-ld      -T arch/riscv/xen.lds -N prelink.o \
    ./common/symbols-dummy.o -o ./.xen-syms.0
riscv64-linux-gnu-ld: prelink.o: in function `register_keyhandler':
/build/xen/common/keyhandler.c:106: undefined reference to
`guest_physmap_remove_page'
riscv64-linux-gnu-ld: ./.xen-syms.0: hidden symbol
`guest_physmap_remove_page' isn't defined
riscv64-linux-gnu-ld: final link failed: bad value
make[2]: *** [arch/riscv/Makefile:15: xen-syms] Error 1
make[1]: *** [build.mk:90: xen] Error 2
make: *** [Makefile:610: xen] Error 2
user@3c393ef3b4c0:/build/xen$ find . -name \*.o | while read F; do nm $F
| grep guest_physmap_remove_page && echo $F; done
                 U guest_physmap_remove_page
./common/memory.o
                 U guest_physmap_remove_page
./common/built_in.o
                 U guest_physmap_remove_page
./prelink.o

despite the linker fingering keyhandler.c (very likely a toolchain bug), it's memory.o which has the undefined reference.

Looking at memory.i, there are calls in guest_remove_page(), memory_exchange(), and do_memory_op(), and no obvious way to DCE any of them.

However, with bookworm, while memory.i does still have the same calls, the resulting object file has no undefined references, so clearly something has DCE'd them.

Looking at both memory.o's, bookwork really does have no reference, while bullseye's reference is in memory_exchange().

So I guess there is something complicated there which bookworm can DCE but bullseye can't.

Either way, this is the right fix, so lets not worry any more.

~Andrew

#3 lore raw
Quoted 53 lines · Andrew Cooper
Quoted 8 lines · Oleksii Kurochko

Address compilation error on bullseye-riscv64 container:
undefined reference to guest_physmap_remove_page

Since there is no current implementation of guest_physmap_remove_page(), a stub function has been added.

Usually we do Fixes/Reported-by tags first.  (We try to do tags in chronological/logical order).

I've confirmed this fixes the issue, so Acked-by: Andrew Cooper <[email protected]>

Having tried a different approach,

user@3c393ef3b4c0:/build/xen$ make
  UPD     include/xen/compile.h
Xen 4.20-unstable
make[1]: Nothing to be done for 'include'.
make[1]: 'arch/riscv/include/asm/asm-offsets.h' is up to date.
  CC      common/version.o
  LD      common/built_in.o
  CC      arch/riscv/setup.o
  LD      arch/riscv/built_in.o
  LD      prelink.o
  LDS     arch/riscv/xen.lds
riscv64-linux-gnu-ld      -T arch/riscv/xen.lds -N prelink.o \
    ./common/symbols-dummy.o -o ./.xen-syms.0
riscv64-linux-gnu-ld: prelink.o: in function `register_keyhandler':
/build/xen/common/keyhandler.c:106: undefined reference to
`guest_physmap_remove_page'
riscv64-linux-gnu-ld: ./.xen-syms.0: hidden symbol
`guest_physmap_remove_page' isn't defined
riscv64-linux-gnu-ld: final link failed: bad value
make[2]: *** [arch/riscv/Makefile:15: xen-syms] Error 1
make[1]: *** [build.mk:90: xen] Error 2
make: *** [Makefile:610: xen] Error 2
user@3c393ef3b4c0:/build/xen$ find . -name \*.o | while read F; do nm $F
| grep guest_physmap_remove_page && echo $F; done
                 U guest_physmap_remove_page
./common/memory.o
                 U guest_physmap_remove_page
./common/built_in.o
                 U guest_physmap_remove_page
./prelink.o

despite the linker fingering keyhandler.c (very likely a toolchain bug), it's memory.o which has the undefined reference.

Quoted 7 lines

Looking at memory.i, there are calls in guest_remove_page(), memory_exchange(), and do_memory_op(), and no obvious way to DCE any of them.

However, with bookworm, while memory.i does still have the same calls, the resulting object file has no undefined references, so clearly something has DCE'd them.

The many stubs that have just BUG() in them result in a lot of DCE according to my checking (many functions or basic blocks end - somewhat confusingly - in a function call leading to such a stub). But apparently not enough with the older compiler version.

Jan