[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANgfPd9LmFfZisR3oXKZ7xSeTRi7GyDr+VWf0dE9U4y6_icmTA@mail.gmail.com>
Date: Tue, 6 Oct 2020 15:35:08 -0700
From: Ben Gardon <bgardon@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Sean Christopherson <sean.j.christopherson@...el.com>,
LKML <linux-kernel@...r.kernel.org>, kvm <kvm@...r.kernel.org>,
Cannon Matthews <cannonmatthews@...gle.com>,
Peter Xu <peterx@...hat.com>, Peter Shier <pshier@...gle.com>,
Peter Feiner <pfeiner@...gle.com>,
Junaid Shahid <junaids@...gle.com>,
Jim Mattson <jmattson@...gle.com>,
Yulei Zhang <yulei.kernel@...il.com>,
Wanpeng Li <kernellwp@...il.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Xiao Guangrong <xiaoguangrong.eric@...il.com>
Subject: Re: [PATCH 10/22] kvm: mmu: Add TDP MMU PF handler
On Wed, Sep 30, 2020 at 10:38 AM Paolo Bonzini <pbonzini@...hat.com> 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
>
Powered by blists - more mailing lists