lkml.org 
[lkml]   [2017]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 083/212] arm/arm64: KVM: Enforce unconditional flush to PoC when mapping to stage-2
    3.16.44-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Marc Zyngier <marc.zyngier@arm.com>

    commit 8f36ebaf21fdae99c091c67e8b6fab33969f2667 upstream.

    When we fault in a page, we flush it to the PoC (Point of Coherency)
    if the faulting vcpu has its own caches off, so that it can observe
    the page we just brought it.

    But if the vcpu has its caches on, we skip that step. Bad things
    happen when *another* vcpu tries to access that page with its own
    caches disabled. At that point, there is no garantee that the
    data has made it to the PoC, and we access stale data.

    The obvious fix is to always flush to PoC when a page is faulted
    in, no matter what the state of the vcpu is.

    Fixes: 2d58b733c876 ("arm64: KVM: force cache clean on page fault when caches are off")
    Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    [bwh: Backported to 3.16: conditions for flushing were simpler here]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    arch/arm/include/asm/kvm_mmu.h | 9 +--------
    arch/arm64/include/asm/kvm_mmu.h | 3 +--
    2 files changed, 2 insertions(+), 10 deletions(-)

    --- a/arch/arm/include/asm/kvm_mmu.h
    +++ b/arch/arm/include/asm/kvm_mmu.h
    @@ -142,8 +142,7 @@ static inline bool vcpu_has_cache_enable
    static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva,
    unsigned long size)
    {
    - if (!vcpu_has_cache_enabled(vcpu))
    - kvm_flush_dcache_to_poc((void *)hva, size);
    + kvm_flush_dcache_to_poc((void *)hva, size);

    /*
    * If we are going to insert an instruction page and the icache is
    --- a/arch/arm64/include/asm/kvm_mmu.h
    +++ b/arch/arm64/include/asm/kvm_mmu.h
    @@ -141,8 +141,7 @@ static inline bool vcpu_has_cache_enable
    static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva,
    unsigned long size)
    {
    - if (!vcpu_has_cache_enabled(vcpu))
    - kvm_flush_dcache_to_poc((void *)hva, size);
    + kvm_flush_dcache_to_poc((void *)hva, size);

    if (!icache_is_aliasing()) { /* PIPT */
    flush_icache_range(hva, hva + size);
    \
     
     \ /
      Last update: 2017-06-01 18:29    [W:4.028 / U:0.284 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site