Re: [Part2 PATCH v7 25/38] KVM: SVM: Add KVM_SEV_INIT command

From: Borislav Petkov
Date: Mon Nov 06 2017 - 05:58:00 EST


On Wed, Nov 01, 2017 at 04:16:10PM -0500, Brijesh Singh wrote:
> The command initializes the SEV platform context and allocates a new ASID
> for this guest from the SEV ASID pool. The firmware must be initialized
> before we issue any guest launch commands to create a new memory encryption
> context.
>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: "Radim KrÄmÃÅ" <rkrcmar@xxxxxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxx>
> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Cc: x86@xxxxxxxxxx
> Cc: kvm@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Signed-off-by: Brijesh Singh <brijesh.singh@xxxxxxx>
> ---
> arch/x86/include/asm/kvm_host.h | 7 +++
> arch/x86/kvm/svm.c | 130 +++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 136 insertions(+), 1 deletion(-)

...

> @@ -1167,10 +1187,18 @@ static __init int svm_hardware_setup(void)
> return r;
> }
>
> +static __exit void sev_hardware_unsetup(void)
> +{
> + if (svm_sev_enabled())
> + kfree(sev_asid_bitmap);
> +}

Just get rid of that silly function:

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1410e6b7e8d8..5f5c3ddad139 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1187,17 +1187,12 @@ static __init int svm_hardware_setup(void)
return r;
}

-static __exit void sev_hardware_unsetup(void)
-{
- if (svm_sev_enabled())
- kfree(sev_asid_bitmap);
-}
-
static __exit void svm_hardware_unsetup(void)
{
int cpu;

- sev_hardware_unsetup();
+ if (svm_sev_enabled())
+ kfree(sev_asid_bitmap);

for_each_possible_cpu(cpu)
svm_cpu_uninit(cpu);

with that:

Reviewed-by: Borislav Petkov <bp@xxxxxxx>

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.