From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3CA9C001DB for ; Fri, 4 Aug 2023 18:34:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+0Ye/0XSVAmBT3Jlqqdz3JBjWvABGVD0GM703JgQrrU=; b=myAjNxWzSH9wnYHNMODb8F+Ovk 7kKChQdiA1rhbKcFR5Igi+8Yca7jvIHL0dRADdyH5T7EVWEwSRuFabRSMJQ4vnD0efOChiS/xsWS2 2M1FBlP4UYJK+Ic9V7ptwT6mVA4ax6yJ5dic4thpDTsUtlBeDssnKiQ/4ha1j5N90b23vnVm+29Wd oNZe4oivDMo4VWKXH3GKwiGlvKxG3tLU9+AFmebNt5pCyCsvLJmhPRxS6IzJgPqG4QxBX7PeCfTNg i1vMbI1ob/Pyx9zocGFCwLPNKN3DaG99vR/6uqvlF3g68VNgwh4T8tNHw/gQSQWw6LgtHBg3s4rd+ Mva275ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRzch-00D0Tq-0y; Fri, 04 Aug 2023 18:34:03 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRzce-00D0T7-2R for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2023 18:34:02 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d41bfd5e507so1783201276.3 for ; Fri, 04 Aug 2023 11:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691174034; x=1691778834; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SzgCQZrREJ8wwDiX6siz2qHa1/7eISD6QAlgSdu5Knw=; b=dafKDsAUIw0Ie3fHqOzQMKvbKji+TOslqxd+53S8Ae1ULDmkeB/ua1YPOdYXPbSr0W n0B0znsGS31LPviJM1SZCFmESkuTcUMny2hya9DL0xdvpWCSxSHRJCfVCbNxLfYyeFRv EIycdVeNgQRE7OZLu04A+9r6jEyZbrSMa/ojO+QiKtGQ5lFCv7kKrPSc1rHckvDKMSWE Py9HduHTpVfSHRrXxUOhd0+x82M2xiEsF5OLWY4E2sB+9UWBaFq9En3wnmE643RVcCta tFFvd4rXgtsTJi80YNeW/3oG4StJ9Y06uzrmvVFVFIhnYu0yb5aHuCS39qa1aL/NYiUV FCOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691174034; x=1691778834; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SzgCQZrREJ8wwDiX6siz2qHa1/7eISD6QAlgSdu5Knw=; b=OhS1uxFMOzdoOIsRC2NWK+qGA3wq81XMVdbizkkNaq7OE269s4srkz2yYRkhgxsacT BvLM/kB/lG0liRdzNsXEE9o4JeiWiqn3n70cGYysv4yzeBeTjNCCK/E52Y3IFn1uvEwv mEMd8jqzJEPAkbVsYkeJMfty4tpc7OiP40R/jAr/Z/+5jFQgM73tjlYje4oyFqd2Ib4B fet8C1DaFae4Xlf0YUSyD7+I6PVQvw4M04Xz5DHd61R42qvr4GUr522oZ03vWGvACA0s 5pC64HI3Jxqfq8D1aCh1p0U7Lh8JRkIMwAAhs2z7KDC23qDUAU78poxPoA3zVGLDtpIK 1fsg== X-Gm-Message-State: AOJu0YwfXA8H+x/P5UmQYWt04PeTwh1IX/Pl+j4FOAsFSjsslFi3KmOv qGHlkc8dzUCZEVNNRxItzCpFKuqTr/w= X-Google-Smtp-Source: AGHT+IEu3d94rrVmJ78RS29lOywQDiyzD14VCrwEVoVIDv3RxrRH95F0M9gwGQrPVV9YwLdxoui14M8wTbI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:42ca:0:b0:d07:16db:6f8f with SMTP id p193-20020a2542ca000000b00d0716db6f8fmr13913yba.6.1691174034726; Fri, 04 Aug 2023 11:33:54 -0700 (PDT) Date: Fri, 4 Aug 2023 11:33:53 -0700 In-Reply-To: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH 2/4] KVM: selftests: Add helper macros for ioctl()s that return file descriptors From: Sean Christopherson To: Colton Lewis Cc: Oliver Upton , maz@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, mhal@rbox.co X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230804_113400_818843_D22D83F4 X-CRM114-Status: GOOD ( 19.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 04, 2023, Colton Lewis wrote: > Oliver Upton writes: > > > Hi Sean, > > > On Thu, Aug 03, 2023 at 05:42:24PM -0700, Sean Christopherson wrote: > > > Add KVM, VM, and vCPU scoped helpers for ioctl()s that return file > > > descriptors, i.e. deduplicate code for asserting success on ioctls() for > > > which a positive return value, not just zero, is considered success. > > > > Signed-off-by: Sean Christopherson > > > I appreciate the desire to eliminate duplicate code, but I think the > > naming just muddies the waters. TBH, when I first read the diff w/o the > > changelog, I thought you were describing the input fd (i.e. 'kvm_fd', > > 'vm_fd', 'vcpu_fd'). I don't think explicitly spelling out the condition > > each time (i.e. ret >= 0) is all that difficult. > > Couldn't ret >= 0 be the assert condition for everything? Don't see why > there needs to be different helpers to check == 0 and >= 0. > > Unless I'm missing something, error returns are only ever negative. Using "ret >= 0" would work in the sense that the tests wouldn't fail, but it would degrade our test coverage, e.g. selftests wouldn't detect KVM bugs where an ioctl() unexpectedly returns a non-zero, positive value. The other wrinkle is that selftests need to actually consume the return value for ioctl()s that return a positive value, i.e. the fd (or whatever it is) needs to propagated up the stack. I.e. all of the generic ioctl() macros would need to "return" the value, which I really don't want to do because that would (re)open the gates for having helpers that return an int, even though the only possible return value is '0'. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel