lkml.org 
[lkml]   [2021]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH v13 12/12] x86/kvm: Add guest support for detecting and enabling SEV Live Migration feature.
    On Thu, Apr 15, 2021 at 04:01:16PM +0000, Ashish Kalra wrote:
    > From: Ashish Kalra <ashish.kalra@amd.com>
    >
    > The guest support for detecting and enabling SEV Live migration
    > feature uses the following logic :
    >
    > - kvm_init_plaform() invokes check_kvm_sev_migration() which
    > checks if its booted under the EFI
    >
    > - If not EFI,
    >
    > i) check for the KVM_FEATURE_CPUID

    Where do you do that?

    $ git grep KVM_FEATURE_CPUID
    $

    Do you mean

    kvm_para_has_feature(KVM_FEATURE_SEV_LIVE_MIGRATION)

    per chance?

    > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
    > index 78bb0fae3982..94ef16d263a7 100644
    > --- a/arch/x86/kernel/kvm.c
    > +++ b/arch/x86/kernel/kvm.c
    > @@ -26,6 +26,7 @@
    > #include <linux/kprobes.h>
    > #include <linux/nmi.h>
    > #include <linux/swait.h>
    > +#include <linux/efi.h>
    > #include <asm/timer.h>
    > #include <asm/cpu.h>
    > #include <asm/traps.h>
    > @@ -429,6 +430,59 @@ static inline void __set_percpu_decrypted(void *ptr, unsigned long size)
    > early_set_memory_decrypted((unsigned long) ptr, size);
    > }
    >
    > +static int __init setup_kvm_sev_migration(void)

    kvm_init_sev_migration() or so.

    ...

    > @@ -48,6 +50,8 @@ EXPORT_SYMBOL_GPL(sev_enable_key);
    >
    > bool sev_enabled __section(".data");
    >
    > +bool sev_live_migration_enabled __section(".data");

    Pls add a function called something like:

    bool sev_feature_enabled(enum sev_feature)

    and gets SEV_FEATURE_LIVE_MIGRATION and then use it instead of adding
    yet another boolean which contains whether some aspect of SEV has been
    enabled or not.

    Then add a

    static enum sev_feature sev_features;

    in mem_encrypt.c and that function above will query that sev_features
    enum for set flags.
    Then, if you feel bored, you could convert sme_active, sev_active,
    sev_es_active, mem_encrypt_active and whetever else code needs to query
    any aspect of SEV being enabled or not, to that function.

    > +void __init check_kvm_sev_migration(void)
    > +{
    > + if (sev_active() &&
    > + kvm_para_has_feature(KVM_FEATURE_SEV_LIVE_MIGRATION)) {

    Save an indentation level:

    if (!sev_active() ||
    !kvm_para_has_feature(KVM_FEATURE_SEV_LIVE_MIGRATION))
    return;
    > + unsigned long nr_pages;
    > + int i;
    > +
    > + pr_info("KVM enable live migration\n");

    That should be at the end of the function and say:

    pr_info("KVM live migration enabled.\n");

    > + WRITE_ONCE(sev_live_migration_enabled, true);

    Why WRITE_ONCE?

    And that needs to go to the end of the function too.

    Thx.

    --
    Regards/Gruss,
    Boris.

    https://people.kernel.org/tglx/notes-about-netiquette

    \
     
     \ /
      Last update: 2021-04-21 16:45    [W:4.264 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site