Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'sparc-for-6.13-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/alarsson/linux-sparc

Pull sparc updates from Andreas Larsson:

- Make sparc64 compilable with clang

- Replace one-element array with flexible array member

* tag 'sparc-for-6.13-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/alarsson/linux-sparc:
sparc/vdso: Add helper function for 64-bit right shift on 32-bit target
sparc: Replace one-element array with flexible array member
sparc/build: Add SPARC target flags for compiling with clang
sparc/build: Put usage of -fcall-used* flags behind cc-option

+33 -11
+3
Documentation/kbuild/llvm.rst
··· 179 179 * - s390 180 180 - Maintained 181 181 - ``LLVM=1`` (LLVM >= 18.1.0), ``CC=clang`` (LLVM < 18.1.0) 182 + * - sparc (sparc64 only) 183 + - Maintained 184 + - ``CC=clang LLVM_IAS=0`` (LLVM >= 20) 182 185 * - um (User Mode) 183 186 - Maintained 184 187 - ``LLVM=1``
+2 -2
arch/sparc/Makefile
··· 29 29 # versions of gcc. Some gcc versions won't pass -Av8 to binutils when you 30 30 # give -mcpu=v8. This silently worked with older bintutils versions but 31 31 # does not any more. 32 - KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 32 + KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) 33 33 KBUILD_CFLAGS += -Wa,-Av8 34 34 35 35 KBUILD_AFLAGS += -m32 -Wa,-Av8 ··· 45 45 UTS_MACHINE := sparc64 46 46 47 47 KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow 48 - KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare 48 + KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g7) -Wno-sign-compare 49 49 KBUILD_CFLAGS += -Wa,--undeclared-regs 50 50 KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3) 51 51 KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs
+1 -1
arch/sparc/include/asm/hvtramp.h
··· 17 17 __u64 fault_info_va; 18 18 __u64 fault_info_pa; 19 19 __u64 thread_reg; 20 - struct hvtramp_mapping maps[1]; 20 + struct hvtramp_mapping maps[]; 21 21 }; 22 22 23 23 void hv_cpu_startup(unsigned long hvdescr_pa);
+1 -3
arch/sparc/kernel/smp_64.c
··· 297 297 unsigned long hv_err; 298 298 int i; 299 299 300 - hdesc = kzalloc(sizeof(*hdesc) + 301 - (sizeof(struct hvtramp_mapping) * 302 - num_kernel_image_mappings - 1), 300 + hdesc = kzalloc(struct_size(hdesc, maps, num_kernel_image_mappings), 303 301 GFP_KERNEL); 304 302 if (!hdesc) { 305 303 printk(KERN_ERR "ldom_startcpu_cpuid: Cannot allocate "
+1 -1
arch/sparc/vdso/Makefile
··· 46 46 -fno-omit-frame-pointer -foptimize-sibling-calls \ 47 47 -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 48 48 49 - SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7 49 + SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) 50 50 51 51 $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) 52 52
+24 -4
arch/sparc/vdso/vclock_gettime.c
··· 86 86 } 87 87 88 88 #ifdef CONFIG_SPARC64 89 + notrace static __always_inline u64 __shr64(u64 val, int amt) 90 + { 91 + return val >> amt; 92 + } 93 + 89 94 notrace static __always_inline u64 vread_tick(void) 90 95 { 91 96 u64 ret; ··· 107 102 return ret; 108 103 } 109 104 #else 105 + notrace static __always_inline u64 __shr64(u64 val, int amt) 106 + { 107 + u64 ret; 108 + 109 + __asm__ __volatile__("sllx %H1, 32, %%g1\n\t" 110 + "srl %L1, 0, %L1\n\t" 111 + "or %%g1, %L1, %%g1\n\t" 112 + "srlx %%g1, %2, %L0\n\t" 113 + "srlx %L0, 32, %H0" 114 + : "=r" (ret) 115 + : "r" (val), "r" (amt) 116 + : "g1"); 117 + return ret; 118 + } 119 + 110 120 notrace static __always_inline u64 vread_tick(void) 111 121 { 112 122 register unsigned long long ret asm("o4"); ··· 174 154 ts->tv_sec = vvar->wall_time_sec; 175 155 ns = vvar->wall_time_snsec; 176 156 ns += vgetsns(vvar); 177 - ns >>= vvar->clock.shift; 157 + ns = __shr64(ns, vvar->clock.shift); 178 158 } while (unlikely(vvar_read_retry(vvar, seq))); 179 159 180 160 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); ··· 194 174 ts->tv_sec = vvar->wall_time_sec; 195 175 ns = vvar->wall_time_snsec; 196 176 ns += vgetsns_stick(vvar); 197 - ns >>= vvar->clock.shift; 177 + ns = __shr64(ns, vvar->clock.shift); 198 178 } while (unlikely(vvar_read_retry(vvar, seq))); 199 179 200 180 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); ··· 214 194 ts->tv_sec = vvar->monotonic_time_sec; 215 195 ns = vvar->monotonic_time_snsec; 216 196 ns += vgetsns(vvar); 217 - ns >>= vvar->clock.shift; 197 + ns = __shr64(ns, vvar->clock.shift); 218 198 } while (unlikely(vvar_read_retry(vvar, seq))); 219 199 220 200 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); ··· 234 214 ts->tv_sec = vvar->monotonic_time_sec; 235 215 ns = vvar->monotonic_time_snsec; 236 216 ns += vgetsns_stick(vvar); 237 - ns >>= vvar->clock.shift; 217 + ns = __shr64(ns, vvar->clock.shift); 238 218 } while (unlikely(vvar_read_retry(vvar, seq))); 239 219 240 220 ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
+1
scripts/Makefile.clang
··· 10 10 CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu 11 11 CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu 12 12 CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu 13 + CLANG_TARGET_FLAGS_sparc := sparc64-linux-gnu 13 14 CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu 14 15 CLANG_TARGET_FLAGS_um := $(CLANG_TARGET_FLAGS_$(SUBARCH)) 15 16 CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH))