linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Question about TLB flush while set Stage-2 huge pages
@ 2019-03-11 16:31 Zheng Xiang
  2019-03-12 11:32 ` Marc Zyngier
  0 siblings, 1 reply; 22+ messages in thread
From: Zheng Xiang @ 2019-03-11 16:31 UTC (permalink / raw)
  To: christoffer.dall, marc.zyngier, catalin.marinas, will.deacon,
	suzuki.poulose, james.morse
  Cc: linux-arm-kernel, kvmarm, linux-kernel, Wang Haibin, yuzenghui,
	lious.lilei, lishuo1

Hi all,

While a page is merged into a transparent huge page, KVM will invalidate Stage-2 for
the base address of the huge page and the whole of Stage-1.
However, this just only invalidates the first page within the huge page and the other
pages are not invalidated, see bellow:

    +---------------+--------------+
    |abcde       2MB-Page          |
    +---------------+--------------+

    TLB before setting new pmd:
    +---------------+--------------+
    |      VA       |    PAGESIZE  |
    +---------------+--------------+
    |      a        |      4KB     |
    +---------------+--------------+
    |      b        |      4KB     |
    +---------------+--------------+
    |      c        |      4KB     |
    +---------------+--------------+
    |      d        |      4KB     |
    +---------------+--------------+

    TLB after setting new pmd:
    +---------------+--------------+
    |      VA       |    PAGESIZE  |
    +---------------+--------------+
    |      a        |      2MB     |
    +---------------+--------------+
    |      b        |      4KB     |
    +---------------+--------------+
    |      c        |      4KB     |
    +---------------+--------------+
    |      d        |      4KB     |
    +---------------+--------------+

When VM access *b* address, it will hit the TLB and result in TLB conflict aborts or other potential exceptions.

For example, we need to keep tracking of the VM memory dirty pages when VM is in live migration.
KVM will set the memslot READONLY and split the huge pages.
After live migration is canceled and abort, the pages will be merged into THP.
The later access to these pages which are READONLY will cause level-3 Permission Fault until they are invalidated.

So should we invalidate the tlb entries for all relative pages(e.g a,b,c,d), like __flush_tlb_range()?
Or we can call __kvm_tlb_flush_vmid() to invalidate all tlb entries.



-- 

Thanks,
Xiang


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-03-20 17:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 16:31 [RFC] Question about TLB flush while set Stage-2 huge pages Zheng Xiang
2019-03-12 11:32 ` Marc Zyngier
2019-03-12 15:30   ` Zheng Xiang
2019-03-12 18:18     ` Marc Zyngier
2019-03-13  9:45       ` Zheng Xiang
2019-03-14 10:55         ` Suzuki K Poulose
2019-03-14 15:50           ` Zenghui Yu
2019-03-15  8:21             ` Zheng Xiang
2019-03-15 14:56               ` Suzuki K Poulose
2019-03-17 13:34                 ` Zenghui Yu
2019-03-18 17:34                   ` Suzuki K Poulose
2019-03-19  9:05                     ` Zenghui Yu
2019-03-19 14:11                       ` [PATCH] kvm: arm: Fix handling of stage2 huge mappings Suzuki K Poulose
2019-03-19 16:02                         ` Zenghui Yu
2019-03-20  8:15                         ` Marc Zyngier
2019-03-20  9:44                           ` Suzuki K Poulose
2019-03-20 10:11                             ` Marc Zyngier
2019-03-20 10:23                               ` Suzuki K Poulose
2019-03-20 10:35                                 ` Marc Zyngier
2019-03-20 11:12                                   ` Suzuki K Poulose
2019-03-20 17:24                                     ` Marc Zyngier
2019-03-17 13:55                 ` [RFC] Question about TLB flush while set Stage-2 huge pages Zenghui Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).