mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
[S390] hibernation: fix guest page hinting related crash
On resume the system that loads the to be resumed image might have unstable pages. When the resume image is copied back and a write access happen to an unstable page this causes an exception and the system crashes. To fix this set all free pages to stable before copying the resumed image data. Also after everything has been restored set all free pages of the resumed system to unstable again. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
2e50195f58
commit
846955c8af
2 changed files with 53 additions and 10 deletions
|
@ -102,6 +102,9 @@ swsusp_arch_resume:
|
|||
aghi %r15,-STACK_FRAME_OVERHEAD
|
||||
stg %r1,__SF_BACKCHAIN(%r15)
|
||||
|
||||
/* Make all free pages stable */
|
||||
lghi %r2,1
|
||||
brasl %r14,arch_set_page_states
|
||||
#ifdef CONFIG_SMP
|
||||
/* Save boot cpu number */
|
||||
brasl %r14,smp_get_phys_cpu_id
|
||||
|
@ -178,6 +181,10 @@ swsusp_arch_resume:
|
|||
/* Activate DAT */
|
||||
stosm __SF_EMPTY(%r15),0x04
|
||||
|
||||
/* Make all free pages unstable */
|
||||
lghi %r2,0
|
||||
brasl %r14,arch_set_page_states
|
||||
|
||||
/* Return 0 */
|
||||
lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15)
|
||||
lghi %r2,0
|
||||
|
|
|
@ -50,28 +50,64 @@ void __init cmma_init(void)
|
|||
cmma_flag = 0;
|
||||
}
|
||||
|
||||
void arch_free_page(struct page *page, int order)
|
||||
static inline void set_page_unstable(struct page *page, int order)
|
||||
{
|
||||
int i, rc;
|
||||
|
||||
if (!cmma_flag)
|
||||
return;
|
||||
for (i = 0; i < (1 << order); i++)
|
||||
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
|
||||
: "=&d" (rc)
|
||||
: "a" ((page_to_pfn(page) + i) << PAGE_SHIFT),
|
||||
: "a" (page_to_phys(page + i)),
|
||||
"i" (ESSA_SET_UNUSED));
|
||||
}
|
||||
|
||||
void arch_free_page(struct page *page, int order)
|
||||
{
|
||||
if (!cmma_flag)
|
||||
return;
|
||||
set_page_unstable(page, order);
|
||||
}
|
||||
|
||||
static inline void set_page_stable(struct page *page, int order)
|
||||
{
|
||||
int i, rc;
|
||||
|
||||
for (i = 0; i < (1 << order); i++)
|
||||
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
|
||||
: "=&d" (rc)
|
||||
: "a" (page_to_phys(page + i)),
|
||||
"i" (ESSA_SET_STABLE));
|
||||
}
|
||||
|
||||
void arch_alloc_page(struct page *page, int order)
|
||||
{
|
||||
int i, rc;
|
||||
if (!cmma_flag)
|
||||
return;
|
||||
set_page_stable(page, order);
|
||||
}
|
||||
|
||||
void arch_set_page_states(int make_stable)
|
||||
{
|
||||
unsigned long flags, order, t;
|
||||
struct list_head *l;
|
||||
struct page *page;
|
||||
struct zone *zone;
|
||||
|
||||
if (!cmma_flag)
|
||||
return;
|
||||
for (i = 0; i < (1 << order); i++)
|
||||
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
|
||||
: "=&d" (rc)
|
||||
: "a" ((page_to_pfn(page) + i) << PAGE_SHIFT),
|
||||
"i" (ESSA_SET_STABLE));
|
||||
if (make_stable)
|
||||
drain_local_pages(NULL);
|
||||
for_each_populated_zone(zone) {
|
||||
spin_lock_irqsave(&zone->lock, flags);
|
||||
for_each_migratetype_order(order, t) {
|
||||
list_for_each(l, &zone->free_area[order].free_list[t]) {
|
||||
page = list_entry(l, struct page, lru);
|
||||
if (make_stable)
|
||||
set_page_stable(page, order);
|
||||
else
|
||||
set_page_unstable(page, order);
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&zone->lock, flags);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue