Message ID | 20240214163358.2913090-1-kernel@xen0n.name |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-65556-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1340379dyb; Wed, 14 Feb 2024 08:37:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0G6OegYfMBzrIomb2mIGbVuEkV/HrScmH2fCp2gHdmnRYJy3iw1vIQLYmOKPYbNogf+jcoU8svvUHkbQtW+0LCnIx6g== X-Google-Smtp-Source: AGHT+IFcD/T2KBucW+xQRuKZTyJze6OwHBIfRbGbPiyefvc7xHRN404Q8OJzJM7QF4EmrvrEYog0 X-Received: by 2002:a05:6871:5227:b0:219:eeb6:2ebc with SMTP id ht39-20020a056871522700b00219eeb62ebcmr3287167oac.51.1707928677478; Wed, 14 Feb 2024 08:37:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707928677; cv=pass; d=google.com; s=arc-20160816; b=Rerz6pmRT6ji3MfWX0qmbkkXEjuQTtPF60enmozncRGh47IzFyZ/CiJnwEq8dlfTlW 8iYJsqGaW8dNvFiFrXlN0mXdbIIBhkWzkuByP/utRAFQnFJrmpJK/xgXB9/p7lcE+AiC FZoLnkkbG+YIsl45aXdGrqaCpcT8tedR/4KfjZWdJMD298FmjfmI3sZLlgP1ZUs576i8 S2Ak6ao7UJzNO5jhwgXG4Pt3Wml1sv7TKyus2JHnojGHLzVI8NUgUGnXsNqW2mY3TBGX kbwGYE7lKPROnSy1xlwi+BHfo0Nurq9ekNBC86j8XpUBarOQbRxrdnI2bTNC01ZgFiB7 UmrQ== 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=sGImop4AG5njvu7HVHB5RqCRGDdvZ7Lnr18T0h/+CKo=; fh=2m4YHE6o7Mtd9IHl+8EQTXh9Omo2Ntw1QBd04q+5Zaw=; b=DT4IXg0sYEzXeL9JfdEV6k4/C/W/G7TTeWWqqFXUPeO4jvDdccs/sCa0dSdm9ezDYQ zgj/C4ARJNIK7NABufKmbeJRNC2hFGkPIXAzG2iIN+Xw8GLi38sULW+bXS5BkWGRfSYL A+4JTu7yII7FRCyknEeP+x+L/jAN8UPQYDYo1T7yhIT8aKqquwm5f/MrVmBTs7pNhuet kTROaH/K0EW9tsP41brSb6i2+NgIqYSUA0VOJRlZ6mAFdAm1hd1NUVvRyCBGFa4Ngebs +a7W6PgZ+8o5YK1iJTDch2MJOKUq2ndrawV0UUJwlfPIb6QRFSJOddKPUegzNPiwKp5/ TR6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=QqaH5u+X; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65556-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXD4I+xv7jKkMMJwGLDOETxYnIidxpdn1+SB0vQEgwz6P3GFkELq7G3Qop4YFrdK5/2scBjNHf65qmI44Kspl+HIrUpcQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dw3-20020a05613028c300b007d8f1f85d4asi728413uab.92.2024.02.14.08.37.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:37:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65556-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=QqaH5u+X; arc=pass (i=1 spf=pass spfdomain=xen0n.name dkim=pass dkdomain=xen0n.name); spf=pass (google.com: domain of linux-kernel+bounces-65556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65556-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 144AF1C20F46 for <ouuuleilei@gmail.com>; Wed, 14 Feb 2024 16:37:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87715651BC; Wed, 14 Feb 2024 16:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b="QqaH5u+X" 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 5014D612E3; Wed, 14 Feb 2024 16:34:04 +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=1707928447; cv=none; b=FDjyjZ5IOO10Qa0E0cWjHwmhG319D+2A/ZdUhBNCr2Lm7R9sTvtnI/a42Q3It5rj+qzn68Nta6hetFScH3nwPd8ZowrosaqXiy7BMxB0YFwPB5pWM+XSzOW0Ex/kILeLYzzaMx94mL+3nj3MSFK4QqokOuXN18iG1wcQvjexDgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707928447; c=relaxed/simple; bh=1XKtHdaBogGBmhevzOA+1J0TfVkkoFlByHGLSLFpVbk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rL9KHAyKyYtLx6o/17cuxJj+VKg79RUCYvz0VlR05989+S5boXKPa8SQgM7GGZtMNxxgYkY7m+TQhapVzFrxEqwLn6Q5vsVvae2PEQ856O7+HT6sM8ughFCKaKdZIPss5kik9WVpJdb187mQNiVMNIT/utt/5dcI7phmJXAxEZE= 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=QqaH5u+X; 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=1707928440; bh=1XKtHdaBogGBmhevzOA+1J0TfVkkoFlByHGLSLFpVbk=; h=From:To:Cc:Subject:Date:From; b=QqaH5u+Xo/W9IJRaaHTp6Ju4nqebG3xvKSTIwxz831cpCmcUQVG91DIGbxk3Zm8Iv nh+RTfX8v1mqXpodNLsMwpHBRpXl4+vgEpG68T45ufcRD/DkSQverm2FYO6dZP461a 7QKm9YZerI3YHGQ2zuB9GGe9jjUI87GKlhr1EY1U= Received: from ld50.lan (unknown [IPv6:240e:388:8d00:6500:42e8:c06f:a0dc:12f8]) (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 ABC0B60114; Thu, 15 Feb 2024 00:33:59 +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 v2 0/4] KVM: LoongArch: Fix wrong CPUCFG ID handling Date: Thu, 15 Feb 2024 00:33:53 +0800 Message-ID: <20240214163358.2913090-1-kernel@xen0n.name> X-Mailer: git-send-email 2.43.0 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: 1790870194464462907 X-GMAIL-MSGID: 1790893020975892343 |
Series |
KVM: LoongArch: Fix wrong CPUCFG ID handling
|
|
Message
WANG Xuerui
Feb. 14, 2024, 4:33 p.m. UTC
From: WANG Xuerui <git@xen0n.name>
Hi,
While trying to add loongarch to the Rust kvm-bindings crate, I
accidentally discovered faulty logic in the handling of CPUCFG IDs
("leaves" for those more familiar with x86), that could result in
incorrectly accepting every possible int for the ID; fortunately it is
6.8 material that hasn't seen a release yet, so a fix is possible.
The first two patches contain the fix, while the rest are general
drive-by refactoring and comment cleanups.
(As it is currently the Chinese holiday season, it is probably best for
this series to go through the kvm tree, instead of the loongarch one
even though they seem to like prefer collecting every loongarch patch.)
v2 changes:
- Squashed the v1 patches 4 and 5 according to Huacai's review
- Reworded comments according to Huacai's suggestion
- Use WARN_ON_ONCE (instead of BUG) to replace unreachable() for not
crashing the kernel (per checkpatch.pl suggestion)
WANG Xuerui (4):
KVM: LoongArch: Fix input value checking of _kvm_get_cpucfg
KVM: LoongArch: Fix kvm_check_cpucfg incorrectly accepting bad CPUCFG
IDs
KVM: LoongArch: Rename _kvm_get_cpucfg to _kvm_get_cpucfg_mask
KVM: LoongArch: Streamline kvm_check_cpucfg and improve comments
arch/loongarch/kvm/vcpu.c | 68 ++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 41 deletions(-)