From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH 11/18] arm/arm64: make mmu_on per cpu Date: Sun, 1 Feb 2015 19:34:39 +0100 Message-ID: <1422815686-24591-12-git-send-email-drjones@redhat.com> References: <1422815686-24591-1-git-send-email-drjones@redhat.com> Cc: christoffer.dall@linaro.org, pbonzini@redhat.com To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37098 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753992AbbBASfL (ORCPT ); Sun, 1 Feb 2015 13:35:11 -0500 In-Reply-To: <1422815686-24591-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: We introduced a variable called mmu_on to the mmu implementation because unit tests may want to run with the mmu off, yet still call into common code that could lead to {Load,Store}-Exclusive instructions - which is illegal. So, the mmu_on variable was added and made query-able (through mmu_enabled()) in order to guard those paths. But, mmu_on is really a per cpu concept, so for smp we need to change it. As it's just a bool, we can easily make it per cpu by changing it into a cpumask. We rename it more appropriately too. Signed-off-by: Andrew Jones --- lib/arm/asm/mmu-api.h | 1 + lib/arm/mmu.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/arm/asm/mmu-api.h b/lib/arm/asm/mmu-api.h index f2511e3dc7dee..68dc707d67241 100644 --- a/lib/arm/asm/mmu-api.h +++ b/lib/arm/asm/mmu-api.h @@ -2,6 +2,7 @@ #define __ASMARM_MMU_API_H_ extern pgd_t *mmu_idmap; extern bool mmu_enabled(void); +extern void mmu_set_enabled(void); extern void mmu_enable(pgd_t *pgtable); extern void mmu_enable_idmap(void); extern void mmu_init_io_sect(pgd_t *pgtable, unsigned long virt_offset); diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 1c024538663ce..732000a8eb088 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -6,16 +6,25 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include +#include +#include #include extern unsigned long etext; pgd_t *mmu_idmap; -static bool mmu_on; +static cpumask_t mmu_enabled_cpumask; bool mmu_enabled(void) { - return mmu_on; + struct thread_info *ti = current_thread_info(); + return cpumask_test_cpu(ti->cpu, &mmu_enabled_cpumask); +} + +void mmu_set_enabled(void) +{ + struct thread_info *ti = current_thread_info(); + cpumask_set_cpu(ti->cpu, &mmu_enabled_cpumask); } extern void asm_mmu_enable(phys_addr_t pgtable); @@ -23,7 +32,7 @@ void mmu_enable(pgd_t *pgtable) { asm_mmu_enable(__pa(pgtable)); flush_tlb_all(); - mmu_on = true; + mmu_set_enabled(); } void mmu_set_range_ptes(pgd_t *pgtable, unsigned long virt_offset, -- 1.9.3