From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753675AbcFANg0 (ORCPT ); Wed, 1 Jun 2016 09:36:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59000 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbcFANgZ (ORCPT ); Wed, 1 Jun 2016 09:36:25 -0400 Date: Wed, 1 Jun 2016 09:36:18 -0400 From: Neil Horman To: David Kershner Cc: corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, gregkh@linuxfoundation.org, erik.arfvidson@unisys.com, timothy.sell@unisys.com, hofrat@osadl.org, dzickus@redhat.com, jes.sorensen@redhat.com, alexander.curtin@unisys.com, janani.rvchndrn@gmail.com, sudipm.mukherjee@gmail.com, prarit@redhat.com, david.binder@unisys.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, driverdev-devel@linuxdriverproject.org, sparmaintainer@unisys.com Subject: Re: [PATCH v2 03/27] staging: unisys: iovmcall_gnuc.h change -1 return values Message-ID: <20160601133618.GC4578@hmsreliant.think-freely.org> References: <1464748013-31309-1-git-send-email-david.kershner@unisys.com> <1464748013-31309-4-git-send-email-david.kershner@unisys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464748013-31309-4-git-send-email-david.kershner@unisys.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 01 Jun 2016 13:36:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 31, 2016 at 10:26:29PM -0400, David Kershner wrote: > From: Erik Arfvidson > > This patch changes the vague -1 return values to -EPERM. > This operation is not supported is a good alternative > to -1 because the return is basically telling the caller > that the processor doesn't support vmcall operations. > > Signed-off-by: Erik Arfvidson > Signed-off-by: David Kershner > Reviewed-by: Tim Sell > --- > drivers/staging/unisys/visorbus/iovmcall_gnuc.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/unisys/visorbus/iovmcall_gnuc.h b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h > index b08b6ec..98ea7f3 100644 > --- a/drivers/staging/unisys/visorbus/iovmcall_gnuc.h > +++ b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h > @@ -22,7 +22,7 @@ __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx, > > cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); > if (!(cpuid_ecx & 0x80000000)) > - return -1; > + return -EPERM; > > __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : > "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); > @@ -40,7 +40,7 @@ __unisys_extended_vmcall_gnuc(unsigned long long tuple, > > cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); > if (!(cpuid_ecx & 0x80000000)) > - return -1; > + return -EPERM; > > __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : > "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx)); > -- > 1.9.1 > This gets properly checked as far as return codes go for the most part, which is good, but in the case of an issuing of the VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET ioctl, the return code is simply copied into a user space buffer. That might be expected if -1 is used as an error condition marker, but I would check before you assume that a user space caller will handle -EINVAL properly there.