LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 5/5] net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg
From: David Miller @ 2013-06-06  5:00 UTC (permalink / raw)
  To: eric.dumazet
  Cc: mikey, netdev, x86, linux-kernel, luto, linuxppc-dev, anton,
	trinity, torvalds
In-Reply-To: <1370493325.24311.332.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 05 Jun 2013 21:35:25 -0700

> On Thu, 2013-06-06 at 12:56 +1000, Michael Neuling wrote:
>> On Thu, May 23, 2013 at 7:07 AM, Andy Lutomirski <luto@amacapital.net> wrote:
>> > MSG_CMSG_COMPAT is (AFAIK) not intended to be part of the API --
>> > it's a hack that steals a bit to indicate to other networking code
>> > that a compat entry was used.  So don't allow it from a non-compat
>> > syscall.
>> 
>> Dave & Linus
>> 
>> This is causing a regression on 64bit powerpc with 32bit usermode.
>> When I hit userspace, udev is broken and I suspect all networking is
>> broken as well.
>> 
>> Can we please revert 1be374a0518a288147c6a7398792583200a67261 upstream?
>> 
> 
> It seems to also break x86_64, if using 32bit usermode.

Sorry, I only merged this because Ingo Molnar and others kept beating
me over the head about merging this fix.

Linus please revert, and I will not bow to such pressure in the future,
I should know better.

^ permalink raw reply

* Re: [PATCH] powerpc/pci: Improve device hotplug initialization
From: Guenter Roeck @ 2013-06-06  5:25 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Yuanquan Chen, Hiroo Matsumoto, linux-kernel, Paul Mackerras,
	Chen Yuanquan-B41889, linuxppc-dev
In-Reply-To: <1370480404.3766.260.camel@pasglop>

On Thu, Jun 06, 2013 at 11:00:04AM +1000, Benjamin Herrenschmidt wrote:
> On Sat, 2013-06-01 at 06:58 -0700, Guenter Roeck wrote:
> > the comment was actuially directed towards Yuanquan.
> > 
> > No problem, take your time. I did my best to test it, but I agree that this is a
> > critical area of the code, and it would be desirable to get additional scrutiny
> > and test feedback.
> > 
> > The code has been running in our system (P2020 and P5040) for several months.
> > I was preparing a patch for upstream submission when I noticed commit 37f02195b.
> > After testing ithis commit, I noticed the problems with it and wrote this patch,
> > which aligns the code with our initial patch. I tested it as good as I could on
> > our systems as well as with a P5040 evaluation board and an Intel GE PCIe
> > card.
> 
> Ok, so I like this very much. So much that I was considering still sneaking it
> into 3.10, until I hit a snag...
> 
> [ Basically, the previous patch that moved the setup to pcibios_enable_device()
> always made me nervous. It did regress at least one platform (mac stuff) due
> to missed IRQ fixup, which I worked around later on, and I'm still not terribly
> happy about it. Your approach is much cleaner. ]
> 
> I suppose that when I wrote the original setup stuff there wasn't an add
> hook or I didn't see it...
> 
> In fact I would go further and completely remove pcibios_setup_bus_devices()
> which is now empty since it's only called by the powerpc code, it's not
> a generic hook.
> 
> However, here's the snag. Unless I missed something, we now setup the devices
> DMA before we call pcibios_fixup_bus(). And *that* is going to break some
> pseries.
> 
> We have an assumption in there that the bus fixup is done first, because in
> some cases, the DMA windows are established at the bus level, and the "dev"
> setup just picks up the bits.
> 
> Now looking at that code, it's not unfixable but it won't make 3.10. Maybe
> we need a new pre-scan hook for busses... we can use the pcibios_add_device()
> hook of the bridge itself for P2P but that won't do for the root bus and I
> don't like having two different path here...
> 
Hi Ben,

you are right, pcibios_fixup_bus() is called after pcibios_add_device(),
at least in the initial scan.

Can you point me to some of the breaking code ? I guess it must be in some of
the pci_dma_dev_setup callbacks, but those I looked at only check devicetree
data or simply set function pointers, both of which should not be affected by
the call order.

How about pcibios_fixup_device, to be called after pcibios_fixup_bus ?

Thanks,
Guenter

^ permalink raw reply

* [PATCH] net: Unbreak compat_sys_{send,recv}msg
From: Andy Lutomirski @ 2013-06-06  5:38 UTC (permalink / raw)
  To: x86, torvalds, David S. Miller
  Cc: Michael Neuling, netdev, linux-kernel, Andy Lutomirski,
	Linux PPC dev, trinity
In-Reply-To: <20130606132926.f4161ddff87dc9a55e33a8ca@canb.auug.org.au>

I broke them in this commit:

    commit 1be374a0518a288147c6a7398792583200a67261
    Author: Andy Lutomirski <luto@amacapital.net>
    Date:   Wed May 22 14:07:44 2013 -0700

        net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg

This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints.  It
also reverts some unnecessary checks in sys_socketcall.

Apparently I was suffering from underscore blindness the first time around.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---

I've tested this a little, but I'm not sure I have a great test case.

If the decision is that it's better to leave this for the 3.11, I can send
a squashed version.  Note that the oops that this fixes is only an oops if
the other patches in the original series are applied.

(FWIW, I wasn't sure how to submit this stuff in the first place.  I submitted
some kernel hardening patches for the x86 tree that converted an access_ok
oddity in the net code into an actual oops.  In a bit of looking, I couldn't
find any failure mode other than a -EFAULT return without the other patches
applied.  This was clear in the patch series description but not in the
change log message for the net part.)

 include/linux/socket.h |  3 +++
 net/compat.c           | 13 +++++++--
 net/socket.c           | 72 +++++++++++++++++++++++---------------------------
 3 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 2b9f74b..e897bdc 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -321,6 +321,9 @@ extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
 
 struct timespec;
 
+/* The __sys_...msg variants allow MSG_CMSG_COMPAT */
+extern long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
+extern long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
 extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 			  unsigned int flags, struct timespec *timeout);
 extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
diff --git a/net/compat.c b/net/compat.c
index 79ae884..f0a1ba6 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -734,19 +734,25 @@ static unsigned char nas[21] = {
 
 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
 {
-	return sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
+	return __sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
 }
 
 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 				    unsigned int vlen, unsigned int flags)
 {
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
 	return __sys_sendmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 			      flags | MSG_CMSG_COMPAT);
 }
 
 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
 {
-	return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
+	return __sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
 }
 
 asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned int flags)
@@ -768,6 +774,9 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 	int datagrams;
 	struct timespec ktspec;
 
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
+
 	if (COMPAT_USE_64BIT_TIME)
 		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 				      flags | MSG_CMSG_COMPAT,
diff --git a/net/socket.c b/net/socket.c
index 0e16888..e216502 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1978,7 +1978,7 @@ struct used_address {
 	unsigned int name_len;
 };
 
-static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
+static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
 			 struct msghdr *msg_sys, unsigned int flags,
 			 struct used_address *used_address)
 {
@@ -2093,26 +2093,30 @@ out:
  *	BSD sendmsg interface
  */
 
-SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
+long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
 {
 	int fput_needed, err;
 	struct msghdr msg_sys;
 	struct socket *sock;
 
-	if (flags & MSG_CMSG_COMPAT)
-		return -EINVAL;
-
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
 		goto out;
 
-	err = __sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
+	err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
 
 	fput_light(sock->file, fput_needed);
 out:
 	return err;
 }
 
+SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
+{
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
+	return __sys_sendmsg(fd, msg, flags);
+}
+
 /*
  *	Linux sendmmsg interface
  */
@@ -2143,15 +2147,16 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 
 	while (datagrams < vlen) {
 		if (MSG_CMSG_COMPAT & flags) {
-			err = __sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
-					    &msg_sys, flags, &used_address);
+			err = ___sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
+					     &msg_sys, flags, &used_address);
 			if (err < 0)
 				break;
 			err = __put_user(err, &compat_entry->msg_len);
 			++compat_entry;
 		} else {
-			err = __sys_sendmsg(sock, (struct msghdr __user *)entry,
-					    &msg_sys, flags, &used_address);
+			err = ___sys_sendmsg(sock,
+					     (struct msghdr __user *)entry,
+					     &msg_sys, flags, &used_address);
 			if (err < 0)
 				break;
 			err = put_user(err, &entry->msg_len);
@@ -2180,7 +2185,7 @@ SYSCALL_DEFINE4(sendmmsg, int, fd, struct mmsghdr __user *, mmsg,
 	return __sys_sendmmsg(fd, mmsg, vlen, flags);
 }
 
-static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
+static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
 			 struct msghdr *msg_sys, unsigned int flags, int nosec)
 {
 	struct compat_msghdr __user *msg_compat =
@@ -2272,27 +2277,31 @@ out:
  *	BSD recvmsg interface
  */
 
-SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
-		unsigned int, flags)
+long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags)
 {
 	int fput_needed, err;
 	struct msghdr msg_sys;
 	struct socket *sock;
 
-	if (flags & MSG_CMSG_COMPAT)
-		return -EINVAL;
-
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
 		goto out;
 
-	err = __sys_recvmsg(sock, msg, &msg_sys, flags, 0);
+	err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0);
 
 	fput_light(sock->file, fput_needed);
 out:
 	return err;
 }
 
+SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
+		unsigned int, flags)
+{
+	if (flags & MSG_CMSG_COMPAT)
+		return -EINVAL;
+	return __sys_recvmsg(fd, msg, flags);
+}
+
 /*
  *     Linux recvmmsg interface
  */
@@ -2330,17 +2339,18 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 		 * No need to ask LSM for more than the first datagram.
 		 */
 		if (MSG_CMSG_COMPAT & flags) {
-			err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
-					    &msg_sys, flags & ~MSG_WAITFORONE,
-					    datagrams);
+			err = ___sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
+					     &msg_sys, flags & ~MSG_WAITFORONE,
+					     datagrams);
 			if (err < 0)
 				break;
 			err = __put_user(err, &compat_entry->msg_len);
 			++compat_entry;
 		} else {
-			err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
-					    &msg_sys, flags & ~MSG_WAITFORONE,
-					    datagrams);
+			err = ___sys_recvmsg(sock,
+					     (struct msghdr __user *)entry,
+					     &msg_sys, flags & ~MSG_WAITFORONE,
+					     datagrams);
 			if (err < 0)
 				break;
 			err = put_user(err, &entry->msg_len);
@@ -2525,31 +2535,15 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
 				   (int __user *)a[4]);
 		break;
 	case SYS_SENDMSG:
-		if (a[2] & MSG_CMSG_COMPAT) {
-			err = -EINVAL;
-			break;
-		}
 		err = sys_sendmsg(a0, (struct msghdr __user *)a1, a[2]);
 		break;
 	case SYS_SENDMMSG:
-		if (a[3] & MSG_CMSG_COMPAT) {
-			err = -EINVAL;
-			break;
-		}
 		err = sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3]);
 		break;
 	case SYS_RECVMSG:
-		if (a[2] & MSG_CMSG_COMPAT) {
-			err = -EINVAL;
-			break;
-		}
 		err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
 		break;
 	case SYS_RECVMMSG:
-		if (a[3] & MSG_CMSG_COMPAT) {
-			err = -EINVAL;
-			break;
-		}
 		err = sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3],
 				   (struct timespec __user *)a[4]);
 		break;
-- 
1.8.1.4

^ permalink raw reply related

* Re: [PATCH] powerpc/pci: Improve device hotplug initialization
From: Benjamin Herrenschmidt @ 2013-06-06  5:44 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Yuanquan Chen, Hiroo Matsumoto, linux-kernel, Paul Mackerras,
	Chen Yuanquan-B41889, linuxppc-dev
In-Reply-To: <20130606052508.GA1901@roeck-us.net>

On Wed, 2013-06-05 at 22:25 -0700, Guenter Roeck wrote:
> 
> 
> Can you point me to some of the breaking code ? I guess it must be in some of
> the pci_dma_dev_setup callbacks, but those I looked at only check devicetree
> data or simply set function pointers, both of which should not be affected by
> the call order.
> 
> How about pcibios_fixup_device, to be called after pcibios_fixup_bus ?

Mostly the pseries ones from a cursory glance. They could be improved to
be agnostic to the call order I suppose or simply done better but heh...

I like using pcibios_add though ... we just need to figure out how to
sort out that ordering if possible.

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH] net: Unbreak compat_sys_{send,recv}msg
From: Michael Neuling @ 2013-06-06  5:48 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: netdev, x86, linux-kernel, Linux PPC dev, trinity, torvalds,
	David S. Miller
In-Reply-To: <e3bf421e44c6d27817c15a8683612a49e093b419.1370496702.git.luto@amacapital.net>

Andy Lutomirski <luto@amacapital.net> wrote:

> I broke them in this commit:
> 
>     commit 1be374a0518a288147c6a7398792583200a67261
>     Author: Andy Lutomirski <luto@amacapital.net>
>     Date:   Wed May 22 14:07:44 2013 -0700
> 
>         net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg
> 
> This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
> MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints.  It
> also reverts some unnecessary checks in sys_socketcall.
> 
> Apparently I was suffering from underscore blindness the first time around.

FWIW This fixes the problem I was seeing with powerpc 32bit user on 64
bit kernel.

Mikey

> 
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
> 
> I've tested this a little, but I'm not sure I have a great test case.
> 
> If the decision is that it's better to leave this for the 3.11, I can send
> a squashed version.  Note that the oops that this fixes is only an oops if
> the other patches in the original series are applied.
> 
> (FWIW, I wasn't sure how to submit this stuff in the first place.  I submitted
> some kernel hardening patches for the x86 tree that converted an access_ok
> oddity in the net code into an actual oops.  In a bit of looking, I couldn't
> find any failure mode other than a -EFAULT return without the other patches
> applied.  This was clear in the patch series description but not in the
> change log message for the net part.)
> 
>  include/linux/socket.h |  3 +++
>  net/compat.c           | 13 +++++++--
>  net/socket.c           | 72 +++++++++++++++++++++++---------------------------
>  3 files changed, 47 insertions(+), 41 deletions(-)
> 
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 2b9f74b..e897bdc 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -321,6 +321,9 @@ extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
>  
>  struct timespec;
>  
> +/* The __sys_...msg variants allow MSG_CMSG_COMPAT */
> +extern long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
> +extern long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
>  extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  			  unsigned int flags, struct timespec *timeout);
>  extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
> diff --git a/net/compat.c b/net/compat.c
> index 79ae884..f0a1ba6 100644
> --- a/net/compat.c
> +++ b/net/compat.c
> @@ -734,19 +734,25 @@ static unsigned char nas[21] = {
>  
>  asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
>  {
> -	return sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
>  				    unsigned int vlen, unsigned int flags)
>  {
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
>  	return __sys_sendmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
>  			      flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
>  {
> -	return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned int flags)
> @@ -768,6 +774,9 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
>  	int datagrams;
>  	struct timespec ktspec;
>  
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +
>  	if (COMPAT_USE_64BIT_TIME)
>  		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
>  				      flags | MSG_CMSG_COMPAT,
> diff --git a/net/socket.c b/net/socket.c
> index 0e16888..e216502 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1978,7 +1978,7 @@ struct used_address {
>  	unsigned int name_len;
>  };
>  
> -static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
> +static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
>  			 struct msghdr *msg_sys, unsigned int flags,
>  			 struct used_address *used_address)
>  {
> @@ -2093,26 +2093,30 @@ out:
>   *	BSD sendmsg interface
>   */
>  
> -SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
> +long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
>  {
>  	int fput_needed, err;
>  	struct msghdr msg_sys;
>  	struct socket *sock;
>  
> -	if (flags & MSG_CMSG_COMPAT)
> -		return -EINVAL;
> -
>  	sock = sockfd_lookup_light(fd, &err, &fput_needed);
>  	if (!sock)
>  		goto out;
>  
> -	err = __sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
> +	err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
>  
>  	fput_light(sock->file, fput_needed);
>  out:
>  	return err;
>  }
>  
> +SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
> +{
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_sendmsg(fd, msg, flags);
> +}
> +
>  /*
>   *	Linux sendmmsg interface
>   */
> @@ -2143,15 +2147,16 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  
>  	while (datagrams < vlen) {
>  		if (MSG_CMSG_COMPAT & flags) {
> -			err = __sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
> -					    &msg_sys, flags, &used_address);
> +			err = ___sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
> +					     &msg_sys, flags, &used_address);
>  			if (err < 0)
>  				break;
>  			err = __put_user(err, &compat_entry->msg_len);
>  			++compat_entry;
>  		} else {
> -			err = __sys_sendmsg(sock, (struct msghdr __user *)entry,
> -					    &msg_sys, flags, &used_address);
> +			err = ___sys_sendmsg(sock,
> +					     (struct msghdr __user *)entry,
> +					     &msg_sys, flags, &used_address);
>  			if (err < 0)
>  				break;
>  			err = put_user(err, &entry->msg_len);
> @@ -2180,7 +2185,7 @@ SYSCALL_DEFINE4(sendmmsg, int, fd, struct mmsghdr __user *, mmsg,
>  	return __sys_sendmmsg(fd, mmsg, vlen, flags);
>  }
>  
> -static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
> +static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
>  			 struct msghdr *msg_sys, unsigned int flags, int nosec)
>  {
>  	struct compat_msghdr __user *msg_compat =
> @@ -2272,27 +2277,31 @@ out:
>   *	BSD recvmsg interface
>   */
>  
> -SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
> -		unsigned int, flags)
> +long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags)
>  {
>  	int fput_needed, err;
>  	struct msghdr msg_sys;
>  	struct socket *sock;
>  
> -	if (flags & MSG_CMSG_COMPAT)
> -		return -EINVAL;
> -
>  	sock = sockfd_lookup_light(fd, &err, &fput_needed);
>  	if (!sock)
>  		goto out;
>  
> -	err = __sys_recvmsg(sock, msg, &msg_sys, flags, 0);
> +	err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0);
>  
>  	fput_light(sock->file, fput_needed);
>  out:
>  	return err;
>  }
>  
> +SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
> +		unsigned int, flags)
> +{
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_recvmsg(fd, msg, flags);
> +}
> +
>  /*
>   *     Linux recvmmsg interface
>   */
> @@ -2330,17 +2339,18 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  		 * No need to ask LSM for more than the first datagram.
>  		 */
>  		if (MSG_CMSG_COMPAT & flags) {
> -			err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
> -					    &msg_sys, flags & ~MSG_WAITFORONE,
> -					    datagrams);
> +			err = ___sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
> +					     &msg_sys, flags & ~MSG_WAITFORONE,
> +					     datagrams);
>  			if (err < 0)
>  				break;
>  			err = __put_user(err, &compat_entry->msg_len);
>  			++compat_entry;
>  		} else {
> -			err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
> -					    &msg_sys, flags & ~MSG_WAITFORONE,
> -					    datagrams);
> +			err = ___sys_recvmsg(sock,
> +					     (struct msghdr __user *)entry,
> +					     &msg_sys, flags & ~MSG_WAITFORONE,
> +					     datagrams);
>  			if (err < 0)
>  				break;
>  			err = put_user(err, &entry->msg_len);
> @@ -2525,31 +2535,15 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
>  				   (int __user *)a[4]);
>  		break;
>  	case SYS_SENDMSG:
> -		if (a[2] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_sendmsg(a0, (struct msghdr __user *)a1, a[2]);
>  		break;
>  	case SYS_SENDMMSG:
> -		if (a[3] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3]);
>  		break;
>  	case SYS_RECVMSG:
> -		if (a[2] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
>  		break;
>  	case SYS_RECVMMSG:
> -		if (a[3] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3],
>  				   (struct timespec __user *)a[4]);
>  		break;
> -- 
> 1.8.1.4
> 

^ permalink raw reply

* Re: [PATCH V2 1/2] powerpc, perf: Ignore separate BHRB privilege state filter request
From: Anshuman Khandual @ 2013-06-06  6:04 UTC (permalink / raw)
  To: Michael Neuling; +Cc: linuxppc-dev
In-Reply-To: <20699.1370494560@ale.ozlabs.ibm.com>

On 06/06/2013 10:26 AM, Michael Neuling wrote:
> Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
> 
>> Completely ignore BHRB privilege state filter request as we are
>> already configuring that with privilege state filtering attribute
>> for the accompanying PMU event. This would help achieve cleaner
>> user space interaction for BHRB.
>>
>> This patch fixes a situation like this
>>
>> Before patch:-
>> ------------
>> ./perf record -j any -e branch-misses:k ls
>> Error:
>> The sys_perf_event_open() syscall returned with 95 (Operation not supported) for event (branch-misses:k).
>> /bin/dmesg may provide additional information.
>> No CONFIG_PERF_EVENTS=y kernel support configured?
>>
>> Here 'perf record' actually copies over ':k' filter request into BHRB
>> privilege state filter config and our previous check in kernel would
>> fail that.
>>
>> After patch:-
>> -------------
>> ./perf record -j any -e branch-misses:k ls
>> perf  perf.data  perf.data.old  test-mmap-ring
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
>>
>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/perf/power8-pmu.c | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
>> index f7d1c4f..3a58416 100644
>> --- a/arch/powerpc/perf/power8-pmu.c
>> +++ b/arch/powerpc/perf/power8-pmu.c
>> @@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type)
>>  	u64 pmu_bhrb_filter = 0;
>>  	u64 br_privilege = branch_sample_type & ONLY_PLM;
>>  
>> -	/* BHRB and regular PMU events share the same prvillege state
>> +	/* BHRB and regular PMU events share the same privilege state
>>  	 * filter configuration. BHRB is always recorded along with a
>> -	 * regular PMU event. So privilege state filter criteria for BHRB
>> -	 * and the companion PMU events has to be the same. As a default
>> -	 * "perf record" tool sets all privillege bits ON when no filter
>> -	 * criteria is provided in the command line. So as along as all
>> -	 * privillege bits are ON or they are OFF, we are good to go.
>> +	 * regular PMU event. As the privilege state filter is handled
>> +	 * in the basic PMC configuration of the accompanying regular
>> +	 * PMU event, we ignore any separate BHRB specific request.
>>  	 */
>> -	if ((br_privilege != 7) && (br_privilege != 0))
>> -		return -1;
> 
> br_privilege is now unused which causes this compile error.
> 
> arch/powerpc/perf/power8-pmu.c:526:6: error: unused variable ‘br_privilege’ [-Werror=unused-variable]
> 
> I assume since you didn't compile test this code, you also didn't
> runtime test it either?!!?!?!?


Always compile with the cross compiler "ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make"
I copied over arch/powerpc/config/pseries_defconfig and compiled it. Some how it missed
to be a 64 bit kernel config which resulted in shutting down compilation of arch/powerpc/perf/power8-pmu.c
file. So never encountered this compiler warning message before. Will fix this.

Regards
Anshuman

^ permalink raw reply

* Re: [PATCH -V10 00/15] THP support for PPC64
From: Aneesh Kumar K.V @ 2013-06-06  6:05 UTC (permalink / raw)
  To: Andrew Morton, Benjamin Herrenschmidt; +Cc: linuxppc-dev, paulus
In-Reply-To: <20130605171310.065c6fe2a3313c69bcfa0fc8@linux-foundation.org>

Andrew Morton <akpm@linux-foundation.org> writes:

> On Thu, 06 Jun 2013 09:31:06 +1000 Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
>> On Wed, 2013-06-05 at 20:58 +0530, Aneesh Kumar K.V wrote:
>> > 
>> > This is the second patchset needed to support THP on ppc64. Some of the changes
>> > included in this series are tricky in that it changes the powerpc linux page table
>> > walk subtly. We also overload few of the pte flags for ptes at PMD level (huge
>> > page PTEs).
>> > 
>> > The related mm/ changes are already merged to Andrew's -mm tree.
>> 
>> If I am to put that into powerpc-next, I need the dependent mm/ changes as well.
>> 
>> Do you have them in the form of a separate git tree that is *exactly* (same SHA1s)
>> what is expected to go upstream via Andrew ?
>> 
>> Andrew, are they fully acked on your side and ready to go ?
>
> Not being on linuxppc-dev I'm at a bit of a loss here.
>
> I assume we're referring to
>
> mm-thp-add-pmd-args-to-pgtable-deposit-and-withdraw-apis.patch
> mm-thp-withdraw-the-pgtable-after-pmdp-related-operations.patch
> mm-thp-withdraw-the-pgtable-after-pmdp-related-operations-fix.patch
> mm-thp-dont-use-hpage_shift-in-transparent-hugepage-code.patch
> mm-thp-deposit-the-transpare-huge-pgtable-before-set_pmd.patch
>

There is one more:

mm/THP: Use the right function when updating access flags

mm-thp-use-the-right-function-when-updating-access-flags.patc

-aneesh

^ permalink raw reply

* Re: [PATCH -V10 00/15] THP support for PPC64
From: Andrew Morton @ 2013-06-06  7:20 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: paulus, linuxppc-dev
In-Reply-To: <8738svyds4.fsf@linux.vnet.ibm.com>

On Thu, 06 Jun 2013 11:35:47 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:

> Andrew Morton <akpm@linux-foundation.org> writes:
> 
> > On Thu, 06 Jun 2013 09:31:06 +1000 Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> >
> >> On Wed, 2013-06-05 at 20:58 +0530, Aneesh Kumar K.V wrote:
> >> > 
> >> > This is the second patchset needed to support THP on ppc64. Some of the changes
> >> > included in this series are tricky in that it changes the powerpc linux page table
> >> > walk subtly. We also overload few of the pte flags for ptes at PMD level (huge
> >> > page PTEs).
> >> > 
> >> > The related mm/ changes are already merged to Andrew's -mm tree.
> >> 
> >> If I am to put that into powerpc-next, I need the dependent mm/ changes as well.
> >> 
> >> Do you have them in the form of a separate git tree that is *exactly* (same SHA1s)
> >> what is expected to go upstream via Andrew ?
> >> 
> >> Andrew, are they fully acked on your side and ready to go ?
> >
> > Not being on linuxppc-dev I'm at a bit of a loss here.
> >
> > I assume we're referring to
> >
> > mm-thp-add-pmd-args-to-pgtable-deposit-and-withdraw-apis.patch
> > mm-thp-withdraw-the-pgtable-after-pmdp-related-operations.patch
> > mm-thp-withdraw-the-pgtable-after-pmdp-related-operations-fix.patch
> > mm-thp-dont-use-hpage_shift-in-transparent-hugepage-code.patch
> > mm-thp-deposit-the-transpare-huge-pgtable-before-set_pmd.patch
> >
> 
> There is one more:
> 
> mm/THP: Use the right function when updating access flags
> 
> mm-thp-use-the-right-function-when-updating-access-flags.patc

Hereunder.  This actually precedes the above four(+fix) patches.


From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: mm/thp: use the correct function when updating access flags

We should use pmdp_set_access_flags to update access flags.  Archs like
powerpc use extra checks(_PAGE_BUSY) when updating a hugepage PTE.  A
set_pmd_at doesn't do those checks.  We should use set_pmd_at only when
updating a none hugepage PTE.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>a
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/huge_memory.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN mm/huge_memory.c~mm-thp-use-the-right-function-when-updating-access-flags mm/huge_memory.c
--- a/mm/huge_memory.c~mm-thp-use-the-right-function-when-updating-access-flags
+++ a/mm/huge_memory.c
@@ -1265,7 +1265,9 @@ struct page *follow_trans_huge_pmd(struc
 		 * young bit, instead of the current set_pmd_at.
 		 */
 		_pmd = pmd_mkyoung(pmd_mkdirty(*pmd));
-		set_pmd_at(mm, addr & HPAGE_PMD_MASK, pmd, _pmd);
+		if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK,
+					  pmd, _pmd,  1))
+			update_mmu_cache_pmd(vma, addr, pmd);
 	}
 	if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
 		if (page->mapping && trylock_page(page)) {
_

^ permalink raw reply

* Re: [PATCH] net: Unbreak compat_sys_{send,recv}msg
From: David Miller @ 2013-06-06  7:26 UTC (permalink / raw)
  To: luto
  Cc: mikey, eric.dumazet, netdev, x86, linux-kernel, linuxppc-dev,
	trinity, torvalds
In-Reply-To: <e3bf421e44c6d27817c15a8683612a49e093b419.1370496702.git.luto@amacapital.net>

From: Andy Lutomirski <luto@amacapital.net>
Date: Wed,  5 Jun 2013 22:38:26 -0700

> I broke them in this commit:
> 
>     commit 1be374a0518a288147c6a7398792583200a67261
>     Author: Andy Lutomirski <luto@amacapital.net>
>     Date:   Wed May 22 14:07:44 2013 -0700
> 
>         net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg
> 
> This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
> MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints.  It
> also reverts some unnecessary checks in sys_socketcall.
> 
> Apparently I was suffering from underscore blindness the first time around.
> 
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>

Eric, can you test this patch too?

Thanks.

> ---
> 
> I've tested this a little, but I'm not sure I have a great test case.
> 
> If the decision is that it's better to leave this for the 3.11, I can send
> a squashed version.  Note that the oops that this fixes is only an oops if
> the other patches in the original series are applied.
> 
> (FWIW, I wasn't sure how to submit this stuff in the first place.  I submitted
> some kernel hardening patches for the x86 tree that converted an access_ok
> oddity in the net code into an actual oops.  In a bit of looking, I couldn't
> find any failure mode other than a -EFAULT return without the other patches
> applied.  This was clear in the patch series description but not in the
> change log message for the net part.)
> 
>  include/linux/socket.h |  3 +++
>  net/compat.c           | 13 +++++++--
>  net/socket.c           | 72 +++++++++++++++++++++++---------------------------
>  3 files changed, 47 insertions(+), 41 deletions(-)
> 
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 2b9f74b..e897bdc 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -321,6 +321,9 @@ extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
>  
>  struct timespec;
>  
> +/* The __sys_...msg variants allow MSG_CMSG_COMPAT */
> +extern long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
> +extern long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
>  extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  			  unsigned int flags, struct timespec *timeout);
>  extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
> diff --git a/net/compat.c b/net/compat.c
> index 79ae884..f0a1ba6 100644
> --- a/net/compat.c
> +++ b/net/compat.c
> @@ -734,19 +734,25 @@ static unsigned char nas[21] = {
>  
>  asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
>  {
> -	return sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
>  				    unsigned int vlen, unsigned int flags)
>  {
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
>  	return __sys_sendmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
>  			      flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
>  {
> -	return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
>  }
>  
>  asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned int flags)
> @@ -768,6 +774,9 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
>  	int datagrams;
>  	struct timespec ktspec;
>  
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +
>  	if (COMPAT_USE_64BIT_TIME)
>  		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
>  				      flags | MSG_CMSG_COMPAT,
> diff --git a/net/socket.c b/net/socket.c
> index 0e16888..e216502 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1978,7 +1978,7 @@ struct used_address {
>  	unsigned int name_len;
>  };
>  
> -static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
> +static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
>  			 struct msghdr *msg_sys, unsigned int flags,
>  			 struct used_address *used_address)
>  {
> @@ -2093,26 +2093,30 @@ out:
>   *	BSD sendmsg interface
>   */
>  
> -SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
> +long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
>  {
>  	int fput_needed, err;
>  	struct msghdr msg_sys;
>  	struct socket *sock;
>  
> -	if (flags & MSG_CMSG_COMPAT)
> -		return -EINVAL;
> -
>  	sock = sockfd_lookup_light(fd, &err, &fput_needed);
>  	if (!sock)
>  		goto out;
>  
> -	err = __sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
> +	err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
>  
>  	fput_light(sock->file, fput_needed);
>  out:
>  	return err;
>  }
>  
> +SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
> +{
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_sendmsg(fd, msg, flags);
> +}
> +
>  /*
>   *	Linux sendmmsg interface
>   */
> @@ -2143,15 +2147,16 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  
>  	while (datagrams < vlen) {
>  		if (MSG_CMSG_COMPAT & flags) {
> -			err = __sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
> -					    &msg_sys, flags, &used_address);
> +			err = ___sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
> +					     &msg_sys, flags, &used_address);
>  			if (err < 0)
>  				break;
>  			err = __put_user(err, &compat_entry->msg_len);
>  			++compat_entry;
>  		} else {
> -			err = __sys_sendmsg(sock, (struct msghdr __user *)entry,
> -					    &msg_sys, flags, &used_address);
> +			err = ___sys_sendmsg(sock,
> +					     (struct msghdr __user *)entry,
> +					     &msg_sys, flags, &used_address);
>  			if (err < 0)
>  				break;
>  			err = put_user(err, &entry->msg_len);
> @@ -2180,7 +2185,7 @@ SYSCALL_DEFINE4(sendmmsg, int, fd, struct mmsghdr __user *, mmsg,
>  	return __sys_sendmmsg(fd, mmsg, vlen, flags);
>  }
>  
> -static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
> +static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
>  			 struct msghdr *msg_sys, unsigned int flags, int nosec)
>  {
>  	struct compat_msghdr __user *msg_compat =
> @@ -2272,27 +2277,31 @@ out:
>   *	BSD recvmsg interface
>   */
>  
> -SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
> -		unsigned int, flags)
> +long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags)
>  {
>  	int fput_needed, err;
>  	struct msghdr msg_sys;
>  	struct socket *sock;
>  
> -	if (flags & MSG_CMSG_COMPAT)
> -		return -EINVAL;
> -
>  	sock = sockfd_lookup_light(fd, &err, &fput_needed);
>  	if (!sock)
>  		goto out;
>  
> -	err = __sys_recvmsg(sock, msg, &msg_sys, flags, 0);
> +	err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0);
>  
>  	fput_light(sock->file, fput_needed);
>  out:
>  	return err;
>  }
>  
> +SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
> +		unsigned int, flags)
> +{
> +	if (flags & MSG_CMSG_COMPAT)
> +		return -EINVAL;
> +	return __sys_recvmsg(fd, msg, flags);
> +}
> +
>  /*
>   *     Linux recvmmsg interface
>   */
> @@ -2330,17 +2339,18 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  		 * No need to ask LSM for more than the first datagram.
>  		 */
>  		if (MSG_CMSG_COMPAT & flags) {
> -			err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
> -					    &msg_sys, flags & ~MSG_WAITFORONE,
> -					    datagrams);
> +			err = ___sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
> +					     &msg_sys, flags & ~MSG_WAITFORONE,
> +					     datagrams);
>  			if (err < 0)
>  				break;
>  			err = __put_user(err, &compat_entry->msg_len);
>  			++compat_entry;
>  		} else {
> -			err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
> -					    &msg_sys, flags & ~MSG_WAITFORONE,
> -					    datagrams);
> +			err = ___sys_recvmsg(sock,
> +					     (struct msghdr __user *)entry,
> +					     &msg_sys, flags & ~MSG_WAITFORONE,
> +					     datagrams);
>  			if (err < 0)
>  				break;
>  			err = put_user(err, &entry->msg_len);
> @@ -2525,31 +2535,15 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
>  				   (int __user *)a[4]);
>  		break;
>  	case SYS_SENDMSG:
> -		if (a[2] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_sendmsg(a0, (struct msghdr __user *)a1, a[2]);
>  		break;
>  	case SYS_SENDMMSG:
> -		if (a[3] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_sendmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3]);
>  		break;
>  	case SYS_RECVMSG:
> -		if (a[2] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
>  		break;
>  	case SYS_RECVMMSG:
> -		if (a[3] & MSG_CMSG_COMPAT) {
> -			err = -EINVAL;
> -			break;
> -		}
>  		err = sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], a[3],
>  				   (struct timespec __user *)a[4]);
>  		break;
> -- 
> 1.8.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe trinity" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* RE: [RFC PATCH 0/6] KVM: PPC: Book3E: AltiVec support
From: Caraman Mihai Claudiu-B02008 @ 2013-06-06  9:42 UTC (permalink / raw)
  To: Wood Scott-B07421
  Cc: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
	kvm-ppc@vger.kernel.org, Alexander Graf
In-Reply-To: <1370450103.26139.0@snotra>

> > > This looks like a bit much for 3.10 (certainly, subject lines like
> > > "refactor" and "enhance" and "add support" aren't going to make
> > Linus
> > > happy given that we're past rc4) so I think we should apply
> > > http://patchwork.ozlabs.org/patch/242896/ for 3.10.  Then for 3.11,
> > > revert it after applying this patchset.
> > >
> >
> > Why not 1/6 plus e6500 removal?
>=20
> 1/6 is not a bugfix.

Not sure I get it. Isn't this a better fix for AltiVec build breakage:

-#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 42
-#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 43
+#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
+#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33

This removes the need for additional kvm_handlers. Obvious this doesn't mak=
e
AltiVec to work so we still need to disable e6500.

-Mike

^ permalink raw reply

* Re: IBM OpenPower 720 ipr driver woes
From: Brian King @ 2013-06-06 11:32 UTC (permalink / raw)
  To: Robert Knight; +Cc: linuxppc-dev, Wendy Xiong, Gavin Shan
In-Reply-To: <51AFAA2C.5060304@princeton.edu>

On 06/05/2013 04:14 PM, Robert Knight wrote:
> On 6/3/2013 11:52 PM, Gavin Shan wrote:
>> On Tue, Jun 04, 2013 at 01:16:52PM +1000, Tony Breeds wrote:
>>> On Mon, Jun 03, 2013 at 09:40:52PM -0400, Robert Knight wrote:
>>>> On 6/3/2013 8:01 PM, Tony Breeds wrote:
>>>>> On Mon, Jun 03, 2013 at 05:20:12PM -0400, Robert Knight wrote:
>>>>>
>>>>>>> Device tree struct  0x0000000004820000 -> 0x0000000004840000
>>>>>>> Calling quiesce...
>>>>>>> returning from prom_init
>>>>>>> [    1.376359] ehci-pci 0000:c8:01.2: can't setup
>>>>> Can you try adding "debug" to the kernel commandline.  We're missing a
>>>>> great chunk of detail. If you're starting from scratch either try F18 or
>>>>> the F19 Beta (if you're brave :))
>>>>>
>>>>> Yours Tony
>>>> So, two points.  Since I have no live disks, I can't copy the dmesg
>>>> output in dracut onto a disk and just sent it to you -- the only way
>>>> that I know to get it is cut and paste from a HMC console window
>>>> into a vi buffer.
>>> Okay, when I've been in that situation, I run "script" locally and then
>>> conenct to the HMC console.
>>>
>>> When you're done you can exit script adn then a file called typescript
>>> will exist in the directory you ran script in.
>>>
>>> It's a less overhead way of doign what you're already doing.
>>> [    0.087097] NET: Registered protocol family 16
>>>
>>>> [    0.087144] pseries_eeh_init: RTAS service <ibm,get-config-addr-info2> and <i
>>>> bm,get-config-addr-info> invalid
>>>> [    0.087155] eeh_init: Failed to call platform init function (-22)
>>> Hmm this seems pretty strange to me.  Gavin are these RTAS tokens
>>> supported on older power5 boxes?
>>>
>> Yes, Tony. "ibm,get-config-addr-info" should be supported on Power5 box.
>> Newer PowerBox (e.g. P7) should support "ibm,get-config-addr-info2"
>>
>> Please have a try on the attached patch, which is based on mainline (3.10).
>>
>> Thanks,
>> Gavin
>>
>>
> The system boots with that patch.  I applied it to kernel-3.8.11-100.

Does that patch resolve all your issues, or are there still issues with ipr remaining
after applying the patch?

Thanks,

Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

^ permalink raw reply

* Re: IBM OpenPower 720 ipr driver woes
From: Robert Knight @ 2013-06-06 12:39 UTC (permalink / raw)
  To: Brian King; +Cc: linuxppc-dev, Wendy Xiong, Gavin Shan
In-Reply-To: <51B07336.7040609@linux.vnet.ibm.com>

On 06/06/2013 07:32 AM, Brian King wrote:
> On 06/05/2013 04:14 PM, Robert Knight wrote:
>> On 6/3/2013 11:52 PM, Gavin Shan wrote:
>>> On Tue, Jun 04, 2013 at 01:16:52PM +1000, Tony Breeds wrote:
>>>> On Mon, Jun 03, 2013 at 09:40:52PM -0400, Robert Knight wrote:
>>>>> On 6/3/2013 8:01 PM, Tony Breeds wrote:
>>>>>> On Mon, Jun 03, 2013 at 05:20:12PM -0400, Robert Knight wrote:
>>>>>>
>>>>>>>> Device tree struct  0x0000000004820000 -> 0x0000000004840000
>>>>>>>> Calling quiesce...
>>>>>>>> returning from prom_init
>>>>>>>> [    1.376359] ehci-pci 0000:c8:01.2: can't setup
>>>>>> Can you try adding "debug" to the kernel commandline.  We're missing a
>>>>>> great chunk of detail. If you're starting from scratch either try F18 or
>>>>>> the F19 Beta (if you're brave :))
>>>>>>
>>>>>> Yours Tony
>>>>> So, two points.  Since I have no live disks, I can't copy the dmesg
>>>>> output in dracut onto a disk and just sent it to you -- the only way
>>>>> that I know to get it is cut and paste from a HMC console window
>>>>> into a vi buffer.
>>>> Okay, when I've been in that situation, I run "script" locally and then
>>>> conenct to the HMC console.
>>>>
>>>> When you're done you can exit script adn then a file called typescript
>>>> will exist in the directory you ran script in.
>>>>
>>>> It's a less overhead way of doign what you're already doing.
>>>> [    0.087097] NET: Registered protocol family 16
>>>>
>>>>> [    0.087144] pseries_eeh_init: RTAS service <ibm,get-config-addr-info2> and <i
>>>>> bm,get-config-addr-info> invalid
>>>>> [    0.087155] eeh_init: Failed to call platform init function (-22)
>>>> Hmm this seems pretty strange to me.  Gavin are these RTAS tokens
>>>> supported on older power5 boxes?
>>>>
>>> Yes, Tony. "ibm,get-config-addr-info" should be supported on Power5 box.
>>> Newer PowerBox (e.g. P7) should support "ibm,get-config-addr-info2"
>>>
>>> Please have a try on the attached patch, which is based on mainline (3.10).
>>>
>>> Thanks,
>>> Gavin
>>>
>>>
>> The system boots with that patch.  I applied it to kernel-3.8.11-100.
> Does that patch resolve all your issues, or are there still issues with ipr remaining
> after applying the patch?
>
> Thanks,
>
> Brian
>
Yes.  I've started rebuilding the kernel and I'm up to the module 
building part, so I'd say it is solid.  Will this patch make it into 
some version of the kernel?

What was killing me was that it would not complete boot.  It now does.  
I see:

[   11.934481] scsi 0:0:15:0: Resetting device
[   11.934813] ipr 0001:d0:01.0: Adapter being reset as a result of 
error recovery.

on each boot.  It does not appear to affect operation.

Thank you and the rest of the team for your rapid and helpful responses.

Best regards,
Robert

^ permalink raw reply

* Re: [PATCH] net: Unbreak compat_sys_{send,recv}msg
From: Eric Dumazet @ 2013-06-06 13:45 UTC (permalink / raw)
  To: David Miller
  Cc: mikey, netdev, x86, linux-kernel, luto, linuxppc-dev, trinity,
	torvalds
In-Reply-To: <20130606.002625.223430401087826901.davem@davemloft.net>

On Thu, 2013-06-06 at 00:26 -0700, David Miller wrote:
> From: Andy Lutomirski <luto@amacapital.net>
> Date: Wed,  5 Jun 2013 22:38:26 -0700
> 
> > I broke them in this commit:
> > 
> >     commit 1be374a0518a288147c6a7398792583200a67261
> >     Author: Andy Lutomirski <luto@amacapital.net>
> >     Date:   Wed May 22 14:07:44 2013 -0700
> > 
> >         net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg
> > 
> > This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
> > MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints.  It
> > also reverts some unnecessary checks in sys_socketcall.
> > 
> > Apparently I was suffering from underscore blindness the first time around.
> > 
> > Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> 
> Eric, can you test this patch too?

Yes, this fixes the problem as well on x86_64

Tested-by: Eric Dumazet <edumazet@google.com>

Thanks !

PS: I had following fuzz while applying on Linus tree :

patching file include/linux/socket.h
Hunk #1 succeeded at 320 (offset -1 lines).
patching file net/compat.c
patching file net/socket.c
Hunk #1 succeeded at 1956 (offset -22 lines).
Hunk #2 succeeded at 2071 (offset -22 lines).
Hunk #3 succeeded at 2125 (offset -22 lines).
Hunk #4 succeeded at 2163 (offset -22 lines).
Hunk #5 succeeded at 2255 (offset -22 lines).
Hunk #6 succeeded at 2317 (offset -22 lines).
Hunk #7 succeeded at 2515 (offset -20 lines).

^ permalink raw reply

* [PATCH 2/2] KVM: PPC: Book3E: Get vcpu's last instruction for emulation
From: Mihai Caraman @ 2013-06-06 16:11 UTC (permalink / raw)
  To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm
In-Reply-To: <1370535119-26425-1-git-send-email-mihai.caraman@freescale.com>

lwepx faults needs to be handled by KVM and this implies additional code
in DO_KVM macro to identify the source of the exception originated in
host context. This requires to check the Exception Syndrome Register
(ESR[EPID]) and External PID Load Context Register (EPLC[EGS]) for DTB_MISS,
DSI and LRAT exceptions which is too intrusive for the host.

Get rid of lwepx and acquire last instuction in kvmppc_handle_exit() by
searching for the physical address and kmap it. This fixes an infinite loop
caused by lwepx's data TLB miss handled in the host and the TODO for TLB
eviction and execute-but-not-read entries.

Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
 arch/powerpc/include/asm/mmu-book3e.h |    6 ++-
 arch/powerpc/kvm/booke.c              |    6 +++
 arch/powerpc/kvm/booke.h              |    2 +
 arch/powerpc/kvm/bookehv_interrupts.S |   32 ++-------------
 arch/powerpc/kvm/e500.c               |    4 ++
 arch/powerpc/kvm/e500mc.c             |   69 +++++++++++++++++++++++++++++++++
 6 files changed, 91 insertions(+), 28 deletions(-)

diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index 99d43e0..32e470e 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -40,7 +40,10 @@
 
 /* MAS registers bit definitions */
 
-#define MAS0_TLBSEL(x)		(((x) << 28) & 0x30000000)
+#define MAS0_TLBSEL_MASK	0x30000000
+#define MAS0_TLBSEL_SHIFT	28
+#define MAS0_TLBSEL(x)		(((x) << MAS0_TLBSEL_SHIFT) & MAS0_TLBSEL_MASK)
+#define MAS0_GET_TLBSEL(mas0)	(((mas0) & MAS0_TLBSEL_MASK) >> MAS0_TLBSEL_SHIFT)
 #define MAS0_ESEL_MASK		0x0FFF0000
 #define MAS0_ESEL_SHIFT		16
 #define MAS0_ESEL(x)		(((x) << MAS0_ESEL_SHIFT) & MAS0_ESEL_MASK)
@@ -58,6 +61,7 @@
 #define MAS1_TSIZE_MASK		0x00000f80
 #define MAS1_TSIZE_SHIFT	7
 #define MAS1_TSIZE(x)		(((x) << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
+#define MAS1_GET_TSIZE(mas1)	(((mas1) & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT)
 
 #define MAS2_EPN		(~0xFFFUL)
 #define MAS2_X0			0x00000040
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 1020119..6764a8e 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -836,6 +836,12 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	/* update before a new last_exit_type is rewritten */
 	kvmppc_update_timing_stats(vcpu);
 
+	/*
+	 * The exception type can change at this point, such as if the TLB entry
+	 * for the emulated instruction has been evicted.
+	 */
+	kvmppc_prepare_for_emulation(vcpu, &exit_nr);
+
 	/* restart interrupts if they were meant for the host */
 	kvmppc_restart_interrupt(vcpu, exit_nr);
 
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
index 5fd1ba6..a0d0fea 100644
--- a/arch/powerpc/kvm/booke.h
+++ b/arch/powerpc/kvm/booke.h
@@ -90,6 +90,8 @@ void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
 void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
 
+void kvmppc_prepare_for_emulation(struct kvm_vcpu *vcpu, unsigned int *exit_nr);
+
 enum int_class {
 	INT_CLASS_NONCRIT,
 	INT_CLASS_CRIT,
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index 20c7a54..0538ab9 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -120,37 +120,20 @@
 
 	.if	\flags & NEED_EMU
 	/*
-	 * This assumes you have external PID support.
-	 * To support a bookehv CPU without external PID, you'll
-	 * need to look up the TLB entry and create a temporary mapping.
-	 *
-	 * FIXME: we don't currently handle if the lwepx faults.  PR-mode
-	 * booke doesn't handle it either.  Since Linux doesn't use
-	 * broadcast tlbivax anymore, the only way this should happen is
-	 * if the guest maps its memory execute-but-not-read, or if we
-	 * somehow take a TLB miss in the middle of this entry code and
-	 * evict the relevant entry.  On e500mc, all kernel lowmem is
-	 * bolted into TLB1 large page mappings, and we don't use
-	 * broadcast invalidates, so we should not take a TLB miss here.
-	 *
-	 * Later we'll need to deal with faults here.  Disallowing guest
-	 * mappings that are execute-but-not-read could be an option on
-	 * e500mc, but not on chips with an LRAT if it is used.
+	 * We don't use external PID support. lwepx faults would need to be
+	 * handled by KVM and this implies aditional code in DO_KVM (for
+	 * DTB_MISS, DSI and LRAT) to check ESR[EPID] and EPLC[EGS] which
+	 * is too intrusive for the host. Get last instuction in
+	 * kvmppc_handle_exit().
 	 */
-
-	mfspr	r3, SPRN_EPLC	/* will already have correct ELPID and EGS */
 	PPC_STL	r15, VCPU_GPR(R15)(r4)
 	PPC_STL	r16, VCPU_GPR(R16)(r4)
 	PPC_STL	r17, VCPU_GPR(R17)(r4)
 	PPC_STL	r18, VCPU_GPR(R18)(r4)
 	PPC_STL	r19, VCPU_GPR(R19)(r4)
-	mr	r8, r3
 	PPC_STL	r20, VCPU_GPR(R20)(r4)
-	rlwimi	r8, r6, EPC_EAS_SHIFT - MSR_IR_LG, EPC_EAS
 	PPC_STL	r21, VCPU_GPR(R21)(r4)
-	rlwimi	r8, r6, EPC_EPR_SHIFT - MSR_PR_LG, EPC_EPR
 	PPC_STL	r22, VCPU_GPR(R22)(r4)
-	rlwimi	r8, r10, EPC_EPID_SHIFT, EPC_EPID
 	PPC_STL	r23, VCPU_GPR(R23)(r4)
 	PPC_STL	r24, VCPU_GPR(R24)(r4)
 	PPC_STL	r25, VCPU_GPR(R25)(r4)
@@ -160,11 +143,6 @@
 	PPC_STL	r29, VCPU_GPR(R29)(r4)
 	PPC_STL	r30, VCPU_GPR(R30)(r4)
 	PPC_STL	r31, VCPU_GPR(R31)(r4)
-	mtspr	SPRN_EPLC, r8
-	isync
-	lwepx   r9, 0, r5
-	mtspr	SPRN_EPLC, r3
-	stw	r9, VCPU_LAST_INST(r4)
 	.endif
 
 	.if	\flags & NEED_ESR
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index ce6b73c..c82a89f 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -439,6 +439,10 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id,
 	return r;
 }
 
+void kvmppc_prepare_for_emulation(struct kvm_vcpu *vcpu, unsigned int *exit_nr)
+{
+}
+
 struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 {
 	struct kvmppc_vcpu_e500 *vcpu_e500;
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index c3bdc0a..3641df7 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -271,6 +271,75 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id,
 	return r;
 }
 
+void kvmppc_prepare_for_emulation(struct kvm_vcpu *vcpu, unsigned int *exit_nr)
+{
+	gva_t geaddr;
+	hpa_t addr;
+	u64 mas7_mas3;
+	hva_t eaddr;
+	u32 mas1, mas3;
+	struct page *page;
+	unsigned int addr_space, psize_shift;
+	bool pr;
+
+	if ((*exit_nr != BOOKE_INTERRUPT_DATA_STORAGE) &&
+	    (*exit_nr != BOOKE_INTERRUPT_DTLB_MISS) &&
+	    (*exit_nr != BOOKE_INTERRUPT_HV_PRIV))
+		return;
+
+	/* Search guest translation to find the real addressss */
+	geaddr = vcpu->arch.pc;
+	addr_space = (vcpu->arch.shared->msr & MSR_IS) >> MSR_IR_LG;
+	mtspr(SPRN_MAS6, (vcpu->arch.pid << MAS6_SPID_SHIFT) | addr_space);
+	mtspr(SPRN_MAS5, MAS5_SGS | vcpu->kvm->arch.lpid);
+	isync();
+	asm volatile("tlbsx 0, %[geaddr]\n" : : [geaddr] "r" (geaddr));
+	mtspr(SPRN_MAS5, 0);
+	mtspr(SPRN_MAS8, 0);	
+
+	mas1 = mfspr(SPRN_MAS1);
+	if (!(mas1 & MAS1_VALID)) {
+		/*
+	 	 * There is no translation for the emulated instruction.
+		 * Simulate an instruction TLB miss. This should force the host
+		 * or ultimately the guest to add the translation and then
+		 * reexecute the instruction.
+		 */
+		*exit_nr = BOOKE_INTERRUPT_ITLB_MISS;
+		return;
+	}
+
+	mas3 = mfspr(SPRN_MAS3);
+	pr = vcpu->arch.shared->msr & MSR_PR;
+	if ((pr && (!(mas3 & MAS3_UX))) || ((!pr) && (!(mas3 & MAS3_SX)))) {
+	 	/*
+		 * Another thread may rewrite the TLB entry in parallel, don't
+		 * execute from the address if the execute permission is not set
+		 */
+		vcpu->arch.fault_esr = 0;
+		*exit_nr = BOOKE_INTERRUPT_INST_STORAGE;
+		return;
+	}
+
+	/* Get page size */
+	if (MAS0_GET_TLBSEL(mfspr(SPRN_MAS0)) == 0)
+		psize_shift = PAGE_SHIFT;
+	else
+		psize_shift = MAS1_GET_TSIZE(mas1) + 10;
+
+	mas7_mas3 = (((u64) mfspr(SPRN_MAS7)) << 32) |
+		    mfspr(SPRN_MAS3);
+	addr = (mas7_mas3 & (~0ULL << psize_shift)) |
+	       (geaddr & ((1ULL << psize_shift) - 1ULL));
+
+	/* Map a page and get guest's instruction */
+	page = pfn_to_page(addr >> PAGE_SHIFT);
+	eaddr = (unsigned long)kmap_atomic(page);
+	eaddr |= addr & ~PAGE_MASK;
+	vcpu->arch.last_inst = *(u32 *)eaddr;
+	kunmap_atomic((u32 *)eaddr);
+}
+
 struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 {
 	struct kvmppc_vcpu_e500 *vcpu_e500;
-- 
1.7.4.1

^ permalink raw reply related

* [PATCH 1/2] KVM: PPC: e500mc: Revert "add load inst fixup"
From: Mihai Caraman @ 2013-06-06 16:11 UTC (permalink / raw)
  To: kvm-ppc; +Cc: Mihai Caraman, linuxppc-dev, kvm

lwepx faults needs to be handled by KVM. With the current solution
the host kernel searches for the faulting address using its LPID context.
If a host translation is found we return to the lwepx instr instead of the
fixup ending up in an infinite loop.

Revert the commit 1d628af7 "add load inst fixup". We will address lwepx
issue in a subsequent patch without the need of fixups.

Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
---
 arch/powerpc/kvm/bookehv_interrupts.S |   26 +-------------------------
 1 files changed, 1 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..20c7a54 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -29,7 +29,6 @@
 #include <asm/asm-compat.h>
 #include <asm/asm-offsets.h>
 #include <asm/bitsperlong.h>
-#include <asm/thread_info.h>
 
 #ifdef CONFIG_64BIT
 #include <asm/exception-64e.h>
@@ -162,32 +161,9 @@
 	PPC_STL	r30, VCPU_GPR(R30)(r4)
 	PPC_STL	r31, VCPU_GPR(R31)(r4)
 	mtspr	SPRN_EPLC, r8
-
-	/* disable preemption, so we are sure we hit the fixup handler */
-	CURRENT_THREAD_INFO(r8, r1)
-	li	r7, 1
-	stw	r7, TI_PREEMPT(r8)
-
 	isync
-
-	/*
-	 * In case the read goes wrong, we catch it and write an invalid value
-	 * in LAST_INST instead.
-	 */
-1:	lwepx	r9, 0, r5
-2:
-.section .fixup, "ax"
-3:	li	r9, KVM_INST_FETCH_FAILED
-	b	2b
-.previous
-.section __ex_table,"a"
-	PPC_LONG_ALIGN
-	PPC_LONG 1b,3b
-.previous
-
+	lwepx   r9, 0, r5
 	mtspr	SPRN_EPLC, r3
-	li	r7, 0
-	stw	r7, TI_PREEMPT(r8)
 	stw	r9, VCPU_LAST_INST(r4)
 	.endif
 
-- 
1.7.4.1

^ permalink raw reply related

* Re: [PATCH v3, part1 03/10] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
From: Jiang Liu @ 2013-06-06 16:16 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Neela Syam Kolli, sparclinux, Toshi Kani, Jiang Liu,
	linux-scsi@vger.kernel.org, David Airlie, Myron Stowe,
	linuxppc-dev, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, James E.J. Bottomley,
	Rafael J . Wysocki, Yijing Wang, Greg Kroah-Hartman, Gu Zheng,
	Paul Mackerras, Andrew Morton, Yinghai Lu, David S. Miller
In-Reply-To: <CAErSpo6C-QMFCbMMivBE5TN4sEOFR_EyPmtN=OUNo8eN-+t=GQ@mail.gmail.com>

On Thu 06 Jun 2013 04:07:18 AM CST, Bjorn Helgaas wrote:
> On Sat, May 25, 2013 at 7:48 AM, Jiang Liu <liuj97@gmail.com> wrote:
>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>
>> Use the new pci_alloc_dev(bus) to replace the existing using of
>> alloc_pci_dev(void).
>> ...
>
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index 26df9c8..d5d18a0 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -1130,6 +1130,7 @@ static void pci_release_dev(struct device *dev)
>>         struct pci_dev *pci_dev;
>>
>>         pci_dev = to_pci_dev(dev);
>> +       pci_bus_put(pci_dev->bus);
>>         pci_release_capabilities(pci_dev);
>>         pci_release_of_node(pci_dev);
>>         kfree(pci_dev);
>
> I think we should drop the pci_bus reference *last* (before the
> kfree).  Otherwise, we have to audit pci_release_capabilities() and
> pci_release_of_node() to make sure they don't use pci_dev->bus.
>
> I made this change on my branch already; just let me know if you object.
Hi Bjorn,
       You are right, thanks for fixing it.

>
> Bjorn

^ permalink raw reply

* Re: [PATCH] net: Unbreak compat_sys_{send,recv}msg
From: David Miller @ 2013-06-06 18:53 UTC (permalink / raw)
  To: eric.dumazet
  Cc: mikey, netdev, x86, linux-kernel, luto, linuxppc-dev, trinity,
	torvalds
In-Reply-To: <1370526337.24311.335.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 06 Jun 2013 06:45:37 -0700

> On Thu, 2013-06-06 at 00:26 -0700, David Miller wrote:
>> From: Andy Lutomirski <luto@amacapital.net>
>> Date: Wed,  5 Jun 2013 22:38:26 -0700
>> 
>> > I broke them in this commit:
>> > 
>> >     commit 1be374a0518a288147c6a7398792583200a67261
>> >     Author: Andy Lutomirski <luto@amacapital.net>
>> >     Date:   Wed May 22 14:07:44 2013 -0700
>> > 
>> >         net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg
>> > 
>> > This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
>> > MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints.  It
>> > also reverts some unnecessary checks in sys_socketcall.
>> > 
>> > Apparently I was suffering from underscore blindness the first time around.
>> > 
>> > Signed-off-by: Andy Lutomirski <luto@amacapital.net>
>> 
>> Eric, can you test this patch too?
> 
> Yes, this fixes the problem as well on x86_64
> 
> Tested-by: Eric Dumazet <edumazet@google.com>

Applied, thanks.

^ permalink raw reply

* Re: [RFC PATCH 0/6] KVM: PPC: Book3E: AltiVec support
From: Scott Wood @ 2013-06-06 19:57 UTC (permalink / raw)
  To: Caraman Mihai Claudiu-B02008
  Cc: Wood Scott-B07421, linuxppc-dev@lists.ozlabs.org,
	kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Alexander Graf
In-Reply-To: <300B73AA675FCE4A93EB4FC1D42459FF453564@039-SN2MPN1-011.039d.mgd.msft.net>

On 06/06/2013 04:42:44 AM, Caraman Mihai Claudiu-B02008 wrote:
> > > > This looks like a bit much for 3.10 (certainly, subject lines =20
> like
> > > > "refactor" and "enhance" and "add support" aren't going to make
> > > Linus
> > > > happy given that we're past rc4) so I think we should apply
> > > > http://patchwork.ozlabs.org/patch/242896/ for 3.10.  Then for =20
> 3.11,
> > > > revert it after applying this patchset.
> > > >
> > >
> > > Why not 1/6 plus e6500 removal?
> >
> > 1/6 is not a bugfix.
>=20
> Not sure I get it. Isn't this a better fix for AltiVec build breakage:
>=20
> -#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 42
> -#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 43
> +#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
> +#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33
>=20
> This removes the need for additional kvm_handlers. Obvious this =20
> doesn't make
> AltiVec to work so we still need to disable e6500.

OK, didn't realize you meant it as an alternative fix to what was in my =20
patch.

-Scott=

^ permalink raw reply

* Re: [PATCH -V7 09/18] powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format
From: Scott Wood @ 2013-06-06 22:42 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: dwg, linux-mm, paulus, Aneesh Kumar K.V, linuxppc-dev
In-Reply-To: <1367177859-7893-10-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

On 04/28/2013 02:37:30 PM, Aneesh Kumar K.V wrote:
> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>=20
> We will be switching PMD_SHIFT to 24 bits to facilitate THP =20
> impmenetation.
> With PMD_SHIFT set to 24, we now have 16MB huge pages allocated at =20
> PGD level.
> That means with 32 bit process we cannot allocate normal pages at
> all, because we cover the entire address space with one pgd entry. =20
> Fix this
> by switching to a new page table format for hugepages. With the new =20
> page table
> format for 16GB and 16MB hugepages we won't allocate hugepage =20
> directory. Instead
> we encode the PTE information directly at the directory level. This =20
> forces 16MB
> hugepage at PMD level. This will also make the page take walk much =20
> simpler later
> when we add the THP support.
>=20
> With the new table format we have 4 cases for pgds and pmds:
> (1) invalid (all zeroes)
> (2) pointer to next table, as normal; bottom 6 bits =3D=3D 0
> (3) leaf pte for huge page, bottom two bits !=3D 00
> (4) hugepd pointer, bottom two bits =3D=3D 00, next 4 bits indicate size =
=20
> of table
>=20
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  arch/powerpc/include/asm/page.h    |   2 +
>  arch/powerpc/include/asm/pgtable.h |   2 +
>  arch/powerpc/mm/gup.c              |  18 +++-
>  arch/powerpc/mm/hugetlbpage.c      | 176 =20
> +++++++++++++++++++++++++++++++------
>  4 files changed, 168 insertions(+), 30 deletions(-)

After this patch, on 64-bit book3e (e5500, and thus 4K pages), I see =20
messages like this after exiting a program that uses hugepages =20
(specifically, qemu):

/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221516.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221516.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc2214d6.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc2214d6.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221916.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221916.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc2218d6.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc2218d6.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221496.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221496.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221856.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221856.
/home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd =20
40000001fc221816.

-Scott=

^ permalink raw reply

* Re: [PATCH V2 1/2] powerpc, perf: Ignore separate BHRB privilege state filter request
From: Michael Neuling @ 2013-06-06 23:46 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: linuxppc-dev
In-Reply-To: <51B0266F.3090708@linux.vnet.ibm.com>

Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:

> On 06/06/2013 10:26 AM, Michael Neuling wrote:
> > Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
> >=20
> >> Completely ignore BHRB privilege state filter request as we are
> >> already configuring that with privilege state filtering attribute
> >> for the accompanying PMU event. This would help achieve cleaner
> >> user space interaction for BHRB.
> >>
> >> This patch fixes a situation like this
> >>
> >> Before patch:-
> >> ------------
> >> ./perf record -j any -e branch-misses:k ls
> >> Error:
> >> The sys_perf_event_open() syscall returned with 95 (Operation not supp=
orted) for event (branch-misses:k).
> >> /bin/dmesg may provide additional information.
> >> No CONFIG_PERF_EVENTS=3Dy kernel support configured?
> >>
> >> Here 'perf record' actually copies over ':k' filter request into BHRB
> >> privilege state filter config and our previous check in kernel would
> >> fail that.
> >>
> >> After patch:-
> >> -------------
> >> ./perf record -j any -e branch-misses:k ls
> >> perf  perf.data  perf.data.old  test-mmap-ring
> >> [ perf record: Woken up 1 times to write data ]
> >> [ perf record: Captured and wrote 0.002 MB perf.data (~102 samples) ]
> >>
> >> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> >> ---
> >>  arch/powerpc/perf/power8-pmu.c | 12 ++++--------
> >>  1 file changed, 4 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8=
-pmu.c
> >> index f7d1c4f..3a58416 100644
> >> --- a/arch/powerpc/perf/power8-pmu.c
> >> +++ b/arch/powerpc/perf/power8-pmu.c
> >> @@ -525,16 +525,12 @@ static u64 power8_bhrb_filter_map(u64 branch_sam=
ple_type)
> >>  	u64 pmu_bhrb_filter =3D 0;
> >>  	u64 br_privilege =3D branch_sample_type & ONLY_PLM;
> >>=20=20
> >> -	/* BHRB and regular PMU events share the same prvillege state
> >> +	/* BHRB and regular PMU events share the same privilege state
> >>  	 * filter configuration. BHRB is always recorded along with a
> >> -	 * regular PMU event. So privilege state filter criteria for BHRB
> >> -	 * and the companion PMU events has to be the same. As a default
> >> -	 * "perf record" tool sets all privillege bits ON when no filter
> >> -	 * criteria is provided in the command line. So as along as all
> >> -	 * privillege bits are ON or they are OFF, we are good to go.
> >> +	 * regular PMU event. As the privilege state filter is handled
> >> +	 * in the basic PMC configuration of the accompanying regular
> >> +	 * PMU event, we ignore any separate BHRB specific request.
> >>  	 */
> >> -	if ((br_privilege !=3D 7) && (br_privilege !=3D 0))
> >> -		return -1;
> >=20
> > br_privilege is now unused which causes this compile error.
> >=20
> > arch/powerpc/perf/power8-pmu.c:526:6: error: unused variable =E2=80=98b=
r_privilege=E2=80=99 [-Werror=3Dunused-variable]
> >=20
> > I assume since you didn't compile test this code, you also didn't
> > runtime test it either?!!?!?!?
>=20
>=20
> Always compile with the cross compiler "ARCH=3Dpowerpc
> CROSS_COMPILE=3Dpowerpc64-linux-gnu- make" I copied over
> arch/powerpc/config/pseries_defconfig and compiled it. Some how it
> missed to be a 64 bit kernel config which resulted in shutting down
> compilation of arch/powerpc/perf/power8-pmu.c file. So never
> encountered this compiler warning message before. Will fix this.

I don't understand this at all... pseries_defconfig is a 64bit kernel.

BTW. you don't need to copy it.  Just do "make pseries_defconfig && make
vmlinux".

Mikey

^ permalink raw reply

* Re: IBM OpenPower 720 ipr driver woes
From: Gavin Shan @ 2013-06-07  0:24 UTC (permalink / raw)
  To: Robert Knight; +Cc: Brian King, Wendy Xiong, linuxppc-dev, Gavin Shan
In-Reply-To: <51B08311.3080406@princeton.edu>

On Thu, Jun 06, 2013 at 08:39:45AM -0400, Robert Knight wrote:
>On 06/06/2013 07:32 AM, Brian King wrote:
>>On 06/05/2013 04:14 PM, Robert Knight wrote:
>>>On 6/3/2013 11:52 PM, Gavin Shan wrote:
>>>>On Tue, Jun 04, 2013 at 01:16:52PM +1000, Tony Breeds wrote:
>>>>>On Mon, Jun 03, 2013 at 09:40:52PM -0400, Robert Knight wrote:
>>>>>>On 6/3/2013 8:01 PM, Tony Breeds wrote:
>>>>>>>On Mon, Jun 03, 2013 at 05:20:12PM -0400, Robert Knight wrote:

.../...

>Yes.  I've started rebuilding the kernel and I'm up to the module
>building part, so I'd say it is solid.  Will this patch make it into
>some version of the kernel?
>

The patch is being pushed to mainline or linux-next, and backported
to stable-kernel (v3.4+)


>What was killing me was that it would not complete boot.  It now
>does.  I see:
>
>[   11.934481] scsi 0:0:15:0: Resetting device
>[   11.934813] ipr 0001:d0:01.0: Adapter being reset as a result of
>error recovery.
>
>on each boot.  It does not appear to affect operation.
>
>Thank you and the rest of the team for your rapid and helpful responses.
>

Thanks,
Gavin

^ permalink raw reply

* Re: [PATCH 1/3] powerpc/mpc85xx: remove the unneeded pci init functions for corenet ds board
From: Kevin Hao @ 2013-06-07  2:00 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc
In-Reply-To: <1370277723.21388.1@snotra>

[-- Attachment #1: Type: text/plain, Size: 9649 bytes --]

On Mon, Jun 03, 2013 at 11:42:03AM -0500, Scott Wood wrote:
> On 06/01/2013 07:07:20 PM, Kevin Hao wrote:
> >On Sat, Jun 01, 2013 at 09:47:16PM +1000, Benjamin Herrenschmidt
> >wrote:
> >> On Sat, 2013-06-01 at 18:59 +0800, Kevin Hao wrote:
> >>
> >> > The effect of this change is that the isa_io_base will be 0
> >and the IO
> >> > resource are equal to the virtual address of the IO space. But
> >the IO
> >> > functions such as outx/inx should work as well. This is why I
> >ask the
> >> > above question. What do you think about this? Are there any
> >subtle bugs
> >> > that will be triggered by this?
> >>
> >> I don't see any obvious reason why that wouldn't work but like
> >anything
> >> in that area, it needs a bit of testing & hammering to be sure ;-)
> >
> >Agreed.
> 
> Please include QEMU in your testing, as that was where breakage was
> observed that caused us to add the default primary.

I tested this on a qemu with the following command:
  ./qemu-system-ppc -m 1024 -nographic -M ppce500 -kernel ./uImage \
  -initrd /root/initrd.gz \
  -append "root=/dev/ram rw console=ttyS0,115200 ramdisk_size=0x60000"  \
  -cpu e500mc -machine dt_compatible=fsl,,P4080DS

Before applying my patch:
  PCI: Probing PCI hardware
  fsl-pci e0008000.pci: PCI host bridge to bus 0000:00
  pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
  pci_bus 0000:00: root bus resource [mem 0xc0000000-0xdfffffff]
  pci_bus 0000:00: root bus resource [bus 00-ff]
  pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to ff
  pci 0000:00:00.0: [1957:0030] type 01 class 0x060400
  pci 0000:00:00.0: reg 10: [mem 0xfff00000-0xffffffff]
  pci 0000:00:01.0: [1af4:1000] type 00 class 0x020000
  pci 0000:00:01.0: reg 10: [io  0x0000-0x001f]
  pci 0000:00:01.0: reg 14: [mem 0x00000000-0x00000fff]
  pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
  pci 0000:00:00.0: PCI bridge to [bus 01-ff]
  pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
  pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
  pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
  pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
  pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 01
  PCI: Cannot allocate resource region 0 of device 0000:00:00.0, will remap
  PCI 0000:00 Cannot reserve Legacy IO [io  0x0000-0x0fff]
  pci 0000:00:00.0: BAR 0: assigned [mem 0xc0000000-0xc00fffff]
  pci 0000:00:00.0: BAR 8: assigned [mem 0xc0100000-0xc01fffff]
  pci 0000:00:01.0: BAR 1: assigned [mem 0xc0200000-0xc0200fff]
  pci 0000:00:01.0: BAR 0: assigned [io  0x1000-0x101f]
  pci 0000:00:00.0: PCI bridge to [bus 01]
  pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
  pci 0000:00:00.0:   bridge window [mem 0xc0100000-0xc01fffff]
  pci_bus 0000:00: resource 4 [io  0x0000-0xffff]
  pci_bus 0000:00: resource 5 [mem 0xc0000000-0xdfffffff]
  pci_bus 0000:01: resource 0 [io  0x0000-0x0fff]
  pci_bus 0000:01: resource 1 [mem 0xc0100000-0xc01fffff]
  
  # lspci -vvv
  00:00.0 PCI bridge: Freescale Semiconductor Inc MPC8533E (prog-if 00 [Normal decode])
          Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
          Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
          Latency: 0
          Region 0: Memory at c0000000 (32-bit, non-prefetchable) [size=1M]
          Bus: primary=00, secondary=00, subordinate=00, sec-latency=0
          I/O behind bridge: 00000000-00000fff
          Memory behind bridge: 00000000-000fffff
          Prefetchable memory behind bridge: 00000000-000fffff
          Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
          BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
                  PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
  
  00:01.0 Ethernet controller: Red Hat, Inc Virtio network device
          Subsystem: Red Hat, Inc Device 0001
          Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-                                                                
          Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
          Interrupt: pin A routed to IRQ 17
          Region 0: I/O ports at 1000 [disabled] [size=32]
          Region 1: Memory at c0200000 (32-bit, non-prefetchable) [disabled] [size=4K]
          Capabilities: [40] MSI-X: Enable- Count=3 Masked-
                  Vector table: BAR=1 offset=00000000
                  PBA: BAR=1 offset=00000800
  
After applying my patch:
  PCI: Probing PCI hardware
  fsl-pci e0008000.pci: PCI host bridge to bus 0000:00
  pci_bus 0000:00: root bus resource [io  0xf1020000-0xf102ffff] (bus address [0x0000-0xffff])
  pci_bus 0000:00: root bus resource [mem 0xc0000000-0xdfffffff]
  pci_bus 0000:00: root bus resource [bus 00-ff]
  pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to ff
  pci 0000:00:00.0: [1957:0030] type 01 class 0x060400
  pci 0000:00:00.0: reg 10: [mem 0xfff00000-0xffffffff]
  pci 0000:00:01.0: [1af4:1000] type 00 class 0x020000
  pci 0000:00:01.0: reg 10: [io  0xf1020000-0xf102001f]
  pci 0000:00:01.0: reg 14: [mem 0x00000000-0x00000fff]
  pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
  pci 0000:00:00.0: PCI bridge to [bus 01-ff]
  pci 0000:00:00.0:   bridge window [io  0xf1020000-0xf1020fff]
  pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
  pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
  pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
  pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 01
  PCI: Cannot allocate resource region 0 of device 0000:00:00.0, will remap
  PCI: Cannot allocate resource region 0 of device 0000:00:01.0, will remap
  PCI 0000:00 Cannot reserve Legacy IO [io  0xf1020000-0xf1020fff]
  pci 0000:00:00.0: BAR 0: assigned [mem 0xc0000000-0xc00fffff]
  pci 0000:00:00.0: BAR 8: assigned [mem 0xc0100000-0xc01fffff]
  pci 0000:00:01.0: BAR 1: assigned [mem 0xc0200000-0xc0200fff]
  pci 0000:00:01.0: BAR 0: assigned [io  0xf1021000-0xf102101f]
  pci 0000:00:00.0: PCI bridge to [bus 01]
  pci 0000:00:00.0:   bridge window [io  0xf1020000-0xf1020fff]
  pci 0000:00:00.0:   bridge window [mem 0xc0100000-0xc01fffff]
  pci_bus 0000:00: resource 4 [io  0xf1020000-0xf102ffff]
  pci_bus 0000:00: resource 5 [mem 0xc0000000-0xdfffffff]
  pci_bus 0000:01: resource 0 [io  0xf1020000-0xf1020fff]
  pci_bus 0000:01: resource 1 [mem 0xc0100000-0xc01fffff]
  
  # lspci -vvv
  00:00.0 PCI bridge: Freescale Semiconductor Inc MPC8533E (prog-if 00 [Normal decode])
          Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
          Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
          Latency: 0
          Region 0: Memory at c0000000 (32-bit, non-prefetchable) [size=1M]
          Bus: primary=00, secondary=00, subordinate=00, sec-latency=0
          I/O behind bridge: 00000000-00000fff
          Memory behind bridge: 00000000-000fffff
          Prefetchable memory behind bridge: 00000000-000fffff
          Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
          BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
                  PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
  
  00:01.0 Ethernet controller: Red Hat, Inc Virtio network device
          Subsystem: Red Hat, Inc Device 0001
          Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
          Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
          Interrupt: pin A routed to IRQ 17
          Region 0: I/O ports at 1000 [disabled] [size=32]                                                                                                                     
          Region 1: Memory at c0200000 (32-bit, non-prefetchable) [disabled] [size=4K]
          Capabilities: [40] MSI-X: Enable- Count=3 Masked-
                  Vector table: BAR=1 offset=00000000
                  PBA: BAR=1 offset=00000800


As you can see, the only difference between these two logs is the
io resource address and all the mem and bus address are still the
same.

> 
> >> In fact it would work on pmac32 as well since those generally
> >don't have
> >> legacy crap either.
> >>
> >> So I have no fundamental objection, it just needs testing. My
> >worry is
> >> that we need to make sure we don't break old chrp and I don't
> >have any
> >> to test with.
> >
> >Don't worry, my patch just drop the picking of primary bus for several
> >fsl boards. All these changes are in board specific file, so it should
> >have no affect to other boards at all.
> 
> Is anything actually fixed by this?

No. As you know the reason we need a primary bus is that we need to support
some ISA legacy devices. So it seems a little weird that we have to pick
one primary bus even on a board which doesn't has ISA at all. Even though
we can't drop the support of the primary bus due to these legacy devices,
we had better narrow the scope of using it instead of propagating it to
the boards which definitely don't care the primary bus at all.

Thanks,
Kevin

> 
> -Scott

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* Re: SATA FSL and upstreaming
From: Benjamin Herrenschmidt @ 2013-06-07  3:52 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Xie Shaohui-B21989, Liu Qiang-B32616, Zang Roy-R61911,
	tiejun.chen, Fleming Andy-AFLEMING, Bhushan Bharat-R65777,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <CAOZdJXU79kqEGk_nqv1NSzna7c=bgwSv+6WFgaTVjR4Rj4cZVg@mail.gmail.com>

On Thu, 2013-05-16 at 09:56 -0500, Timur Tabi wrote:
> On Thu, May 16, 2013 at 1:52 AM, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> >> 3) run " pix altbak" command
> >>
> >> 4) check you are on bank4
> >
> > It stays on bank 0
> 
> pix altbank

So I got the rev2 chip today, put it in, and PCI-E is still not getting
a link. Since the LEDs of the e1000 aren't coming up at all, I *suspect*
the slots are getting no power.

Is there a power control somewhere ? Maybe some DIP or jumpers that
might have gone off ?

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH -V7 09/18] powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format
From: Aneesh Kumar K.V @ 2013-06-07  3:55 UTC (permalink / raw)
  To: Scott Wood; +Cc: linux-mm, paulus, linuxppc-dev, dwg
In-Reply-To: <1370558559.32518.4@snotra>

Scott Wood <scottwood@freescale.com> writes:

> On 04/28/2013 02:37:30 PM, Aneesh Kumar K.V wrote:
>> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>> 
>> We will be switching PMD_SHIFT to 24 bits to facilitate THP  
>> impmenetation.
>> With PMD_SHIFT set to 24, we now have 16MB huge pages allocated at  
>> PGD level.
>> That means with 32 bit process we cannot allocate normal pages at
>> all, because we cover the entire address space with one pgd entry.  
>> Fix this
>> by switching to a new page table format for hugepages. With the new  
>> page table
>> format for 16GB and 16MB hugepages we won't allocate hugepage  
>> directory. Instead
>> we encode the PTE information directly at the directory level. This  
>> forces 16MB
>> hugepage at PMD level. This will also make the page take walk much  
>> simpler later
>> when we add the THP support.
>> 
>> With the new table format we have 4 cases for pgds and pmds:
>> (1) invalid (all zeroes)
>> (2) pointer to next table, as normal; bottom 6 bits == 0
>> (3) leaf pte for huge page, bottom two bits != 00
>> (4) hugepd pointer, bottom two bits == 00, next 4 bits indicate size  
>> of table
>> 
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/include/asm/page.h    |   2 +
>>  arch/powerpc/include/asm/pgtable.h |   2 +
>>  arch/powerpc/mm/gup.c              |  18 +++-
>>  arch/powerpc/mm/hugetlbpage.c      | 176  
>> +++++++++++++++++++++++++++++++------
>>  4 files changed, 168 insertions(+), 30 deletions(-)
>
> After this patch, on 64-bit book3e (e5500, and thus 4K pages), I see  
> messages like this after exiting a program that uses hugepages  
> (specifically, qemu):
>
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221516.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221516.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc2214d6.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc2214d6.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221916.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221916.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc2218d6.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc2218d6.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221496.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221496.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221856.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221856.
> /home/scott/fsl/git/linux/upstream/mm/memory.c:407: bad pmd  
> 40000001fc221816.

hmm that implies some of the code paths are not properly #ifdef.
The goal was to limit the new format CONFIG_PPC_BOOK3S_64 as seen in the
definition of huge_pte_alloc. Can you send me the .config ?

-aneesh

^ permalink raw reply

* Re: SATA FSL and upstreaming
From: Benjamin Herrenschmidt @ 2013-06-07  4:39 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Xie Shaohui-B21989, Liu Qiang-B32616, Zang Roy-R61911,
	tiejun.chen, Fleming Andy-AFLEMING, Bhushan Bharat-R65777,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1370577138.3766.342.camel@pasglop>

On Fri, 2013-06-07 at 13:52 +1000, Benjamin Herrenschmidt wrote:

> So I got the rev2 chip today, put it in, and PCI-E is still not getting
> a link. Since the LEDs of the e1000 aren't coming up at all, I *suspect*
> the slots are getting no power.
> 
> Is there a power control somewhere ? Maybe some DIP or jumpers that
> might have gone off ?

Forget it, reset all the jumpers to the default setup (found the doc !)
and they come up now in slot 4 and 7. It also looks like uBoot now
has an e1000 driver so I don't have to use fman (for which I believe
there is still no upstream driver right ?)

BTW. Is that normal during boot ?

Net:   Initializing Fman
Fman1: Uploading microcode version 106.1.7
PHY reset timed out
PHY reset timed out
PHY reset timed out
PHY reset timed out

Cheers,
Ben.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox