From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752297AbdHHSET (ORCPT ); Tue, 8 Aug 2017 14:04:19 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:34349 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbdHHSES (ORCPT ); Tue, 8 Aug 2017 14:04:18 -0400 Subject: Re: [PATCH] lib: Add test module for CONFIG_DEBUG_VIRTUAL To: "Luis R. Rodriguez" , Juergen Gross Cc: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org, labbott@redhat.com, Andrew Morton , "Paul E. McKenney" , Kees Cook , Ingo Molnar , "David S. Miller" , Peter Zijlstra , Geert Uytterhoeven , Nicholas Piggin , Olof Johansson , "Jason A. Donenfeld" , "Theodore Ts'o" , Thomas Gleixner , Josh Poimboeuf , Andy Shevchenko , Bart Van Assche , Matthew Wilcox , Al Viro , Jiri Pirko , Jeff Layton References: <20170808164035.26725-1-f.fainelli@gmail.com> <20170808175708.GR27873@wotan.suse.de> From: Florian Fainelli Message-ID: Date: Tue, 8 Aug 2017 11:04:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170808175708.GR27873@wotan.suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/08/2017 10:57 AM, Luis R. Rodriguez wrote: > On Tue, Aug 08, 2017 at 09:40:26AM -0700, Florian Fainelli wrote: >> Add a test module that allows testing that CONFIG_DEBUG_VIRTUAL works >> correctly, at least that it can catch invalid calls to virt_to_phys() >> against the non-linear kernel virtual address map. >> >> Signed-off-by: Florian Fainelli >> --- >> +static int __init test_debug_virtual_init(void) >> +{ >> + phys_addr_t pa; >> + void *va; >> + >> + va = (void *)VMALLOC_START; >> + pa = virt_to_phys(va); >> + >> + pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); >> + >> + foo = kzalloc(sizeof(*foo), GFP_KERNEL); >> + if (!foo) >> + return -ENOMEM; >> + >> + pa = virt_to_phys(foo); >> + va = foo; >> + pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); > > Should there be a tests here of some sort? When should this fail, why? There is no test per-se, the kernel will produce warning with CONFIG_DEBUG_VIRTUAL telling you that what you are doing is wrong. > There is no docs on this self test, could one be added? I suppose I could add one even though that just means pointing out the code that produces the warning? -- Florian