Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp120334iob; Tue, 17 May 2022 20:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq12li11DXiVnGXNyfIYVY2aaU50GnvhD91RSRkk3UE1eIUGh0NZ+v/ljLS59ds5VSB5UV X-Received: by 2002:a05:6a00:843:b0:510:7550:6005 with SMTP id q3-20020a056a00084300b0051075506005mr25779807pfk.75.1652846047808; Tue, 17 May 2022 20:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652846047; cv=none; d=google.com; s=arc-20160816; b=H2/un+U7EV7kezxmxUzUSl2q5QqQqi8Y+KRDRLIwe+kfeXCNcyDfHTwVyRH3QkszxS qCzirFap09dwL0NpGcXshxDQeZ/P2jeuKngpZmTu7oFpLUR2kVWtnErlEBI7y95oaCqk sQFPxVR2NbAcHucNgfeepU8/yVhYQg1JtImVq6tCMKR2eKKCIwFLGbliv+CfbRCUe24W C8nmeU2u7xE0/KnxhEKIRiemQ0sMNESjXe5FXYZkTLbsiGji7rCwZ5BwGYGQ4s9yRy7i k88JeH1s64PosCQq1iT0QY9PQMo8+xYfkNekclKLma+ZKdj06EqS3gloIwl/VbYyoE2W y9sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=41gKco1J/++TtreF8EsjcxpWEHilaWXDDY/LjXxgSx8=; b=YcGiCfNJGe8qe9kmhGa22u1YvxN4ZdNXy5z6YMAxK9xtZwMfG6sqtSs2pRCbtvKdS2 4yOxbkewo4vyFrVDEEbLNZDT/RFU3o8dQWHqwEgYyD1vF976v53Ho0HluWx7hH/2YH1e 3UBRdBGZACz7/chPOFrjjJNnTCYU4SW7ErgP7Jfg1LN4xKx8YilBkw+p3DT3+ufU+DqX mvJzC9yW0CO3p2bQlnGrqUNBZ36IF8LnL7OjCe7a/X2blXuIRAQ7b3GuyoH/c96kG1Y9 c7HlhQn1YfztGw/0tAHXC1l5oPE8e9f1qoGmS8zHLQWDDKMpyBTdN3dlgLsYBXuiXSF6 JBBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l17-20020a170903245100b0015eb10a9f67si1334648pls.379.2022.05.17.20.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 20:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A15A95DF2; Tue, 17 May 2022 20:35:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241232AbiEQH1l (ORCPT + 99 others); Tue, 17 May 2022 03:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240831AbiEQH11 (ORCPT ); Tue, 17 May 2022 03:27:27 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4994943EEF; Tue, 17 May 2022 00:27:26 -0700 (PDT) Received: from kwepemi100019.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L2SNp0JjxzhZ7T; Tue, 17 May 2022 15:26:50 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100019.china.huawei.com (7.221.188.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 17 May 2022 15:27:24 +0800 Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 17 May 2022 15:27:23 +0800 From: Tong Tiangen To: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , Arnd Bergmann CC: , , , , Tong Tiangen , , Guohanjun , Xie XiuQi Subject: [PATCH -next 1/2] riscv/mm: fix two page table check related issues Date: Tue, 17 May 2022 07:45:47 +0000 Message-ID: <20220517074548.2227779-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517074548.2227779-1-tongtiangen@huawei.com> References: <20220517074548.2227779-1-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Two page table check related issues have been fixed here. 1. Open CONFIG_PAGE_TABLE_CHECK in riscv32, we got a compile error[1]: error: implicit declaration of function 'pud_leaf' Add pud_leaf() definition to incluce/asm-generic/pgtable-nopmd.h to fix this issue. 2. Keep consistent with other pud_xxx() helpers, move pud_user() to pgtable-64.h and add pud_user() to pgtable-nopmd.h. [1]https://lore.kernel.org/linux-mm/202205161811.2nLxmN2O-lkp@intel.com/T/ Fixes: 856eed79f8d3 ("riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") Reported-by: kernel test robot Signed-off-by: Tong Tiangen --- arch/riscv/include/asm/pgtable-64.h | 5 +++++ arch/riscv/include/asm/pgtable.h | 5 ----- include/asm-generic/pgtable-nopmd.h | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 7e246e9f8d70..ba2494cbc24f 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -86,6 +86,11 @@ static inline int pud_leaf(pud_t pud) return pud_present(pud) && (pud_val(pud) & _PAGE_LEAF); } +static inline int pud_user(pud_t pud) +{ + return pud_val(pud) & _PAGE_USER; +} + static inline void set_pud(pud_t *pudp, pud_t pud) { *pudp = pud; diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 62e733c85836..4200ddede880 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -634,11 +634,6 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, return __set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd)); } -static inline int pud_user(pud_t pud) -{ - return pte_user(pud_pte(pud)); -} - static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud) { diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h index 10789cf51d16..8ffd64e7a24c 100644 --- a/include/asm-generic/pgtable-nopmd.h +++ b/include/asm-generic/pgtable-nopmd.h @@ -30,6 +30,8 @@ typedef struct { pud_t pud; } pmd_t; static inline int pud_none(pud_t pud) { return 0; } static inline int pud_bad(pud_t pud) { return 0; } static inline int pud_present(pud_t pud) { return 1; } +static inline int pud_user(pud_t pud) { return 0; } +static inline int pud_leaf(pud_t pud) { return 0; } static inline void pud_clear(pud_t *pud) { } #define pmd_ERROR(pmd) (pud_ERROR((pmd).pud)) -- 2.25.1