Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp670461pxu; Tue, 6 Oct 2020 16:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVaQg4+Yqnc1AVdYz8rebfPwNSGkSuKpPu6mN69sKQ0N7KvwFgT83/194S7wcZcczN7itZ X-Received: by 2002:a17:906:4910:: with SMTP id b16mr36404ejq.546.1602027133988; Tue, 06 Oct 2020 16:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602027133; cv=none; d=google.com; s=arc-20160816; b=b2K9fszTt4CgGsoDu/GRUIKqhVOlSdOOeC3m0Vkxq2m8J0w3nGcTf3aExTAfP1wV8K LqxN7JbWnmk5a96qTsmgrVbPEawcA2HDMXC4MMg/LV+86dXhOTvSoPHP3Avm3VON0e19 fgNzGqDoEPqe3yrBxEJyC//+ySqhnIfYxrzT/oKsPUeUBp+7yPV7aVzdIt8MaIyn0THw sYgT6/BhFvzApiVpwyqNFd87EE+hBZ+d017p/IstqczrvgkfdcM4U5ETszuSH7bKXYCS /MK7jt0FRaNW8oAOgD0aLtkHOIhQQUYXGYvVgOuii19E79xOHFN/prE3CZ8w9O8IU96x PdpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=swHb/KR/ZWp6i2rbsmi7Thg0YMjjYF8TV8HVF7qu0sI=; b=1EEkCz7gdjQyOyerb0n5eESCqx6JIIVI3TPxg8m5j4WNu9M/k+N2n+lMJ5PYFbnAbW B2KcC0e360Ah9YMm6CCF1K8d9uDcVPsugHf5OAxzHqLUeo+YdQwd0PKtNmkwVomNihgw ghV4lTc1NdZW6lI1p3d3eLrQE2xG1yLOh5IwWxz9kXcTya3PXSuUibQExSLQAMuVm5F2 FL4WgIug2uuLZ6FHH3DAK5XsMafS6zvPzA9NOoUNrI6SSj563qJCo46Qy7pjg6DAN66D 1lNuNKzBo0WWTetNKUNfWKNMea2MszRYk0dkULX+VYPZ9eIL3ptr0CcdR6xrosAHdll2 DZRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RPmCEgOg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si50598edv.507.2020.10.06.16.31.51; Tue, 06 Oct 2020 16:32:13 -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=@google.com header.s=20161025 header.b=RPmCEgOg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgJFWfU (ORCPT + 99 others); Tue, 6 Oct 2020 18:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbgJFWfU (ORCPT ); Tue, 6 Oct 2020 18:35:20 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76BDAC0613D2 for ; Tue, 6 Oct 2020 15:35:20 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id g7so181472iov.13 for ; Tue, 06 Oct 2020 15:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=swHb/KR/ZWp6i2rbsmi7Thg0YMjjYF8TV8HVF7qu0sI=; b=RPmCEgOgY2e63BA92hfU543iiUc4nOFxZjZgWswSWW5Zl053YNAOb4JqEQZ0Tw3nIh FDwiB5NTupvmRf7pBHuqAb8KroEmqOx9ebKKq1nYfW5T9qIm7gUKATt/G5R9Hx7+xObT S8ol3nj1pjrymArRfKVK1gysBNOSFRv/TUAjXPR/NstVX+cIss8xRuZ/AcoHoQryfn0w p+GeSeA/pHYtvS0BYIEuUDirs947eJ9TqbPYX28IxgE6Yq/DrE6vqS9R2ieotCpohIc7 88oOVhEEWrJIeWTp248NzDbbrI6pqXowouvdNJFrjLVEpZGh0f9TxH329DO7/l4CvoPf r2rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=swHb/KR/ZWp6i2rbsmi7Thg0YMjjYF8TV8HVF7qu0sI=; b=Kf5W5Fq/4qdyR0oPTMZVWtyaivDyWtnH0cuR1QZzEnYrlytEd29s2myg3iMqHjL/6z VHQbwt1sdc5kq5jSQ6/LYBI9fKCoX7lwO8bTeDXvQRAl/cmuVsqkwZZ4BcNOtZV8rFSD LsPV0s8UazTBHZNRXvczOVuYDEPslSTtm3Y0ldOpJFCbWXJxd3ftAJO7J7cz1LIlTKhk We35RmCHUB05TvPtWWHvkhQCNgAB8EkjqCaaGCBdPF6whnfW6L1qmrNnCGtqNG2Xh+Uc qExpTGIoGR3QYswzArwBFMrsMbs/H7MzLP4kt4O1RZG2NyXHXPsQ0JN70EJPTtucv8QD e6rg== X-Gm-Message-State: AOAM532GwJuavbhG69tZY60nLkX77adSfAQ3ZNQeqh6Bl4wqu7qHZiXN HA1kCVdbycO0HKdlLIB15rzt6kg5QSVBdi0+lmctCg== X-Received: by 2002:a6b:1646:: with SMTP id 67mr25486iow.189.1602023719577; Tue, 06 Oct 2020 15:35:19 -0700 (PDT) MIME-Version: 1.0 References: <20200925212302.3979661-1-bgardon@google.com> <20200925212302.3979661-11-bgardon@google.com> <20200930163740.GD32672@linux.intel.com> In-Reply-To: From: Ben Gardon Date: Tue, 6 Oct 2020 15:35:08 -0700 Message-ID: Subject: Re: [PATCH 10/22] kvm: mmu: Add TDP MMU PF handler To: Paolo Bonzini Cc: Sean Christopherson , LKML , kvm , Cannon Matthews , Peter Xu , Peter Shier , Peter Feiner , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 10:38 AM Paolo Bonzini wrote: > > On 30/09/20 18:37, Sean Christopherson wrote: > >> + ret = page_fault_handle_target_level(vcpu, write, map_writable, > >> + as_id, &iter, pfn, prefault); > >> + > >> + /* If emulating, flush this vcpu's TLB. */ > > Why? It's obvious _what_ the code is doing, the comment should explain _why_. > > > >> + if (ret == RET_PF_EMULATE) > >> + kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); > >> + > >> + return ret; > >> +} > > In particular it seems to be only needed in this case... > > + /* > + * If the page fault was caused by a write but the page is write > + * protected, emulation is needed. If the emulation was skipped, > + * the vCPU would have the same fault again. > + */ > + if ((make_spte_ret & SET_SPTE_WRITE_PROTECTED_PT) && write) > + ret = RET_PF_EMULATE; > + > > ... corresponding to this code in mmu.c > > if (set_spte_ret & SET_SPTE_WRITE_PROTECTED_PT) { > if (write_fault) > ret = RET_PF_EMULATE; > kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu); > } > > So it should indeed be better to make the code in > page_fault_handle_target_level look the same as mmu/mmu.c. That's an excellent point. I've made an effort to make them more similar. I think this difference arose from the synchronization changes I was working back from, but this will be much more elegant in either case. > > Paolo >