Skip to content

Commit bbcf9cd

Browse files
committed
Merge tag 'xtensa-20200805' of git://github.com/jcmvbkbc/linux-xtensa
Pull Xtensa updates from Max Filippov: - add syscall audit support - add seccomp filter support - clean up make rules under arch/xtensa/boot - fix state management for exclusive access opcodes - fix build with PMU enabled * tag 'xtensa-20200805' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: add missing exclusive access state management xtensa: fix xtensa_pmu_setup prototype xtensa: add boot subdirectories build artifacts to 'targets' xtensa: add uImage and xipImage to targets xtensa: move vmlinux.bin[.gz] to boot subdirectory xtensa: initialize_mmu.h: fix a duplicated word selftests/seccomp: add xtensa support xtensa: add seccomp support xtensa: expose syscall through user_pt_regs xtensa: add audit support
2 parents 9ab9bc5 + a0fc143 commit bbcf9cd

14 files changed

Lines changed: 87 additions & 16 deletions

File tree

Documentation/features/seccomp/seccomp-filter/arch-support.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
| sparc: | TODO |
3030
| um: | ok |
3131
| x86: | ok |
32-
| xtensa: | TODO |
32+
| xtensa: | ok |
3333
-----------------------

arch/xtensa/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ config XTENSA
2121
select GENERIC_PCI_IOMAP
2222
select GENERIC_SCHED_CLOCK
2323
select GENERIC_STRNCPY_FROM_USER if KASAN
24+
select HAVE_ARCH_AUDITSYSCALL
2425
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
2526
select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
27+
select HAVE_ARCH_SECCOMP_FILTER
2628
select HAVE_ARCH_TRACEHOOK
2729
select HAVE_DEBUG_KMEMLEAK
2830
select HAVE_DMA_CONTIGUOUS
@@ -215,6 +217,20 @@ config HOTPLUG_CPU
215217

216218
Say N if you want to disable CPU hotplug.
217219

220+
config SECCOMP
221+
bool
222+
prompt "Enable seccomp to safely compute untrusted bytecode"
223+
help
224+
This kernel feature is useful for number crunching applications
225+
that may need to compute untrusted bytecode during their
226+
execution. By using pipes or other transports made available to
227+
the process as file descriptors supporting the read/write
228+
syscalls, it's possible to isolate those applications in
229+
their own address space using seccomp. Once seccomp is
230+
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
231+
and the task is only allowed to execute a few safe syscalls
232+
defined by each seccomp mode.
233+
218234
config FAST_SYSCALL_XTENSA
219235
bool "Enable fast atomic syscalls"
220236
default n

arch/xtensa/boot/Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ BIG_ENDIAN := $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
1717
export BIG_ENDIAN
1818

1919
subdir-y := lib
20+
targets += vmlinux.bin vmlinux.bin.gz
21+
targets += uImage xipImage
2022

2123
# Subdirs for the boot loader(s)
2224

@@ -35,19 +37,19 @@ boot-elf boot-redboot: $(addprefix $(obj)/,$(subdir-y))
3537

3638
OBJCOPYFLAGS = --strip-all -R .comment -R .notes -O binary
3739

38-
vmlinux.bin: vmlinux FORCE
40+
$(obj)/vmlinux.bin: vmlinux FORCE
3941
$(call if_changed,objcopy)
4042

41-
vmlinux.bin.gz: vmlinux.bin FORCE
43+
$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
4244
$(call if_changed,gzip)
4345

44-
boot-elf: vmlinux.bin
45-
boot-redboot: vmlinux.bin.gz
46+
boot-elf: $(obj)/vmlinux.bin
47+
boot-redboot: $(obj)/vmlinux.bin.gz
4648

4749
UIMAGE_LOADADDR = $(CONFIG_KERNEL_LOAD_ADDRESS)
4850
UIMAGE_COMPRESSION = gzip
4951

50-
$(obj)/uImage: vmlinux.bin.gz FORCE
52+
$(obj)/uImage: $(obj)/vmlinux.bin.gz FORCE
5153
$(call if_changed,uimage)
5254
$(Q)$(kecho) ' Kernel: $@ is ready'
5355

arch/xtensa/boot/boot-elf/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export CPPFLAGS_boot.lds += -P -C
1515
export KBUILD_AFLAGS += -mtext-section-literals
1616

1717
boot-y := bootstrap.o
18+
targets += $(boot-y) boot.lds
1819

1920
OBJS := $(addprefix $(obj)/,$(boot-y))
2021

21-
$(obj)/Image.o: vmlinux.bin $(OBJS)
22+
$(obj)/Image.o: $(obj)/../vmlinux.bin $(OBJS)
2223
$(Q)$(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
23-
--add-section image=vmlinux.bin \
24+
--add-section image=$< \
2425
--set-section-flags image=contents,alloc,load,load,data \
2526
$(OBJS) $@
2627

arch/xtensa/boot/boot-redboot/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ endif
1313
LD_ARGS = -T $(srctree)/$(obj)/boot.ld
1414

1515
boot-y := bootstrap.o
16+
targets += $(boot-y)
1617

1718
OBJS := $(addprefix $(obj)/,$(boot-y))
1819
LIBS := arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a
1920

2021
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
2122

22-
$(obj)/zImage.o: vmlinux.bin.gz $(OBJS)
23+
$(obj)/zImage.o: $(obj)/../vmlinux.bin.gz $(OBJS)
2324
$(Q)$(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
24-
--add-section image=vmlinux.bin.gz \
25+
--add-section image=$< \
2526
--set-section-flags image=contents,alloc,load,load,data \
2627
$(OBJS) $@
2728

arch/xtensa/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ generic-y += mcs_spinlock.h
77
generic-y += param.h
88
generic-y += qrwlock.h
99
generic-y += qspinlock.h
10+
generic-y += seccomp.h
1011
generic-y += user.h

arch/xtensa/include/asm/initialize_mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* For the new V3 MMU we remap the TLB from virtual == physical
77
* to the standard Linux mapping used in earlier MMU's.
88
*
9-
* The the MMU we also support a new configuration register that
9+
* For the MMU we also support a new configuration register that
1010
* specifies how the S32C1I instruction operates with the cache
1111
* controller.
1212
*

arch/xtensa/include/asm/thread_info.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ struct thread_info {
5555
mm_segment_t addr_limit; /* thread address space */
5656

5757
unsigned long cpenable;
58+
#if XCHAL_HAVE_EXCLUSIVE
59+
/* result of the most recent exclusive store */
60+
unsigned long atomctl8;
61+
#endif
5862

5963
/* Allocate storage for extra user states and coprocessor states. */
6064
#if XTENSA_HAVE_COPROCESSORS
@@ -111,15 +115,20 @@ static inline struct thread_info *current_thread_info(void)
111115
#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
112116
#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
113117
#define TIF_DB_DISABLED 8 /* debug trap disabled for syscall */
118+
#define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */
119+
#define TIF_SECCOMP 10 /* secure computing */
114120

115121
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
116122
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
117123
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
118124
#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
119125
#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
126+
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
127+
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
120128

121129
#define _TIF_WORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
122-
_TIF_SYSCALL_TRACEPOINT)
130+
_TIF_SYSCALL_TRACEPOINT | \
131+
_TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
123132

124133
#define THREAD_SIZE KERNEL_STACK_SIZE
125134
#define THREAD_SIZE_ORDER (KERNEL_STACK_SHIFT - PAGE_SHIFT)

arch/xtensa/include/uapi/asm/ptrace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ struct user_pt_regs {
5050
__u32 windowstart;
5151
__u32 windowbase;
5252
__u32 threadptr;
53-
__u32 reserved[7 + 48];
53+
__u32 syscall;
54+
__u32 reserved[6 + 48];
5455
__u32 a[64];
5556
};
5657

arch/xtensa/kernel/asm-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ int main(void)
9393
DEFINE(THREAD_RA, offsetof (struct task_struct, thread.ra));
9494
DEFINE(THREAD_SP, offsetof (struct task_struct, thread.sp));
9595
DEFINE(THREAD_CPENABLE, offsetof (struct thread_info, cpenable));
96+
#if XCHAL_HAVE_EXCLUSIVE
97+
DEFINE(THREAD_ATOMCTL8, offsetof (struct thread_info, atomctl8));
98+
#endif
9699
#if XTENSA_HAVE_COPROCESSORS
97100
DEFINE(THREAD_XTREGS_CP0, offsetof(struct thread_info, xtregs_cp.cp0));
98101
DEFINE(THREAD_XTREGS_CP1, offsetof(struct thread_info, xtregs_cp.cp1));

0 commit comments

Comments
 (0)