From patchwork Fri Feb 16 15:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 202227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp611027dyb; Fri, 16 Feb 2024 08:02:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVzOI61vsp9wGe/p9s6nyIm7lAMPsC7DkvquRrBf915bhhDlm3N6wvFdPkuJOEjM92Hqy+A6vGrSwG/8i/d1hC+Sl8hw== X-Google-Smtp-Source: AGHT+IEhpb76voVq3cmuINH9IxjH3kEYKS7UGpa1K82DcgoHNHJ3a4fEDHas0sofv+jtMt6ku7UY X-Received: by 2002:a17:902:d501:b0:1d9:7782:316f with SMTP id b1-20020a170902d50100b001d97782316fmr7056392plg.39.1708099332244; Fri, 16 Feb 2024 08:02:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708099332; cv=pass; d=google.com; s=arc-20160816; b=t194IxI87/US4eYmMnJx0ysJw2jJ8tcqJ9d/0kH6H71XTfc6qANlt4mux5ESzVwrLY sw7/ogGGYauFwfuk6QaRr8ysYTaPlw5XyWeQ+w6dyBLmmc7RgHRIWLbIrxff4BJ61Zl4 HrYUCUlFAykaYbvOevqbyvQrnwC3Cfv/XXpyjDAYDczPWVUFWj9glo01t2WbRmYjNmiR l/28L0QyWaLvalVFdHNPF9P9RWYSOLIgbMnD+D8V6Zo6fHeIJCvteLhI7n4+uuRcXPZ0 D7G3RynLHmZ6xmGTPb1laWIUNk+gJGk592iasSF5mxNb5BZ43KgPbzBEUJPYyZ5lKCfT JxZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=7Gmt3BZeS8RFm72X8X8sJg3/SSmmSkJFO1q6nTV3Suo=; fh=okV94x2dRlXDrBVMiz2SuDmkd8y18YO5na7VyZ1e0A4=; b=YsLNAXY2a7crIAzVD5CB6hOlfApoSOEAgpir5rxA5aL33nrYmSa+N1ElRb/1qecrEi bo3GiHyEf3K4+OW5GVNPZI/hYjYclicH1HfHO6A1LP29G4yPX85yYb/WUaws55GgznEk kxmSIlY7j9tRRhAdP2d+8+E7YhIrzvzikpUudMovmyPNe3f2MnjicbESsrmCoQWmVUUc Jshg1D9qKhxodUBvJpzuRpgF05rZOeJXjUXQio10PNO5FI16NduZ1TENUrniZDkI2I64 gGTb5h7qu5/THbwmMuqcKikGG72AjFXWboFOT5OHZe8gWlCxGslQ1Vt59sn5YhspmlrD uQ/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HJaT5BWS; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-68932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mc3-20020a1709032b0300b001d950cac4e0si44798plb.557.2024.02.16.08.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:02:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HJaT5BWS; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-68932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7B05D282BBB for ; Fri, 16 Feb 2024 16:01:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB083131738; Fri, 16 Feb 2024 16:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HJaT5BWS" Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73DF112F588 for ; Fri, 16 Feb 2024 16:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708099203; cv=none; b=fcO5BckyvR8pUZWqA5oLqpA66JA4IiZ8GD3aPpWocr27TI3gPEZqwg+LkKIhcl7NQpsP6kFWH+V6ixDYECx3DgAe4w1cdfNRkrWjOO5hsj5qg14wRD9AtUvqRo/zmuP7cr9lRLZa+ZwgOhz1MOwTyihV3bLiOf/KeDVk7ci0ZNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708099203; c=relaxed/simple; bh=WBW4bGvns6QMpjKS4b4uKVjwK41RvyqpoB5X0RlniAw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=A5yslsQPvcc23N3q3WxHkshnH0T0DSMNImTGm7XJ5xY6aXMjAusfk1eXLrTxafsyP1M4YoVexgUmbW1a3l+GrsUMH+8xAsUiFS/veS/OX+UPtMb8ppNWd20JHt8agT/hU5NSs4aZhnnGxtFKbnm+kBOm3m288x0fvE9SS/+jBDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HJaT5BWS; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708099199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7Gmt3BZeS8RFm72X8X8sJg3/SSmmSkJFO1q6nTV3Suo=; b=HJaT5BWS4uxFC6UFeVy4nov0HxfRiVDg9bNe5LZ0a3KwXko3RYLdUg1GNNAml18SbfPs+/ gtkxdGq5pZ1pqrZPBN/puEMYAhm2RHO71RmUhlriBMq+Hy/5a9BDI65VGOgKmLqYLWDvkP xWLCC0GZQbLkbnUKZ5z8fkXpOrIsAyk= From: Oliver Upton To: kvm@vger.kernel.org Cc: Nicholas Piggin , Michael Ellerman , Christophe Leroy , aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com, Sean Christopherson , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Sebastian Ene , Oliver Upton Subject: [PATCH] KVM: Get rid of return value from kvm_arch_create_vm_debugfs() Date: Fri, 16 Feb 2024 15:59:41 +0000 Message-ID: <20240216155941.2029458-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791071965510475698 X-GMAIL-MSGID: 1791071965510475698 The general expectation with debugfs is that any initialization failure is nonfatal. Nevertheless, kvm_arch_create_vm_debugfs() allows implementations to return an error and kvm_create_vm_debugfs() allows that to fail VM creation. Change to a void return to discourage architectures from making debugfs failures fatal for the VM. Seems like everyone already had the right idea, as all implementations already return 0 unconditionally. Signed-off-by: Oliver Upton Acked-by: Marc Zyngier Acked-by: Paolo Bonzini --- Compile-tested on arm64, powerpc, and x86 since I don't trust myself to even get this simple patch right. arch/powerpc/kvm/powerpc.c | 3 +-- arch/x86/kvm/debugfs.c | 3 +-- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 8 ++------ 4 files changed, 5 insertions(+), 11 deletions(-) base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 23407fbd73c9..d32abe7fe6ab 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -2538,9 +2538,8 @@ void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_ vcpu->kvm->arch.kvm_ops->create_vcpu_debugfs(vcpu, debugfs_dentry); } -int kvm_arch_create_vm_debugfs(struct kvm *kvm) +void kvm_arch_create_vm_debugfs(struct kvm *kvm) { if (kvm->arch.kvm_ops->create_vm_debugfs) kvm->arch.kvm_ops->create_vm_debugfs(kvm); - return 0; } diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c index 95ea1a1f7403..999227fc7c66 100644 --- a/arch/x86/kvm/debugfs.c +++ b/arch/x86/kvm/debugfs.c @@ -189,9 +189,8 @@ static const struct file_operations mmu_rmaps_stat_fops = { .release = kvm_mmu_rmaps_stat_release, }; -int kvm_arch_create_vm_debugfs(struct kvm *kvm) +void kvm_arch_create_vm_debugfs(struct kvm *kvm) { debugfs_create_file("mmu_rmaps_stat", 0644, kvm->debugfs_dentry, kvm, &mmu_rmaps_stat_fops); - return 0; } diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7e7fd25b09b3..9a45f673f687 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1507,7 +1507,7 @@ bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu); bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu); int kvm_arch_post_init_vm(struct kvm *kvm); void kvm_arch_pre_destroy_vm(struct kvm *kvm); -int kvm_arch_create_vm_debugfs(struct kvm *kvm); +void kvm_arch_create_vm_debugfs(struct kvm *kvm); #ifndef __KVM_HAVE_ARCH_VM_ALLOC /* diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 10bfc88a69f7..c681149c382a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1150,10 +1150,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname) &stat_fops_per_vm); } - ret = kvm_arch_create_vm_debugfs(kvm); - if (ret) - goto out_err; - + kvm_arch_create_vm_debugfs(kvm); return 0; out_err: kvm_destroy_vm_debugfs(kvm); @@ -1183,9 +1180,8 @@ void __weak kvm_arch_pre_destroy_vm(struct kvm *kvm) * Cleanup should be automatic done in kvm_destroy_vm_debugfs() recursively, so * a per-arch destroy interface is not needed. */ -int __weak kvm_arch_create_vm_debugfs(struct kvm *kvm) +void __weak kvm_arch_create_vm_debugfs(struct kvm *kvm) { - return 0; } static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)