Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp825650ybz; Wed, 29 Apr 2020 10:03:36 -0700 (PDT) X-Google-Smtp-Source: APiQypLpdgtXuwpfJYgQ56Oa1rO3Hk7YbTeBzvzjJq4pFdENtgG4Zcb0OWYZl1eSsEnZYoN8Rart X-Received: by 2002:aa7:d513:: with SMTP id y19mr3468146edq.367.1588179816155; Wed, 29 Apr 2020 10:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588179816; cv=none; d=google.com; s=arc-20160816; b=r/9/w3JrBjbctGncxbEkC28Oy27qD3ain132hvc4RSok4/HEHeWOTLFS2CmkjK1e4O udyvc96a0f8jOsHooWbHYQ4W9AQ1vDyqb7PJJwXcCw3HCpqn7AvGZvfQJMEjsZjR1Au1 L17GGOMXRj0SZ7r1Nlbgc9zQFaO4Iqo60PtHqbWTCHETl1ehseJtJ78pOrN1lEDtHea3 BewrB1cjcvqj8CYC5MkzKMoZiZqB9ZJt+ALH6T5P8vxQvHsSWzRdlxlO7P+ctSK5oMil ZVi7duz1TlpNTU3oVuq4yLJfSm41QFGLWbgqi0xr1IHaogmLJjRd72h3ZEDREM0+UJQU +TTg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:cc:from:references:to:subject; bh=TG3BF2v2B5MTlZ7YUI5/eMbDwsbX7nukGh2RxPbdkeg=; b=sRhIi+bH7OY6UzUhu0IHro11LyamPp5cZugPje0fDXTQRW1QVxm8uZ8mcsDMjhTCqr t86TNA09SzMNreG4hTrDXbTROMJSvf+Bz24BiEVDpINuR4dDdAvDQpPRsfFihVTRWCFm wfj3CNF+LlELG9hdTPG41Wu/MBlLnNkT8H0/vaqyBp9s12gLnm9Ux4xcvBhySXyRmzOl w20PCtC2j1cAN0FsXDKuAHFSPHl8roKVAcSE/jTRoAUprl/mF/5k/AEoW40t7+VUiuM7 3ZN2+l6AezY3etkmvfwR9bQA/DvdyMshimNU4+pmnUQ0F7iVk0kLvWew+0yNvvASp8nM Ot7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si3696847edp.0.2020.04.29.10.03.11; Wed, 29 Apr 2020 10:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbgD2RBI (ORCPT + 99 others); Wed, 29 Apr 2020 13:01:08 -0400 Received: from foss.arm.com ([217.140.110.172]:42362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbgD2RBH (ORCPT ); Wed, 29 Apr 2020 13:01:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D65C91045; Wed, 29 Apr 2020 10:01:06 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE83A3F73D; Wed, 29 Apr 2020 10:01:03 -0700 (PDT) Subject: Re: [PATCH v9 03/18] arm64: trans_pgd: make trans_pgd_map_page generic To: Pavel Tatashin References: <20200326032420.27220-1-pasha.tatashin@soleen.com> <20200326032420.27220-4-pasha.tatashin@soleen.com> From: James Morse Cc: jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com Message-ID: Date: Wed, 29 Apr 2020 18:01:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200326032420.27220-4-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, On 26/03/2020 03:24, Pavel Tatashin wrote: > kexec is going to use a different allocator, so make > trans_pgd_map_page to accept allocator as an argument, and also > kexec is going to use a different map protection, so also pass > it via argument. This trans_pgd_map_page() used to be create_single_mapping() It creates page tables that map one page: the relocation code. Why do you need a different pgprot? Surely PAGE_KERNEL_EXEC is exactly what you want. > diff --git a/arch/arm64/include/asm/trans_pgd.h b/arch/arm64/include/asm/trans_pgd.h > index 23153c13d1ce..ad5194ad178d 100644 > --- a/arch/arm64/include/asm/trans_pgd.h > +++ b/arch/arm64/include/asm/trans_pgd.h > @@ -12,10 +12,24 @@ > #include > #include > > +/* > + * trans_alloc_page > + * - Allocator that should return exactly one zeroed page, if this > + * allocator fails, trans_pgd returns -ENOMEM error. trans_pgd is what you pass in to trans_pgd_map_page() or trans_pgd_create_copy(). Do you mean what those functions return? > + * > + * trans_alloc_arg > + * - Passed to trans_alloc_page as an argument > + */ > diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c > index 3d6f0fd73591..607bb1fbc349 100644 > --- a/arch/arm64/kernel/hibernate.c > +++ b/arch/arm64/kernel/hibernate.c > @@ -195,6 +200,11 @@ static int create_safe_exec_page(void *src_start, size_t length, > unsigned long dst_addr, > phys_addr_t *phys_dst_addr) > { > + struct trans_pgd_info trans_info = { > + .trans_alloc_page = hibernate_page_alloc, > + .trans_alloc_arg = (void *)GFP_ATOMIC, > + }; As you need another copy of this in the next patch, is it worth declaring this globally and making it const? > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c > index d20e48520cef..275a79935d7e 100644 > --- a/arch/arm64/mm/trans_pgd.c > +++ b/arch/arm64/mm/trans_pgd.c > @@ -180,8 +185,18 @@ int trans_pgd_create_copy(pgd_t **dst_pgdp, unsigned long start, > return rc; > } > > -int trans_pgd_map_page(pgd_t *trans_pgd, void *page, unsigned long dst_addr, > - pgprot_t pgprot) > +/* > + * Add map entry to trans_pgd for a base-size page at PTE level. > + * info: contains allocator and its argument > + * trans_pgd: page table in which new map is added. > + * page: page to be mapped. > + * dst_addr: new VA address for the pages ~s/pages/page/ This thing only maps one page. > + * pgprot: protection for the page. > + * > + * Returns 0 on success, and -ENOMEM on failure. > + */ > +int trans_pgd_map_page(struct trans_pgd_info *info, pgd_t *trans_pgd, > + void *page, unsigned long dst_addr, pgprot_t pgprot) > { > pgd_t *pgdp; > pud_t *pudp; Thanks, James