Message ID | 20240214101557.2900512-2-kernel@xen0n.name |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1118935dyb; Wed, 14 Feb 2024 02:35:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6f2znKiLbgqaHkg0U4aoBM2T3tGKQaVMLc2K6hF03VN18WvtRI+pYJQaNa0dcbcFLQwh0ZAmzMHHIrVDkpPfG+OUc4Q== X-Google-Smtp-Source: AGHT+IHXiubwAUFkF3PeYZ1LMapQtxaTc22RJ24bgZG6lx0v+g6kOyFXdPpbFJk8T385b4SccBo/ X-Received: by 2002:a05:622a:58e:b0:42d:b68a:4f56 with SMTP id c14-20020a05622a058e00b0042db68a4f56mr2236820qtb.45.1707906923730; Wed, 14 Feb 2024 02:35:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707906923; cv=pass; d=google.com; s=arc-20160816; b=zyERP6PfIQTbZ6NdKZ9o/pgGXCpGgStiZOoXnwslcw1gMXPnCdrbJ+IBxF4NtmSuww r31krNgygVbA7HoN/dPlewZo96UQEt6LZRGVPJl+QwAaynugmLbrh0KCm7m0OPSrZHZG RTgapspVKfV5OcM4bBDW6i80sVCbGzOJ5Oh6iIxomhmH+RuMGiQOMI1zgfSnGG6SQ3Se sYDOJTYfoZD2NEiHLQQy4cRV9nwbvpPJRn4f7XFELoZXvyi1IhOkEMdRZzUP8Frp8sJB xynu7bn/2uOLR3sIhHqt9Af1E8ny4y/JiSkuXhYSnWidQ5/7yp0n8CTpDXQExEMFPBJ6 ZX1A== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bfiqB3+pwN35nisRVs+YFHtHnge1kJcbRHJbqJ+9U+o=; fh=Kc6m0sf1pzFksumkOKN/VAszzW+1uwS3X3KWYQqt8Ms=; b=vpEk6zG74u/NjSjsMmnV3B/40NgczDJEcaeGE2dEGopc2kG1oyvAnuIlw3Fa4yP6+v BSLmdiiBm9R5n6KqhLAfYclzANfqP9dTcZhTwQwt1/z44wrTP9tY23SM3FoZbx6Rb1By deVVHZz3im2wfbLp84C0fqU2tiOyJu63eqlKSbhVm2KExDuCLFTLb4l3R0GJkh6wza75 tyzHGL4Jfic7A7wkA0or8i7wJ32N8Cb0s4Rt54Ej8bVjP6DB7bhXHYuEm9xMFdSees0B aNUQxonUCPmAEBsTcLhxECBa7+eDRBsPGsATtlUhS1BKlgCbCtHoyTD837d12qfiN3Xb gcFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=AnHykjQd; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWWJIlOHgvcmT7SabSViFn+6rS4EY8SUGVmm90Yqc1QJ1tqjVtfEVIrp3jOEnfYc6qbMfKKusDyz86qlHWplq1xEXlWtg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e17-20020a05622a111100b0042db696fff1si2186865qty.283.2024.02.14.02.35.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:35:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=AnHykjQd; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65045-ouuuleilei=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0B4451C2734A for <ouuuleilei@gmail.com>; Wed, 14 Feb 2024 10:25:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF3EB1BC3B; Wed, 14 Feb 2024 10:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b="AnHykjQd" Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) (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 69EC0171A2; Wed, 14 Feb 2024 10:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.28.160.31 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707906252; cv=none; b=SO1olORUl7NxlbJFNsiBRkBXRFI1Jm5yE5hjRiHHukn8dni7iuQjZpC1VWuAerpTdf+VtdQxNCemNFCgrwoqYYCDuGCaPpWVPUhke+Sb5ux2Z1UrkL6iRt71hkv8YwBo8oQLj9fufSSxZ0m9W+e0eyTVlRmcCotbUYWYms2xjvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707906252; c=relaxed/simple; bh=qUTm7/R3ovfw0MXxK4QrZKdILlZUuBNM9kI6bR5Fxzc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XFgxRPbgwNYJ1qRIO8JZshUWBOO2ncGYUuoiuOIAGaE43e9iNIloXoKkHAby5qAaDAWcdOxUYLFaWbVK0gZgcF6iD6IIhh17waVrpSKdMkJZtp89e8UjLFe6EtxpF6DAM8LNhtoUD/RufE62eYkO5gyZD+pafbaFcDKzvnQFvcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen0n.name; spf=pass smtp.mailfrom=xen0n.name; dkim=pass (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b=AnHykjQd; arc=none smtp.client-ip=115.28.160.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen0n.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xen0n.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1707905765; bh=qUTm7/R3ovfw0MXxK4QrZKdILlZUuBNM9kI6bR5Fxzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AnHykjQdE1CficUI8gdhrgpFjRfWTnDfdo/3pAtd8JVI8QHIsghXTdXwSjL1Fg7sz jw8WvUNInaOnTLhKJuxzq29eNk0fhq9PYUwGntbZSLVCe/uMu13LjJmVOhkc8wgEPV VunNPOwdUcIGAqKUPO9cRjUrvDXrZRe/bAfifxGg= Received: from ld50.lan (unknown [IPv6:240e:388:8d00:6500:5531:eef6:1274:cebe]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 6215D6017D; Wed, 14 Feb 2024 18:16:05 +0800 (CST) From: WANG Xuerui <kernel@xen0n.name> To: Paolo Bonzini <pbonzini@redhat.com>, Huacai Chen <chenhuacai@kernel.org> Cc: Tianrui Zhao <zhaotianrui@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui <git@xen0n.name> Subject: [PATCH for-6.8 1/5] KVM: LoongArch: Fix input value checking of _kvm_get_cpucfg Date: Wed, 14 Feb 2024 18:15:53 +0800 Message-ID: <20240214101557.2900512-2-kernel@xen0n.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214101557.2900512-1-kernel@xen0n.name> References: <20240214101557.2900512-1-kernel@xen0n.name> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790870210682610535 X-GMAIL-MSGID: 1790870210682610535 |
Series |
KVM: LoongArch: Fix wrong CPUCFG ID handling
|
|
Commit Message
WANG Xuerui
Feb. 14, 2024, 10:15 a.m. UTC
From: WANG Xuerui <git@xen0n.name> The range check for the CPUCFG ID is wrong (should have been a || instead of &&), and pointless, because the default case a few lines below already serves to deny all unhandled cases. Furthermore, the juggling of the temp return value is unnecessary, because it is semantically equivalent and more readable to just return at every switch case's end. This is done too to avoid potential bugs in the future related to the unwanted complexity. Fixes: db1ecca22edf ("LoongArch: KVM: Add LSX (128bit SIMD) support") Signed-off-by: WANG Xuerui <git@xen0n.name> --- arch/loongarch/kvm/vcpu.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c index 27701991886d..c4a592623da6 100644 --- a/arch/loongarch/kvm/vcpu.c +++ b/arch/loongarch/kvm/vcpu.c @@ -300,11 +300,6 @@ static int _kvm_setcsr(struct kvm_vcpu *vcpu, unsigned int id, u64 val) static int _kvm_get_cpucfg(int id, u64 *v) { - int ret = 0; - - if (id < 0 && id >= KVM_MAX_CPUCFG_REGS) - return -EINVAL; - switch (id) { case 2: /* Return CPUCFG2 features which have been supported by KVM */ @@ -324,12 +319,10 @@ static int _kvm_get_cpucfg(int id, u64 *v) if (cpu_has_lasx) *v |= CPUCFG2_LASX; - break; + return 0; default: - ret = -EINVAL; - break; + return -EINVAL; } - return ret; } static int kvm_check_cpucfg(int id, u64 val)