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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 104FBC433FE for ; Sat, 19 Feb 2022 00:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240347AbiBSAXO (ORCPT ); Fri, 18 Feb 2022 19:23:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240336AbiBSAXN (ORCPT ); Fri, 18 Feb 2022 19:23:13 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF9406E351 for ; Fri, 18 Feb 2022 16:22:55 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id s16so9174039pgs.13 for ; Fri, 18 Feb 2022 16:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PKozzWeotfW0H/XChUhKVfvoVAWx3v86SwCGH78y65k=; b=YJr7T4GPIwDLm8MhhOOQayyse45vPIFv4uPo7XIm+miZ9JCsK1JdIoXK3rAPZLB5X4 A5CrKN2EGzd1cx5YPsdVhNoBP2nvJvTS/4QmYgq19BFsLKn3YLZYB9LJ8xgqA/uchgUP ipCYRjqs/l0CY3IVqWzqCQtTcQeA0rNGszozpIa2Zx6netouSyuIUZq28gdMEIF9VStY JKN6n7q0vweWxZEDIlaG78NXQVOwViN+B2oSQp+FSwOTjG11PB1XxaW1DqIS6HFxZ69S qc5rB61GQSn1mjkgAWZJ8+Bx6Bjc+qVnwuCDcLglHfqIMXvEWaayvbu8KmVN9SES6FNm H2KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PKozzWeotfW0H/XChUhKVfvoVAWx3v86SwCGH78y65k=; b=WldBGFZZB4SuR9jzgnXtd30/vs7HgwKxHAdZBXfVYEu/gJW6DEvqejvNWrf186tPVP iUv7t1QptGGj5jMHsNOM6Q0AJHBiyyusVXZdy3szb8wxvmJXRfEyrzT5uoGFfqK/XFN2 EYVt01R7JPKjV7wkeM7N34UCFTebrw7H/fYfBurW/SZqcz9ONnBw+aatgGmpZ+X66DoO xFDfTTivM4B4Rmu0jVZVw+un734nM9boQ7jany9Dlj3uC4flr10Lp99w4s0n2EOE7mKv PkMG9IFLKqbjl+Ty+EewnxwfS6Nlug8eZ2e9wwrvJ3ZZKHjy33/7vvOp5fthTlsgt/27 r9xA== X-Gm-Message-State: AOAM530hHuD6MJ9kkuEq9wtMteF8oZJrYGtfyNJlOsJkrk136naRDmh8 nTpAXU0R+JP4zXj5ejG4LnuOsg== X-Google-Smtp-Source: ABdhPJyam7kTYq5rTQAMSu2ALEE50Ee8PLPQAi1b3BzbfQybJRbIYqYjX74rsUr8nmhHftAfrz1Whw== X-Received: by 2002:a05:6a00:2391:b0:4a8:d88:9cd with SMTP id f17-20020a056a00239100b004a80d8809cdmr9879701pfc.11.1645230175301; Fri, 18 Feb 2022 16:22:55 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id i17sm12004965pgv.8.2022.02.18.16.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 16:22:54 -0800 (PST) Date: Sat, 19 Feb 2022 00:22:50 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v2 13/18] KVM: x86: reset and reinitialize the MMU in __set_sregs_common Message-ID: References: <20220217210340.312449-1-pbonzini@redhat.com> <20220217210340.312449-14-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217210340.312449-14-pbonzini@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 17, 2022, Paolo Bonzini wrote: > Do a full unload of the MMU in KVM_SET_SREGS and KVM_SEST_REGS2, in > preparation for not doing so in kvm_mmu_reset_context. There is no > need to delay the reset until after the return, so do it directly in > the __set_sregs_common function and remove the mmu_reset_needed output > parameter. > > Signed-off-by: Paolo Bonzini > --- Reviewed-by: Sean Christopherson > + kvm_init_mmu(vcpu); > if (update_pdptrs) { > idx = srcu_read_lock(&vcpu->kvm->srcu); > - if (is_pae_paging(vcpu)) { > + if (is_pae_paging(vcpu)) > load_pdptrs(vcpu, kvm_read_cr3(vcpu)); > - *mmu_reset_needed = 1; Eww (not your code, just this whole pile). It might be worth calling out in the changelog that calling kvm_init_mmu() before load_pdptrs() will (subtly) _not_ impact the functionality of load_pdptrs(). If the MMU is nested, kvm_init_mmu() will modify vcpu->arch.nested_mmu, whereas kvm_translate_gpa() will walk vcpu->arch.guest_mmu. And if the MMU is not nested, kvm_translate_gpa() will not consuming vcpu->arch.mmu other than to check if it's == &guest_mmu. > - } > srcu_read_unlock(&vcpu->kvm->srcu, idx); > } >