Merge tag 'powerpc-5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc updates from Michael Ellerman:

 - Optimise radix KVM guest entry/exit by 2x on Power9/Power10.

 - Allow firmware to tell us whether to disable the entry and uaccess
   flushes on Power10 or later CPUs.

 - Add BPF_PROBE_MEM support for 32 and 64-bit BPF jits.

 - Several fixes and improvements to our hard lockup watchdog.

 - Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on 32-bit.

 - Allow building the 64-bit Book3S kernel without hash MMU support, ie.
   Radix only.

 - Add KUAP (SMAP) support for 40x, 44x, 8xx, Book3E (64-bit).

 - Add new encodings for perf_mem_data_src.mem_hops field, and use them
   on Power10.

 - A series of small performance improvements to 64-bit interrupt entry.

 - Several commits fixing issues when building with the clang integrated
   assembler.

 - Many other small features and fixes.

Thanks to Alan Modra, Alexey Kardashevskiy, Ammar Faizi, Anders Roxell,
Arnd Bergmann, Athira Rajeev, Cédric Le Goater, Christophe JAILLET,
Christophe Leroy, Christoph Hellwig, Daniel Axtens, David Yang, Erhard
Furtner, Fabiano Rosas, Greg Kroah-Hartman, Guo Ren, Hari Bathini, Jason
Wang, Joel Stanley, Julia Lawall, Kajol Jain, Kees Cook, Laurent Dufour,
Madhavan Srinivasan, Mark Brown, Minghao Chi, Nageswara R Sastry, Naresh
Kamboju, Nathan Chancellor, Nathan Lynch, Nicholas Piggin, Nick Child,
Oliver O'Halloran, Peiwei Hu, Randy Dunlap, Ravi Bangoria, Rob Herring,
Russell Currey, Sachin Sant, Sean Christopherson, Segher Boessenkool,
Thadeu Lima de Souza Cascardo, Tyrel Datwyler, Xiang wangx, and Yang
Guang.

* tag 'powerpc-5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (240 commits)
  powerpc/xmon: Dump XIVE information for online-only processors.
  powerpc/opal: use default_groups in kobj_type
  powerpc/cacheinfo: use default_groups in kobj_type
  powerpc/sched: Remove unused TASK_SIZE_OF
  powerpc/xive: Add missing null check after calling kmalloc
  powerpc/floppy: Remove usage of the deprecated "pci-dma-compat.h" API
  selftests/powerpc: Add a test of sigreturning to an unaligned address
  powerpc/64s: Use EMIT_WARN_ENTRY for SRR debug warnings
  powerpc/64s: Mask NIP before checking against SRR0
  powerpc/perf: Fix spelling of "its"
  powerpc/32: Fix boot failure with GCC latent entropy plugin
  powerpc/code-patching: Replace patch_instruction() by ppc_inst_write() in selftests
  powerpc/code-patching: Move code patching selftests in its own file
  powerpc/code-patching: Move instr_is_branch_{i/b}form() in code-patching.h
  powerpc/code-patching: Move patch_exception() outside code-patching.c
  powerpc/code-patching: Use test_trampoline for prefixed patch test
  powerpc/code-patching: Fix patch_branch() return on out-of-range failure
  powerpc/code-patching: Reorganise do_patch_instruction() to ease error handling
  powerpc/code-patching: Fix unmap_patch_area() error handling
  powerpc/code-patching: Fix error handling in do_patch_instruction()
  ...
This commit is contained in:
Linus Torvalds
2022-01-14 15:17:26 +01:00
370 changed files with 5636 additions and 3449 deletions

View File

@@ -44,7 +44,10 @@ mitigations="barrier_nospec stf_barrier count_cache_flush rfi_flush entry_flush
for m in $mitigations
do
do_one "$m" &
if [[ -f /sys/kernel/debug/powerpc/$m ]]
then
do_one "$m" &
fi
done
echo "Spawned threads enabling/disabling mitigations ..."

View File

@@ -193,7 +193,7 @@ int spectre_v2_test(void)
* We are not vulnerable and reporting otherwise, so
* missing such a mismatch is safe.
*/
if (state == VULNERABLE)
if (miss_percent > 95)
return 4;
return 1;

View File

@@ -4,3 +4,5 @@ signal_tm
sigfuz
sigreturn_vdso
sig_sc_double_restart
sigreturn_kernel
sigreturn_unaligned

View File

@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
TEST_GEN_PROGS := signal signal_tm sigfuz sigreturn_vdso sig_sc_double_restart
TEST_GEN_PROGS += sigreturn_kernel
TEST_GEN_PROGS += sigreturn_unaligned
CFLAGS += -maltivec
$(OUTPUT)/signal_tm: CFLAGS += -mhtm

View File

@@ -0,0 +1,132 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Test that we can't sigreturn to kernel addresses, or to kernel mode.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "utils.h"
#define MSR_PR (1ul << 14)
static volatile unsigned long long sigreturn_addr;
static volatile unsigned long long sigreturn_msr_mask;
static void sigusr1_handler(int signo, siginfo_t *si, void *uc_ptr)
{
ucontext_t *uc = (ucontext_t *)uc_ptr;
if (sigreturn_addr)
UCONTEXT_NIA(uc) = sigreturn_addr;
if (sigreturn_msr_mask)
UCONTEXT_MSR(uc) &= sigreturn_msr_mask;
}
static pid_t fork_child(void)
{
pid_t pid;
pid = fork();
if (pid == 0) {
raise(SIGUSR1);
exit(0);
}
return pid;
}
static int expect_segv(pid_t pid)
{
int child_ret;
waitpid(pid, &child_ret, 0);
FAIL_IF(WIFEXITED(child_ret));
FAIL_IF(!WIFSIGNALED(child_ret));
FAIL_IF(WTERMSIG(child_ret) != 11);
return 0;
}
int test_sigreturn_kernel(void)
{
struct sigaction act;
int child_ret, i;
pid_t pid;
act.sa_sigaction = sigusr1_handler;
act.sa_flags = SA_SIGINFO;
sigemptyset(&act.sa_mask);
FAIL_IF(sigaction(SIGUSR1, &act, NULL));
for (i = 0; i < 2; i++) {
// Return to kernel
sigreturn_addr = 0xcull << 60;
pid = fork_child();
expect_segv(pid);
// Return to kernel virtual
sigreturn_addr = 0xc008ull << 48;
pid = fork_child();
expect_segv(pid);
// Return out of range
sigreturn_addr = 0xc010ull << 48;
pid = fork_child();
expect_segv(pid);
// Return to no-man's land, just below PAGE_OFFSET
sigreturn_addr = (0xcull << 60) - (64 * 1024);
pid = fork_child();
expect_segv(pid);
// Return to no-man's land, above TASK_SIZE_4PB
sigreturn_addr = 0x1ull << 52;
pid = fork_child();
expect_segv(pid);
// Return to 0xd space
sigreturn_addr = 0xdull << 60;
pid = fork_child();
expect_segv(pid);
// Return to 0xe space
sigreturn_addr = 0xeull << 60;
pid = fork_child();
expect_segv(pid);
// Return to 0xf space
sigreturn_addr = 0xfull << 60;
pid = fork_child();
expect_segv(pid);
// Attempt to set PR=0 for 2nd loop (should be blocked by kernel)
sigreturn_msr_mask = ~MSR_PR;
}
printf("All children killed as expected\n");
// Don't change address, just MSR, should return to user as normal
sigreturn_addr = 0;
sigreturn_msr_mask = ~MSR_PR;
pid = fork_child();
waitpid(pid, &child_ret, 0);
FAIL_IF(!WIFEXITED(child_ret));
FAIL_IF(WIFSIGNALED(child_ret));
FAIL_IF(WEXITSTATUS(child_ret) != 0);
return 0;
}
int main(void)
{
return test_harness(test_sigreturn_kernel, "sigreturn_kernel");
}

View File

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Test sigreturn to an unaligned address, ie. low 2 bits set.
* Nothing bad should happen.
* This was able to trigger warnings with CONFIG_PPC_RFI_SRR_DEBUG=y.
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
#include <unistd.h>
#include "utils.h"
static void sigusr1_handler(int signo, siginfo_t *info, void *ptr)
{
ucontext_t *uc = ptr;
UCONTEXT_NIA(uc) |= 3;
}
static int test_sigreturn_unaligned(void)
{
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_sigaction = sigusr1_handler;
action.sa_flags = SA_SIGINFO;
FAIL_IF(sigaction(SIGUSR1, &action, NULL) == -1);
raise(SIGUSR1);
return 0;
}
int main(void)
{
return test_harness(test_sigreturn_unaligned, "sigreturn_unaligned");
}