Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1648491pxj; Fri, 4 Jun 2021 22:19:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXvwpBr0MgRjP5TNpKSMN4vO10GD16pksCCpFLlXCQ22IRXCnnKpBnp5GytQ6Tb4m/7B1o X-Received: by 2002:a50:cc0b:: with SMTP id m11mr8342812edi.297.1622870391729; Fri, 04 Jun 2021 22:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622870391; cv=none; d=google.com; s=arc-20160816; b=IOLdnwjb980uuV2G0LWQDhPa6soTw3w76lqJibi4yYbXKQkjyrPCp0o1Ym34Jnffty DIc5lRsRnyWRzhekt+ZPC4BPYV7B16k8FNGK+LcauFRJuaIIrM+XEDz4+TmA1Kl2Xv/K MjSZwBaMN1BqCPIPUqOafN4eDhCS4h4Hf7Botmdhu4v6/rx57t7JoX9ylK7b7IWu2dWN T3DDQqy4v1AUWJmAx5BHvGUSD9iV3o4G4HKjxjE/+vjYkLUpHBH2bVDTNyMmg8KL9U// FtS90a/pntRCNNtY0I86fTOk8PDTiR173EI3ooTjYGO0m0ruXNoCSs9c3lRhlJYtN2gf HXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=yg4qfjz32iR7I+scue6c8QW9Zo61QtRmXy+5P2YitMw=; b=QZsZCdN1wwwVieWy9ECqBvrU3qaOinOQLpi5z3t9uPdxasj+20rgvFiKxNcxwOHSDh 7KfWl2RKfoi+QcmoyFuQesaqkVKEd/elHaMd+DByW/Iabg+NNeo2sE3adtfuoWWXfFHN DbhOhUkhii/+8TA3p1kLifxyNwdNxTfUsEqDUgHDKi9RRFtS66lY2NmX3cAPaOqBv1yr oPjF3//Zb0JtptVfSSoHLglqW2g6LpItezj1tb5H00FiZxSEl59BzoeBi0AfQ94Nxo/d mlDwNWF3nm+baLeM1bBnNrBLpxCMJbJdrUWm7KSaDMZ+oMqWmx1fsxkVC04h9lsMDDKN 1sjw== 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id uz14si6368641ejb.694.2021.06.04.22.19.28; Fri, 04 Jun 2021 22:19:51 -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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbhFEFSL (ORCPT + 99 others); Sat, 5 Jun 2021 01:18:11 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:4312 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhFEFSK (ORCPT ); Sat, 5 Jun 2021 01:18:10 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FxnmQ5Crtz1BGXl; Sat, 5 Jun 2021 13:11:34 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 5 Jun 2021 13:16:21 +0800 Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 5 Jun 2021 13:16:20 +0800 From: Liu Shixin To: Paul Walmsley , Palmer Dabbelt , Albert Ou CC: , , "Liu Shixin" Subject: [PATCH -next] riscv: Enable HAVE_ARCH_HUGE_VMAP for 64BIT Date: Sat, 5 Jun 2021 13:48:37 +0800 Message-ID: <20210605054838.2017817-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This sets the HAVE_ARCH_HUGE_VMAP option. Enable pmd vmap support and define the required page table functions(Currently, riscv has only three-level page tables support for 64BIT). Signed-off-by: Liu Shixin --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/vmalloc.h | 12 ++++++++++ arch/riscv/mm/Makefile | 1 + arch/riscv/mm/pgtable.c | 40 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 arch/riscv/mm/pgtable.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 4c0bfb2569e9..fb3c48fa96c1 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -61,6 +61,7 @@ config RISCV select GENERIC_TIME_VSYSCALL if MMU && 64BIT select HANDLE_DOMAIN_IRQ select HAVE_ARCH_AUDITSYSCALL + select HAVE_ARCH_HUGE_VMAP if MMU && 64BIT select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN if MMU && 64BIT diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h index ff9abc00d139..8f17f421f80c 100644 --- a/arch/riscv/include/asm/vmalloc.h +++ b/arch/riscv/include/asm/vmalloc.h @@ -1,4 +1,16 @@ #ifndef _ASM_RISCV_VMALLOC_H #define _ASM_RISCV_VMALLOC_H +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP + +#define IOREMAP_MAX_ORDER (PMD_SHIFT) + +#define arch_vmap_pmd_supported arch_vmap_pmd_supported +static inline bool __init arch_vmap_pmd_supported(pgprot_t prot) +{ + return true; +} + +#endif + #endif /* _ASM_RISCV_VMALLOC_H */ diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile index 7ebaef10ea1b..f932b4d69946 100644 --- a/arch/riscv/mm/Makefile +++ b/arch/riscv/mm/Makefile @@ -13,6 +13,7 @@ obj-y += extable.o obj-$(CONFIG_MMU) += fault.o pageattr.o obj-y += cacheflush.o obj-y += context.o +obj-y += pgtable.o ifeq ($(CONFIG_MMU),y) obj-$(CONFIG_SMP) += tlbflush.o diff --git a/arch/riscv/mm/pgtable.c b/arch/riscv/mm/pgtable.c new file mode 100644 index 000000000000..738dc6f3530f --- /dev/null +++ b/arch/riscv/mm/pgtable.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP + +#ifndef __PAGETABLE_PMD_FOLDED +int pmd_set_huge(pmd_t *pmd, phys_addr_t phys, pgprot_t prot) +{ + pmd_t new_pmd = pfn_pmd(__phys_to_pfn(phys), prot); + + set_pmd(pmd, new_pmd); + return 1; +} + +int pmd_clear_huge(pmd_t *pmd) +{ + if (!pmd_leaf(READ_ONCE(*pmd))) + return 0; + pmd_clear(pmd); + return 1; +} +#endif + +int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) +{ + pte_t *pte; + + pte = (pte_t *)pmd_page_vaddr(*pmd); + pmd_clear(pmd); + + flush_tlb_kernel_range(addr, addr + PMD_SIZE); + pte_free_kernel(NULL, pte); + return 1; +} + +#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ -- 2.18.0.huawei.25