Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp83575imd; Fri, 26 Oct 2018 05:33:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5e1XhXhwbDr674R6Y9Ec1PgtUK/YYp5aYA6KS73e2v3UsykbPDclIzRooBHy7Ro5zClvdTU X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr3407387plb.82.1540557196453; Fri, 26 Oct 2018 05:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540557196; cv=none; d=google.com; s=arc-20160816; b=opW9iSwPeXYcux0vRhHW5mExMQK5Mkk098M7bSGa/+14D7S9/4lpYYEbYBFCip8/fu Qil1cHoGPS0fGJOoAIxRYyRp94LFAmm3To6YlepGBvBS79nWhhwZECqM7JBGu6K5cCd7 PZqpr+NsV9//cfeUBFJN9kD+9wIV7X3tGnCju/cSqqRpSl1XoQ4/G79Y1gEsnBCKFX1z h1eDrNWItE3Zgw3AOice32dOqOsk/bjbdCoSHKBXYgj+/7lodNWb/f4Rewj98HavdnUt UhNZVTh7WSSCL48++rVdVLu2MrH5LFD5C4wKmtYm2Is8wi/ATJ8YtVNDY5+t53RfrNVn XKAQ== 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:from:references:cc:to:subject; bh=SSlu9flZ3sXCLeE+0gSo4OuUkWMZnjKk+VzAKVi/Gm4=; b=D8jZQbAwdud0DndsfqJ7z38LRIByOSdNz8apWag2dQBunl655g7MBGWBmX/tWiIqnG cWbbLMX58TU+Lzu3Dvs5Rxbr2dHzAuHSCi8zj7eKrb6QlzVUEVK1i2xJ/b1zUYOrhcjP lveMYXWhJoNr7QtXrJ40hV5BDHP/8VcYvWkxCbQKbfoWMtvKMEhkdaxy69oPWPYrVoRT NoZU7lB0Um0jSJXSa8pOdtUb2dw7zgBDVgceBpnb0lihOX3yVN9N0PUGkFpWYlQZT6hf 1y2ZVhyqKfgEPwwr8pOYEJDXA6Uq5JJhJl32Ky6OjuR/6iEb/kJ0tcu68G6ItYgCAD7l TOTg== 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 z25-v6si7609459pgl.405.2018.10.26.05.32.59; Fri, 26 Oct 2018 05:33:16 -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 S1727659AbeJZVJW (ORCPT + 99 others); Fri, 26 Oct 2018 17:09:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbeJZVJV (ORCPT ); Fri, 26 Oct 2018 17:09:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0AB2E30820C8; Fri, 26 Oct 2018 12:32:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-142.pek2.redhat.com [10.72.12.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4E8165F54; Fri, 26 Oct 2018 12:32:16 +0000 (UTC) Subject: Re: [PATCH] kdump, vmcoreinfo: Export sme_me_mask value to vmcoreinfo To: Boris Petkov , linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, bhe@redhat.com, dyoung@redhat.com References: <20181026093630.8520-1-lijiang@redhat.com> <053CC83A-9A95-4C12-9627-AABD1427DA9C@alien8.de> From: lijiang Message-ID: <1263471c-a27d-a698-15f0-b5947f13ea93@redhat.com> Date: Fri, 26 Oct 2018 20:32:11 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <053CC83A-9A95-4C12-9627-AABD1427DA9C@alien8.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 26 Oct 2018 12:32:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2018年10月26日 17:43, Boris Petkov 写道: > On October 26, 2018 10:36:30 AM GMT+01:00, Lianbo Jiang wrote: >> For AMD machine with SME feature, makedumpfile tools need to know >> whether the crash kernel was encrypted or not. > > Why? > If SME is enabled in the first kernel, the crash kernel's page table(pgd/pud/pmd/pte) contains the memory encryption mask, so i have to remove the sme mask to obtain the true physical address when dump vmcore. >> So it is necessary >> to write the sme_me_mask to vmcoreinfo. >> >> Signed-off-by: Lianbo Jiang >> --- >> arch/x86/kernel/machine_kexec_64.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/arch/x86/kernel/machine_kexec_64.c >> b/arch/x86/kernel/machine_kexec_64.c >> index 4c8acdfdc5a7..dcfdb64d1097 100644 >> --- a/arch/x86/kernel/machine_kexec_64.c >> +++ b/arch/x86/kernel/machine_kexec_64.c >> @@ -357,6 +357,8 @@ void arch_crash_save_vmcoreinfo(void) >> vmcoreinfo_append_str("NUMBER(pgtable_l5_enabled)=%d\n", >> pgtable_l5_enabled()); >> >> + VMCOREINFO_NUMBER(sme_me_mask); > > No we're not going to expose a kernel-internal mask to userspace. > If so, can i set a variable flag for the 'sme_me_mask' and export the variable flag? For example: void arch_crash_save_vmcoreinfo(void) { .... if (sme_active()) sme_enabled = 1; VMCOREINFO_NUMBER(sme_enabled); .... } > If at all needed, add functions to kexec which figure out whether we are encrypted or not and export that result as a kexec variable. > > For AMD machine with the SME feature, the msr 'MSR_K8_SYSCFG' can examine whether SME is enabled in kernel, but the kexec is also userspace tool, it has no permission to access the msr. Furthermore, i also tried to read the "/dev/cpu/cpu[number]/msr", but the value depends on BIOS's configuration. That is to say, if SME is set in BIOS, the value of msr is always 0xF40000 whatever the kernel commandline parameter is "mem_encrypt=on" or "mem_encrypt=off". If i made a mistake, please help to point it out. Thanks. Lianbo