Received: by 10.223.176.46 with SMTP id f43csp4006823wra; Tue, 23 Jan 2018 02:45:17 -0800 (PST) X-Google-Smtp-Source: AH8x226E1lwa1Y1WkB86VzP28Jp3nUpVa6nZcTCt/LctTajUZ6hRaVScZP9FJTtQWTo1udze2DB/ X-Received: by 2002:a17:902:4:: with SMTP id 4-v6mr5155448pla.187.1516704317605; Tue, 23 Jan 2018 02:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516704317; cv=none; d=google.com; s=arc-20160816; b=NA6rQBcPXoRb7EpKPyQZyYmntImegQPyuiCPGXASzxP6f1goLGJHWkOX2FOh8x9xhb kaaxtGp1GODvH5dsOrURkBHrpvq+gffJ1CZC9uiRhTIsKJ0bBYsKxFSSly/1hAzZEtt6 jVTTY/kTWEJFnYlinAWWzDXpf++GbtIuJY9RcdJlD5hFL8Bge745YBXwnUp8LIWYkQru XHh0BJMfQi2VGQzEIUmgr75PbkNUMoS9F5Mhn+Rhsb4YPzTSUYQTBce9a/WCGzO/A3pi Ur8C8rnQ2M3veineCvTASBmsae179n613M09seU0g90iSY/eSr6FbM1KmOVs23/a2xN2 7sHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=5X+Pobc0N08A2Dj+bkST8DabWaOQmXHMlM4pT4+rGJs=; b=V6HCvl/Z7iOx251msRHcYN+mgu/h77fN4CJXlWOHyNaZLKUak3hwJG2ajK2Myq+T5K UB46eH65lwJ08LQnnzENwHxapKMoZkY13B59g1tMKs5BH+hFc8yTDEBhrh09rP+noC2B 8eFGEUrbR6yNSfhCIXRqx8Ob4YZIpejYJJyX4Znk6wi4XtfeXK6KhNWooj+mM8XLvFmD zdopRae1fUhtvXM78Kc9seF5yP3NaKTsTn/12XLXhOpAM9pSR3abGE1ruSAsfbrekSoi Kka5qkgxPU9GXhorXWSE+Hh1KlCfTKXb/ylr/tP11gmxTtkZgyiLMxe5WK3d9bVlsNhI vaiw== 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 f20-v6si4551750plj.727.2018.01.23.02.45.03; Tue, 23 Jan 2018 02:45:17 -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 S1751443AbeAWKo0 (ORCPT + 99 others); Tue, 23 Jan 2018 05:44:26 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:4677 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751255AbeAWKoY (ORCPT ); Tue, 23 Jan 2018 05:44:24 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6ADA99E61D151; Tue, 23 Jan 2018 18:44:10 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Tue, 23 Jan 2018 18:44:11 +0800 Subject: Re: [PATCH v3 11/20] arm64: mm: Map entry trampoline into trampoline and kernel page tables To: Will Deacon References: <1512563739-25239-1-git-send-email-will.deacon@arm.com> <1512563739-25239-12-git-send-email-will.deacon@arm.com> <20180123100447.GB1686@arm.com> CC: , , , , , , , , , , From: Yisheng Xie Message-ID: <09b4f791-241d-61f5-a6b5-889021a83fe4@huawei.com> Date: Tue, 23 Jan 2018 18:43:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20180123100447.GB1686@arm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, On 2018/1/23 18:04, Will Deacon wrote: > 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. oh, I missed that. Maybe a comment inline is better to understand. Thanks once more for your help and explain :) Thanks Yisheng > > Will > > . >