Patch "x86/tdx: Account shared memory" has been added to the 6.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/tdx: Account shared memory

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-tdx-account-shared-memory.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8066e22947aa074499e766c86d887e3809015968
Author: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
Date:   Fri Jun 14 12:58:54 2024 +0300

    x86/tdx: Account shared memory
    
    [ Upstream commit c3abbf1376874f0d6eb22859a8655831644efa42 ]
    
    The kernel will convert all shared memory back to private during kexec.
    The direct mapping page tables will provide information on which memory
    is shared.
    
    It is extremely important to convert all shared memory. If a page is
    missed, it will cause the second kernel to crash when it accesses it.
    
    Keep track of the number of shared pages. This will allow for
    cross-checking against the shared information in the direct mapping and
    reporting if the shared bit is lost.
    
    Memory conversion is slow and does not happen often. Global atomic is
    not going to be a bottleneck.
    
    Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
    Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
    Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
    Tested-by: Tao Liu <ltao@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240614095904.1345461-10-kirill.shutemov@xxxxxxxxxxxxxxx
    Stable-dep-of: d4fc4d014715 ("x86/tdx: Fix "in-kernel MMIO" check")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index fdcc081317764..729ef77b65865 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -38,6 +38,8 @@
 
 #define TDREPORT_SUBTYPE_0	0
 
+static atomic_long_t nr_shared;
+
 /* Called from __tdx_hypercall() for unrecoverable failure */
 noinstr void __noreturn __tdx_hypercall_failed(void)
 {
@@ -820,6 +822,11 @@ static int tdx_enc_status_change_finish(unsigned long vaddr, int numpages,
 	if (!enc && !tdx_enc_status_changed(vaddr, numpages, enc))
 		return -EIO;
 
+	if (enc)
+		atomic_long_sub(numpages, &nr_shared);
+	else
+		atomic_long_add(numpages, &nr_shared);
+
 	return 0;
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux