Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp227522rdb; Sun, 28 Jan 2024 23:22:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBBSL2yoovHMldNMdjgBzAhl8PwdDOKj0LVhEKYONL7zlt+jhEB4RpHdViU36WiC+JvQJ6 X-Received: by 2002:a05:6214:c6e:b0:68c:46ce:1107 with SMTP id t14-20020a0562140c6e00b0068c46ce1107mr3809786qvj.97.1706512946643; Sun, 28 Jan 2024 23:22:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706512946; cv=pass; d=google.com; s=arc-20160816; b=RR2MQ8DaZ5kGO2UCJiZqJM4RJsvzLYlPvzut/0lgQvvzORegeYa2du5DrtxtKrJcyg uUV6LVMv3aPue0xFnUuBEGA1vECCRfga9Fpan+Z+Ikr95Vh1LxAIKZLr8XZXa7ephb4r ohCDPIB4BbaLAxLUkW3UuL+EwxaWxGTdsHYs+NpGf0LIXQhyti2QYaypztTFbBm52ZI8 L76LO8XJqCO0sR39ZtKXhdNaC2gzdZti4WOCjbAHFM4+FKQVw0sxp6LZaJtQOnVkfLUe IBva86GCCzWwGPtgfJp5v9ZlyfrP+Swjo4uPlVj5pONJQKX5Y85ZQl+QnPm+hLuUeiDO oceQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LrgnZOGulcP9tuVmCHC1ajU+ERsd9Badipl3nQjKaNo=; fh=cHoPloON7bjP722I6WmJv8Zbx+3xWEPssMYpLtoAQ8s=; b=lUYygabqXdWsA9TxInG3FEsCAWxAa0lE7YIVVkwdTtZPp5kOlP5K/4MRN+vGj6pIT2 Cdkn3Rs1imM/kPEwt8SAVNG6YCKCrVowh2miu0GNK/je/+nmuCDumeloFyqHZ4h2r9Th gWzDfyBr4eYbwLoQteurlfB4HijpRU+iah569ONWxji4Z5rb9Rj6I8EQLvMG+ilXLtNN 1uxpbdqfAG/m7REigugOAVSBqmkl6uWCq50RYj/5Zv4BBgyHYfeO0dN2fEVsZq3ZCiUj mazgd8y4Z+81no03p6KtucTor3i2V92S6B7wANAw3azf0+j8JOvLCOrP4EyPGhq9MLLg 9P2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=ZqSzo3D4; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-42279-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jx15-20020a0562142b0f00b0068c467dc60csi2909897qvb.441.2024.01.28.23.22.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 23:22:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42279-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=ZqSzo3D4; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-42279-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 660A21C21C53 for ; Mon, 29 Jan 2024 07:22:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B6F74E1DA; Mon, 29 Jan 2024 07:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZqSzo3D4" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 844914D5BC for ; Mon, 29 Jan 2024 07:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706512940; cv=none; b=sPj1jz7hSnYvysoeRagcnPqAbjnABCBWsn09DnCGTbyPGFoV4G7yWze5ODsW0YD0QWWn5iIVhWdo8wdWzCXNUQEoATqCUbu/FvHaHw7jBDsEnedfu1rCODuJdnDTJ4KQyPiIuhDJZE1tg0kUNzDfprfnwfLYEF3SofP12yVgzVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706512940; c=relaxed/simple; bh=pOeBpfnIGTyAcSL/FQR58BXAk2dTUWrcGwza6diBqqU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z5dvt/8fjVXRnwS7vBVjTexsKk8r5KvriDOcMZJpqv/5IFIu2Z1jiBT2Jr2+TqnEP7xp/Nt4G49hvGEDVFzyKZx0VX7p7inq4u+7/PjIcBe5rnK0oAZI2Vhp/BzKo/UsijUoHq+23j2431/YbeBNBCn6PL5oOd8eS1LsYQ6794I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZqSzo3D4; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40ef64d8955so5780785e9.3 for ; Sun, 28 Jan 2024 23:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1706512936; x=1707117736; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LrgnZOGulcP9tuVmCHC1ajU+ERsd9Badipl3nQjKaNo=; b=ZqSzo3D4q/txo/BFmkHYXsv+bsUXiovUDrBdj5kbx45WjLxSLLflhbrkeHbj9spUTT VazYrftokXg6Zepoo75luFk4eucEaPAsgYiBfErGfe3Vim3dE5xES4AnyNv0/82AnG3p OxKtlBUZqDvB8sRef7alfuPpUV+61OtfhH5O8irCXVqdQo5Fn64dU9AhhSDNnRJKZ60q wfnFvTBZ56ebx4k9nVVwh6SHwzqwyEuSWmSRLpfHAU/P8O50oo++hGNJyihFG059krTd lCZqFONEMlghfd019mpBoGDxGAFihuvKrXQbCjcNiNH127fqZZ7vgd/d8a9U+xjtKds6 97Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706512936; x=1707117736; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LrgnZOGulcP9tuVmCHC1ajU+ERsd9Badipl3nQjKaNo=; b=OhNMUP4v/PKNPFlUlGmYn9LxIOIouwiwNmw4ZwtHenNM0lWFWBfIkiCUmk2pqBVAOc jKrRQwIhIKzMytF7avGq9oPL/mI9Op2guz61GO8wrCvJGr76KFphXOzEQBlgb8tGEffz aIDxCrA9nxlZahhvqppIP9LUmnMmHzNC3rez2ExTQXEYIpTEvzIOxaWSWJ7O3dJony49 wHjOSeNrBIxwJHS3zeVLBhxODwfaT7w4mj3vreJnk9Cf6S0ImsEaDnUmWJK3Sg67x9Om hQS1RfBiHJoKTaiyc6Dt+XDaazJXiMPQC4LqPYNvScIK2afWYO/2SVnlkUJd4TiNFs7a 0XOw== X-Gm-Message-State: AOJu0YzXCxkIwhaGvWT++qoiYqQkuF9ISOx6f/fRpoq06rY+TdxhnMF4 lGwas8IDQfewIG80ZHYRmTxqKvxICpoIhOykeUOss248Nlb7YuC9GKWR8L4N5sA= X-Received: by 2002:a05:600c:4f50:b0:40e:93b4:25ef with SMTP id m16-20020a05600c4f5000b0040e93b425efmr5101615wmq.26.1706512935752; Sun, 28 Jan 2024 23:22:15 -0800 (PST) Received: from ?IPV6:2a10:bac0:b000:7588:cd6b:e8a3:8a4d:4601? ([2a10:bac0:b000:7588:cd6b:e8a3:8a4d:4601]) by smtp.gmail.com with ESMTPSA id s18-20020a5d69d2000000b003393457afc2sm7224289wrw.95.2024.01.28.23.22.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jan 2024 23:22:15 -0800 (PST) Message-ID: Date: Mon, 29 Jan 2024 09:22:13 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv6 09/16] 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 , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240124125557.493675-1-kirill.shutemov@linux.intel.com> <20240124125557.493675-10-kirill.shutemov@linux.intel.com> From: Nikolay Borisov In-Reply-To: <20240124125557.493675-10-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 24.01.24 г. 14:55 ч., 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