Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp115485ybj; Fri, 8 May 2020 07:45:54 -0700 (PDT) X-Google-Smtp-Source: APiQypI/UqhOAvFLc1Sl87g8TAoh4OSRM9OnjjBpK2VIMDgIUoR6gRbnCm6RMmB7Qf5wJEs1n3Kw X-Received: by 2002:a05:6402:154e:: with SMTP id p14mr2265012edx.326.1588949154193; Fri, 08 May 2020 07:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588949154; cv=none; d=google.com; s=arc-20160816; b=yMthCGASjHo4jOHhNvB9d/tWetIG3Ewb4Uf9KURE6kajnK4IhrWCeiEKYeg1pwkZ1i jZMbvJsm1bBBd29NxRck9QlEL0PeFsmbuGCySWYMaP4LVA7hSn80PT/VCWv4RG4gqlfg hr0nx2YPpraTHsSM3qL4HxB0wpD65FV09PC5b1vXmRPL5Hx2+6t848u3ARE0axyYxFjt NxXlURLyulLhGvWitfDZvDmVCDrYPW+ogkR5w3wbbPgYLOzJdurlztPuxaSsev/+DY73 JA6vAzaMImdEUd1bftUA+/yYp53NzcG2us+7Sk5qJKv2mnISO6FD1NzGpIY3ZKsJpOHq o3Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=LHYw8efL0LeFFywd3oP7tRH4ZaXyRF39elgRBQo4okc=; b=zh3iOp5S2WZPx8sBvlxjyWQ/Iz5CQhF7Nd5In3X9FwSz8ufb/wUwWCsj0Czf6w4uNK l7cVMORg2PuOYpWaAi283X1FGxhfVyPHx4OeaboXkNJ89dbys/YybqGT+M2kfgG8fWQb UNZtxQwvf6ALBAg8uNUkCNjb4u/ng7D4poc+dNgAcS9hB+znXz90CyZQQ0+sxLBXLMQZ 5mCHVk7RgKsP7F8k6+2BXNPDHJkps1rkd7GgtN1XxO5Nwj4wfzmiBh3JA2u3pTWZg8Al wv9entQOhhcm2TNfwOZeEmin20VeG2vqk7LKDOYWqLBG9OZR6WmvdQQuDyro9c5IZykY kvJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp17si1296916ejc.317.2020.05.08.07.45.30; Fri, 08 May 2020 07:45:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728348AbgEHOlT (ORCPT + 99 others); Fri, 8 May 2020 10:41:19 -0400 Received: from 8bytes.org ([81.169.241.247]:41686 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbgEHOky (ORCPT ); Fri, 8 May 2020 10:40:54 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 1DF48485; Fri, 8 May 2020 16:40:51 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: hpa@zytor.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , rjw@rjwysocki.net, Arnd Bergmann , Andrew Morton , Steven Rostedt , Vlastimil Babka , Michal Hocko , Joerg Roedel , joro@8bytes.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 5/7] x86/mm/32: Implement arch_sync_kernel_mappings() Date: Fri, 8 May 2020 16:40:41 +0200 Message-Id: <20200508144043.13893-6-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508144043.13893-1-joro@8bytes.org> References: <20200508144043.13893-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Implement the function to sync changes in vmalloc and ioremap ranges to all page-tables. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/pgtable-2level_types.h | 2 ++ arch/x86/include/asm/pgtable-3level_types.h | 2 ++ arch/x86/mm/fault.c | 25 +++++++++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/pgtable-2level_types.h b/arch/x86/include/asm/pgtable-2level_types.h index 6deb6cd236e3..7f6ccff0ba72 100644 --- a/arch/x86/include/asm/pgtable-2level_types.h +++ b/arch/x86/include/asm/pgtable-2level_types.h @@ -20,6 +20,8 @@ typedef union { #define SHARED_KERNEL_PMD 0 +#define ARCH_PAGE_TABLE_SYNC_MASK PGTBL_PMD_MODIFIED + /* * traditional i386 two-level paging structure: */ diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h index 33845d36897c..80fbb4a9ed87 100644 --- a/arch/x86/include/asm/pgtable-3level_types.h +++ b/arch/x86/include/asm/pgtable-3level_types.h @@ -27,6 +27,8 @@ typedef union { #define SHARED_KERNEL_PMD (!static_cpu_has(X86_FEATURE_PTI)) #endif +#define ARCH_PAGE_TABLE_SYNC_MASK (SHARED_KERNEL_PMD ? 0 : PGTBL_PMD_MODIFIED) + /* * PGDIR_SHIFT determines what a top-level page table entry can map */ diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index a51df516b87b..edeb2adaf31f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -190,16 +190,13 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) return pmd_k; } -static void vmalloc_sync(void) +void arch_sync_kernel_mappings(unsigned long start, unsigned long end) { - unsigned long address; - - if (SHARED_KERNEL_PMD) - return; + unsigned long addr; - for (address = VMALLOC_START & PMD_MASK; - address >= TASK_SIZE_MAX && address < VMALLOC_END; - address += PMD_SIZE) { + for (addr = start & PMD_MASK; + addr >= TASK_SIZE_MAX && addr < VMALLOC_END; + addr += PMD_SIZE) { struct page *page; spin_lock(&pgd_lock); @@ -210,13 +207,23 @@ static void vmalloc_sync(void) pgt_lock = &pgd_page_get_mm(page)->page_table_lock; spin_lock(pgt_lock); - vmalloc_sync_one(page_address(page), address); + vmalloc_sync_one(page_address(page), addr); spin_unlock(pgt_lock); } spin_unlock(&pgd_lock); } } +static void vmalloc_sync(void) +{ + unsigned long address; + + if (SHARED_KERNEL_PMD) + return; + + arch_sync_kernel_mappings(VMALLOC_START, VMALLOC_END); +} + void vmalloc_sync_mappings(void) { vmalloc_sync(); -- 2.17.1