* [PATCH] x86/hyperv: Fix undefined reference to isolation_type_en_snp without CONFIG_HYPERV
@ 2023-08-23 3:20 Dexuan Cui
2023-08-23 5:42 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Dexuan Cui @ 2023-08-23 3:20 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, linux-hyperv, mikelley, tiala,
tglx, mingo, bp, dave.hansen, hpa, thomas.lendacky
Cc: linux-kernel, x86
When CONFIG_HYPERV is not set, arch/x86/hyperv/ivm.c is not built (see
arch/x86/Kbuild), so 'isolation_type_en_snp' in the ivm.c is not defined,
and this failure happens:
ld: arch/x86/kernel/cpu/mshyperv.o: in function `ms_hyperv_init_platform':
arch/x86/kernel/cpu/mshyperv.c:417: undefined reference to `isolation_type_en_snp'
Fix the failure by testing hv_get_isolation_type() and
ms_hyperv.paravisor_present for a fully enlightened SNP VM: when
CONFIG_HYPERV is not set, hv_get_isolation_type() is defined as a
static inline function that always returns HV_ISOLATION_TYPE_NONE
(see include/asm-generic/mshyperv.h), so the compiler won't generate any
code for the ms_hyperv.paravisor_present and static_branch_enable().
Reported-by: Tom Lendacky <thomas.lendacky@amd.com>
Closes: https://lore.kernel.org/lkml/b4979997-23b9-0c43-574e-e4a3506500ff@amd.com/
Fixes: d6e2d6524437 ("x86/hyperv: Add sev-snp enlightened guest static key")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
arch/x86/kernel/cpu/mshyperv.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 26b9fcabd7d95..c8d3ca2b0e0ee 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -413,10 +413,11 @@ static void __init ms_hyperv_init_platform(void)
ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b);
- if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) {
- static_branch_enable(&isolation_type_en_snp);
- } else if (hv_get_isolation_type() == HV_ISOLATION_TYPE_SNP) {
- static_branch_enable(&isolation_type_snp);
+ if (hv_get_isolation_type() == HV_ISOLATION_TYPE_SNP) {
+ if (ms_hyperv.paravisor_present)
+ static_branch_enable(&isolation_type_snp);
+ else
+ static_branch_enable(&isolation_type_en_snp);
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] x86/hyperv: Fix undefined reference to isolation_type_en_snp without CONFIG_HYPERV
2023-08-23 3:20 [PATCH] x86/hyperv: Fix undefined reference to isolation_type_en_snp without CONFIG_HYPERV Dexuan Cui
@ 2023-08-23 5:42 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2023-08-23 5:42 UTC (permalink / raw)
To: Dexuan Cui
Cc: kys, haiyangz, wei.liu, linux-hyperv, mikelley, tiala, tglx,
mingo, bp, dave.hansen, hpa, thomas.lendacky, linux-kernel, x86
On Tue, Aug 22, 2023 at 08:20:08PM -0700, Dexuan Cui wrote:
> When CONFIG_HYPERV is not set, arch/x86/hyperv/ivm.c is not built (see
> arch/x86/Kbuild), so 'isolation_type_en_snp' in the ivm.c is not defined,
> and this failure happens:
>
> ld: arch/x86/kernel/cpu/mshyperv.o: in function `ms_hyperv_init_platform':
> arch/x86/kernel/cpu/mshyperv.c:417: undefined reference to `isolation_type_en_snp'
>
> Fix the failure by testing hv_get_isolation_type() and
> ms_hyperv.paravisor_present for a fully enlightened SNP VM: when
> CONFIG_HYPERV is not set, hv_get_isolation_type() is defined as a
> static inline function that always returns HV_ISOLATION_TYPE_NONE
> (see include/asm-generic/mshyperv.h), so the compiler won't generate any
> code for the ms_hyperv.paravisor_present and static_branch_enable().
>
> Reported-by: Tom Lendacky <thomas.lendacky@amd.com>
> Closes: https://lore.kernel.org/lkml/b4979997-23b9-0c43-574e-e4a3506500ff@amd.com/
> Fixes: d6e2d6524437 ("x86/hyperv: Add sev-snp enlightened guest static key")
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
Applied. Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-23 5:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 3:20 [PATCH] x86/hyperv: Fix undefined reference to isolation_type_en_snp without CONFIG_HYPERV Dexuan Cui
2023-08-23 5:42 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).