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] [day] [month] [year] [list]
Message-ID: <4C9F45F3.7000405@redhat.com>
Date:	Sun, 26 Sep 2010 15:09:07 +0200
From:	Avi Kivity <avi@...hat.com>
To:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
CC:	Marcelo Tosatti <mtosatti@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>, KVM <kvm@...r.kernel.org>
Subject: Re: [PATCH 4/4] KVM: MMU: Don't touch unsync sp in kvm_mmu_pte_write()

  On 09/23/2010 04:59 AM, Xiao Guangrong wrote:
> On 09/20/2010 11:24 PM, Avi Kivity wrote:
> >   On 09/20/2010 04:21 PM, Xiao Guangrong wrote:
> >>  Gfn may have many shadow pages, when one sp need be synced, we write
> >>  protected sp->gfn and sync this sp but we keep other shadow pages
> >>  asynchronous
> >>
> >>  So, while gfn happen page fault, let it not touches unsync page, the
> >>  unsync
> >>  page only updated at invlpg/flush TLB time
> >>
> >>  @@ -3157,6 +3164,9 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu,
> >>  gpa_t gpa,
> >>
> >>        mask.cr0_wp = mask.cr4_pae = mask.nxe = 1;
> >>        for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn, node) {
> >>  +        if (sp->unsync)
> >>  +            continue;
> >>  +
> >>
> >
> >  Not sure this is a win.  If a gpte is updated from having p=0 to p=1 (or
> >  permissions upgraded), we may not have an invlpg to sync the spte, since
> >  the hardware doesn't require it.  With this change, we may get an extra
> >  #PF.
> >
>
> Avi,
>
> Thanks for your review, i think this case is not too bad since:
>
> 1: This case only impacts local vcpu since if permissions is increased, it's
>     no need send IPT to flush remote vcpu's tlb, so even if we update unsync
>     spte in kvm_mmu_pte_write() path, the #PF still occur on other vcpus.

IIRC, the cpu will re-validate the tlb entry from the page tables before 
issuing a fault, so we won't see a spurious fault.  Not 100% sure.

For !P -> P, there won't be a tlb entry, so 100% there won't be a 
spurious fault.

> 2: If the unsync sp which is updated in kvm_mmu_pte_write() is not using by the
>     vcpu, it will sync automatically after it's loaded.

True, and this is a likely case.

> 3: If the sp is using, update this sp in kvm_mmu_pte_write() will avoid extra #PF,
>     in this case, two(or more) sps have the same gfn, there are mapped in the same
>     page table and with different kinds(unsync/sync), i thinks this case is infrequency.
>     And even we updated it, we can not sure it can be accessed latter,

If it's infrequent, the why do we optimize it?

> So, i think it's better lazily update unsync sp until it's used or the flush time,
> your opinion? :-)
>

Any performance numbers?

To me it seems saving a possible exit is worth extra computation.

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ