lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Dec 2020 17:10:53 -0800
From:   Andy Lutomirski <>
To:     Michael Roth <>
Cc:     Andy Lutomirski <>, kvm list <>,
        Paolo Bonzini <>,
        Sean Christopherson <>,
        Vitaly Kuznetsov <>,
        Wanpeng Li <>,
        Jim Mattson <>,
        Joerg Roedel <>,
        Thomas Gleixner <>,
        Ingo Molnar <>, Borislav Petkov <>,
        X86 ML <>, "H . Peter Anvin" <>,
        LKML <>,
        Tom Lendacky <>
Subject: Re: [PATCH] KVM: SVM: use vmsave/vmload for saving/restoring
 additional host state

> On Dec 10, 2020, at 4:48 PM, Michael Roth <> wrote:

>> I think there are two reasonable ways to do this:
>> 1. VMLOAD before STGI.  This is obviously correct, and it's quite simple.
> For the testing I ended up putting it immediately after __svm_vcpu_run()
> since that's where we restored GS base previously. Does that seem okay or did
> you have another place in mind?

Looks okay.  If we get an NMI or MCE with the wrong MSR_GS_BASE, then
we are toast, at least on Zen 2 and earlier.  But that spot has GI ==
0, so this won't happen.

>> 2. Save cpu_kernelmode_gs_base(cpu) before VM entry, and restore that
>> value to MSR_GS_BASE using code like this (or its asm equivalent)
>> before STGI:
>> if (static_cpu_has(X86_FEATURE_FSGSBASE))
>>  wrgsbase(base);
>> else
>>  wrmsr...
>> and then VMLOAD in the vcpu_put() path.
>> I can't think of any reason to use loadsegment(), load_gs_index(), or
>> savesegment() at all, nor can I think of any reason to touch
> I'm sort of lumping MSR_GS_BASE restoration in with everything else since I
> don't fully understand what the original was code doing either and was content
> to leave it be if we couldn't use VMLOAD to handle it without a performance
> regression, but since it looks like we can use VMLOAD here instead I agree
> we should just drop it all.

The original code is entirely bogus. Don’t try to hard to understand
how it’s correct — I’m pretty sure it’s not. In fact, I was planning
to write a patch a lot like yours, but I don’t have an SVM-capable CPU
to test on.  In general, I suspect that you could delete all these
fields from the structs, see what fails to compile, and fix it pretty

MSR_GS_BASE is kernel state. (On 32-bit, fs and maybe gs are kernel
state.). Everything else is host *user* state and isn’t touched by
normal kernel code.

Powered by blists - more mailing lists