On Fri, 7 Feb 2020 07:24:09 +0100 Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxx> wrote: > > > > > > > > Would be nicer but this is acceptable too I think. Especially, the > > > monospaced font allows breaking the table and keeping the parts aligned. > > I couldn't resist trying to use a table ;-) > > The following patch does that. IMO, it looks nice on both text and html > outputs. Now that I see this, I think this version is actually more readable than the existing text. > > Cheers, > Mauro > > diff --git a/Documentation/virt/kvm/locking.rst b/Documentation/virt/kvm/locking.rst > index 428cb3412ecc..c02291beac3f 100644 > --- a/Documentation/virt/kvm/locking.rst > +++ b/Documentation/virt/kvm/locking.rst > @@ -59,30 +59,39 @@ The mapping from gfn to pfn may be changed since we can only ensure the pfn > is not changed during cmpxchg. This is a ABA problem, for example, below case > will happen: > > -At the beginning:: > - > - gpte = gfn1 > - gfn1 is mapped to pfn1 on host > - spte is the shadow page table entry corresponding with gpte and > - spte = pfn1 > - > - VCPU 0 VCPU0 > - > -on fast page fault path:: > - > - old_spte = *spte; > - pfn1 is swapped out: > - spte = 0; > - > - pfn1 is re-alloced for gfn2. > - > - gpte is changed to point to > - gfn2 by the guest: > - spte = pfn1; > - > - if (cmpxchg(spte, old_spte, old_spte+W) > - mark_page_dirty(vcpu->kvm, gfn1) > - OOPS!!! > ++------------------------------------------------------------------------+ > +| At the beginning:: | > +| | > +| gpte = gfn1 | > +| gfn1 is mapped to pfn1 on host | > +| spte is the shadow page table entry corresponding with gpte and | > +| spte = pfn1 | > ++------------------------------------------------------------------------+ > +| On fast page fault path: | > ++------------------------------------+-----------------------------------+ > +| CPU 0: | CPU 1: | > ++------------------------------------+-----------------------------------+ > +| :: | | The '::' directives look a bit like leftover christmas decorations, but it's not really distracting, and on the plus side, we'll get nice html formatting. > +| | | > +| old_spte = *spte; | | > ++------------------------------------+-----------------------------------+ > +| | pfn1 is swapped out:: | > +| | | > +| | spte = 0; | > +| | | > +| | pfn1 is re-alloced for gfn2. | > +| | | > +| | gpte is changed to point to | > +| | gfn2 by the guest:: | > +| | | > +| | spte = pfn1; | > ++------------------------------------+-----------------------------------+ > +| :: | > +| | > +| if (cmpxchg(spte, old_spte, old_spte+W) | > +| mark_page_dirty(vcpu->kvm, gfn1) | > +| OOPS!!! | > ++------------------------------------------------------------------------+ > > We dirty-log for gfn1, that means gfn2 is lost in dirty-bitmap. > So I'd like to cast my vote for this version :)