Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1385037lqh; Mon, 6 May 2024 06:22:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8aKWjzPeEfO+cIMlThtQkhgImZ9FKjWw7BZQw0p6HY+47MTvmkFJZq9FZ4m2jMpO6iDkuGz2O4qR3/8NshXXnexaoe8ReqQGnDCOOEw== X-Google-Smtp-Source: AGHT+IGonwVVl9h462asjgzBLFCAsY2kCqPgXUMAa5RSTa+xu+ilJQiICRalqlK6bLMLAZ3QvibL X-Received: by 2002:a50:9982:0:b0:572:3a93:ee69 with SMTP id m2-20020a509982000000b005723a93ee69mr8586619edb.3.1715001757364; Mon, 06 May 2024 06:22:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715001757; cv=pass; d=google.com; s=arc-20160816; b=ifA5pdD0awzH6nb9iHq2HUFyxgQaAmie/TupyLHDiFwNMsgq1ClWxb+FQTszLRqiLE hKMB7T2IS5WXaD0aYW8nnH62soOLL7I0m9r4o2J9J0zr9gBLE4/DfAJLswgt8Ao07xWT 5Iv6zQr3/4rhyVBd1o/UqeenQ2lvuLHP0cagWugIrupNMXxCMbCUJ9FAscjC57BhbXrE 6fmRR97V2Y3oA3lkKtVSvnhm5Go4jbMlUIko/38NMSHGoN4zSQls76L1sIB0K2NPNuXv +U+vSosDHwwuVt7GLOUPvg9mEUh5nO7w+5IAj8ag6uR27Yhn3dAr8mMPFJby00NIdz0d qsCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3SW4si2r5qJWxmTlb3yNhDeY0hdLYU6wRNX6GDCVFWM=; fh=mYuoruwpAvYKOA2RWUeRUKKAE9xKLXX9D0LYSWvFkvU=; b=JzpUas0aI8dniQPi9TwAGvLXj90ni1t3Qs3sMMu+A7zHkD9aQ7cOEyr5L7a/aCyovK O2TG07lRiZnE85FKOuEDh+j2TasD00qo72h9aXPkx35jGqWzgzFvMC+Bi8cpd+hi4lLs Q/YQ6Qwdankww8kFWrj9ccJch65T+Vqo84fYVayiuxAYSTE8oXfucd1QbQiIKsRsgMWp JdaMJXsiZ+CjOeVbsXLCU3RlYWWGtW9G3JZyc+6isZzwqUide/OqovwNdSFxCtQSnf1S 5JTKgVsbm2IgJqGEsxLf3otn8vSUA+KeQ8rm80xLY4hdRMhCzHCSVXXAlSoNl08DxcBx X5+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gGtMz7uH; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-169882-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a20-20020aa7d914000000b0056e0e0bfef0si4875352edr.244.2024.05.06.06.22.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169882-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gGtMz7uH; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-169882-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 046971F24C7C for ; Mon, 6 May 2024 13:22:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FAC71EB26; Mon, 6 May 2024 13:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gGtMz7uH" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CD03FBF0 for ; Mon, 6 May 2024 13:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715001731; cv=none; b=SDYZqGXsZYRQ8Xx32dVqI8H3FnZkPhEZRFnzCo6Bh12+9Rp7W392akL+Fdg5Td/2r7o5UvDj9J9/DHOw8jZ6aSurJuynFNZRpZeVLp6WXDknBPPlEBUCTom5bxCdYuOhePfe/AjKo395uMZbcPXSEcsIZKun9alI5uBvxIOuUIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715001731; c=relaxed/simple; bh=BCuAyhvvdHlZNeT/yRgbvu9IxMPed1+0m8MQqbV2QlI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cGKco2WuBQO2h9lUzkDtlx83G0216rCkimn+C59ICRX93/4NOrdgsekYdZRQKoWyRROt9R3jPmrZxYcjonYArY+1pUUx6A9nQbEa8EX3zPVNkdd4bQVul89ljj3FHFDLr1/Z1uJKsftLKy1X/VQdDpxEYlX8OUbr3r7kAZpliGI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gGtMz7uH; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715001730; x=1746537730; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=BCuAyhvvdHlZNeT/yRgbvu9IxMPed1+0m8MQqbV2QlI=; b=gGtMz7uHVirWTs1RbaZRydGj9Ixi1vnPKozbVf51yfmPIJScwd2Dq164 aynYfkVDluj2XK2TkWHn1SKFCIP9yNyCw+b3WcSjoXR8Y186F2TPghhYr S9D7wfCDmmCZ2kRB0tVvD/PQVXuD+wDXm0v3AzV6urNH6uoYyRLkSAsiG R6l2Ln12tXFm9WPTN20UebG8RBYvq5ldBv+rtaOHlNkR2qzYdPL2DS7xv D7YtJRlmV/kPK5RE/TdgBQNtq9Vq491gUB738DsJG3bmlAr4Cjp/Amk+y XRtcL4Jayj/5bEFYb79ho3IHDN5DklG50qerbOigXsV/93I8oDVhqDder A==; X-CSE-ConnectionGUID: R8IOLx23Suq+jr2N5CQrbQ== X-CSE-MsgGUID: WiWlW4tnSVKea3ZKbn/HtA== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="21900692" X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="21900692" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 06:22:09 -0700 X-CSE-ConnectionGUID: by/aMopuSXyo3mmKnNMsxg== X-CSE-MsgGUID: kPhhB31ETkuyZsPTIKNoJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="28256756" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 06 May 2024 06:22:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 0513A12B; Mon, 06 May 2024 16:22:02 +0300 (EEST) Date: Mon, 6 May 2024 16:22:02 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: adrian.hunter@intel.com, ashish.kalra@amd.com, bhe@redhat.com, dave.hansen@linux.intel.com, elena.reshetova@intel.com, jun.nakajima@intel.com, kai.huang@intel.com, kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, ltao@redhat.com, mingo@redhat.com, nik.borisov@suse.com, peterz@infradead.org, rafael@kernel.org, rick.p.edgecombe@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, seanjc@google.com, tglx@linutronix.de, thomas.lendacky@amd.com, x86@kernel.org Subject: Re: [PATCHv10.1 09/18] x86/mm: Adding callbacks to prepare encrypted memory for kexec Message-ID: References: <20240427164747.GCZi0sM6HBCBYtgWqF@fat_crate.local> <20240427170634.2397725-1-kirill.shutemov@linux.intel.com> <20240502134506.GDZjOY4guvlKH9-73J@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240502134506.GDZjOY4guvlKH9-73J@fat_crate.local> On Thu, May 02, 2024 at 03:45:06PM +0200, Borislav Petkov wrote: > > diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c > > index e74d0c4286c1..f1b261be78b4 100644 > > --- a/arch/x86/kernel/crash.c > > +++ b/arch/x86/kernel/crash.c > > @@ -128,6 +128,10 @@ void native_machine_crash_shutdown(struct pt_regs *regs) > > #ifdef CONFIG_HPET_TIMER > > hpet_disable(); > > #endif > > + > > + x86_platform.guest.enc_kexec_stop_conversion(true); > > + x86_platform.guest.enc_kexec_unshare_mem(); > > + > > You call them here back-to-back... > > > crash_save_cpu(regs, safe_smp_processor_id()); > > } > > > > diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c > > index f3130f762784..c1920ec34f0c 100644 > > --- a/arch/x86/kernel/reboot.c > > +++ b/arch/x86/kernel/reboot.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -716,6 +717,14 @@ static void native_machine_emergency_restart(void) > > > > void native_machine_shutdown(void) > > { > > + /* > > + * Call enc_kexec_stop_conversion() while all CPUs are still active and > > + * interrupts are enabled. This will allow all in-flight memory > > + * conversions to finish cleanly. > > + */ > > + if (kexec_in_progress) > > + x86_platform.guest.enc_kexec_stop_conversion(false); > > + > > /* Stop the cpus and apics */ > > #ifdef CONFIG_X86_IO_APIC > > /* > > @@ -752,6 +761,9 @@ void native_machine_shutdown(void) > > #ifdef CONFIG_X86_64 > > x86_platform.iommu_shutdown(); > > #endif > > + > > + if (kexec_in_progress) > > + x86_platform.guest.enc_kexec_unshare_mem(); > > ... but they're split here. > > And I don't know why and nothing tells me... I do. See comment just above enc_kexec_stop_conversion() call. Do you want also comment for enc_kexec_unshare_mem() ? -- Kiryl Shutsemau / Kirill A. Shutemov