Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp199851imm; Sun, 8 Jul 2018 23:29:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfxZqM4tN3IImhXPJSzNU7DKxd5ZppndmhEaPeGj//frb/sYiZelyhoE+NYiDEdywcw+d1b X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr19301162plb.74.1531117764681; Sun, 08 Jul 2018 23:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531117764; cv=none; d=google.com; s=arc-20160816; b=wGkyCVl9vL0eI8D2ULhtPOjdTaTH+8NQ38teLy7uW/bn0ALQREXpsxm6P7SACZrUa9 GDJ6Mnu74E/wMJW3bBh4gzBJgZ1TvS2ynigBOAD6Dy0shDY0tPvr5UPaEeh/KEsiAz2e 2OqxbulOMgJlkCbp1JiANWwe01KH8zebcQsIrOvmUhimHSZLVaHPFUwkcfU4w25KMPMF kUL3toQTmFtWzxwvbCMSggtpD4atISWeOT3EQwiJV3f94NQxeXdeQHtaaZRkqPS0SBqv FnnC5urSNasTKBafAbLtXttHmrweh1QHL+G2f7NjkOVlzZQKargm2Cs+8VboETKmKUHJ scuQ== 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:references:cc:to:from:subject:arc-authentication-results; bh=DHeBO8QYic38luh0ZoLTTEOKEmnlJdQsY/joJw9+pjs=; b=dMskEITCZ3NUBDyo9U9k17+S5SU4XOOmNiwDrK4sZd5abN9YRf5pRuxBbHpQaqs2Q7 R3ngT8Gz8zUInG3zhm9IsDtImSeSr44Ugds5zjdNUrBqvGryT6hp3wWRUgIYznd017xU xQLaXqR6NIGmjo0QQzF+Zp22xvrBFzIagdyW6OqfJ6SYQk9lAnPDEHcj8aWk0kMulAvK ypCBjJkz+gbh+qLethQEF/vfUko5t3v2Xv7DkqDBia29Bl5eg6xC3JAAisgue4R4Ecws SPOaV9F1bLQ82J/NHFZam1hdhmoStB+CLiDFgCdRlNkd25EyzuncR3M+xWjO7iONudrv 4Zsg== 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 s84-v6si14456418pfd.288.2018.07.08.23.29.08; Sun, 08 Jul 2018 23:29:24 -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 S1754374AbeGIG22 (ORCPT + 99 others); Mon, 9 Jul 2018 02:28:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751321AbeGIG21 (ORCPT ); Mon, 9 Jul 2018 02:28:27 -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 C04914001388; Mon, 9 Jul 2018 06:28:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-43.pek2.redhat.com [10.72.12.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2FA5111E3EB; Mon, 9 Jul 2018 06:28:16 +0000 (UTC) Subject: Re: [PATCH 1/5 V5] Add a function(ioremap_encrypted) for kdump when AMD sme enabled From: lijiang To: Borislav Petkov Cc: linux-kernel@vger.kernel.org, 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 References: <20180702072639.10110-1-lijiang@redhat.com> <20180702072639.10110-2-lijiang@redhat.com> <20180702101451.GB28730@zn.tnic> <4ae1cfb5-0a4b-2aac-2575-024e2c74826f@redhat.com> <895db996-febd-d50c-91af-4f1ef3d27bd8@redhat.com> <20180703111428.GB5748@zn.tnic> <4fbb843b-9597-a48b-8b6f-00e354b91950@redhat.com> Message-ID: Date: Mon, 9 Jul 2018 14:28:11 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <4fbb843b-9597-a48b-8b6f-00e354b91950@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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]); Mon, 09 Jul 2018 06:28:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 09 Jul 2018 06:28:26 +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 在 2018年07月03日 19:44, lijiang 写道: > 在 2018年07月03日 19:14, Borislav Petkov 写道: >> On Tue, Jul 03, 2018 at 06:58:14PM +0800, lijiang wrote: >>> For kdump, the elf header finally use the crash kernel reserved memory, it is not an old memory. >> >> Lamme repeat my suggestion: >> >> So beef up the logic in __ioremap_caller() to figure out based on the >> address whether to access the memory encrypted or not. In general, you >> can deduce, based on the region you're mapping, whether you need to map >> in encrypted or decrypted. >> >> For example: >> >> addr = elfcorehdr_addr; >> >> /* Read Elf header */ >> rc = elfcorehdr_read((char *)&ehdr, sizeof(Elf64_Ehdr), &addr); >> if (rc < 0) >> return rc; >> >> elfcorehdr_addr has that elfcorehdr address. So you can check which address >> you're mapping and do: >> >> __ioremap_caller: >> >> ... >> prot = __ioremap_compute_prot(...); >> >> and that __ioremap_compute_prot() function which you will add will have >> all that logic to determine encrypted or not by comparing addresses etc. >> >> Does that make more sense? >> > Thank you, Boris. Good idea, I will rethink about this issue and post it again. > Hi, Boris Last week, I had tried many ways to do this work, but it looks like that the ways of deducing address is not suitable to another scenarios, such as mapping some devices mmio space, which are unencrypted, and the device mmio space is outside kdump kernel like the old memory, but the old memory is encrypted, we can't find the general rules to decide when to encrypt or not. So it should be the best way that the caller care about encryption or not. What do you think? > Regards, > Lianbo >