Re: [PATCH Part1 RFC v4 16/36] KVM: SVM: define new SEV_FEATURES field in the VMCB Save State Area

Borislav Petkov
2021-08-17T17:53:45Z

On Wed, Jul 07, 2021 at 01:14:46PM -0500, Brijesh Singh wrote:
> The hypervisor uses the SEV_FEATURES field (offset 3B0h) in the Save State
> Area to control the SEV-SNP guest features such as SNPActive, vTOM,
> ReflectVC etc. An SEV-SNP guest can read the SEV_FEATURES fields through
> the SEV_STATUS MSR.
>
> While at it, update the dump_vmcb() to log the VMPL level.
>
> See APM2 Table 15-34 and B-4 for more details.
>
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---
> arch/x86/include/asm/svm.h | 15 +++++++++++++--
> arch/x86/kvm/svm/svm.c | 4 ++--
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
> index 772e60efe243..ff614cdcf628 100644
> --- a/arch/x86/include/asm/svm.h
> +++ b/arch/x86/include/asm/svm.h
> @@ -212,6 +212,15 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
> #define SVM_NESTED_CTL_SEV_ENABLE BIT(1)
> #define SVM_NESTED_CTL_SEV_ES_ENABLE BIT(2)
>
> +#define SVM_SEV_FEATURES_SNP_ACTIVE BIT(0)
> +#define SVM_SEV_FEATURES_VTOM BIT(1)
> +#define SVM_SEV_FEATURES_REFLECT_VC BIT(2)
> +#define SVM_SEV_FEATURES_RESTRICTED_INJECTION BIT(3)
> +#define SVM_SEV_FEATURES_ALTERNATE_INJECTION BIT(4)
> +#define SVM_SEV_FEATURES_DEBUG_SWAP BIT(5)
> +#define SVM_SEV_FEATURES_PREVENT_HOST_IBS BIT(6)
> +#define SVM_SEV_FEATURES_BTB_ISOLATION BIT(7)

Only some of those get used and only later. Please introduce only those
with the patch that adds usage.

Also,

s/SVM_SEV_FEATURES_/SVM_SEV_FEAT_/g

at least.

And by the way, why is this patch and the next 3 part of the guest set?
They look like they belong into the hypervisor set.

--
Regards/Gruss,
Boris.