Re: [PATCH] powerpc/64s: Clear PCR on boot

2018-05-26 Thread Guenter Roeck
Hi Michael,

On Sun, May 27, 2018 at 12:22:23PM +1000, Michael Ellerman wrote:
> 
> 
> On 25 May 2018 11:33:08 pm AEST, Guenter Roeck  wrote:
> >On Fri, May 18, 2018 at 11:37:42AM +1000, Michael Neuling wrote:
> >> Clear the PCR (Processor Compatibility Register) on boot to ensure we
> >> are not running in a compatibility mode.
> >> 
> >> We've seen this cause problems when a crash (and kdump) occurs while
> >> running compat mode guests. The kdump kernel then runs with the PCR
> >> set and causes problems. The symptom in the kdump kernel (also seen
> >in
> >> petitboot after fast-reboot) is early userspace programs taking
> >> sigills on newer instructions (seen in libc).
> >> 
> >
> >Hi folks,
> >
> >this patch causes qemu to bail out with
> >
> >Trying to write privileged spr 338 (0x152) at c0033454
> >
> >when running it with "-M powernv -cpu POWER8" and powernv_defconfig.
> >
> >Can you confirm that this is a bug in qemu ?
> 
> Hi Guenter,
> 
> Thanks for the report. As far as I'm concerned this is a qemu bug, that 
> register should exist on a bare metal Power8.
> 
> Will try and get you a qemu patch to fix it.
> 
I already have a patch, or at least one that does the trick for me.
Getting qemu patched was not the problem. I just want to be sure that
the problem is indeed a qemu problem.

Thanks,
Guenter

---
>From 1617bac264b4c49d817b6947611affa9b73318f6 Mon Sep 17 00:00:00 2001
From: Guenter Roeck 
Date: Fri, 25 May 2018 06:38:40 -0700
Subject: [PATCH] PowerPC: Permit privileged access to SPR_PCR for POWER7+

Without this access, Linux mainline bails out.

Signed-off-by: Guenter Roeck 
---
 target/ppc/translate_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index 391b94b..3b09c49 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -7953,11 +7953,12 @@ static void gen_spr_power6_common(CPUPPCState *env)
 #endif
 /*
  * Register PCR to report POWERPC_EXCP_PRIV_REG instead of
- * POWERPC_EXCP_INVAL_SPR.
+ * POWERPC_EXCP_INVAL_SPR in userspace. Permit privileged
+ * access.
  */
 spr_register(env, SPR_PCR, "PCR",
  SPR_NOACCESS, SPR_NOACCESS,
- SPR_NOACCESS, SPR_NOACCESS,
+ &spr_read_generic, &spr_write_generic,
  0x);
 }
 
-- 
2.7.4





Re: [PATCH] powerpc/64s: Clear PCR on boot

2018-05-26 Thread Michael Ellerman


On 25 May 2018 11:33:08 pm AEST, Guenter Roeck  wrote:
>On Fri, May 18, 2018 at 11:37:42AM +1000, Michael Neuling wrote:
>> Clear the PCR (Processor Compatibility Register) on boot to ensure we
>> are not running in a compatibility mode.
>> 
>> We've seen this cause problems when a crash (and kdump) occurs while
>> running compat mode guests. The kdump kernel then runs with the PCR
>> set and causes problems. The symptom in the kdump kernel (also seen
>in
>> petitboot after fast-reboot) is early userspace programs taking
>> sigills on newer instructions (seen in libc).
>> 
>
>Hi folks,
>
>this patch causes qemu to bail out with
>
>Trying to write privileged spr 338 (0x152) at c0033454
>
>when running it with "-M powernv -cpu POWER8" and powernv_defconfig.
>
>Can you confirm that this is a bug in qemu ?

Hi Guenter,

Thanks for the report. As far as I'm concerned this is a qemu bug, that 
register should exist on a bare metal Power8.

Will try and get you a qemu patch to fix it.

cheers

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


ptrace_syscall_dropped.c:298:TRACE_syscall.ptrace_syscall_dropped:Expected 1 (1) == syscall(286) (4294967295)

2018-05-26 Thread Mathieu Malaterre
Hi,

On Tue, May 8, 2018 at 4:34 PM, Michael Ellerman  wrote:
> Mathieu Malaterre  writes:
>
>> Hi there,
>>
>> Quick question (I have not investigate root cause): is support for
>> seccomp complete on ppc32 ?
>
> Doesn't look like it does it :)
>
>> $ make KBUILD_OUTPUT=/tmp/kselftest TARGETS=seccomp kselftest
>> ...
>> seccomp_bpf.c:1804:TRACE_syscall.ptrace_syscall_dropped:Expected 1 (1)
>> == syscall(286) (4294967295)
>> TRACE_syscall.ptrace_syscall_dropped: Test failed at step #13
>> [ FAIL ] TRACE_syscall.ptrace_syscall_dropped
>> ...
>> [ RUN  ] global.get_metadata
>> seccomp_bpf.c:2880:global.get_metadata:Expected 0 (0) == seccomp(1, 2,
>> &prog) (4294967295)
>> seccomp_bpf.c:2892:global.get_metadata:Expected 1 (1) ==
>> read(pipefd[0], &buf, 1) (0)
>> global.get_metadata: Test terminated by assertion
>> [ FAIL ] global.get_metadata
>
> I'm not sure sorry.
>
> That could be a test case bug, hard to say without looking at the
> details.

I've reduced the test case to the attached file. Does that help, or
should I reduce it some more ?

$ gcc -m32 -o ptrace_syscall_dropped ptrace_syscall_dropped.c

running it as root:

# ./ptrace_syscall_dropped
[==] Running 1 tests from 1 test cases.
[ RUN  ] TRACE_syscall.ptrace_syscall_dropped
ptrace_syscall_dropped.c:298:TRACE_syscall.ptrace_syscall_dropped:Expected
1 (1) == syscall(286) (4294967295)
TRACE_syscall.ptrace_syscall_dropped: Test failed at step #13
[ FAIL ] TRACE_syscall.ptrace_syscall_dropped
[==] 0 / 1 tests passed.
[  FAILED  ]


Thanks
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define _GNU_SOURCE
#include 
#include 

#include "tools/testing/selftests/kselftest_harness.h"

#define IS_SECCOMP_EVENT(status) ((status >> 16) == PTRACE_EVENT_SECCOMP)
static bool tracer_running;
static void tracer_stop(int sig)
{
	tracer_running = false;
}

typedef void tracer_func_t(struct __test_metadata *_metadata,
			   pid_t tracee, int status, void *args);

static void start_tracer(struct __test_metadata *_metadata, int fd, pid_t tracee,
	tracer_func_t tracer_func, void *args, bool ptrace_syscall)
{
	int ret = -1;
	struct sigaction action = {
		.sa_handler = tracer_stop,
	};

	/* Allow external shutdown. */
	tracer_running = true;
	ASSERT_EQ(0, sigaction(SIGUSR1, &action, NULL));

	errno = 0;
	while (ret == -1 && errno != EINVAL)
		ret = ptrace(PTRACE_ATTACH, tracee, NULL, 0);
	ASSERT_EQ(0, ret) {
		kill(tracee, SIGKILL);
	}
	/* Wait for attach stop */
	wait(NULL);

	ret = ptrace(PTRACE_SETOPTIONS, tracee, NULL, ptrace_syscall ?
		  PTRACE_O_TRACESYSGOOD :
		  PTRACE_O_TRACESECCOMP);
	ASSERT_EQ(0, ret) {
		TH_LOG("Failed to set PTRACE_O_TRACESECCOMP");
		kill(tracee, SIGKILL);
	}
	ret = ptrace(ptrace_syscall ? PTRACE_SYSCALL : PTRACE_CONT,
		 tracee, NULL, 0);
	ASSERT_EQ(0, ret);

	/* Unblock the tracee */
	ASSERT_EQ(1, write(fd, "A", 1));
	ASSERT_EQ(0, close(fd));

	/* Run until we're shut down. Must assert to stop execution. */
	while (tracer_running) {
		int status;

		if (wait(&status) != tracee)
			continue;
		if (WIFSIGNALED(status) || WIFEXITED(status))
			/* Child is dead. Time to go. */
			return;

		/* Check if this is a seccomp event. */
		ASSERT_EQ(!ptrace_syscall, IS_SECCOMP_EVENT(status));

		tracer_func(_metadata, tracee, status, args);

		ret = ptrace(ptrace_syscall ? PTRACE_SYSCALL : PTRACE_CONT,
			 tracee, NULL, 0);
		ASSERT_EQ(0, ret);
	}
	/* Directly report the status of our test harness results. */
	syscall(__NR_exit, _metadata->passed ? EXIT_SUCCESS : EXIT_FAILURE);
}

/* Common tracer setup/teardown functions. */
static void cont_handler(int num)
{ }
static pid_t setup_trace_fixture(struct __test_metadata *_metadata,
			  tracer_func_t func, void *args, bool ptrace_syscall)
{
	char sync;
	int pipefd[2];
	pid_t tracer_pid;
	pid_t tracee = getpid();

	/* Setup a pipe for clean synchronization. */
	ASSERT_EQ(0, pipe(pipefd));

	/* Fork a child which we'll promote to tracer */
	tracer_pid = fork();
	ASSERT_LE(0, tracer_pid);
	signal(SIGALRM, cont_handler);
	if (tracer_pid == 0) {
		close(pipefd[0]);
		start_tracer(_metadata, pipefd[1], tracee, func, args,
			 ptrace_syscall);
		syscall(__NR_exit, 0);
	}
	close(pipefd[1]);
	prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
	read(pipefd[0], &sync, 1);
	close(pipefd[0]);

	return tracer_pid;
}
static void teardown_trace_fixture(struct __test_metadata *_metadata,
			pid_t tracer)
{
	if (tracer) {
		int status;
		/*
		 * Extract the exit code from the other process and
		 * adopt it for ourselves in case its asserts failed.
		 */
		ASSERT_EQ(0, kill(tracer, SIGUSR1));
		ASSERT_EQ(tracer, waitpid(tracer, &status, 0));
		if (WEXITSTATUS(status))
			_metadata->passed = 0;
	}
}

# define ARCH_REGS	struct pt_regs
# define SYSCALL_NUM	gpr[0]
# define SYSCALL_RET	gpr[3]

/* Architecture-specific syscall fetching routine. */
static int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
{
	ARCH_

Re: arch/powerpc/kernel/head_32.S:1106: Error: missing operand

2018-05-26 Thread Segher Boessenkool
On Sat, May 26, 2018 at 06:35:34AM +0200, Paul Menzel wrote:
> Building the configuration created with `make tinyconfig` on the Power 8 
> system IBM S822LC with Ubuntu 18.04 fails with the error below.

>   AS  arch/powerpc/kernel/head_32.o
> arch/powerpc/kernel/head_32.S: Assembler messages:
> arch/powerpc/kernel/head_32.S:1106: Error: missing operand

You are building a 32-bit kernel for a 64-bit machine.  This is not
supported, and as you found out, does not work.


Segher


Re: arch/powerpc/kernel/head_32.S:1106: Error: missing operand

2018-05-26 Thread Paul Menzel

Dear Christophe,


Am 26.05.2018 um 18:02 schrieb christophe leroy:


Le 26/05/2018 à 06:35, Paul Menzel a écrit :


Building the configuration created with `make tinyconfig` on the Power 
8 system IBM S822LC with Ubuntu 18.04 fails with the error below.


```
$ git describe --dirty
v4.17-rc6-296-gbc2dbc5420e8
$ git log --oneline -1
bc2dbc5420e8 (HEAD -> master, origin/master, origin/HEAD) Merge branch 
'akpm' (patches from Andrew)

$ make tinyconfig
$ make -j120
[…]
   AS  arch/powerpc/kernel/head_32.o
arch/powerpc/kernel/head_32.S: Assembler messages:
arch/powerpc/kernel/head_32.S:1106: Error: missing operand


There was a similar problem in 2015, see 
http://linux-kernel.2935.n7.nabble.com/Missing-operand-for-tlbie-instruction-on-Power7-td1206917.html


Which version of binutils do you use ?


2.30-15ubuntu1 is installed.


Kind regards,

Paul


Re: arch/powerpc/kernel/head_32.S:1106: Error: missing operand

2018-05-26 Thread christophe leroy



Le 26/05/2018 à 06:35, Paul Menzel a écrit :

Dear Linux folks,


Building the configuration created with `make tinyconfig` on the Power 8 
system IBM S822LC with Ubuntu 18.04 fails with the error below.


```
$ git describe --dirty
v4.17-rc6-296-gbc2dbc5420e8
$ git log --oneline -1
bc2dbc5420e8 (HEAD -> master, origin/master, origin/HEAD) Merge branch 
'akpm' (patches from Andrew)

$ make tinyconfig
$ make -j120
[…]
   AS  arch/powerpc/kernel/head_32.o
arch/powerpc/kernel/head_32.S: Assembler messages:
arch/powerpc/kernel/head_32.S:1106: Error: missing operand


There was a similar problem in 2015, see 
http://linux-kernel.2935.n7.nabble.com/Missing-operand-for-tlbie-instruction-on-Power7-td1206917.html


Which version of binutils do you use ?

Christophe

scripts/Makefile.build:413: recipe for target 
'arch/powerpc/kernel/head_32.o' failed

make[1]: *** [arch/powerpc/kernel/head_32.o] Error 1
[…]
```

Is this expected? *ppc64_defconfig* and *ppc64e_defconfig* build fine.


Kind regards,

Paul


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus



[PATCH] powerpc-opal: fix spelling mistake "Uniterrupted" -> "Uninterrupted"

2018-05-26 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in hmi_error_types text

Signed-off-by: Colin Ian King 
---
 arch/powerpc/platforms/powernv/opal-hmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal-hmi.c 
b/arch/powerpc/platforms/powernv/opal-hmi.c
index 4efc95b4c7d4..586ec71a4e17 100644
--- a/arch/powerpc/platforms/powernv/opal-hmi.c
+++ b/arch/powerpc/platforms/powernv/opal-hmi.c
@@ -177,7 +177,7 @@ static void print_hmi_event_info(struct OpalHMIEvent 
*hmi_evt)
"Processor recovery occurred for masked error",
"Timer facility experienced an error",
"TFMR SPR is corrupted",
-   "UPS (Uniterrupted Power System) Overflow indication",
+   "UPS (Uninterrupted Power System) Overflow indication",
"An XSCOM operation failure",
"An XSCOM operation completed",
"SCOM has set a reserved FIR bit to cause recovery",
-- 
2.17.0



arch/powerpc/kernel/head_32.S:1106: Error: missing operand

2018-05-26 Thread Paul Menzel

Dear Linux folks,


Building the configuration created with `make tinyconfig` on the Power 8 
system IBM S822LC with Ubuntu 18.04 fails with the error below.


```
$ git describe --dirty
v4.17-rc6-296-gbc2dbc5420e8
$ git log --oneline -1
bc2dbc5420e8 (HEAD -> master, origin/master, origin/HEAD) Merge branch 
'akpm' (patches from Andrew)

$ make tinyconfig
$ make -j120
[…]
  AS  arch/powerpc/kernel/head_32.o
arch/powerpc/kernel/head_32.S: Assembler messages:
arch/powerpc/kernel/head_32.S:1106: Error: missing operand
scripts/Makefile.build:413: recipe for target 
'arch/powerpc/kernel/head_32.o' failed

make[1]: *** [arch/powerpc/kernel/head_32.o] Error 1
[…]
```

Is this expected? *ppc64_defconfig* and *ppc64e_defconfig* build fine.


Kind regards,

Paul


Re: [PATCH] sound: Use octal not symbolic permissions

2018-05-26 Thread Vinod
On 23-05-18, 12:20, Joe Perches wrote:
> Convert the S_ symbolic permissions to their octal equivalents as
> using octal and not symbolic permissions is preferred by many as more
> readable.
> 
> see: https://lkml.org/lkml/2016/8/2/1945
> 
> Done with automated conversion via:
> $ ./scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace 
> 
> Miscellanea:
> 
> o Wrapped one multi-line call to a single line
> 
> Signed-off-by: Joe Perches 
> ---
>  sound/core/compress_offload.c |  2 +-

Acked-By: Vinod Koul 

-- 
~Vinod