Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2227533rbb; Tue, 27 Feb 2024 15:18:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWyDwgICOD/yzq2E83hx5+Fazd+tXjZm4BudmH9IEZDcqWMkbkvFlJEnqHbsM4taZFJQgmM9EFYlKrbxk+p9ngxrnnCjfdDQviDDo8s0g== X-Google-Smtp-Source: AGHT+IHTw7+z4PcuTr2ucSzDcMFbS5G8LGYrqiQzDOSR+0zVYau54u8n0ML1ZBZAJwV8ISVd0nCm X-Received: by 2002:a17:906:26db:b0:a3e:e3a9:57e5 with SMTP id u27-20020a17090626db00b00a3ee3a957e5mr8302949ejc.58.1709075889304; Tue, 27 Feb 2024 15:18:09 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y2-20020a1709060bc200b00a3ecdade91bsi1142707ejg.930.2024.02.27.15.18.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:18:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84185-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tk+S6k29; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-84185-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84185-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 A4BCA1F240BF for ; Tue, 27 Feb 2024 23:16:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EBB356460; Tue, 27 Feb 2024 23:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Tk+S6k29" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 73E0255E45 for ; Tue, 27 Feb 2024 23:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.9 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075792; cv=fail; b=O+hjluqI2nzgcx/dV4y1LhtRmXo9SilcgpSrPzZkKXbX64KRFGE+X9pED29pQGKwIH/XtgQmAyhTeGrqBsWH/nLHRc7iFN6AVVDFcFsYtoGp2kz1lrj/7axlk+CqjC8bEGaYuW1aiTpPwg5+cPUjSmaQ1GSsoBq+kFayQenKgXg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075792; c=relaxed/simple; bh=toWAAySRY9cdVsfoJkQx1O3bNVVtOR4qOakOqLQ4PlI=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=i7hGT9sdhkRNO7gerZuynhBZYm7fFH/wMmoGY91UrEVoQpcGeuhjkeb9sosOiP2v5JMh122SfMjWdoUUzlOUH56erCHn4aWcTxWSplrWBG7To6/7AA/zrkpDcuhtcu2qookTr5JDw7xuUTmAPzSrmgCULhiJG5j2z78dGWCJK4c= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Tk+S6k29; arc=fail smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709075789; x=1740611789; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=toWAAySRY9cdVsfoJkQx1O3bNVVtOR4qOakOqLQ4PlI=; b=Tk+S6k29/eIB4GXfvkOOYJjvHneKAc8okEmQ9mE+LKvFuTZEKdJSxova DBYLIs1FsRrtzt2Jy6XZ76bkEhssqPTxFxIv8qAWKRzl98EYd9JJm8l/V Thpi3+1EobQrPCSTb1mTvDn9RwK5n+27Wv+MBbc1O2AG5NeqH+b/sw4KE 5XnazbZfRIlWCLyIZpKulqU5xLvmB4rDgMXwiRmATa/bi/npcWo+4heuY KktTaFTW17SVoabf3PkGxb4z6+SHq7YzSKKLWIWOCOEO2bsF3CX9eaFyr TVZN7BAGKbLysJZd5vxbnf5dwp6exErNqh4CJm4uBVvrWvd3kdzaTvHkb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14160643" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14160643" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 15:16:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7182266" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa010.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 27 Feb 2024 15:16:27 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 27 Feb 2024 15:16:27 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 27 Feb 2024 15:16:26 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 27 Feb 2024 15:16:26 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 27 Feb 2024 15:16:26 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HyQ8CNlpWZ9g4wIRzyxzjp5RGe1NQLryxF/x84BzL4Ps5c6aK3rIB+ZErqe1C2aQt78kW3bhPNHBhtX5XNqE4TBjq7DUhbjrwvednY6b6TGDdZDIRSv/BasFX+AHvAdJ0RTvSMlSK3kdShT8q1ZL2RzQq1T2BFeFKQ6ZJEuwCZ4piaR3he3DNnlHJOjIwlIicqHYOVROjtMcSaIzOIWmBAdWGScA9r4JZAh+cygZ6A6LB37wvUOGnoFXL9NIrOgoZ+ePj4kGkV49RbmZguTiNqc3F+D6outcAs2hNIFcmshe3OfEXElXhAqovpBABCVYWoE+6E0QteaW3c5mSZHqxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q2p9yJ4YIjenNxszbc1H7CPMB3w85BjC27k8qwD7JOs=; b=KihDz7Kd++RNl8DcSwAan1IR8M8XvDQmrtxaqZMIBxa/BtsTPG6XwGpf+GoSqyDxqOjMRjzSiiQoGVGO/tahwUt7c00x0BNsvFww/rsoTZ0GuGn5QESDFm9f8YND1XCOZ4uFPDYRG6EaktwH2ZnbjEJfp9pr4vG6CnMVlDMeZBIgw4qMLwT9A0bHnoshyUpIig/d+eI9WBQ3rnfyJUptM3BK7mPRBaqJWkML50raOyC2iHNDvvj/WTbO1gnE+lPqFdwo0k0I3IOmTAm0butMR4pP+QJZvNdB6ig7dbJPtWcKWz00zPVyhiiPGCZDx8knxtUs4DC5Rbl035vmhRseEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) by IA0PR11MB7355.namprd11.prod.outlook.com (2603:10b6:208:433::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.13; Tue, 27 Feb 2024 23:16:24 +0000 Received: from BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::ef2c:d500:3461:9b92]) by BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::ef2c:d500:3461:9b92%4]) with mapi id 15.20.7339.024; Tue, 27 Feb 2024 23:16:24 +0000 Message-ID: <3885ab33-d704-4e50-bad7-0dbe3b012ebe@intel.com> Date: Wed, 28 Feb 2024 12:16:11 +1300 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv8 09/17] x86/mm: Adding callbacks to prepare encrypted memory for kexec Content-Language: en-US To: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , CC: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , "Kuppuswamy Sathyanarayanan" , "Elena Reshetova" , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , "Sean Christopherson" , Baoquan He , , , , Nikolay Borisov References: <20240227212452.3228893-1-kirill.shutemov@linux.intel.com> <20240227212452.3228893-10-kirill.shutemov@linux.intel.com> From: "Huang, Kai" In-Reply-To: <20240227212452.3228893-10-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MW4PR03CA0086.namprd03.prod.outlook.com (2603:10b6:303:b6::31) To BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR11MB5978:EE_|IA0PR11MB7355:EE_ X-MS-Office365-Filtering-Correlation-Id: 199ac9fd-83a5-4ccc-080f-08dc37ea1dcd X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5KJ1tkKPRCl/1WNTt+E8wZU94udEVuZNlE5+wdDqt/DMEqhA8PpbF2ukyU1waerI+dMoMmRi7SV9piU92iwUHl0Z07KAM0CtRJslzdx0EN5Fx9p7woORs6n6IL9FgaP87wWW38a0eEJtxvmlRg/CAgJQsVFotxJsZFrDeinJBGYZSZloJkwTAIDP7U+cW8w36oSjsjpagDG/vql3IWE4CY2IjNVbWnG8k3jtGCAktjWvQUcIyBH2sF4q6M3hyS+6KpUV3aB0chNV9s7vGm31dpipYZXP5fNNlCC6Zk5TmHVxrtiPxOt2BXAWXVN2TfWvV8gpai0g2oG+mUsTAnMmB4/WU9mm9ooJf0iRqWEe3B9VO47ABwBaj115HFP84gIOtxEZa1Tly12Vu5d7/vZ51Kqp7aRxPgWF5U0E5fcC338t0ZA6GRJEvtIUbE2JCm7PLAMmqXx+x6/u4hMPoGBLX5XsPlZfjC7oEsrhmeAj1d1PWaRoxa2k5koHj1/984Q9lkCWywHWhEqMU+7TsEctDP8HbkjbJM40bDIec/YQXbDxJ+9PqCtYBF6hcg6BOglnxQ9o06xOnBjTUpFIalxHY6lPrd3RdVU1iao/xeX8lN0h67bPlcM5Mmj7+Sl/OImuUHUgXy+S9umLP1A/d0ykhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5978.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TnZ6QTdGTDdiS3FJUm5aSU82RFpqN1pUU01ta1E3Wk9NUzA1a3V0UEorNk5q?= =?utf-8?B?ejVYNmp5VElmbnpwenQwUVpkU2pWYnNhWEtEU0JtdFBhRTVCaFNlbTRQSjNl?= =?utf-8?B?QWJqdi9aNWV0SWw1bE9oakUvODBBWFgrNzhqWXhxZmZZcFJXTWYvRTVoTUxO?= =?utf-8?B?UUw3ZmRoTmVRNjRVbHl2QzFndEdqT3haWHBGUit4VUYvTXZMV1NpUDFPRlNx?= =?utf-8?B?QTA2RXRjYWUwWEFqc216NGw3YWY5aTY5Y2xlbGZlL0F0SEg3Tm9GQzJkWTJv?= =?utf-8?B?MlNoR0VFa0gyb1o4OGo4S0E1blZNL245ZkVleUpZaHAxaHVrT0lhWVZmNHdh?= =?utf-8?B?SVBCYzZZaUt5VGZuMDhvNWpFTDZlRWNvMFB6SEs0WGd1OFozSldWQ0lLRGNU?= =?utf-8?B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Av?= =?utf-8?B?NCtNMWVFelpwa29VeWRnVFNmbEhPNzJEdkYyVEl4bjNRMldhdVgrdmQvVDkz?= =?utf-8?B?TWNlYXVIL0VCU1p6OFZGbUphdlVrSm5pSUhhL0ZEWXorcmo1Rk56UkdaSjBR?= =?utf-8?B?Yi9jRTdtaHp0OUEvc2xGVzRRNlgrd0RpaDkzNXJNcmxFeWV4MnBtUlp5a21I?= =?utf-8?B?VFphaWxtb2E4akdncE05SU1mRUxjaE9zNW5hMXA0eUppSG1VTDNnS2xvVGR0?= =?utf-8?B?NlM0aTFaMjJTVXdKWW5uQWZETzJXeVYzb2NCMTV2ZVRPaVErcWNtNkkwWEtl?= =?utf-8?B?ZUZUa21VS2NmUUVYYUJaZEc2b0dnK0M0a3czRm4wam1Md2FYbGJ6K0lJeXF4?= =?utf-8?B?eTdkSzFMZ2JIMU14S01kN3I3eE96alJIUk5Wd283cFFEMlZGdzN6VUw1RVFE?= =?utf-8?B?cFhwS1dSaTErZzVNNk95V1B3bFVqNU54Q0tBYzIvODRIcFF0cGRydy9pL3VL?= =?utf-8?B?M0xiNDdqek5hdVhoWlRUb2VORW1yQlUrOXoyak14QXRkZXpyMkhvSjFBL1d5?= =?utf-8?B?RCtsdmJIVjVXRDI2VUM1WkVVbEIvRkpybFp4c2M0T3VYd3I4RjhieXRYcG9U?= =?utf-8?B?emd4S2xvL2NMR3FxSW5wNjY1RW03SkpSUzhCb3Y1cDVweFRPUkhKM3NtTXlr?= =?utf-8?B?RzVyRVN6d25kZWxDRzc0VjgvcVBZSm9NRUlSL3lpUmVKZHZuYUZ2MlIvdy90?= =?utf-8?B?QzZ3VFYzejVDa3JQV2dTMnY4YUVoZTFobHJ1UDVqNTZ4ZFRCZUVDcjR1VzVO?= =?utf-8?Q?hI4OZSEKto0McEEryScck3Pzo?= X-MS-Exchange-CrossTenant-Network-Message-Id: 199ac9fd-83a5-4ccc-080f-08dc37ea1dcd X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5978.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 23:16:24.3104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pXrMxQ+ZwR4lEhURnzYaohhAKLDmkxMw9n6j2aCWggktlI089lyijQaEIqpg3qB7pqsQI3D3GoBvoIhANY0rWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7355 X-OriginatorOrg: intel.com On 28/02/2024 10:24 am, Kirill A. Shutemov wrote: > AMD SEV and Intel TDX guests allocate shared buffers for performing I/O. > This is done by allocating pages normally from the buddy allocator and > then converting them to shared using set_memory_decrypted(). > > On kexec, the second kernel is unaware of which memory has been > converted in this manner. It only sees E820_TYPE_RAM. Accessing shared > memory as private is fatal. > > Therefore, the memory state must be reset to its original state before > starting the new kernel with kexec. > > The process of converting shared memory back to private occurs in two > steps: > > - enc_kexec_stop_conversion() stops new conversions. > > - enc_kexec_unshare_mem() unshares all existing shared memory, reverting > it back to private. > > Signed-off-by: Kirill A. Shutemov > Reviewed-by: Nikolay Borisov x > --- Reviewed-by: Kai Huang