Message ID | e14dac75ff1088b2c4bea361954b37e414edd03c.1617804573.git.viremana@linux.microsoft.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Hyper-V nested virt enlightenments for SVM | expand |
On Wed, Apr 07, 2021 at 02:41:22PM +0000, Vineeth Pillai wrote: > Detect nested features exposed by Hyper-V if SVM is enabled. > > Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> > --- > arch/x86/kernel/cpu/mshyperv.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 3546d3e21787..4d364acfe95d 100644 > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -325,9 +325,17 @@ static void __init ms_hyperv_init_platform(void) > ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); > } > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > + /* > + * AMD does not need enlightened VMCS as VMCB is already a > + * datastructure in memory. We need to get the nested > + * features if SVM is enabled. > + */ > + if (boot_cpu_has(X86_FEATURE_SVM) || Pls use: cpu_feature_enabled here.
From: Vineeth Pillai <viremana@linux.microsoft.com> Sent: Wednesday, April 7, 2021 7:41 AM > > Detect nested features exposed by Hyper-V if SVM is enabled. > > Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> > --- > arch/x86/kernel/cpu/mshyperv.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 3546d3e21787..4d364acfe95d 100644 > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -325,9 +325,17 @@ static void __init ms_hyperv_init_platform(void) > ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); > } > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > + /* > + * AMD does not need enlightened VMCS as VMCB is already a > + * datastructure in memory. We need to get the nested > + * features if SVM is enabled. > + */ > + if (boot_cpu_has(X86_FEATURE_SVM) || > + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > ms_hyperv.nested_features = > cpuid_eax(HYPERV_CPUID_NESTED_FEATURES); > + pr_info("Hyper-V nested_features: 0x%x\n", Nit: Most other similar lines put the colon in a different place: pr_info("Hyper-V: nested features 0x%x\n", One of these days, I'm going to fix the ones that don't follow this pattern. :-) > + ms_hyperv.nested_features); > } > > /* > -- > 2.25.1
On Wed, Apr 07, 2021, Michael Kelley wrote: > From: Vineeth Pillai <viremana@linux.microsoft.com> Sent: Wednesday, April 7, 2021 7:41 AM > > > > Detect nested features exposed by Hyper-V if SVM is enabled. > > > > Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> > > --- > > arch/x86/kernel/cpu/mshyperv.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > > index 3546d3e21787..4d364acfe95d 100644 > > --- a/arch/x86/kernel/cpu/mshyperv.c > > +++ b/arch/x86/kernel/cpu/mshyperv.c > > @@ -325,9 +325,17 @@ static void __init ms_hyperv_init_platform(void) > > ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); > > } > > > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > > + /* > > + * AMD does not need enlightened VMCS as VMCB is already a > > + * datastructure in memory. We need to get the nested > > + * features if SVM is enabled. > > + */ > > + if (boot_cpu_has(X86_FEATURE_SVM) || > > + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > > ms_hyperv.nested_features = > > cpuid_eax(HYPERV_CPUID_NESTED_FEATURES); > > + pr_info("Hyper-V nested_features: 0x%x\n", > > Nit: Most other similar lines put the colon in a different place: > > pr_info("Hyper-V: nested features 0x%x\n", > > One of these days, I'm going to fix the ones that don't follow this > pattern. :-) Any reason not to use pr_fmt?
Vineeth Pillai <viremana@linux.microsoft.com> writes: > Detect nested features exposed by Hyper-V if SVM is enabled. > > Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> > --- > arch/x86/kernel/cpu/mshyperv.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 3546d3e21787..4d364acfe95d 100644 > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -325,9 +325,17 @@ static void __init ms_hyperv_init_platform(void) > ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); > } > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > + /* > + * AMD does not need enlightened VMCS as VMCB is already a > + * datastructure in memory. Well, VMCS is also a structure in memory, isn't it? It's just that we don't have a 'clean field' concept for it and we can't use normal memory accesses. > We need to get the nested > + * features if SVM is enabled. > + */ > + if (boot_cpu_has(X86_FEATURE_SVM) || > + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { Do I understand correctly that we can just look at CPUID.0x40000000.EAX and in case it is >= 0x4000000A we can read HYPERV_CPUID_NESTED_FEATURES leaf? I'd suggest we do that intead then. > ms_hyperv.nested_features = > cpuid_eax(HYPERV_CPUID_NESTED_FEATURES); > + pr_info("Hyper-V nested_features: 0x%x\n", > + ms_hyperv.nested_features); > } > > /*
Hi Vitaly, On 4/8/21 7:06 AM, Vitaly Kuznetsov wrote: > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > + /* > + * AMD does not need enlightened VMCS as VMCB is already a > + * datastructure in memory. > Well, VMCS is also a structure in memory, isn't it? It's just that we > don't have a 'clean field' concept for it and we can't use normal memory > accesses. Yes, you are right. I was referring to the fact that we cant use normal memory accesses, but is a bit mis-worded. > >> We need to get the nested >> + * features if SVM is enabled. >> + */ >> + if (boot_cpu_has(X86_FEATURE_SVM) || >> + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > Do I understand correctly that we can just look at CPUID.0x40000000.EAX > and in case it is >= 0x4000000A we can read HYPERV_CPUID_NESTED_FEATURES > leaf? I'd suggest we do that intead then. I agree, that is a better way to consolidate both the cases. Will change it in the next iteration. Probably the above code comment is not needed when we consolidate the cases here. Thanks, Vineeth
On 4/7/21 6:48 PM, Sean Christopherson wrote: > On Wed, Apr 07, 2021, Michael Kelley wrote: >> >>> + pr_info("Hyper-V nested_features: 0x%x\n", >> Nit: Most other similar lines put the colon in a different place: >> >> pr_info("Hyper-V: nested features 0x%x\n", >> >> One of these days, I'm going to fix the ones that don't follow this >> pattern. :-) > Any reason not to use pr_fmt? Yes, that would be the best way to go. As Michael suggested, it would be better to fix the whole file as a cleanup patch. I shall fix this one to conform to the previous style and use pr_fmt as a separate fixup patch. Thanks, Vineeth
On Thu, Apr 08, 2021, Vineeth Pillai wrote: > Hi Vitaly, > > On 4/8/21 7:06 AM, Vitaly Kuznetsov wrote: > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > > + /* > > + * AMD does not need enlightened VMCS as VMCB is already a > > + * datastructure in memory. > > Well, VMCS is also a structure in memory, isn't it? It's just that we > > don't have a 'clean field' concept for it and we can't use normal memory > > accesses. Technically, you can use normal memory accesses, so long as software guarantees the VMCS isn't resident in the VMCS cache and knows the field offsets for the underlying CPU. The lack of an architecturally defined layout is the biggest issue, e.g. tacking on dirty bits through a PV ABI would be trivial. > Yes, you are right. I was referring to the fact that we cant use normal > memory accesses, but is a bit mis-worded. If you slot in "architectural" it will read nicely, i.e. "VMCB is already an architectural datastructure in memory".
On 4/8/21 11:24 AM, Sean Christopherson wrote: > > Technically, you can use normal memory accesses, so long as software guarantees > the VMCS isn't resident in the VMCS cache and knows the field offsets for the > underlying CPU. The lack of an architecturally defined layout is the biggest > issue, e.g. tacking on dirty bits through a PV ABI would be trivial. > >> Yes, you are right. I was referring to the fact that we cant use normal >> memory accesses, but is a bit mis-worded. > If you slot in "architectural" it will read nicely, i.e. "VMCB is already an > architectural datastructure in memory". Yes, this makes sense. Thanks for the suggestion, will reword as you suggested. Thanks, Vineeth
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 3546d3e21787..4d364acfe95d 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -325,9 +325,17 @@ static void __init ms_hyperv_init_platform(void) ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); } - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { + /* + * AMD does not need enlightened VMCS as VMCB is already a + * datastructure in memory. We need to get the nested + * features if SVM is enabled. + */ + if (boot_cpu_has(X86_FEATURE_SVM) || + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { ms_hyperv.nested_features = cpuid_eax(HYPERV_CPUID_NESTED_FEATURES); + pr_info("Hyper-V nested_features: 0x%x\n", + ms_hyperv.nested_features); } /*
Detect nested features exposed by Hyper-V if SVM is enabled. Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> --- arch/x86/kernel/cpu/mshyperv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)