Received: by 10.223.176.46 with SMTP id f43csp3971979wra; Tue, 23 Jan 2018 02:05:22 -0800 (PST) X-Google-Smtp-Source: AH8x224dJiIImMcnqjo6xdcwa+iCTTck0jnty1UR7Wc1ZXIB1nQmu/h0nhm4wxpr9QGTwfdUGb7b X-Received: by 2002:a17:902:b094:: with SMTP id p20-v6mr5243886plr.391.1516701922568; Tue, 23 Jan 2018 02:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516701922; cv=none; d=google.com; s=arc-20160816; b=xmi818aX5co/MWJCyrG91L9zR0eTY5RSAxcU0SRBOqApJcu6uPVnth+OatYrypNWOQ JzK3+8K0+OLTFUwure+6ngVG/kohElPakOvVrcfxI9pJTt/fDpsKg1ht8Jdee7Ayw9zY 77IymmXG4XUupRE3xLWDsygvIO4Tw6nchpSMtpx1IYY9tQCCZVlNgMpNIkA6zA1NbMS3 apxXVWl2rqa2mfJeb7WWoSnVA8rQ+QslIIfauTrFa2jPWILxF+xdYs9eMIhWgVEHu+3X 0+1Yn15+fG5z5j87AfV8QwPETgQERYbnfzc+NBsj2GLACzPknwxk40Ri5vfNTTygqJ5H wr+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ttYLGuOM8RxLlKd2WjH1v5N6o5X9gDlFGSCVc45FUUo=; b=lVrKF7bKBgtfPu6piZD5qZXC3yKCMleqRwBTv3EICrrjtqCq+TObkZigfdWEpb0K+E y2pVFOMZQcFNTyIPEjXq9W8sSGevmGTWQQx9sCB/3vrTj6PIfpU8KzAXLgFlG8YBqN6R 8zfR2R5IKgnl+OLTkzIgFOmycfY6PQOxK6YYZ777JNt1YOk4bO/QHw8H7kEpWjhZVyKN VG8+8gfBEE63fWC11d1+p4hAcvdPWUCqMd/sRi8yv3FH1xVsMPiN9shUspehAnGC96Fm NSYtWcNlAzjKtT+LSJ9aB13d3Ake3AxZNHCzl0uUizEn4tbjCiK7/4/4KKo73xSzd6oq 8PHg== ARC-Authentication-Results: i=1; mx.google.com; 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 i1si1273091pfa.58.2018.01.23.02.05.07; Tue, 23 Jan 2018 02:05:22 -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; 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 S1751246AbeAWKEk (ORCPT + 99 others); Tue, 23 Jan 2018 05:04:40 -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 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98CA180D; Tue, 23 Jan 2018 02:04:39 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6988F3F41F; Tue, 23 Jan 2018 02:04:39 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id ACC8F1AE301C; Tue, 23 Jan 2018 10:04:47 +0000 (GMT) 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 Precedence: bulk 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