Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3597922imm; Mon, 2 Jul 2018 01:57:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLlR5ynGYvsRSpeOallaEsv1jlhdXFU+EJYqvhu3WhAi/lSMAonsxW/lGPJX/MrskDLG+wK X-Received: by 2002:a17:902:28ea:: with SMTP id f97-v6mr24233008plb.55.1530521843457; Mon, 02 Jul 2018 01:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530521843; cv=none; d=google.com; s=arc-20160816; b=H/WA1Rm8arG7hx8GKZRmPiIm+770+BQhXttchVGNXj7olcavEyvcoisnpl2yyl9GTb EMgAmpUpXQ5l0Me9aSg68+DO5vjcLSZufm1khJpZAbNfa99YjOOVLXVd37JKZVWUWqil WWkL5OBA+3Y9BIx41X33kz/El0v5wlXSfQXYLWggduAe5ZOnaYphk0rJiXrI6wI3sSyF opzF1n10iLqyYveRmLfleVlBTqwxq4Ae26REJb8SWIQI3OeGyqgMmivofJcLTh26ZR9p NcGYNoh8oINk3WlliEDYlkjTnCiJ/ocQl2yKJC22IKFBOZoe3M8AB/oPdLxHlEFsBong uMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=qkSYCQnl4szfkToSLTbLdnUsM4MfLkTxXhupY5bWHX8=; b=h4MUuXZsVsikaeGrfRnsv/zbKbj+rNUvok0N8hapNk0hJn99ZLLzoGmFwpSEApiFXU PA8hw7ze3OZq0whkwJgLNMW6JpzjzsrxwQ7UywqezPw5DJ9+6LR72+kKgC9B2xLXMxxB HY4dimr3jnrQ/TxzaHt9jFy3hpcuyX9o7eQbcR4nyVKVCkcPD8omVhcQ39R2/nNk0Y8E 14Nf4dAI2BhryY2PDxWLe8aOebd5eSJb14AxwSsqgWwHqJOhCZH7vrp8lmYZrskkVaeL 2kJUdbWfa+HSd/d++jSw5kug2FYL6eOvd0wKieBgmY7cU2KIvb8cln6NkIDiB8bSh3uQ EtMA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si13925948pgc.125.2018.07.02.01.57.06; Mon, 02 Jul 2018 01:57:23 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753855AbeGBH1J (ORCPT + 99 others); Mon, 2 Jul 2018 03:27:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40246 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753697AbeGBH1F (ORCPT ); Mon, 2 Jul 2018 03:27:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ABE1CB9D7; Mon, 2 Jul 2018 07:27:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-103.pek2.redhat.com [10.72.12.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84CA8178B7; Mon, 2 Jul 2018 07:26:59 +0000 (UTC) From: Lianbo Jiang To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, ebiederm@xmission.com, joro@8bytes.org, thomas.lendacky@amd.com, dyoung@redhat.com, kexec@lists.infradead.org, iommu@lists.linux-foundation.org, bhe@redhat.com Subject: [PATCH 2/5 V5] Allocate pages for kdump without encryption when SME is enabled Date: Mon, 2 Jul 2018 15:26:36 +0800 Message-Id: <20180702072639.10110-3-lijiang@redhat.com> In-Reply-To: <20180702072639.10110-1-lijiang@redhat.com> References: <20180702072639.10110-1-lijiang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 07:27:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 07:27:05 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lijiang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When SME is enabled in the first kernel, we will allocate pages for kdump without encryption in order to be able to boot the second kernel in the same manner as kexec, which helps to keep the same code style. Signed-off-by: Lianbo Jiang --- Some changes: 1. remove some redundant codes for crash control pages. 2. add some comments. kernel/kexec_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 23a83a4..e7efcd1 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -471,6 +471,16 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image, } } + if (pages) { + /* + * For kdump, we need to ensure that these pages are + * unencrypted pages if SME is enabled. + * By the way, it is unnecessary to call the arch_ + * kexec_pre_free_pages(), which will make the code + * become more simple. + */ + arch_kexec_post_alloc_pages(page_address(pages), 1 << order, 0); + } return pages; } @@ -867,6 +877,7 @@ static int kimage_load_crash_segment(struct kimage *image, result = -ENOMEM; goto out; } + arch_kexec_post_alloc_pages(page_address(page), 1, 0); ptr = kmap(page); ptr += maddr & ~PAGE_MASK; mchunk = min_t(size_t, mbytes, @@ -884,6 +895,7 @@ static int kimage_load_crash_segment(struct kimage *image, result = copy_from_user(ptr, buf, uchunk); kexec_flush_icache_page(page); kunmap(page); + arch_kexec_pre_free_pages(page_address(page), 1); if (result) { result = -EFAULT; goto out; -- 2.9.5