Skip to content

Commit fbb3c22

Browse files
committed
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
2 parents f151670 + b6370b3 commit fbb3c22

File tree

7 files changed

+33
-11
lines changed

7 files changed

+33
-11
lines changed

Documentation/kbuild/llvm.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ yet. Bug reports are always welcome at the issue tracker below!
179179
* - s390
180180
- Maintained
181181
- ``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)
182185
* - um (User Mode)
183186
- Maintained
184187
- ``LLVM=1``

arch/sparc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ UTS_MACHINE := sparc
2929
# versions of gcc. Some gcc versions won't pass -Av8 to binutils when you
3030
# give -mcpu=v8. This silently worked with older bintutils versions but
3131
# 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)
3333
KBUILD_CFLAGS += -Wa,-Av8
3434

3535
KBUILD_AFLAGS += -m32 -Wa,-Av8
@@ -45,7 +45,7 @@ export BITS := 64
4545
UTS_MACHINE := sparc64
4646

4747
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
4949
KBUILD_CFLAGS += -Wa,--undeclared-regs
5050
KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3)
5151
KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs

arch/sparc/include/asm/hvtramp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct hvtramp_descr {
1717
__u64 fault_info_va;
1818
__u64 fault_info_pa;
1919
__u64 thread_reg;
20-
struct hvtramp_mapping maps[1];
20+
struct hvtramp_mapping maps[];
2121
};
2222

2323
void hv_cpu_startup(unsigned long hvdescr_pa);

arch/sparc/kernel/smp_64.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg,
297297
unsigned long hv_err;
298298
int i;
299299

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),
303301
GFP_KERNEL);
304302
if (!hdesc) {
305303
printk(KERN_ERR "ldom_startcpu_cpuid: Cannot allocate "

arch/sparc/vdso/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64
4646
-fno-omit-frame-pointer -foptimize-sibling-calls \
4747
-DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
4848

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)
5050

5151
$(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
5252

arch/sparc/vdso/vclock_gettime.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ notrace static long vdso_fallback_gettimeofday(struct __kernel_old_timeval *tv,
8686
}
8787

8888
#ifdef CONFIG_SPARC64
89+
notrace static __always_inline u64 __shr64(u64 val, int amt)
90+
{
91+
return val >> amt;
92+
}
93+
8994
notrace static __always_inline u64 vread_tick(void)
9095
{
9196
u64 ret;
@@ -102,6 +107,21 @@ notrace static __always_inline u64 vread_tick_stick(void)
102107
return ret;
103108
}
104109
#else
110+
notrace static __always_inline u64 __shr64(u64 val, int amt)
111+
{
112+
u64 ret;
113+
114+
__asm__ __volatile__("sllx %H1, 32, %%g1\n\t"
115+
"srl %L1, 0, %L1\n\t"
116+
"or %%g1, %L1, %%g1\n\t"
117+
"srlx %%g1, %2, %L0\n\t"
118+
"srlx %L0, 32, %H0"
119+
: "=r" (ret)
120+
: "r" (val), "r" (amt)
121+
: "g1");
122+
return ret;
123+
}
124+
105125
notrace static __always_inline u64 vread_tick(void)
106126
{
107127
register unsigned long long ret asm("o4");
@@ -154,7 +174,7 @@ notrace static __always_inline int do_realtime(struct vvar_data *vvar,
154174
ts->tv_sec = vvar->wall_time_sec;
155175
ns = vvar->wall_time_snsec;
156176
ns += vgetsns(vvar);
157-
ns >>= vvar->clock.shift;
177+
ns = __shr64(ns, vvar->clock.shift);
158178
} while (unlikely(vvar_read_retry(vvar, seq)));
159179

160180
ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
@@ -174,7 +194,7 @@ notrace static __always_inline int do_realtime_stick(struct vvar_data *vvar,
174194
ts->tv_sec = vvar->wall_time_sec;
175195
ns = vvar->wall_time_snsec;
176196
ns += vgetsns_stick(vvar);
177-
ns >>= vvar->clock.shift;
197+
ns = __shr64(ns, vvar->clock.shift);
178198
} while (unlikely(vvar_read_retry(vvar, seq)));
179199

180200
ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
@@ -194,7 +214,7 @@ notrace static __always_inline int do_monotonic(struct vvar_data *vvar,
194214
ts->tv_sec = vvar->monotonic_time_sec;
195215
ns = vvar->monotonic_time_snsec;
196216
ns += vgetsns(vvar);
197-
ns >>= vvar->clock.shift;
217+
ns = __shr64(ns, vvar->clock.shift);
198218
} while (unlikely(vvar_read_retry(vvar, seq)));
199219

200220
ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
@@ -214,7 +234,7 @@ notrace static __always_inline int do_monotonic_stick(struct vvar_data *vvar,
214234
ts->tv_sec = vvar->monotonic_time_sec;
215235
ns = vvar->monotonic_time_snsec;
216236
ns += vgetsns_stick(vvar);
217-
ns >>= vvar->clock.shift;
237+
ns = __shr64(ns, vvar->clock.shift);
218238
} while (unlikely(vvar_read_retry(vvar, seq)));
219239

220240
ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);

scripts/Makefile.clang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu
1010
CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu
1111
CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
1212
CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
13+
CLANG_TARGET_FLAGS_sparc := sparc64-linux-gnu
1314
CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
1415
CLANG_TARGET_FLAGS_um := $(CLANG_TARGET_FLAGS_$(SUBARCH))
1516
CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH))

0 commit comments

Comments
 (0)