Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp343868rdb; Mon, 29 Jan 2024 04:15:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEALat83Y2RNk6UIEr1+iu6Q7P2bZl1v9fJKbQEYfmV8Pk5bMZ9ItS7fvwz+SHCgCZt8MLi X-Received: by 2002:a05:6a20:8917:b0:19c:b457:fb8 with SMTP id i23-20020a056a20891700b0019cb4570fb8mr414168pzg.51.1706530500609; Mon, 29 Jan 2024 04:15:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706530500; cv=pass; d=google.com; s=arc-20160816; b=PgrMNh4G7vEJy26NLKKkQjJbuCZZ1ml7TonwsVjbqftAj9mmPjTsVTiEiKKt9T1+od NZdE3XgjIhp6evrwjsYX278PmHlj/CFueftTfhAu8OBo7p181DaEapKxgXRWILvUHIt6 0KLDThVBJdos8nGi1YrG3mHfQ/HWjEnODCbJ/lDygwTlbI1YkwJWKaULeon1LRvNbC3l llwkwWiNKSC4TUKZ26ifbvxDhMGt5jTjtvPIGZiaApQOR9D9+nZAdyDmt8KlZjldWrD7 bWKtei9IamLnDq1Uy0LzLI4rPzs0Ngf8Zftpvi8JYgVmIRYTr3i3/P2uP9TWpy1ybgcj 0bxg== 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=tJ2GO2smSJ+uOdhAu8QWBB55u+aRp85Fye3RRhJ7dOc=; fh=kMInWaKBjCCN8DjvBI1oO4bFYIySf7xgA3lU4lfPxkE=; b=qWs+gHJdryRyKblO39NOIuOa0ynj8K1Nvuw7hwcpoI/GElJRVesAoIteokFHlyeq+M bINM3zhpAWyFRtT4LXLTPG/n80MGMnORJWACFRj75nMJYlX9PqGTiImQGAHyldyNkyuq 5okGxlyiY5tvDCnLD8rV5kTQ0fCRIlw3okyL9D532QIJJXcYoZ5f6DW1rNOjCb8XwfBL dBc+G5oRlndZAwYaKkDhAzqIQKSFnBucQ+6q9CWC8rp7KoeM/vfMSdkai44RBieyTln6 ViyWF1qO1yC5JsQrOTKAabOMNnt8KHFOLBUdWGE9NUpCLrEwsOTHvZrcZxT9iOUBbljG nrFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PLXdZQBX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f18-20020a170902ce9200b001d8e974ed1dsi1135590plg.507.2024.01.29.04.15.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 04:15:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PLXdZQBX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42597-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 19F4AB21787 for ; Mon, 29 Jan 2024 11:14:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEE6C5F849; Mon, 29 Jan 2024 11:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PLXdZQBX" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 9C8015EE60 for ; Mon, 29 Jan 2024 11:14:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706526849; cv=none; b=uI+tSKbtdQ/oQKjxEXw1D36gQLo5RlzJ1QUiZb/9iBWBYPtsZhLdiuHU4EDoFI2cCga97615Z7T4g0IRs65OxNrUgnkAsl4arz/zNjXo4Ajs9fuoHXvfjc0ZyfmI31t0uEcR63XL45siDZQVQu8RbDZhuN15HKEWNZyJ+jrGTt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706526849; c=relaxed/simple; bh=I4gxSa9YE8dZelntOrU+Hi4kAJP1ulsGJuomatELRgY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fL/Xfd3eCnca9I7sSCr5Tg5NawG1YksQaDlSdoxKu+dT44yirpxGtVRwnQtL1KDN97QbTWaA46WgYKXYcBr34a6f9nQI49mzsOxorrFrrdjoigxouwm6e5aLaA5BD1V47RB57+qVdOkJigTiq3xBE8PU3BaDw+pFyiI6xld/yZM= 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=PLXdZQBX; arc=none smtp.client-ip=198.175.65.9 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=1706526848; x=1738062848; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=I4gxSa9YE8dZelntOrU+Hi4kAJP1ulsGJuomatELRgY=; b=PLXdZQBXrFbo25ZV2gOoOH//kXVUtu2SzVzV0ZFixR9XqZ5vVT+G5YeI pvw9K14rSVc/i4GhlhPxkBqcuBzcFJvjwa/OkcFEb8NCKZktUnbmG0RYf QAeeZPr3pYZoJL5ohKj6Vezxnk5tWZjWZF9SBalTJUz7UoekZ2TcA8H3j UOoM0sOB8bZuNQg7q0i349wTEaX7LopG/O0FggThUwlLIb0ggH5sexeSv HEW4o/S/5xWKlP5y29q9PwsJGaujuvWoITo6fisjfwtiqHkKxGFUn3VfT jirAKJXFwCMBBBKa8w5Eu6YRJEEk1Z0yA4GIx4HN1fEH8OCSme83WDIhE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="21448887" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="21448887" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 03:14:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="878044370" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="878044370" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2024 03:14:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 29C46125; Mon, 29 Jan 2024 12:36:09 +0200 (EET) Date: Mon, 29 Jan 2024 12:36:09 +0200 From: "Kirill A. Shutemov" To: "Kalra, Ashish" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , Sean Christopherson , "Huang, Kai" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCHv6 10/16] x86/tdx: Convert shared memory back to private on kexec Message-ID: References: <20240124125557.493675-1-kirill.shutemov@linux.intel.com> <20240124125557.493675-11-kirill.shutemov@linux.intel.com> 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: On Mon, Jan 29, 2024 at 04:24:09AM -0600, Kalra, Ashish wrote: > In case of SNP and crash/kdump case, we need to prevent the boot_ghcb being > converted to shared (in snp_kexec_unshare_mem()) as the boot_ghcb is > required to handle all I/O for disabling IO-APIC/lapic, hpet, etc., as the > enc_kexec_unshare_mem() callback is invoked before the apics, hpet, etc. are > disabled. > > Is there any reason why enc_kexec_unshare_mem() callback is invoked in crash > case before the IO-APIC/lapic, hpet, etc. are shutdown/disabled ? Not really. Either way works for TDX. I've tested the patch below. Is it what you want? diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 6585a5f2c2ba..3001f4857ed7 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -107,11 +107,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs) crash_smp_send_stop(); - if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) { - x86_platform.guest.enc_kexec_stop_conversion(true); - x86_platform.guest.enc_kexec_unshare_mem(); - } - cpu_emergency_disable_virtualization(); /* @@ -129,6 +124,12 @@ void native_machine_crash_shutdown(struct pt_regs *regs) #ifdef CONFIG_HPET_TIMER hpet_disable(); #endif + + if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) { + x86_platform.guest.enc_kexec_stop_conversion(true); + x86_platform.guest.enc_kexec_unshare_mem(); + } + crash_save_cpu(regs, safe_smp_processor_id()); } -- Kiryl Shutsemau / Kirill A. Shutemov