From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751250AbeAWKEl (ORCPT ); Tue, 23 Jan 2018 05:04:41 -0500 Received: from foss.arm.com ([217.140.101.70]:39116 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154AbeAWKEj (ORCPT ); Tue, 23 Jan 2018 05:04:39 -0500 Date: Tue, 23 Jan 2018 10:04:47 +0000 From: Will Deacon To: Yisheng Xie Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ard.biesheuvel@linaro.org, sboyd@codeaurora.org, dave.hansen@linux.intel.com, keescook@chromium.org, msalter@redhat.com, labbott@redhat.com, tglx@linutronix.de Subject: Re: [PATCH v3 11/20] arm64: mm: Map entry trampoline into trampoline and kernel page tables Message-ID: <20180123100447.GB1686@arm.com> References: <1512563739-25239-1-git-send-email-will.deacon@arm.com> <1512563739-25239-12-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 04:28:45PM +0800, Yisheng Xie wrote: > On 2017/12/6 20:35, Will Deacon wrote: > > +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 > > +static int __init map_entry_trampoline(void) > > +{ > > + extern char __entry_tramp_text_start[]; > > + > > + pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; > > + phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start); > > + > > + /* The trampoline is always mapped and can therefore be global */ > > + pgprot_val(prot) &= ~PTE_NG; > > + > > + /* Map only the text into the trampoline page table */ > > + memset(tramp_pg_dir, 0, PGD_SIZE); > > + __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE, > > + prot, pgd_pgtable_alloc, 0); > > How the tramp_pg_dir is used, should it be set to ttbr1 when exit kernel? Sorry > for I do not find where it is used. Yes, that's what happens when we return to userspace. The code is a little convoluted, but the tramp_pg_dir is placed at a fixed offset from swapper (see the linker script) so the sub instruction in tramp_unmap_kernel is what gives us the ttbr1 value we need. Will