Skip to content

Commit e2316b7

Browse files
author
Fox Snowpatch
committed
1 parent 25ce7a5 commit e2316b7

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ config PPC
285285
select HAVE_RSEQ
286286
select HAVE_SAMPLE_FTRACE_DIRECT if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
287287
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
288+
select HAVE_RUST if PPC64
288289
select HAVE_SETUP_PER_CPU_AREA if PPC64
289290
select HAVE_SOFTIRQ_ON_OWN_STACK
290291
select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)

arch/powerpc/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)
172172

173173
asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
174174

175-
KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr)
176-
KBUILD_AFLAGS += $(AFLAGS-y)
177-
KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU)
178-
KBUILD_CFLAGS += $(CFLAGS-y)
175+
KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr)
176+
KBUILD_AFLAGS += $(AFLAGS-y)
177+
KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU)
178+
KBUILD_CFLAGS += $(CFLAGS-y)
179+
KBUILD_RUSTFLAGS += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
179180

180181
CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
181182
ifdef CONFIG_CPU_BIG_ENDIAN

arch/powerpc/include/asm/jump_label.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@
1515
#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
1616
#define JUMP_LABEL_NOP_SIZE 4
1717

18+
#define JUMP_TABLE_ENTRY(key, label) \
19+
".pushsection __jump_table, \"aw\" \n\t" \
20+
".long 1b - ., " label " - . \n\t" \
21+
JUMP_ENTRY_TYPE key " - . \n\t" \
22+
".popsection \n\t"
23+
24+
#define ARCH_STATIC_BRANCH_ASM(key, label) \
25+
"1: nop \n\t" \
26+
JUMP_TABLE_ENTRY(key,label)
27+
1828
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
1929
{
20-
asm goto("1:\n\t"
21-
"nop # arch_static_branch\n\t"
22-
".pushsection __jump_table, \"aw\"\n\t"
23-
".long 1b - ., %l[l_yes] - .\n\t"
24-
JUMP_ENTRY_TYPE "%c0 - .\n\t"
25-
".popsection \n\t"
30+
asm goto(
31+
ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
2632
: : "i" (&((char *)key)[branch]) : : l_yes);
2733

2834
return false;
@@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
3440
{
3541
asm goto("1:\n\t"
3642
"b %l[l_yes] # arch_static_branch_jump\n\t"
37-
".pushsection __jump_table, \"aw\"\n\t"
38-
".long 1b - ., %l[l_yes] - .\n\t"
39-
JUMP_ENTRY_TYPE "%c0 - .\n\t"
40-
".popsection \n\t"
43+
JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
4144
: : "i" (&((char *)key)[branch]) : : l_yes);
4245

4346
return false;

rust/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ BINDGEN_TARGET_x86 := x86_64-linux-gnu
390390
BINDGEN_TARGET_arm64 := aarch64-linux-gnu
391391
BINDGEN_TARGET_arm := arm-linux-gnueabi
392392
BINDGEN_TARGET_loongarch := loongarch64-linux-gnusf
393+
BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
393394
BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
394395
BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
395396

scripts/generate_rust_target.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,30 @@ fn main() {
256256
}
257257
} else if cfg.has("LOONGARCH") {
258258
panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
259+
} else if cfg.has("PPC64") {
260+
ts.push("arch", "powerpc64");
261+
ts.push(
262+
"data-layout",
263+
if cfg.has("CPU_LITTLE_ENDIAN") {
264+
"e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
265+
} else {
266+
"E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
267+
},
268+
);
269+
ts.push("features", "-mma,-altivec,-vsx,-hard-float");
270+
ts.push(
271+
"llvm-target",
272+
if cfg.has("CPU_LITTLE_ENDIAN") {
273+
"powerpc64le-linux-gnu"
274+
} else {
275+
"powerpc64-linux-gnu"
276+
},
277+
);
278+
if cfg.rustc_version_atleast(1, 91, 0) {
279+
ts.push("target-pointer-width", 64);
280+
} else {
281+
ts.push("target-pointer-width", "64");
282+
}
259283
} else {
260284
panic!("Unsupported architecture");
261285
}

0 commit comments

Comments
 (0)