Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp255814rwb; Fri, 4 Aug 2023 12:09:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtFIiE+8gJDPPLwcOkQwj8W6wGbNk3P4tA95FqNYNwtP9bnu6MBjF++8oMipDeQZA/r/iH X-Received: by 2002:aa7:88c9:0:b0:687:35ab:d21f with SMTP id k9-20020aa788c9000000b0068735abd21fmr3238937pff.22.1691176191777; Fri, 04 Aug 2023 12:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176191; cv=none; d=google.com; s=arc-20160816; b=PE1IFVwlG+x+TLsTtDIj17qIQTHHqtWvKuYN1oYt7BRavRgJvpH+0vXVpZeUMRiHNi 0nhogI2PMGKpRocXEax6AqwQ96qlEBYye66z3FmDhF7iJa9BhIKnXpWUxTcIcEj3n/Og ILTy00wxEmULXKMxG1T1f222RLxwmES84rkRxzWLmQUjtPam4aDVcfrWMXoSPnEIZgr5 zk3DUo+Bq63I9DtiA6YBaHczbJhSOm8VW3SfBu1H1NBgUs6FVT5MeJOBAfGbDer6Xfc1 GJjjy60pS1JXv2uzf9+EsRBOPm66uXSMwCYQOFk/C/e6XBWVprwT6OQoDOJdb8AbjNj9 jq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=SzgCQZrREJ8wwDiX6siz2qHa1/7eISD6QAlgSdu5Knw=; fh=5d7d58cYloJviYDb7wc4sRLC2XY54HHu3FOb007YNes=; b=K6LkRTjsq6/r8sGzrVNe4Rykr8Eex5dcc+G6316YNBEPX7DjgY73NN3jsu2AOGtVnf mvc/xfG61YYATDys0nwl3cqIZpjTizGxf6ul6TAoEVmyasd1asSvped+URNkQHUb+5gQ aIsKoPOT4G6Zx1LMlRq59zD3+PSpRNWt/zWK+PHeujlXSlAAbUuMvFX862PEfLBCG5Gv xRVDZC2fO5zF0nwWguLgGC+aodlE6SlbJXaU0ETireBYoCASxhX4c/W1HMxgwUZKCMD6 QiZnnXbtclg+MRaBDDoy90lk2/3CCMnr1Eh5Xcr3JpWN+98aqOGIIP8JbwKxsV34xD4H suzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dafKDsAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g190-20020a636bc7000000b00564b1002adbsi2089102pgc.240.2023.08.04.12.09.19; Fri, 04 Aug 2023 12:09:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dafKDsAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbjHDSgJ (ORCPT + 99 others); Fri, 4 Aug 2023 14:36:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjHDSfN (ORCPT ); Fri, 4 Aug 2023 14:35:13 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C6B4ECE for ; Fri, 4 Aug 2023 11:33:55 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d437624b9c1so1126994276.0 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=Q43yFFd4AC/cQQP9HD2diZIBbRCx8ZxOm7KMG61NkkPWjSBdd0DTv3TQMSj/quhQ+h HyuV51rAFc2eVi1POtRYoHAtOEQf/UdKo6qaZqZ5G2UnSOSM5NboCBX2ZFkd5VNJs1UR RhPYeFb36seTE210+DQiaE0mtDOjY/lGAuQs/RpgTGY8xct3dAvL1nN2YHqan+0YAM5Z qeg6KMJr8mEQi2DD73GzIYf+BX+0M1RJ/oIyz7Mf/p8HvAtcVGIZ6Nts3YCB549/cnGy BFMiijrG10yw5brZ/08DBwG/Zs4gU3ELQUIwNhIQyl3g+ccWUguEI1GUof8kE2RHXp5J lNyA== X-Gm-Message-State: AOJu0YxfZOt5+mzz1DSGQH0V/dWJOR/uWfa9fHG3UMvzxJkIr0ZC8Au5 Efn5PzWRvkLU70nCetawOYjNksWV+rY= 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 Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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'.