From patchwork Tue Jan 16 18:53:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 10167933 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 89130600CA for ; Tue, 16 Jan 2018 18:53:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74DA61FE82 for ; Tue, 16 Jan 2018 18:53:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68439204FD; Tue, 16 Jan 2018 18:53:59 +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=-6.9 required=2.0 tests=BAYES_00,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 0AF261FE82 for ; Tue, 16 Jan 2018 18:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751513AbeAPSx5 (ORCPT ); Tue, 16 Jan 2018 13:53:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60444 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbeAPSx4 (ORCPT ); Tue, 16 Jan 2018 13:53:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E9D1C0568E0; Tue, 16 Jan 2018 18:53:56 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1607760C9E; Tue, 16 Jan 2018 18:53:40 +0000 (UTC) From: Andrew Jones To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, cdall@linaro.org, david@redhat.com, lvivier@redhat.com, thuth@redhat.com Subject: [PATCH kvm-unit-tests 02/11] arm/arm64: add pgtable to thread_info Date: Tue, 16 Jan 2018 19:53:03 +0100 Message-Id: <20180116185312.7257-3-drjones@redhat.com> In-Reply-To: <20180116185312.7257-1-drjones@redhat.com> References: <20180116185312.7257-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 16 Jan 2018 18:53:56 +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 Signed-off-by: Andrew Jones --- lib/arm/asm/thread_info.h | 1 + lib/arm/mmu.c | 5 +++-- lib/arm/processor.c | 1 + lib/arm/smp.c | 1 + lib/arm64/processor.c | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/arm/asm/thread_info.h b/lib/arm/asm/thread_info.h index c2ecebb47d5a..80ab3954a6b0 100644 --- a/lib/arm/asm/thread_info.h +++ b/lib/arm/asm/thread_info.h @@ -47,6 +47,7 @@ static inline void *thread_stack_alloc(void) struct thread_info { int cpu; unsigned int flags; + void *pgtable; #ifdef __arm__ exception_fn exception_handlers[EXCPTN_MAX]; #else diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 9e420269f1c0..b9387efe0065 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -54,12 +54,13 @@ void mmu_mark_disabled(int cpu) extern void asm_mmu_enable(phys_addr_t pgtable); void mmu_enable(pgd_t *pgtable) { - int cpu = current_thread_info()->cpu; + struct thread_info *info = current_thread_info(); asm_mmu_enable(__pa(pgtable)); flush_tlb_all(); - mmu_mark_enabled(cpu); + info->pgtable = pgtable; + mmu_mark_enabled(info->cpu); } extern void asm_mmu_disable(void); diff --git a/lib/arm/processor.c b/lib/arm/processor.c index 54fdb87ef019..49e852c06527 100644 --- a/lib/arm/processor.c +++ b/lib/arm/processor.c @@ -124,6 +124,7 @@ void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr) sp_usr &= (~7UL); /* stack ptr needs 8-byte alignment */ thread_info_init(thread_info_sp(sp_usr), TIF_USER_MODE); + thread_info_sp(sp_usr)->pgtable = current_thread_info()->pgtable; asm volatile( "mrs r0, cpsr\n" diff --git a/lib/arm/smp.c b/lib/arm/smp.c index 3c4e307489b2..27f6fcd07109 100644 --- a/lib/arm/smp.c +++ b/lib/arm/smp.c @@ -33,6 +33,7 @@ secondary_entry_fn secondary_cinit(void) secondary_entry_fn entry; thread_info_init(ti, 0); + ti->pgtable = mmu_idmap; mmu_mark_enabled(ti->cpu); /* diff --git a/lib/arm64/processor.c b/lib/arm64/processor.c index 165980a97d44..96995ccb7733 100644 --- a/lib/arm64/processor.c +++ b/lib/arm64/processor.c @@ -238,6 +238,7 @@ void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr) sp_usr &= (~15UL); /* stack ptr needs 16-byte alignment */ __thread_info_init(thread_info_sp(sp_usr), TIF_USER_MODE); + thread_info_sp(sp_usr)->pgtable = current_thread_info()->pgtable; asm volatile( "mov x0, %0\n"