Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753854AbbFCIpA (ORCPT ); Wed, 3 Jun 2015 04:45:00 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:51045 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752984AbbFCIoy (ORCPT ); Wed, 3 Jun 2015 04:44:54 -0400 X-AuditID: cbfec7f5-f794b6d000001495-7c-556ebe84d41e Message-id: <556EBE81.4030408@samsung.com> Date: Wed, 03 Jun 2015 11:44:49 +0300 From: Andrey Ryabinin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-version: 1.0 To: Ingo Molnar , Alexander Popov Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrey Konovalov , Andrew Morton , Kees Cook , "Peter Zijlstra (Intel)" , Andy Lutomirski , Alexander Kuleshov , Borislav Petkov , Denys Vlasenko , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/1] x86_64: fix KASan shadow region page tables References: <1433249837-7096-1-git-send-email-alpopov@ptsecurity.com> <20150603074427.GA1598@gmail.com> In-reply-to: <20150603074427.GA1598@gmail.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRmVeSWpSXmKPExsVy+t/xq7ot+/JCDbZNZ7H4vXcmq8Wc9WvY LKbv6GO3mNivaXH++yF2i2kbxS3OdOdarN/5md3i8q45bBar1zawWqz+d4rR4tKBBUwWx3sP MFls3jSV2eLHhsesDvwe99/8ZfGY3XCRxWPnrLvsHptXaHlsWtXJ5vHu3Dl2jxMzfrN4bH80 lcXj/b6rbB6bT1d7fN4k53Gi5QtrAE8Ul01Kak5mWWqRvl0CV8afk7cYCz6IVLzp28zewHhQ sIuRk0NCwESi68VeFghbTOLCvfVsXYxcHEICSxklHu49ygThfGeU+Hu9mxWkildAS2LejBVg NouAqsTelU8YQWw2AT2Jf7O2s4HYogIREm8vn2SCqBeU+DH5HtgGEQEfibk71oHVMws8YZY4 1RAAYgsLuEucf/4SrF5IIFNiYv9l5i5GDg5OoJlvHuiDmMxA5v2LWhCd8hKb17xlnsAoMAvJ glkIVbOQVC1gZF7FKJpamlxQnJSea6RXnJhbXJqXrpecn7uJERJtX3cwLj1mdYhRgINRiYd3 RkReqBBrYllxZe4hRgkOZiURXpPdQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8M3e9DxESSE8s Sc1OTS1ILYLJMnFwSjUwBt2YJtsc+eKg9ellF9UCXUqfqioUTjswSf2M/druDKFru3+HS4bs PBrM7lWxv3Fn9ul1nI4/3KYe+6gh/uAU4+OQ8s8nuvik3wV7ul0yOjxv5Z+Cvu4rojGMuSVC 831qlvy7YR7IpruRb9Wy5x8N5x4PnH8856D5zrVbKuuKv1jycd1p5Fy1SomlOCPRUIu5qDgR AIzQ252yAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2843 Lines: 79 On 06/03/2015 10:44 AM, Ingo Molnar wrote: > > * Alexander Popov wrote: > >> #ifdef CONFIG_KASAN >> void __init kasan_map_early_shadow(pgd_t *pgd); >> +void __init kasan_early_init(void); >> void __init kasan_init(void); >> #else >> static inline void kasan_map_early_shadow(pgd_t *pgd) { } >> +static inline void kasan_early_init(void) { } >> static inline void kasan_init(void) { } >> #endif >> >> diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c >> index 2b55ee6..e9a84a1 100644 >> --- a/arch/x86/kernel/head64.c >> +++ b/arch/x86/kernel/head64.c >> @@ -161,11 +161,15 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) >> /* Kill off the identity-map trampoline */ >> reset_early_page_tables(); >> >> - kasan_map_early_shadow(early_level4_pgt); >> - >> - /* clear bss before set_intr_gate with early_idt_handler */ >> + /* >> + * Clear bss before kasan_early_init and set_intr_gate >> + * with early_idt_handler >> + */ >> clear_bss(); >> >> + kasan_early_init(); >> + kasan_map_early_shadow(early_level4_pgt); > > So why isn't kasan_map_early_shadow() called in kasan_early_init()? > > High level x86 init code should not be polluted with too many low level details. > Agreed. Eventually, with the patch bellow, we could get rid of the second kasan_map_early_shadow(init_level4_pgt) call in x86_64_start_kernel(). Make it static, and call it from kasan_early_init() only. ------------------------------------------------------ From: Andrey Ryabinin Subject: [PATCH] x86_64: remove not needed clear_page for init_level4_page Commit 8170e6bed465 ("x86, 64bit: Use a #PF handler to materialize early mappings on demand") introduced clear_page(init_level4_pgt); call in x86_64_start_kernel(). However, this clear_page is useless because init_level4_page already filled with zeroes in head_64.S Commit message in 8170e6bed465 says that this clear_page() was dropped in v7, but it accidentally reappeared in later versions of that patchset. Signed-off-by: Andrey Ryabinin --- arch/x86/kernel/head64.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 5a46681..6a6eefd 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -177,7 +177,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) */ load_ucode_bsp(); - clear_page(init_level4_pgt); /* set init_level4_pgt kernel high mapping*/ init_level4_pgt[511] = early_level4_pgt[511]; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/