Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1526262imm; Fri, 7 Sep 2018 01:36:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdagNKVxKBBGTz3ZlvA2DcYwg6ogLy78x3yVTJaMs/R386r+in4MehGqOMXofUs/tdlYuy3u X-Received: by 2002:a62:5ec3:: with SMTP id s186-v6mr7373802pfb.146.1536309383551; Fri, 07 Sep 2018 01:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536309383; cv=none; d=google.com; s=arc-20160816; b=Fa84fRzbNg+exCp4VM5B3iNeiXf9YgEDiPp13n/HZ9sp022GOCL5S3IOFJrpyCMMeS RY88RTdx0zI39fy6YGVkZ9uv1RLUW7axqCaSVjmjxp/zcscPI3tZL81ccsjODihggian Jf8XGWK7lAngvRiba2sO6KX0u4iwzKcijQQ+OHyr5aW64sFZ0Ap8r7bqTIZgSm2VPpIE e47zD3gVftqDi9vJpBCrMmfOo148XaYBxQr4JK7fO3RU550Dvay1f7rgrfDWzn95DWc0 RPgess9nvUKHq9/jG49kehBXEZOkWmD930IfViT3biTMEEytqd615zqrLNd5eQWi1yQN FXKg== 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; bh=xqHVezKuPNo0McuWSO3Lsc/LNnyHlhiMgfTSCXnEw9k=; b=jx/++UCe+pzlu7Y8qpDXyRcW1NDnck0XVz0qVgedjUFbPzEPS8bL96cA6cRK9VXXgD 6f9RWuPXSfV2kcmFfU7FNy43uq8huWPIUblCmplqYX8A3LHdR6gF0/AvSAoUIZhDNJ3Q VQhgWdMVJXaNIi6XghQzhKdQs9wGEoWrEcXxQDj9p7WA7D1YerfC0Ui5OCqxLG9VvAlo BZAFb9O3QTFjQInhC4OYF2CjjGtk7VCwexsueC2qMJXY4RYObw1UjdS57N3ZUhTHvULC X/4xQ8qF5QNYZwEyjK3wiVyu66BeJBXw+Jx+Cki/OP9hV7ZyA67BQUH7f5u/KLkdVXar W79w== 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 u129-v6si7508790pfb.247.2018.09.07.01.36.07; Fri, 07 Sep 2018 01:36: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 S1728198AbeIGM6c (ORCPT + 99 others); Fri, 7 Sep 2018 08:58:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45668 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726187AbeIGM6b (ORCPT ); Fri, 7 Sep 2018 08:58:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3A35401C96A; Fri, 7 Sep 2018 08:18:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-85.pek2.redhat.com [10.72.12.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42F88112D19B; Fri, 7 Sep 2018 08:18:31 +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/4 v7] kexec: allocate unencrypted control pages for kdump in case SME is enabled Date: Fri, 7 Sep 2018 16:18:03 +0800 Message-Id: <20180907081805.368-3-lijiang@redhat.com> In-Reply-To: <20180907081805.368-1-lijiang@redhat.com> References: <20180907081805.368-1-lijiang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 07 Sep 2018 08:18:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 07 Sep 2018 08:18:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 unencrypted pages for kdump in order to be able to boot the kdump kernel like kexec. Signed-off-by: Lianbo Jiang --- kernel/kexec_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 23a83a4da38a..e7efcd1a977b 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.17.1