s390/mm: Pin identity mapping base to zero

SIE instruction performs faster when the virtual address of
SIE block matches the physical one. Pin the identity mapping
base to zero for the benefit of SIE and other instructions
that have similar performance impact. Still, randomize the
base when DEBUG_VM kernel configuration option is enabled.

Suggested-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by Alexander Gordeev and committed by Vasily Gorbik 32db4019 a3ca27c4

+15 -1
+13
arch/s390/Kconfig
··· 604 as a security feature that deters exploit attempts relying on 605 knowledge of the location of kernel internals. 606 607 config KERNEL_IMAGE_BASE 608 hex "Kernel image base address" 609 range 0x100000 0x1FFFFFE0000000 if !KASAN
··· 604 as a security feature that deters exploit attempts relying on 605 knowledge of the location of kernel internals. 606 607 + config RANDOMIZE_IDENTITY_BASE 608 + bool "Randomize the address of the identity mapping base" 609 + depends on RANDOMIZE_BASE 610 + default DEBUG_VM 611 + help 612 + The identity mapping base address is pinned to zero by default. 613 + Allow randomization of that base to expose otherwise missed 614 + notion of physical and virtual addresses of data structures. 615 + That does not have any impact on the base address at which the 616 + kernel image is loaded. 617 + 618 + If unsure, say N 619 + 620 config KERNEL_IMAGE_BASE 621 hex "Kernel image base address" 622 range 0x100000 0x1FFFFFE0000000 if !KASAN
+2 -1
arch/s390/boot/startup.c
··· 341 BUILD_BUG_ON(MAX_DCSS_ADDR > (1UL << MAX_PHYSMEM_BITS)); 342 max_mappable = max(ident_map_size, MAX_DCSS_ADDR); 343 max_mappable = min(max_mappable, vmemmap_start); 344 - __identity_base = round_down(vmemmap_start - max_mappable, rte_size); 345 346 return asce_limit; 347 }
··· 341 BUILD_BUG_ON(MAX_DCSS_ADDR > (1UL << MAX_PHYSMEM_BITS)); 342 max_mappable = max(ident_map_size, MAX_DCSS_ADDR); 343 max_mappable = min(max_mappable, vmemmap_start); 344 + if (IS_ENABLED(CONFIG_RANDOMIZE_IDENTITY_BASE)) 345 + __identity_base = round_down(vmemmap_start - max_mappable, rte_size); 346 347 return asce_limit; 348 }