From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbdJaWeR (ORCPT ); Tue, 31 Oct 2017 18:34:17 -0400 Received: from mga01.intel.com ([192.55.52.88]:35207 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932945AbdJaWcQ (ORCPT ); Tue, 31 Oct 2017 18:32:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,326,1505804400"; d="scan'208";a="1237918432" Subject: [PATCH 16/23] x86, kaiser: map debug IDT tables To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, dave.hansen@linux.intel.com, moritz.lipp@iaik.tugraz.at, daniel.gruss@iaik.tugraz.at, michael.schwarz@iaik.tugraz.at, luto@kernel.org, torvalds@linux-foundation.org, keescook@google.com, hughd@google.com, x86@kernel.org From: Dave Hansen Date: Tue, 31 Oct 2017 15:32:15 -0700 References: <20171031223146.6B47C861@viggo.jf.intel.com> In-Reply-To: <20171031223146.6B47C861@viggo.jf.intel.com> Message-Id: <20171031223215.4875ED48@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IDT table it references are another structure where the CPU references a virtual address. It also obviously needs these to handle an interrupt in userspace, so these need to be mapped into the user copy of the page tables. Signed-off-by: Dave Hansen Cc: Moritz Lipp Cc: Daniel Gruss Cc: Michael Schwarz Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Kees Cook Cc: Hugh Dickins Cc: x86@kernel.org --- b/arch/x86/mm/kaiser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff -puN arch/x86/mm/kaiser.c~kaiser-user-map-trace-and-debug-idt arch/x86/mm/kaiser.c --- a/arch/x86/mm/kaiser.c~kaiser-user-map-trace-and-debug-idt 2017-10-31 15:03:57.365444956 -0700 +++ b/arch/x86/mm/kaiser.c 2017-10-31 15:03:57.368445098 -0700 @@ -250,6 +250,14 @@ int kaiser_add_user_map_ptrs(const void flags); } +static int kaiser_user_map_ptr_early(const void *start_addr, unsigned long size, + unsigned long flags) +{ + int ret = kaiser_add_user_map(start_addr, size, flags); + WARN_ON(ret); + return ret; +} + /* * Ensure that the top level of the (shadow) page tables are * entirely populated. This ensures that all processes that get @@ -331,6 +339,10 @@ void __init kaiser_init(void) sizeof(gate_desc) * NR_VECTORS, __PAGE_KERNEL_RO); + kaiser_user_map_ptr_early(&debug_idt_table, + sizeof(gate_desc) * NR_VECTORS, + __PAGE_KERNEL); + /* * We could theoretically do this in setup_fixmap_gdt(). * But, we would need to rewrite the above page table _