Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2295287yba; Mon, 15 Apr 2019 08:45:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8jgYhRhCqhBhqGeZ8SCtHUGTCR5jJLTOMLhFnke+c/n/wvKIcfJh03yG7c3yt2YliZHeS X-Received: by 2002:a65:44cd:: with SMTP id g13mr62726073pgs.258.1555343124427; Mon, 15 Apr 2019 08:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555343124; cv=none; d=google.com; s=arc-20160816; b=P4LyRsIMK4FYERGThMZl2/TyjbVSMzojORORsi+3oOwLtX859ISMlGCYcuc1xTeu5s i1xkn6cfGIenUnRt53sr+3QV/GjIbpK7HJkp1uQWD3xxHId1pb2Eywxchnl44EHUhwAU QCSFGWCOusCfgQUAwlnOBZXI2P3ukes1ev3LrkSubodUunj2voBl/WkRqEIw4yACIQ+U 3NmflokTZuIINeL3g9MGxgL80TgcktJRwMsRUrscnDtZx1ZR/9O5aJnqzS/n4JzbwwtK 3S2pNyNXi4QsXWlAHBAJ8tlrJQZyDD4KMd46VElPKRqc9mrxcwYP0yBlU/aPa8G5FPuK xNpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wZDmvh5A7g3XDKwql0kangfenQr/dEn7Cv+rPbn12ng=; b=k/nzH/H+Js3VYh2HV7XkNZs3vH9A7NBfFG5uaWTBwLyzZHDLCTEceMN3Bnkfn7sBS+ dPE3P/z94Gm71GVBHcGrt+OOxHwjgvMkbBKn3gtzpx7ICabXoadD6HPAxQacFtn4Jtcg JRRddt9gEWerJQZ/UmJJPo1pFSJRz3Ag8TCrKMKFBr4+crEiuxLJXVo/MUZ0gPudi5HV ZEJfk7WaYLpjf9+Jyl4+/aFdarUH++Kne2FfaIVETYSzZ09g8yfsp6tyhXmP0DqI6t2O P5g+/X61GD9As7JEMTOMK1fGBQdhwcruOP4I+uO24nWHREnUfKQdMB3qjhSuEJl7mtkV t/Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=pINEupJ9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s79si30411287pfa.69.2019.04.15.08.45.08; Mon, 15 Apr 2019 08:45: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; dkim=pass header.i=@alien8.de header.s=dkim header.b=pINEupJ9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727689AbfDOPoK (ORCPT + 99 others); Mon, 15 Apr 2019 11:44:10 -0400 Received: from mail.skyhub.de ([5.9.137.197]:48068 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbfDOPoK (ORCPT ); Mon, 15 Apr 2019 11:44:10 -0400 Received: from zn.tnic (p4FED3D80.dip0.t-ipconnect.de [79.237.61.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 576071EC0104; Mon, 15 Apr 2019 17:44:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1555343048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=wZDmvh5A7g3XDKwql0kangfenQr/dEn7Cv+rPbn12ng=; b=pINEupJ9N3oNBeNPhKYdX4zU4/oXa7eEsCPvPhKQKH5gFTTRfHPcD0hV4EZNJamkM80FL8 aXV2Zubs7+czdWkwo/9ir18fgWuL26i2ElKWOaTKfpLiagw8pkl3S8nhljbmc/6vq0DIXX 8o/oVDVfFqfm3LFvnNuTx2xQ2x4hBCU= Date: Mon, 15 Apr 2019 17:41:55 +0200 From: Borislav Petkov To: lijiang , Thomas.Lendacky@amd.com Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, akpm@linux-foundation.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, x86@kernel.org, hpa@zytor.com, dyoung@redhat.com, bhe@redhat.com Subject: Re: [PATCH 1/2 RESEND v10] x86/mm, resource: add a new I/O resource descriptor 'IORES_DESC_RESERVED' Message-ID: <20190415154155.GH29317@zn.tnic> References: <20190329123914.20939-1-lijiang@redhat.com> <20190329123914.20939-2-lijiang@redhat.com> <20190402090652.GD6826@zn.tnic> <20190402124328.GG6826@zn.tnic> <384ba880-1b53-8013-8be8-66f294c27100@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <384ba880-1b53-8013-8be8-66f294c27100@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 15, 2019 at 08:22:22PM +0800, lijiang wrote: > They are different problems. Aha, so we're getting closer. You should've lead with that! > The first problem is that passes the e820 reserved ranges to the second kernel, Passes or *doesn't* pass? Because from all the staring, it wants to pass the reserved ranges. > for this case, it is good enough to use the IORES_DESC_RESERVED, which > can ensure that exactly matches the reserved resource ranges when > walking through iomem resources. Ok. > The second problem is about the SEV case. Now, the IORES_DESC_RESERVED has been > created for the reserved areas, therefore the check needs to be expanded so that > these areas are not mapped encrypted when using ioremap(). > > +static int __ioremap_check_desc_none_and_reserved(struct resource *res) That name is crap. If you need to add another desc type, it becomes wrong again. And that whole code around flags->desc_other is just silly: Make that machinery around it something like this: struct ioremap_desc { u64 flags; }; instead of "struct ioremap_mem_flags" and that struct ioremap_desc is an ioremap descriptor which will carry all kinds of settings. system_ram can then be a simple flag too. __ioremap_caller() will hand it down to __ioremap_check_mem() etc and there it will set flags like IOREMAP_DESC_MAP_ENCRYPTED or IOREMAP_DESC_MAP_DECRYPTED and this way you'll have it explicit and clear in __ioremap_caller(): if ((sev_active() && (io_desc.flags & IOREMAP_DESC_MAP_ENCRYPTED)) || encrypted) prot = pgprot_encrypted(prot); But that would need a pre-patch which does that conversion. > Maybe i should split it into two patches. The change of > __ioremap_check_desc_none_and_reserved() should be a separate patch. > Any idea? See above and yes, definitely separate patches. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.