]> git.dujemihanovic.xyz Git - linux.git/commitdiff
KVM: s390: pv: fix index value of replaced ASCE
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Wed, 5 Jul 2023 11:19:37 +0000 (13:19 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 18 Jul 2023 09:21:51 +0000 (11:21 +0200)
The index field of the struct page corresponding to a guest ASCE should
be 0. When replacing the ASCE in s390_replace_asce(), the index of the
new ASCE should also be set to 0.

Having the wrong index might lead to the wrong addresses being passed
around when notifying pte invalidations, and eventually to validity
intercepts (VM crash) if the prefix gets unmapped and the notifier gets
called with the wrong address.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Fixes: faa2f72cb356 ("KVM: s390: pv: leak the topmost page table when destroy fails")
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-ID: <20230705111937.33472-3-imbrenda@linux.ibm.com>

arch/s390/mm/gmap.c

index 989ebd0912b489ba4667c0c8d4452a5e71c13d3a..9c8af31be970515aa56f7553267002c4f5489258 100644 (file)
@@ -2853,6 +2853,7 @@ int s390_replace_asce(struct gmap *gmap)
        page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
        if (!page)
                return -ENOMEM;
+       page->index = 0;
        table = page_to_virt(page);
        memcpy(table, gmap->table, 1UL << (CRST_ALLOC_ORDER + PAGE_SHIFT));