Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp699247ybt; Fri, 10 Jul 2020 10:05:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB8SSpPjC5E2S4Lr3GT0ofrMFf+LB1JKIoxXoyQV6I7gVe8UFQxXvMyGWAhIwbsl4jp6xY X-Received: by 2002:a17:906:d92e:: with SMTP id rn14mr65478769ejb.314.1594400749273; Fri, 10 Jul 2020 10:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594400749; cv=none; d=google.com; s=arc-20160816; b=n25HS94DR3mnecpBguF+NEVLQ29gIZ72kTgkwXn/LrqN0ib9RZGE6+O4iKbEN84CDw ObZweIJ0wtm2DgZrEDVl73XlJ1UWJl+1BzcKVkmn2F3exhFoqkwBbl2GHI6kfkRU08/O Iz5VcgtSV5PuVRlWHvZ88mbDyvdQiB3nPrk2bLEeKFoV64/o8kN8w+8sWUZXrPZy4ba2 18Kumu/oEUvK89qQASk/IftEqZpGQeW2NYc3UUWwGEK6tCGZ1N7eQBpL+m/0uJN5zStX YZ3auwLpRtcg3QUGWdtoFl7gKPJtkw+/Sp8/ut2jzBDI3eoKIdLBGUjVJM/WoFZT1mpI 9Xlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=zJSG5Xu9Pbt04zlwluiGAtbXS/uva9oKZizpa8qTv/A=; b=c767Zu2eg3JiRkQEUluRIfshHrP9ap/nLGKyPB7kOOeec4fV/N64HvoW+sAjZBtq1i LHshZ8W51XK+zYrPZe3BdakWsBnK2+dV0qlVXkUB9Rz5A7AP1s15KcPfmqupgiOdrvHN vneG0RbKpq8riyXmv7ZpZr9T6/O82nCqUQ2GJIzleUnkPzFaJI6m6TshlnaEsY2tUYaJ 08tq0Spz+40O+8LXYN6tKO8nb8BQ9B8c30A4AqIVsT2/T14I2MthwtIWfql6uHMF9JN4 +ZLRrsUbUfZucLZ7PaSIGEKYepmg85kwWLjsL8aNnRa6D9ZqMIDhigYZQtu1MJXEnEJD vZBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DyWWqASY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be11si4170406edb.482.2020.07.10.10.05.25; Fri, 10 Jul 2020 10:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DyWWqASY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728372AbgGJRDo (ORCPT + 99 others); Fri, 10 Jul 2020 13:03:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:35693 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727863AbgGJRDo (ORCPT ); Fri, 10 Jul 2020 13:03:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594400622; 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=zJSG5Xu9Pbt04zlwluiGAtbXS/uva9oKZizpa8qTv/A=; b=DyWWqASYO8cSoUtUyx+XanwtsEleNdWIOyan9UP0mGPclfW25rCPd4PDye64SmAYpxhDLw wZM+YeLtt7XzMUtMGllZqWdI6c4ofxzMgNCiJX52GJxA3rByEAvaG8MhjmrPY/ruVp/8Xz BrvP/3pgMKHCPTGtsTm+h6Km9GSoLeU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-nAI-aUh8N_qnTEFcSU2ZSw-1; Fri, 10 Jul 2020 13:03:40 -0400 X-MC-Unique: nAI-aUh8N_qnTEFcSU2ZSw-1 Received: by mail-wm1-f72.google.com with SMTP id z74so1979589wmc.4 for ; Fri, 10 Jul 2020 10:03:40 -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=zJSG5Xu9Pbt04zlwluiGAtbXS/uva9oKZizpa8qTv/A=; b=I2w3sHTVKRdIGY394a+pywesIidZwd7JxOjyzkaUAWdB8XEyYSTN/48fP+Eu5QJmbo Aq1c4DEZNlXgu0CT5gqHo9lrleIz8PDtDLwhN3VmpbA1XOpDZYNFiasUwHgJGc4ONn10 vshFrcxTuXde5refDPUChHeJDI8fYNjjx7rYNgiyHSQIwJG02xCUfu1Q0V8VZvYP+X/S ogkXyAI5PZw+H4Tjca4escBC8UtCzi63iL1R9y+MGZWaveT1g8/2gudCOZ8G8FUoyKUJ Rp2rFhYsTff4KHyMzx2MWsd64aRZFIw40nkr38RjOB/lTznwHq7fRz1OG4k3VHz/tFc1 ALag== X-Gm-Message-State: AOAM531UKZuEMCjoVDup+gqIhJlRRMFV0TvJW6J+3VJLCVM3BJ4byBXW 8skKs30cw4B/matKPkshKf6dq7ICVKqb7s5pPwpu2ENVc2DKSJ9HkifuVuLtQCOJwXvhgtaXXgn NQn7i72G/FbvFI0nUP1B/Vuxt X-Received: by 2002:a5d:5084:: with SMTP id a4mr71035621wrt.191.1594400619578; Fri, 10 Jul 2020 10:03:39 -0700 (PDT) X-Received: by 2002:a5d:5084:: with SMTP id a4mr71035602wrt.191.1594400619293; Fri, 10 Jul 2020 10:03:39 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:9541:9439:cb0f:89c? ([2001:b07:6468:f312:9541:9439:cb0f:89c]) by smtp.gmail.com with ESMTPSA id b10sm9459481wmj.30.2020.07.10.10.03.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jul 2020 10:03:38 -0700 (PDT) Subject: Re: [PATCH v4 0/9] KVM: nSVM: fixes for CR3/MMU switch upon nested guest entry/exit To: Vitaly Kuznetsov , kvm@vger.kernel.org Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Junaid Shahid , linux-kernel@vger.kernel.org References: <20200710141157.1640173-1-vkuznets@redhat.com> From: Paolo Bonzini Message-ID: <6dba1900-5149-f8dd-2da3-42803ee9f96b@redhat.com> Date: Fri, 10 Jul 2020 19:03:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200710141157.1640173-1-vkuznets@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/07/20 16:11, Vitaly Kuznetsov wrote: > Changes since v3: > - Swapped my "KVM: nSVM: stop dereferencing vcpu->arch.mmu to get the > context in kvm_init_shadow{,_npt}_mmu()" with Paolo's "KVM: MMU: stop > dereferencing vcpu->arch.mmu to get the context for MMU init". > - keeping nested_svm_init_mmu_context() in nested_prepare_vmcb_control() > as this is also used from svm_set_nested_state() [Paolo], > nested_svm_load_cr3() becomes a separate step in enter_svm_guest_mode(). > - nested_prepare_vmcb_save() remains 'void' [Paolo] > > Original description: > > This is a successor of "[PATCH v2 0/3] KVM: nSVM: fix #TF from CR3 switch > when entering guest" and "[PATCH] KVM: x86: drop erroneous mmu_check_root() > from fast_pgd_switch()". > > The snowball is growing fast! It all started with an intention to fix > the particular 'tripple fault' issue (now fixed by PATCH7) but now we > also get rid of unconditional kvm_mmu_reset_context() upon nested guest > entry/exit and make the code resemble nVMX. There is still a huge room > for further improvement (proper error propagation, removing unconditional > MMU sync/TLB flush,...) but at least we're making some progress. > > Tested with kvm selftests/kvm-unit-tests and by running nested Hyper-V > on KVM. The series doesn't seem to introduce any new issues. > > Paolo Bonzini (1): > KVM: MMU: stop dereferencing vcpu->arch.mmu to get the context for MMU > init > > Vitaly Kuznetsov (8): > KVM: nSVM: split kvm_init_shadow_npt_mmu() from kvm_init_shadow_mmu() > KVM: nSVM: reset nested_run_pending upon nested_svm_vmrun_msrpm() > failure > KVM: nSVM: prepare to handle errors from enter_svm_guest_mode() > KVM: nSVM: introduce nested_svm_load_cr3()/nested_npt_enabled() > KVM: nSVM: move kvm_set_cr3() after nested_svm_uninit_mmu_context() > KVM: nSVM: implement nested_svm_load_cr3() and use it for host->guest > switch > KVM: nSVM: use nested_svm_load_cr3() on guest->host switch > KVM: x86: drop superfluous mmu_check_root() from fast_pgd_switch() > > arch/x86/kvm/mmu.h | 3 +- > arch/x86/kvm/mmu/mmu.c | 45 ++++++++++++------ > arch/x86/kvm/svm/nested.c | 97 ++++++++++++++++++++++++++++----------- > arch/x86/kvm/svm/svm.c | 6 ++- > arch/x86/kvm/svm/svm.h | 4 +- > 5 files changed, 110 insertions(+), 45 deletions(-) > Queued, thanks. Paolo