From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933060AbcKHJaz (ORCPT ); Tue, 8 Nov 2016 04:30:55 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59768 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932538AbcKHJav (ORCPT ); Tue, 8 Nov 2016 04:30:51 -0500 Date: Tue, 8 Nov 2016 10:30:42 +0100 From: Heiko Carstens To: Mark Rutland Cc: Dave Hansen , linux-kernel@vger.kernel.org, Andrew Morton , Mel Gorman , Russell King , Thomas Gleixner , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org Subject: Re: [PATCH] mm: only enable sys_pkey* when ARCH_HAS_PKEYS References: <1477958904-9903-1-git-send-email-mark.rutland@arm.com> <20161104234459.GA18760@remoulade> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161104234459.GA18760@remoulade> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110809-0040-0000-0000-0000025551AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110809-0041-0000-0000-00002278D61D Message-Id: <20161108093042.GC3528@osiris> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-08_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611080177 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 04, 2016 at 11:44:59PM +0000, Mark Rutland wrote: > On Wed, Nov 02, 2016 at 12:15:50PM -0700, Dave Hansen wrote: > > On 10/31/2016 05:08 PM, Mark Rutland wrote: > > > When an architecture does not select CONFIG_ARCH_HAS_PKEYS, the pkey_alloc > > > syscall will return -ENOSPC for all (otherwise well-formed) requests, as the > > > generic implementation of mm_pkey_alloc() returns -1. The other pkey syscalls > > > perform some work before always failing, in a similar fashion. > > > > > > This implies the absence of keys, but otherwise functional pkey support. This > > > is odd, since the architecture provides no such support. Instead, it would be > > > preferable to indicate that the syscall is not implemented, since this is > > > effectively the case. > > > > This makes the behavior of an x86 cpu without pkeys and an arm cpu > > without pkeys differ. Is that what we want? > > My rationale was that we have no idea whether architectures will have pkey > support in future, and if/when they do, we may have to apply additional checks > anyhow. i.e. in cases we'd return -ENOSPC today, we might want to return > another error code. > > Returning -ENOSYS retains the current behaviour, and allows us to handle that > ABI issue when we know what architecture support looks like. > > Other architectures not using the generic syscalls seem to handle this with > -ENOSYS, e.g. parisc with commit 18088db042dd9ae2, so there's differing > behaviour regardless of arm specifically. The three system calls won't return -ENOSYS on architectures which decided to ignore them (like with with above mentioned commit), since they haven't allocated a system call number at all. Right now we have one architecture where these three system calls work if the cpu supports the feature (x86). Two architectures (arm, mips) have wired them up and thus allocated system call numbers, even though they don't have ARCH_HAS_PKEYS set. Which seems a bit pointless. Three architectures (parisc, powerpc, s390) decided to ignore the system calls completely, but still have the pkey code linked into the kernel image. imho the generic pkey code should be ifdef'ed with CONFIG_ARCH_HAS_PKEYS. Otherwise only dead code will be linked and increase the kernel image size for no good reason.