Re: sev_es_trampoline_start undefined symbol referenced errors during kunit run

From: Shuah Khan
Date: Tue Apr 15 2025 - 20:54:35 EST


On 4/15/25 16:29, Shuah Khan wrote:
On 4/15/25 16:17, Borislav Petkov wrote:
On Tue, Apr 15, 2025 at 01:06:49PM -0600, Shuah Khan wrote:
Does your arch/x86/realmode/rm/pasyms.h has reference to sev_es_trampoline_start?

The one in my tree has it.

arch/x86/realmode/rm/pasyms.h:pa_sev_es_trampoline_start = sev_es_trampoline_start


# ./tools/testing/kunit/kunit.py run --arch x86_64
...

[00:15:36] Elapsed time: 58.840s total, 2.096s configuring, 53.170s building, 3.487s running

# cat arch/x86/realmode/rm/pasyms.h
cat: arch/x86/realmode/rm/pasyms.h: No such file or directory

Could explain why I don't see the issue...


I see arch/x86/realmode/rm/pasyms.h on my system. It is a generated
file from arch/x86/realmode/rm Makefile

Here is the target information.

REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))

sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'

quiet_cmd_pasyms = PASYMS  $@
      cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@

targets += pasyms.h
$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
        $(call if_changed,pasyms)

The key is how and why this file gets generated and why the reference

pa_sev_es_trampoline_start = sev_es_trampoline_start

is added unconditionally even when  CONFIG_AMD_MEM_ENCRYPT is not
enabled. I think the logic should be fixed to take AMD_MEM_ENCRYPT
enabled or disabled into account when this pasyms.h file is generated.


Okay - I think the logic to extract symbols to include in pasyms.h
will have to take AMD_MEM_ENCRYPT enabled vs. disabled into account.

running git grep sev_es_trampoline_start in arch/x86/realmode/rm shows:

header.S: .long pa_sev_es_trampoline_start
trampoline_64.S:SYM_CODE_START(sev_es_trampoline_start)
trampoline_64.S:SYM_CODE_END(sev_es_trampoline_start)

All of the above are under ifdef AMD_MEM_ENCRYPT conditional.
Even if pasyms.h is generated sev_es_trampoline_start should not
be included in pasyms.h if AMD_MEM_ENCRYPT is disabled.

thanks,
-- Shuah