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

Oleksii Kurochko posted 1 patch 3 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20240731150708.122778-1-oleksii.kurochko@gmail.com
xen/arch/riscv/stubs.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] xen/riscv: fix build issue for bullseye-riscv64 container
Posted by Oleksii Kurochko 3 months, 3 weeks ago
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.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/riscv/stubs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c
index b67d99729f..3285d18899 100644
--- a/xen/arch/riscv/stubs.c
+++ b/xen/arch/riscv/stubs.c
@@ -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)
-- 
2.45.2
Re: [PATCH] xen/riscv: fix build issue for bullseye-riscv64 container
Posted by Andrew Cooper 3 months, 3 weeks ago
On 31/07/2024 4:07 pm, Oleksii Kurochko wrote:
> 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.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>

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
<andrew.cooper3@citrix.com>

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

Re: [PATCH] xen/riscv: fix build issue for bullseye-riscv64 container
Posted by Jan Beulich 3 months, 3 weeks ago
On 31.07.2024 17:37, Andrew Cooper wrote:
> On 31/07/2024 4:07 pm, Oleksii Kurochko wrote:
>> 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.
>>
>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> 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
> <andrew.cooper3@citrix.com>
> 
> 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.

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

Re: [PATCH] xen/riscv: fix build issue for bullseye-riscv64 container
Posted by Jan Beulich 3 months, 3 weeks ago
On 31.07.2024 17:07, Oleksii Kurochko wrote:
> 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.
> 
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

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