Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4523929ybv; Mon, 17 Feb 2020 00:35:00 -0800 (PST) X-Google-Smtp-Source: APXvYqygilJny8GZ51E5owiY9fabQYmAZVmSRFa6zvYnPovjVUBYlqbmMn2oORmfcarG5q2ydaRY X-Received: by 2002:a9d:67d7:: with SMTP id c23mr11391096otn.262.1581928500457; Mon, 17 Feb 2020 00:35:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581928500; cv=none; d=google.com; s=arc-20160816; b=BbobtdHsIUjLkZQ7EfdE2xWXoTffOtNjcDF8MPV9SjhK14ey56mWG2LZwZ8rgQ5yBG hPToUhgVDswEngny5lj2kf39kf/y8u5KmnRP7FeqBYsqe9idfbKdJ2tI6p4tQZuNTqYn LDxLskQbCL3rM6Ppz+hHG+ximQRhEg/j92mXmRhwzNsO19i6vNHwiV7hYMqFVZxGewMW LY/yBRKy0IFnaRgnNzHwdBZmDHk5lWvE9B8hYhGMlA0uK9rvn+k721rryjL0UP60hIVS kUL5GxQ5Y0XAUUc7QV+VUGvlb0cQb5HvPnMqEA+k/cZ4IspXehPvtkf59IG5h3LAyUsu XIXw== 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=fmRXlNLWA66QEXzOsB4SiGAg688bm55gcoXcA+osGcg=; b=J8pF+/QnskO2jEexL3pIu8VJPz590xyhOuu3qpPV2jwkspn6CWJrcsiNj+Qsp13zx4 3wieeHQ31/lYGBwH08etEyWeh3Ay2G/+3jhsdFD4UaaV4O9pehnWn7Zbbas0Zb7crxj1 xIKyYJM+0wRt0HaeRgd6jITNzbmnjDtsIAqAZdH3NfmP/4ZkxTCEaTu1duiKOK2qnzL/ NxB9GZBqGPmMYk3vt8HbeM2XvMEs27qngCCOzqxoUbBvS087jBZVwtDPu6n3ajdx7mEW 2byyahmhamQkJptH2YW7uoW5000J9vY5GWZXgcUZQqMctdWgpcjYIfPrTJkACP1+Sdhq jCFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=IUirukFw; 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 k128si6409505oih.274.2020.02.17.00.34.46; Mon, 17 Feb 2020 00:35:00 -0800 (PST) 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=IUirukFw; 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 S1728448AbgBQIc7 (ORCPT + 99 others); Mon, 17 Feb 2020 03:32:59 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41421 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbgBQIce (ORCPT ); Mon, 17 Feb 2020 03:32:34 -0500 Received: by mail-pf1-f194.google.com with SMTP id j9so8431016pfa.8 for ; Mon, 17 Feb 2020 00:32:34 -0800 (PST) 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=fmRXlNLWA66QEXzOsB4SiGAg688bm55gcoXcA+osGcg=; b=IUirukFwdTH2JYN3UHnCoo0xSkpYjWzQiS46cwG+hnudFzmLHkzzCo69fQwm020L7I YPsBdfIUfOfK15SP3frTDbrkoT0zSf6OORP+Rc+AX/dvOj0bn39D6xK6hNXTuNE1eu5U 0BvCTNuD7Dfde9cqHOdhUn5Jf4f6O/9iUEClIMnfDDBmYy+CRhllzS8JaWsyklDfFDfr 8ZVfNmkCz08xs8qBsuz/d592ISch4tfyoN1Vm2kuEty36Dj5UIPSYkA2iiV0VI0EuJ+Q xXuN6aDYQbFtOe0/wjvuIJg1DZ7K8mTC+6ZAlDzw1iGhfhs/lXxI6lWrENRcM1oUsyJO 8hyw== 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=fmRXlNLWA66QEXzOsB4SiGAg688bm55gcoXcA+osGcg=; b=E82pI6rsX8iVMR75I82Fz/FzghEyhJrAUdLdbQ/Xa4Yjmr3FxlJTZtKJFO/RE2SG8M KU7lkypRr/JItmfEuN8TqoxdOh42shIf4XlzlE6tkaRW7P3O21E054+vgUfmTIjoZbFk RoGc67jKvelauxMtCkCzs6L0Ive8gR7/qzgGy1/HsaxolQM5meY20ZnY15j+ZTk+kflw v0ohjO5JFTT+BF3ZS384xGaacl7rDLAULIS+r7+LpvejnDqL5HYkOfD56T5gZ3TwvSPo TPPvh/+OaWLS/utv3QKddlON/vlgszULMXUzZ70/ZW6PS54SzgMLNKD3OZhgTCMDpmkg Ve+Q== X-Gm-Message-State: APjAAAXK3bgRL6zkZIVz171RzIXQA7Qj8/fqVAD4rnomQYCyWRNH2+Ao zVagZ4yjniISayXoeBsAt38OQQ== X-Received: by 2002:a63:c341:: with SMTP id e1mr17315588pgd.334.1581928354167; Mon, 17 Feb 2020 00:32:34 -0800 (PST) Received: from hsinchu02.internal.sifive.com (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id z10sm16989319pgz.88.2020.02.17.00.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 00:32:33 -0800 (PST) From: Zong Li To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH 3/8] riscv: add ARCH_SUPPORTS_DEBUG_PAGEALLOC support Date: Mon, 17 Feb 2020 16:32:18 +0800 Message-Id: <20200217083223.2011-4-zong.li@sifive.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217083223.2011-1-zong.li@sifive.com> References: <20200217083223.2011-1-zong.li@sifive.com> 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 --- 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 07bf1a7c0dd2..f524d7e60648 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.25.0