Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp359665ybb; Wed, 8 Apr 2020 00:59:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLWRnpoBmNXgORA+fnP12w6MevWG/8cBBJMQU7tSOG2xy1YVsjJnn3CmTxKRWmuMU6xod8D X-Received: by 2002:aca:b7c1:: with SMTP id h184mr1536198oif.77.1586332760379; Wed, 08 Apr 2020 00:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586332760; cv=none; d=google.com; s=arc-20160816; b=SBoRXYaSgclsW7YG3P6RROfaw5nHKI8L2V6Xzytka2XVicq9cyBhhXg8QuCBQl+JSO KcTid3+OZid9VoyvwPcNhKRye4Ma/dGr5BBBxeN23Mr0hkvJGygjPBzlqvvSrF9fk4Hd /kILqv9gUtdbc9b/wMlTaMRfBsyclGsWPSq8f4Kf+rPh1kPRqIdbmWHKOut1xpHw8gWq 32VUwO/KmcFJiWdWjbrTeEnoj8INDQj4rR0byrqLPViavLyX7d+whO3D7rJL6CE2uuSS VBXrd9Pt+NlI/qpdbWXNMs9E3n2usMN/LVfUvl6+xv1Oj/95adBeAMcJNZWQxJeyNDfE RzFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v9zl9wdVM8GEYtYil3Mhwjs87sA3d02fBbOSD/V/2Io=; b=nhpNhc3yBwcaRSXmHh1EOmOF1eF9RhOh3a+FZKDBL5v+cAYGbQy46JpAGRiKQNqdqU 6pa8Sk/jSPiaIOLQBIpFLfOc8W1QA9Ta7kCCGlMP9TampKk9LLH3hAWkUSd2fpqhb6/2 +rKP1D8C0YdhF83G/egCY+LrgHhbxfHhcJ9oKxXOyFRP5W6PyMvZWQrer7+4RV9tg0+i rGy97kUP8O10KdJAGMXrblDEG3wJWpPVhHDR8t/ehdzj0rq1N//K/gDxskNaXoxMiQyk WDyaaflp7HJyHTRh2PczPjxusnb712suQWFKcpTsSyr992GF8GHUfxPZx0lZGtt6bu0k eFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=U7G20s6L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63si1736089oib.217.2020.04.08.00.59.06; Wed, 08 Apr 2020 00:59:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=U7G20s6L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbgDHH5X (ORCPT + 99 others); Wed, 8 Apr 2020 03:57:23 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:34241 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgDHH5W (ORCPT ); Wed, 8 Apr 2020 03:57:22 -0400 Received: by mail-pj1-f68.google.com with SMTP id q16so1953379pje.1 for ; Wed, 08 Apr 2020 00:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v9zl9wdVM8GEYtYil3Mhwjs87sA3d02fBbOSD/V/2Io=; b=U7G20s6LmTf2LuYfnrXDNYEjXHb9WEsy956inSxRQMo/VA6l9qWdgAo0dEbehYjLYD f5E2WmGKWxTZ/YFKy5cJ2nJCMcOHestOXgrl8JHnYc6uOLdJMD66pzAkhMoz0lXMJa1a q6Sd93eJ5SmSFiJQR2GnbVljhf0cUURmRBg2OIVfpRGKqhHY6oA0yOci57cIypYhU94D KQViqVTTVemVaSYG2zoGoljdEnt4pnHr8w+Avu8mP8JIeNAYm12aAVJ+P5t/mLZGbxTk ky/UBHaVirsmaCNTa+FVw3OV3jfW5Xa2HRerKbZmZibpXXzOtY/bXT0OyuTQyV6liYO2 rGmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v9zl9wdVM8GEYtYil3Mhwjs87sA3d02fBbOSD/V/2Io=; b=pGqDQnhxiJIG5j/+SUxfhpKLMU2RB30W8aMRITBFbC1HKHLM6pDAjPC/KJcb+ry/0B 2JlIvN8SUoNBQ7nkSSEfLTCS42pvThDQLmcKHwEXQciZsUxX3Spaig01frbs1Q2gn/lh XrrcPpy28YqQJAruqyuVEpv+bx8brUL51rTpSXvOyNwVPLr3d5jkGwEeiSjQZH4iwtNR m8hjtr2aoqmIWSasK3dSsU7IVv3xy/x09qZ+rFwusZhfUmzPcVnE9nXLVnkJcRbbKnMe ih3XpJXf7fFFWuv5MPih2a+kAeLi0Zc9EDhbcxYdBna8mBdR/pFk772CZDa7PBKxlGMC aAkA== X-Gm-Message-State: AGi0Pub9V1EsI7Bht+VwlW/LFCPNlZVrtAHB6vXO7k/pHH7GeZBEOXlH MaDeglFlR47JLMC527Rm/a2+XA== X-Received: by 2002:a17:90a:db54:: with SMTP id u20mr3902925pjx.140.1586332640815; Wed, 08 Apr 2020 00:57:20 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id d85sm485599pfd.157.2020.04.08.00.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 00:57:20 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, mhiramat@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li , Palmer Dabbelt Subject: [PATCH v5 6/9] riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support Date: Wed, 8 Apr 2020 15:57:01 +0800 Message-Id: <15fce3374de4978c4541beaab8216bf0f84ca72d.1586332296.git.zong.li@sifive.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ARCH_SUPPORTS_DEBUG_PAGEALLOC provides a hook to map and unmap pages for debugging purposes. Implement the __kernel_map_pages functions to fill the poison pattern. Signed-off-by: Zong Li Reviewed-by: Palmer Dabbelt --- arch/riscv/Kconfig | 3 +++ arch/riscv/mm/pageattr.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a94d0f064d9c..1e1efc998baf 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -132,6 +132,9 @@ config ARCH_SELECT_MEMORY_MODEL config ARCH_WANT_GENERAL_HUGETLB def_bool y +config ARCH_SUPPORTS_DEBUG_PAGEALLOC + def_bool y + config SYS_SUPPORTS_HUGETLBFS def_bool y diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c index 7be6cd67e2ef..728759eb530a 100644 --- a/arch/riscv/mm/pageattr.c +++ b/arch/riscv/mm/pageattr.c @@ -172,3 +172,16 @@ int set_direct_map_default_noflush(struct page *page) return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); } + +void __kernel_map_pages(struct page *page, int numpages, int enable) +{ + if (!debug_pagealloc_enabled()) + return; + + if (enable) + __set_memory((unsigned long)page_address(page), numpages, + __pgprot(_PAGE_PRESENT), __pgprot(0)); + else + __set_memory((unsigned long)page_address(page), numpages, + __pgprot(0), __pgprot(_PAGE_PRESENT)); +} -- 2.26.0