Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp527697ybk; Fri, 15 May 2020 07:03:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZoQNJxE5mi51mfmQfUa2VxHNm7/3pX9em89hiWm8z5G71fFVKIRNwkB9rFH4XadH7YrHc X-Received: by 2002:a17:906:3418:: with SMTP id c24mr3020609ejb.365.1589551383314; Fri, 15 May 2020 07:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589551383; cv=none; d=google.com; s=arc-20160816; b=lp2DNA18YhyBJhz6JUuq4J37oaNibro392SRazTvHHCk29kUVjV2helgULNLrTwI2U X0YSV9U4933e75B5Fbv2Tj07yL2zEN+ZdsvwFGoB42NnXmorPmJyvwswGKniBqSlS4qL bNx2oTB9nnj3uXM4Y6fnEvR9Q+nRUG3CuyljF8vDCRPjR+LvU2HL/xC8bVBX6A8hpeEF fdX0MjHtzZ2G5X/0GbOuJlmIUthrZ4EmVmadaDkTsiqu8SczpdmuuZ7NFOYcFC4QQY+1 ttExY+SprH4Tkve29ZHCdDPQXrZ9VvC3/9p23lYLN4lFYocHDBZDBJngjnH4MlczjaYj siBg== 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=pCwEe7b26GLiF03MxTVMqYkWVs5y7a+kj0jJMS0tJ70=; b=p7KRu4to4+BoJ9PfqRDWkmeoTmaokz0PcjeduOXUKyHMMoi/oT3Z7TyAK6MBkaPFeE n2DdbNxJ39RHTEpAlwSXa/eDIQS+0cI4hCAIsSnzlXiQNWHAp6bXNQEZpYsgpOwkgpIY twsCD7w5lnaCaTMyRc8Yx6eLldRZEv70YjpXlJclN0GmDljI9eVMpVlm1fipnGBcECi0 roKSvkjuOGhuAM7LWSezJbLEfkEImtcP2jW8jIeFzQD4uVmRI7vdw7UZaUO7CFC9UtgC a+MODmVIGHBT8uLR0sRZD7u/jRdARUBN92OfA3tcqutxM4S7+lj5rBccl6Yz6YWXtgW3 DGvg== 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 p59si296237edd.241.2020.05.15.07.02.37; Fri, 15 May 2020 07:03:03 -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 S1726460AbgEOOAa (ORCPT + 99 others); Fri, 15 May 2020 10:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726345AbgEOOA3 (ORCPT ); Fri, 15 May 2020 10:00:29 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAFB1C061A0C; Fri, 15 May 2020 07:00:28 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 28808457; Fri, 15 May 2020 16:00:26 +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 , Matthew Wilcox , 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: [PATCH v3 5/7] x86/mm/32: Implement arch_sync_kernel_mappings() Date: Fri, 15 May 2020 16:00:21 +0200 Message-Id: <20200515140023.25469-6-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200515140023.25469-1-joro@8bytes.org> References: <20200515140023.25469-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 Acked-by: Andy Lutomirski --- 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