Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp328258imm; Fri, 31 Aug 2018 01:22:33 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb5fLxi6WJ8rO8N6lpdEPeR89VgPxWQHYE+xpvgKfFJVrub6ZpxYEqBlj/8wSG6nbWSLFCF X-Received: by 2002:a17:902:7794:: with SMTP id o20-v6mr11487981pll.116.1535703753380; Fri, 31 Aug 2018 01:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535703753; cv=none; d=google.com; s=arc-20160816; b=ic1CySLk/8hrV9NOL4z0i72VVjvdMi1aonC0BZj2WQkVdeqgpvXGZv/g+4smC8lKzr 3ZpeHj8VoRac+Fx2DsA3R9+Jly88jLqFcTKZCZYQXL1t+OxRFEad9abZWakdojc0StlJ wLFNk3JWr+bnl8v+7CQ1fBVJYK9OCKmvJ4LMTh785DXT+kzMW6TRf+P2LFrXIglMD6CJ Hng2QvoQz7D9l8cso2my8DqdKItEXMKUJ9A8W73ikAKbTmO53/CGtsvReh4PcviII8VF GpYryKUaZE1G24vfZCVRX9UkWZQv+ascEIiu8ARs1NB33wUc/6ZGGjgHFzk66Njd//au CyLA== 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=xqHVezKuPNo0McuWSO3Lsc/LNnyHlhiMgfTSCXnEw9k=; b=a072aRrn0FAh2ZPPhhOL/SkYVARhfUAA7XwdRwH7EDdi3yPlv2cIlWe5htVe71si2R fHYRCmI8Er+lreilzBPv6bjMiLG10CR0B5Iw5hRPLq75NJKMDixmaftfpobUY0dYUts6 J4Cmj/qn8QyhC04wjzhTS808g0UKlBD3VvBLBJkWqxlVvybhGQTUdDPMuZoxSq8UL9MG rUCH3JDJFzpLThyUxQrSdnk3b4g6EQjSZEVVSC3iYzF3bGvtbFUH85U6dyRRWqSwByrA HFKheeXYwrT+0CsMEbznRxvH/7aBQ0Drf+RZOKBONEJLQJx6fRz/lEj9YavNj1W5Pyg6 Xdmw== 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 m23-v6si9091066pgl.51.2018.08.31.01.22.18; Fri, 31 Aug 2018 01:22:33 -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 S1727759AbeHaM0d (ORCPT + 99 others); Fri, 31 Aug 2018 08:26:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42092 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727229AbeHaM0c (ORCPT ); Fri, 31 Aug 2018 08:26:32 -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 B43A04021CC3; Fri, 31 Aug 2018 08:20:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B554E112D169; Fri, 31 Aug 2018 08:20:07 +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 3/5 V6] kexec: allocate unencrypted control pages for kdump in case SME is enabled Date: Fri, 31 Aug 2018 16:19:28 +0800 Message-Id: <20180831081930.31561-4-lijiang@redhat.com> In-Reply-To: <20180831081930.31561-1-lijiang@redhat.com> References: <20180831081930.31561-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.7]); Fri, 31 Aug 2018 08:20:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 31 Aug 2018 08:20:14 +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