Skip to content

Commit

Permalink
[S390] hibernation: fix guest page hinting related crash
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Sep 22, 2009
1 parent 2e50195 commit 846955c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
7 changes: 7 additions & 0 deletions arch/s390/kernel/swsusp_asm64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
52 changes: 44 additions & 8 deletions arch/s390/mm/page-states.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_alloc_page(struct page *page, int order)
void arch_free_page(struct page *page, int order)
{
int i, rc;

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_pfn(page) + i) << PAGE_SHIFT),
: "a" (page_to_phys(page + i)),
"i" (ESSA_SET_STABLE));
}

void arch_alloc_page(struct page *page, int order)
{
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;
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);
}
}

0 comments on commit 846955c

Please sign in to comment.