From patchwork Thu Nov 23 16:13:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 10073039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D3C046056E for ; Thu, 23 Nov 2017 16:13:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C68B52A12B for ; Thu, 23 Nov 2017 16:13:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAE522A131; Thu, 23 Nov 2017 16:13:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 610972A12B for ; Thu, 23 Nov 2017 16:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751777AbdKWQNH (ORCPT ); Thu, 23 Nov 2017 11:13:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48784 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751415AbdKWQNG (ORCPT ); Thu, 23 Nov 2017 11:13:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC654DF02 for ; Thu, 23 Nov 2017 16:13:06 +0000 (UTC) Received: from flask (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 327345EE1E; Thu, 23 Nov 2017 16:13:02 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 23 Nov 2017 17:13:01 +0100 Date: Thu, 23 Nov 2017 17:13:01 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Andrew Jones Cc: kvm@vger.kernel.org, pbonzini@redhat.com Subject: Re: [PATCH kvm-unit-tests 2/2] arm/arm64: mmu: add missing TLB flushes Message-ID: <20171123161300.GA11746@flask> References: <20171121164921.8396-1-drjones@redhat.com> <20171121164921.8396-3-drjones@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171121164921.8396-3-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 Nov 2017 16:13:06 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 2017-11-21 17:49+0100, Andrew Jones: > Since 031755db "arm: enable vmalloc" the virtual addresses returned > from malloc and friends are no longer identical to the physical > addresses they map to. On some hardware the change exposes missing > TLB flushes. Let's get them added. > > Signed-off-by: Andrew Jones > --- > lib/arm/mmu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c > index 21bcf3a363af..2e5c993f1e7f 100644 > --- a/lib/arm/mmu.c > +++ b/lib/arm/mmu.c > @@ -86,6 +86,7 @@ static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte) > { > pteval_t *p_pte = get_pte(pgtable, vaddr); > *p_pte = pte; > + flush_tlb_page(vaddr); > return p_pte; > } > > @@ -136,9 +137,9 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset, > pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S; > pgd_val(*pgd) |= pgprot_val(prot); > } > + flush_tlb_all(); > } Applied, thanks. Out of curiosity, when does it become better to use flush_tlb_all() than flush_tlb_page()? i.e. diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 2e5c993f1e7f..030c44412c2a 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -136,8 +136,8 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset, pgd_val(*pgd) = paddr; pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S; pgd_val(*pgd) |= pgprot_val(prot); + flush_tlb_page(vaddr); } - flush_tlb_all(); } void *setup_mmu(phys_addr_t phys_end)