4444#include <asm/cpcmd.h>
4545#include <asm/lowcore.h>
4646#include <asm/irq.h>
47+ #include <asm/page.h>
48+ #include <asm/ptrace.h>
4749
4850/*
4951 * Machine setup..
@@ -53,7 +55,6 @@ unsigned int console_devno = -1;
5355unsigned int console_irq = -1 ;
5456unsigned long memory_size = 0 ;
5557unsigned long machine_flags = 0 ;
56- unsigned int default_storage_key = 0 ;
5758struct {
5859 unsigned long addr , size , type ;
5960} memory_chunk [MEMORY_CHUNKS ] = { { 0 } };
@@ -402,7 +403,7 @@ setup_lowcore(void)
402403 lc = (struct _lowcore * )
403404 __alloc_bootmem (lc_pages * PAGE_SIZE , lc_pages * PAGE_SIZE , 0 );
404405 memset (lc , 0 , lc_pages * PAGE_SIZE );
405- lc -> restart_psw .mask = PSW_BASE_BITS ;
406+ lc -> restart_psw .mask = PSW_BASE_BITS | PSW_DEFAULT_KEY ;
406407 lc -> restart_psw .addr =
407408 PSW_ADDR_AMODE | (unsigned long ) restart_int_handler ;
408409 lc -> external_new_psw .mask = PSW_KERNEL_BITS ;
@@ -470,7 +471,7 @@ static void __init
470471setup_memory (void )
471472{
472473 unsigned long bootmap_size ;
473- unsigned long start_pfn , end_pfn ;
474+ unsigned long start_pfn , end_pfn , init_pfn ;
474475 unsigned long last_rw_end ;
475476 int i ;
476477
@@ -481,6 +482,10 @@ setup_memory(void)
481482 start_pfn = (__pa (& _end ) + PAGE_SIZE - 1 ) >> PAGE_SHIFT ;
482483 end_pfn = max_pfn = memory_end >> PAGE_SHIFT ;
483484
485+ /* Initialize storage key for kernel pages */
486+ for (init_pfn = 0 ; init_pfn < start_pfn ; init_pfn ++ )
487+ page_set_storage_key (init_pfn << PAGE_SHIFT , PAGE_DEFAULT_KEY );
488+
484489 /*
485490 * Initialize the boot-time allocator (with low memory only):
486491 */
@@ -491,7 +496,7 @@ setup_memory(void)
491496 */
492497 last_rw_end = start_pfn ;
493498
494- for (i = 0 ; i < 16 && memory_chunk [i ].size > 0 ; i ++ ) {
499+ for (i = 0 ; i < MEMORY_CHUNKS && memory_chunk [i ].size > 0 ; i ++ ) {
495500 unsigned long start_chunk , end_chunk ;
496501
497502 if (memory_chunk [i ].type != CHUNK_READ_WRITE )
@@ -505,6 +510,11 @@ setup_memory(void)
505510 if (end_chunk > end_pfn )
506511 end_chunk = end_pfn ;
507512 if (start_chunk < end_chunk ) {
513+ /* Initialize storage key for RAM pages */
514+ for (init_pfn = start_chunk ; init_pfn < end_chunk ;
515+ init_pfn ++ )
516+ page_set_storage_key (init_pfn << PAGE_SHIFT ,
517+ PAGE_DEFAULT_KEY );
508518 free_bootmem (start_chunk << PAGE_SHIFT ,
509519 (end_chunk - start_chunk ) << PAGE_SHIFT );
510520 if (last_rw_end < start_chunk )
@@ -513,6 +523,8 @@ setup_memory(void)
513523 }
514524 }
515525
526+ psw_set_key (PAGE_DEFAULT_KEY );
527+
516528 if (last_rw_end < end_pfn - 1 )
517529 add_memory_hole (last_rw_end , end_pfn - 1 );
518530
0 commit comments