From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB1FC48BC2 for ; Wed, 23 Jun 2021 12:00:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5686661002 for ; Wed, 23 Jun 2021 12:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbhFWMCv (ORCPT ); Wed, 23 Jun 2021 08:02:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24180 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbhFWMCu (ORCPT ); Wed, 23 Jun 2021 08:02:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624449632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40lufiefSAXJYxyzql25e+wiCU9kJZcVj8CF016XD70=; b=CEstZ7cIdGOqDR+jnolP/XRG/JXhBLjDflf7lCofp0kpQHaMDnWWthH34tcmchbvdBV0ct GJl0+gObI3CuwmCiDP0LxOQZ8lsmAOI+mWDkiJj3CBZWA3Zdc6hRvOOm/ZGUvW7Rt6GMvx f+zXS2rNdBJfAth/dDRE3/o+8wCG0zQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-hvTUk_ASNU2pe_o3jqp8fQ-1; Wed, 23 Jun 2021 08:00:31 -0400 X-MC-Unique: hvTUk_ASNU2pe_o3jqp8fQ-1 Received: by mail-wr1-f72.google.com with SMTP id l2-20020adfe5820000b029011a64161d6aso993797wrm.6 for ; Wed, 23 Jun 2021 05:00:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=40lufiefSAXJYxyzql25e+wiCU9kJZcVj8CF016XD70=; b=aHhpwMXXO1JnBGQ0qtOjHitWEgcDZymqscagLXzKeKjqWp3k17ChLSe/NBIcZ7eL/V G/YbYLy95sbZYqXOyhFBBx87EM3OTRZ3PkKRjbdKwBc/PsaYaQ/tbB4M/Ya60UOPBHOJ mBepPtRRqrOxqh2/aLKP4iClfH5WCgzPgart+sE7RZNkvvYbJpMEf0KpFTNmxDcn5J5N 4bxqX61zMEhxno6P0u/ykkPi3obW7LvYHeWXcoG2DBZz+XsxS6SXnpSYFp39K5upDG+K wDk4cyWw16eaJv1zHmkEPxj2lc5RZC4b2iBec+IeSAnQvHvrVMlHNviXCj+9MXTHX6Ex sVYQ== X-Gm-Message-State: AOAM531/3GU8BBt8l5ypK4wpU1LPStCjCvkOco5sUFGUUyuukRDG4V/e 4ktUWyCy4h7R2Wsh0629YeADhrOkG0pOJJgqzSqZ/Wilbqi9Xa+qssecI4QYAYRtPds9pXLRxfu aHkpbFf+X9i9Argy+xjhKgqcQQ4u1/6fmLJgsYaAejKB16z3JNuFIMAvcFzLWnyfP7gU2geFSe4 vG X-Received: by 2002:a05:600c:b57:: with SMTP id k23mr10532648wmr.133.1624449629776; Wed, 23 Jun 2021 05:00:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNmyUviHSGAy39wspBqD/44uhbsty4Dt6H2q9/tUgrngrqOMapjcP5jZzJYKbXJOEg9kj0+A== X-Received: by 2002:a05:600c:b57:: with SMTP id k23mr10532600wmr.133.1624449629425; Wed, 23 Jun 2021 05:00:29 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o203sm5900649wmo.36.2021.06.23.05.00.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 05:00:28 -0700 (PDT) Subject: Re: [PATCH RFC] KVM: nSVM: Fix L1 state corruption upon return from SMM To: Maxim Levitsky , Vitaly Kuznetsov , kvm@vger.kernel.org Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Cathy Avery , Emanuele Giuseppe Esposito , linux-kernel@vger.kernel.org References: <20210623074427.152266-1-vkuznets@redhat.com> <2eaa94bcc697fec92d994146f7c69625b6a84cd0.camel@redhat.com> From: Paolo Bonzini Message-ID: Date: Wed, 23 Jun 2021 14:00:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <2eaa94bcc697fec92d994146f7c69625b6a84cd0.camel@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/06/21 13:39, Maxim Levitsky wrote: > On Wed, 2021-06-23 at 11:39 +0200, Paolo Bonzini wrote: >> On 23/06/21 09:44, Vitaly Kuznetsov wrote: >>> - RFC: I'm not 100% sure my 'smart' idea to use currently-unused HSAVE area >>> is that smart. Also, we don't even seem to check that L1 set it up upon >>> nested VMRUN so hypervisors which don't do that may remain broken. A very >>> much needed selftest is also missing. >> >> It's certainly a bit weird, but I guess it counts as smart too. It >> needs a few more comments, but I think it's a good solution. >> >> One could delay the backwards memcpy until vmexit time, but that would >> require a new flag so it's not worth it for what is a pretty rare and >> already expensive case. > > I wonder what would happen if SMM entry is triggered by L1 (say with ICR), > on a VCPU which is in L2. Such exit should go straight to L1 SMM mode. Yes, it does, but it still records the L2 state in the guest's SMM state save area. Everything works right as long as the guest stays in L2 (the vmcb12 control save area is still there in svm->nested and is saved/restored by KVM_GET/SET_NESTED_STATE), the problem that Vitaly found is the destruction of the saved L1 host state. Paolo > I will very very soon, maybe even today start testing SMM with my migration > tests and such. I hope I will find more bugs in this area. > > Thanks for fixing this issue! > > Best regards, > Maxim Levitsky >