From patchwork Wed Oct 30 14:01:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra K T X-Patchwork-Id: 3114721 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 531ECBF924 for ; Wed, 30 Oct 2013 14:00:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6313201FE for ; Wed, 30 Oct 2013 14:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DB832037D for ; Wed, 30 Oct 2013 14:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399Ab3J3OAL (ORCPT ); Wed, 30 Oct 2013 10:00:11 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:59911 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899Ab3J3OAI (ORCPT ); Wed, 30 Oct 2013 10:00:08 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Oct 2013 19:30:05 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Oct 2013 19:30:04 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id DB252394004D; Wed, 30 Oct 2013 19:29:41 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9UDxwDq27328522; Wed, 30 Oct 2013 19:29:58 +0530 Received: from d28av05.in.ibm.com (localhost [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9UE02OL020439; Wed, 30 Oct 2013 19:30:03 +0530 Received: from [9.79.207.173] ([9.79.207.173]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r9UDxxZf019971; Wed, 30 Oct 2013 19:30:00 +0530 Message-ID: <52711121.9030606@linux.vnet.ibm.com> Date: Wed, 30 Oct 2013 19:31:05 +0530 From: Raghavendra K T Organization: IBM User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Linus Torvalds CC: Greg KH , Tim Gardner , Linux Kernel Mailing List , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Gleb Natapov , Marcelo Tosatti , Paolo Bonzini , KVM list , Al Viro Subject: Re: [PATCH 3.12-rc7] KVM: Fix modprobe failure for kvm_intel/kvm_amd References: <1383059634-55512-1-git-send-email-tim.gardner@canonical.com> <52700C24.9050001@linux.vnet.ibm.com> In-Reply-To: X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13103014-8878-0000-0000-0000097D66EF Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 10/30/2013 01:03 AM, Linus Torvalds wrote: > On Tue, Oct 29, 2013 at 12:27 PM, Raghavendra K T > wrote: >> >> Could one solution be cascading actual error >> that is lost in fs/debugfs/inode.c:__create_file(), so that we could >> take correct action in case of failure of debugfs_create_dir()? >> >> (ugly side is we increase total number of params for __create_file to >> 6). or I hope there could be some better solution. > > The solution to this would be to simply return an error-pointer. See > . That's what we do for most complex subsystems that > return a pointer to a struct: rather than returning "NULL" as an > error, return the actual error number encoded in the pointer itself. Thank you Linus. Yes, this would have been ideal. > > But that would require every user of debugfs_create_dir() to be > updated to check errors using IS_ERR() instead of checking against > NULL, and there's quite a few of them. > > So I think just making the error be EEXIST is a simpler solution right now. > Agree. I had below patch, and just before sending as formal mail I saw Paolo's pull request which already took care of it. ---8<--- From ac5d9f038c273f27bea7a54aab6af79b57f56317 Mon Sep 17 00:00:00 2001 From: Raghavendra K T Date: Wed, 30 Oct 2013 18:59:46 +0530 Subject: [PATCH] Return EEXIST on debugfs_create_dir failure in kvm As quoted by Linus, EFAULT means "user passed in an invalid virtual address pointer", which is why the error string is Bad address. But when a debugfs directory creation fails, the above error is not valid. Signed-off-by: Raghavendra K T --- I understand that Tim's patch that renames directory to something like kvm-pv would solve kvm-amd/kvm-intel modules insertion problem. This patch is to address error code change complained by Linus. arch/x86/kernel/kvm.c | 2 +- virt/kvm/kvm_main.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index a0e2a8a..e475fdb 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -622,7 +622,7 @@ static int __init kvm_spinlock_debugfs(void) d_kvm = kvm_init_debugfs(); if (d_kvm == NULL) - return -ENOMEM; + return -EEXIST; d_spin_debug = debugfs_create_dir("spinlocks", d_kvm); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a9dd682..0430853 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3091,13 +3091,14 @@ static const struct file_operations *stat_fops[] = { static int kvm_init_debug(void) { - int r = -EFAULT; + int r = -EEXIST; struct kvm_stats_debugfs_item *p; kvm_debugfs_dir = debugfs_create_dir("kvm", NULL); if (kvm_debugfs_dir == NULL) goto out; + r = -EFAULT; for (p = debugfs_entries; p->name; ++p) { p->dentry = debugfs_create_file(p->name, 0444, kvm_debugfs_dir, (void *)(long)p->offset, -- 1.7.11.7