Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5063029imm; Mon, 14 May 2018 18:53:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp37apqMPHLRzo/VV1h+iTG3pfG3ETJ+TbpqqwAUR4kVYxByiKDYfwX5qi13UuO0R9dbtZ1 X-Received: by 2002:a17:902:8bc5:: with SMTP id r5-v6mr12372167plo.182.1526349198380; Mon, 14 May 2018 18:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526349198; cv=none; d=google.com; s=arc-20160816; b=GCYXQ+prjLI3+ebLar8EH2zs1BvlDJKGoLMCUH+FW74W8ejchfs9MIkK7zrk5ETTL9 29bm0l6PTaQg/fqGHr/pO8zWNt31UoFrzm5z15kqHadnoNLN/NrRHTIP0+onIH54t0se 1AdoJk+Uy//7yjOufhpGqH8DrzRCdJIY27t2QXjIoeHyVORSRpHUz9B6yas6MuH3Hyn5 FCofV0s1Kc63LqdCXvY2fouB9+CIzgas9YS67G02aYdHdNG+nOn013DL37IKkh7icUik Xf20788FSTb+TeDRtugvza3yQluvrbv4SRhrdNWZfBdMxLO7KYe5HgAi/U5c1PTeGU15 K90Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7nRQW8xV/sZbnW3S3cz2uaGNVPj9NzX3s+d64iHCag4=; b=ITq6boQMJ1T/DEzJd53EwO/ibv0B6PpbpIqdlbLJjO0iCGGVkvJOWqRmDLMOJJ5cAr RvMve21PxVRJ+KXhRYRwHecXckCxJTROUpR/5z3r7kVyAAYmFoEQTHNw53R1JWyYiOyo uQ/Cm7sFwQkS/inITmH4rNwhpZLiQm+RF/UP1V5e548ah17eAygfFXW20EKJ8X5dXuDl jXasNYpjvzV/ohqdPLnUMgc9JZXj5lmYuqvj1wxejT8vRk/+5OAwIEGf+QSf55R44gIV ttixEM4Trq0LLzT6zsD4Hk6n5KXqdhGiUfQvQ/MnaXh1diPHZb6tDbSGCKPbeHwgVNUI 0b5w== 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 i12-v6si9999901plt.183.2018.05.14.18.53.04; Mon, 14 May 2018 18:53:18 -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 S1752372AbeEOBvo (ORCPT + 99 others); Mon, 14 May 2018 21:51:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39972 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752307AbeEOBvm (ORCPT ); Mon, 14 May 2018 21:51:42 -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 B60B8818533A; Tue, 15 May 2018 01:51:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-33.pek2.redhat.com [10.72.12.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 889DF10AF9D3; Tue, 15 May 2018 01:51:37 +0000 (UTC) From: Lianbo Jiang To: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, thomas.lendacky@amd.com, dyoung@redhat.com Subject: [PATCH 0/2] support kdump for AMD secure memory encryption(sme) Date: Tue, 15 May 2018 09:51:31 +0800 Message-Id: <20180515015133.4363-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.8]); Tue, 15 May 2018 01:51:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 15 May 2018 01:51:41 +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 It is convenient to remap the old memory encrypted to the second kernel by calling ioremap_encrypted(). When sme enabled on AMD server, we also need to support kdump. Because the memory is encrypted in the first kernel, we will remap the old memory encrypted to the second kernel(crash kernel), and sme is also enabled in the second kernel, otherwise the old memory encrypted can not be decrypted. Because simply changing the value of a C-bit on a page will not automatically encrypt the existing contents of a page, and any data in the page prior to the C-bit modification will become unintelligible. A page of memory that is marked encrypted will be automatically decrypted when read from DRAM and will be automatically encrypted when written to DRAM. For the kdump, it is necessary to distinguish whether the memory is encrypted. Furthermore, we should also know which part of the memory is encrypted or decrypted. We will appropriately remap the memory according to the specific situation in order to tell cpu how to deal with the data(encrypted or decrypted). For example, when sme enabled, if the old memory is encrypted, we will remap the old memory in encrypted way, which will automatically decrypt the old memory encrypted when we read those data from the remapping address. ---------------------------------------------- | first-kernel | second-kernel | kdump support | | (mem_encrypt=on|off) | (yes|no) | |--------------+---------------+---------------| | on | on | yes | | off | off | yes | | on | off | no | | off | on | no | |______________|_______________|_______________| Test tools: makedumpfile[v1.6.3]: https://github.com/LianboJ/makedumpfile commit e1de103eca8f (A draft for kdump vmcore about AMD SME) Author: Lianbo Jiang Date: Mon May 14 17:02:40 2018 +0800 Note: This patch can only dump vmcore in the case of SME enabled. crash-7.2.1: https://github.com/crash-utility/crash.git commit 1e1bd9c4c1be (Fix for the "bpf" command display on Linux 4.17-rc1) Author: Dave Anderson Date: Fri May 11 15:54:32 2018 -0400 Test environment: HP ProLiant DL385Gen10 AMD EPYC 7251 8-Core Processor 32768 MB memory 600 GB disk space Linux 4.17-rc4: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 75bc37fefc44 ("Linux 4.17-rc4") Author: Linus Torvalds Date: Sun May 6 16:57:38 2018 -1000 Reference: AMD64 Architecture Programmer's Manual https://support.amd.com/TechDocs/24593.pdf Lianbo Jiang (2): add a function(ioremap_encrypted) for kdump when AMD sme enabled. support kdump when AMD secure memory encryption is active arch/x86/include/asm/dmi.h | 14 +++++++++++++- arch/x86/include/asm/io.h | 2 ++ arch/x86/kernel/acpi/boot.c | 8 ++++++++ arch/x86/kernel/crash_dump_64.c | 27 +++++++++++++++++++++++++++ arch/x86/mm/ioremap.c | 25 +++++++++++++++++-------- drivers/acpi/tables.c | 14 +++++++++++++- drivers/iommu/amd_iommu_init.c | 9 ++++++++- fs/proc/vmcore.c | 36 +++++++++++++++++++++++++++++++----- include/linux/crash_dump.h | 4 ++++ kernel/kexec_core.c | 12 ++++++++++++ 10 files changed, 135 insertions(+), 16 deletions(-) -- 2.9.5