Subject: linux-next: manual merge of the kvm-arm tree with the arm64 tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 15 Jun 2023 12:45:58 +1000

Hi all,

Today's linux-next merge of the kvm-arm tree got a conflict in:

  arch/arm64/kernel/kaslr.c

between commit:

  6e13b6b923b3 ("arm64: kaslr: split kaslr/module initialization")
  e46b7103aef3 ("arm64: module: move module randomization to module.c")

from the arm64 tree and commit:

  0ddc312b7c73 ("arm64: Turn kaslr_feature_override into a generic SW feature override")

from the kvm-arm tree.

I fixed it up (see below) and can carry the fix as necessary. This is
now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your
tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/arm64/kernel/kaslr.c
index 17f96a19781d,5d4ce7f5f157..000000000000
--- a/arch/arm64/kernel/kaslr.c
+++ b/arch/arm64/kernel/kaslr.c
@@@ -4,33 -4,46 +4,33 @@@
   */
  
  #include <linux/cache.h>
 -#include <linux/crc32.h>
  #include <linux/init.h>
 -#include <linux/libfdt.h>
 -#include <linux/mm_types.h>
 -#include <linux/sched.h>
 -#include <linux/types.h>
 -#include <linux/pgtable.h>
 -#include <linux/random.h>
 +#include <linux/printk.h>
  
 -#include <asm/fixmap.h>
 -#include <asm/kernel-pgtable.h>
 +#include <asm/cpufeature.h>
  #include <asm/memory.h>
 -#include <asm/mmu.h>
 -#include <asm/sections.h>
 -#include <asm/setup.h>
  
 -u64 __ro_after_init module_alloc_base;
  u16 __initdata memstart_offset_seed;
  
- struct arm64_ftr_override kaslr_feature_override __initdata;
- 
 -static int __init kaslr_init(void)
 +bool __ro_after_init __kaslr_is_enabled = false;
 +
 +void __init kaslr_init(void)
  {
- 	if (kaslr_feature_override.val & kaslr_feature_override.mask & 0xf) {
 -	u64 module_range;
 -	u32 seed;
 -
 -	/*
 -	 * Set a reasonable default for module_alloc_base in case
 -	 * we end up running with module randomization disabled.
 -	 */
 -	module_alloc_base = (u64)_etext - MODULES_VSIZE;
 -
+ 	if (cpuid_feature_extract_unsigned_field(arm64_sw_feature_override.val &
+ 						 arm64_sw_feature_override.mask,
+ 						 ARM64_SW_FEATURE_OVERRIDE_NOKASLR)) {
  		pr_info("KASLR disabled on command line\n");
 -		return 0;
 +		return;
  	}
  
 -	if (!kaslr_enabled()) {
 +	/*
 +	 * The KASLR offset modulo MIN_KIMG_ALIGN is taken from the physical
 +	 * placement of the image rather than from the seed, so a displacement
 +	 * of less than MIN_KIMG_ALIGN means that no seed was provided.
 +	 */
 +	if (kaslr_offset() < MIN_KIMG_ALIGN) {
  		pr_warn("KASLR disabled due to lack of seed\n");
 -		return 0;
 +		return;
  	}
  
  	pr_info("KASLR enabled\n");