lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f13fcf5b-f6bc-fb95-6f69-ea524ae446f5@redhat.com>
Date:   Wed, 23 Jun 2021 18:38:33 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Yu Zhang <yu.c.zhang@...ux.intel.com>,
        Maxim Levitsky <mlevitsk@...hat.com>
Subject: Re: [PATCH 09/54] KVM: x86/mmu: Unconditionally zap unsync SPs when
 creating >4k SP at GFN

On 23/06/21 17:08, Sean Christopherson wrote:
> Because the shadow page's level is incorporated into its role, if the level of
> the new page is >4k, the branch at (1) will be taken for all 4k shadow pages.
> 
> Maybe something like this for a comment?

Good, integrated.

Though I also wonder why breaking out of the loop early is okay.  Initially I thought
that zapping only matters if there's no existing page with the desired role,
because otherwise the unsync page would have been zapped already by an earlier
kvm_get_mmu_page, but what if the page was synced at the time of kvm_get_mmu_page
and then both were unsynced?

It may be easier to just split the loop to avoid that additional confusion,
something like:

         /*
          * If the guest is creating an upper-level page, zap unsync pages
          * for the same gfn, because the gfn will be write protected and
          * future syncs of those unsync pages could happen with an incompatible
          * context.  While it's possible the guest is using recursive page
          * tables, in all likelihood the guest has stopped using the unsync
          * page and is installing a completely unrelated page.
          */
         if (level > PG_LEVEL_4K) {
                 for_each_valid_sp(vcpu->kvm, sp, sp_list)
                         if (sp->gfn == gfn && sp->role.word != role.word && sp->unsync)
                                 kvm_mmu_prepare_zap_page(vcpu->kvm, sp,
                                                          &invalid_list);
         }

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ