Message ID | 20211205081815.129276-3-ltykernel@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | x86/Hyper-V: Add Hyper-V Isolation VM support(Second part) | expand |
On Sun, Dec 05, 2021 at 03:18:10AM -0500, Tianyu Lan wrote: > +static bool hyperv_cc_platform_has(enum cc_attr attr) > +{ > +#ifdef CONFIG_HYPERV > + return attr == CC_ATTR_GUEST_MEM_ENCRYPT; > +#else > + return false; > +#endif > +} Can we even end up here without CONFIG_HYPERV?
Hi Christoph: Thanks for your review. On 12/6/2021 10:06 PM, Christoph Hellwig wrote: > On Sun, Dec 05, 2021 at 03:18:10AM -0500, Tianyu Lan wrote: >> +static bool hyperv_cc_platform_has(enum cc_attr attr) >> +{ >> +#ifdef CONFIG_HYPERV >> + return attr == CC_ATTR_GUEST_MEM_ENCRYPT; >> +#else >> + return false; >> +#endif >> +} > > Can we even end up here without CONFIG_HYPERV? > Yes, I will update in the next version. Thanks.
diff --git a/arch/x86/kernel/cc_platform.c b/arch/x86/kernel/cc_platform.c index 03bb2f343ddb..27c06b32e7c4 100644 --- a/arch/x86/kernel/cc_platform.c +++ b/arch/x86/kernel/cc_platform.c @@ -11,6 +11,7 @@ #include <linux/cc_platform.h> #include <linux/mem_encrypt.h> +#include <asm/mshyperv.h> #include <asm/processor.h> static bool __maybe_unused intel_cc_platform_has(enum cc_attr attr) @@ -58,9 +59,20 @@ static bool amd_cc_platform_has(enum cc_attr attr) #endif } +static bool hyperv_cc_platform_has(enum cc_attr attr) +{ +#ifdef CONFIG_HYPERV + return attr == CC_ATTR_GUEST_MEM_ENCRYPT; +#else + return false; +#endif +} bool cc_platform_has(enum cc_attr attr) { + if (hv_is_isolation_supported()) + return hyperv_cc_platform_has(attr); + if (sme_me_mask) return amd_cc_platform_has(attr);