Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp181620rdb; Mon, 15 Jan 2024 17:32:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHV2+uS6NXZf13VNcWb2NU9bKkWZRG4jYQLEozM0BQPNVzHI4HwCoaRY8nLddAKOkeKK62X X-Received: by 2002:a05:600c:4505:b0:40e:5534:f6fb with SMTP id t5-20020a05600c450500b0040e5534f6fbmr3706961wmo.165.1705368751930; Mon, 15 Jan 2024 17:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705368751; cv=none; d=google.com; s=arc-20160816; b=iJYLsh3YPfIxHvgLdGIO0iPby3i1KjzaNjxXd6Ep0Xh77ol0XJsLuwFDlaFwSEQx7C Sfrh+uW/BxzwVpoGAv2fZJeKdNDIThJ5RXNTQZTEto9R3+PflM31RdohjouacHxemyee M6CBBXB2nmHrna7oqZquQI1R5B1PH3AM8zz1XQbE5iSXJZahEu+AaendEU9WVhW40MRI K+sKGadxysqI9/SYOr/99P0C1HGeapdyTrHVv+IARgO/lsWx+NqQbQTaCWc+EO0mWSAm uqeiSnCknH+Z4aRtplBBn8j9wc+/nRi6t4BPBAHIvSy1Ycb2XWDmbHHtOd6TsCLbuka2 PLlQ== ARC-Message-Signature: i=1; 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=UaAmrMx+B3E87kMiX/lpatv0nOTDBv0pSwPRJjsHAo4=; fh=gIUsPCw9I9wFR7xqxcaz/kvqJnl49o54RCDwNS0JmtU=; b=wc73xhlcjSwVcgKGqKyA08Ol6aj2G1pc/KyNjhTFzMQYbRnFu2+D4buhtjfGrjZ+Fa IDtKdfy8HgOAVqScxIsZRNuRZqTjVz1zlX6tXtQFuT1A+fwExittc/NgYkgbX38f++hv odWNSMkRiQR5XHUoS8PG2jQM8pyEAy8ApU4MRz2axNIrKnaKdbXk4ANrFuG/NPUQ37GQ mELUQlim5j2FhNys3dDqtUuRSctDBAP0G0R5x2bBf95fWO3K/FBMUgGSkUo3q9CAVbeK 5Kt5lnsrc0NG0zPHjkG3eWjKjb6V5Plm6O8sUoN0VJ0Zh0UdfywCtGsKusME5ClUXxiX kzDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ruCdxsOm; spf=pass (google.com: domain of linux-kernel+bounces-26855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i26-20020a170906251a00b00a2af3048ed1si4283127ejb.873.2024.01.15.17.32.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:32:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ruCdxsOm; spf=pass (google.com: domain of linux-kernel+bounces-26855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9835E1F22A2A for ; Tue, 16 Jan 2024 01:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C4A2241E5; Tue, 16 Jan 2024 01:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ruCdxsOm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BA44923766; Tue, 16 Jan 2024 01:06:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DF16C433C7; Tue, 16 Jan 2024 01:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705367214; bh=1X36pu2JGU5z8vu7uIKJfvyzEz2m8BR2szbRkIw2RwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ruCdxsOm+fyIAGfYyC5vJ+bZofuobPim+Q3gIvM/3I0T2W0s33cLSxqjJ0hG2nZri +6yfLVZ0IzBfcM4HgwLkQuTEEdZenhmMO4gh4SmUT0+kuEn+iNuSUCmsCHFAIrxhjO fkecYdipZa057CZ5QSOmS/gwSICuc6HmA4tpUCnu0hjaFfrIOLSZLlVjSA/Ql6f10f JJ+l7IE7CXY/Vedfmlu8jyJwTqCPo7CwT0Saiet9o3VtJEHAl0TWil+ttLpNDMc7Ds 2Lbhttr9PXz+30JIC1z/7PsW2uMGrzbPjBe5RWSxz24sHz6ynGG3JUsQlocH/wAgGK gTI9UgLaGbykA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Sasha Levin , frankja@linux.ibm.com, gor@linux.ibm.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 05/14] KVM: s390: fix setting of fpc register Date: Mon, 15 Jan 2024 20:06:07 -0500 Message-ID: <20240116010642.218876-5-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116010642.218876-1-sashal@kernel.org> References: <20240116010642.218876-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.73 Content-Transfer-Encoding: 8bit From: Heiko Carstens [ Upstream commit b988b1bb0053c0dcd26187d29ef07566a565cf55 ] kvm_arch_vcpu_ioctl_set_fpu() allows to set the floating point control (fpc) register of a guest cpu. The new value is tested for validity by temporarily loading it into the fpc register. This may lead to corruption of the fpc register of the host process: if an interrupt happens while the value is temporarily loaded into the fpc register, and within interrupt context floating point or vector registers are used, the current fp/vx registers are saved with save_fpu_regs() assuming they belong to user space and will be loaded into fp/vx registers when returning to user space. test_fp_ctl() restores the original user space / host process fpc register value, however it will be discarded, when returning to user space. In result the host process will incorrectly continue to run with the value that was supposed to be used for a guest cpu. Fix this by simply removing the test. There is another test right before the SIE context is entered which will handles invalid values. This results in a change of behaviour: invalid values will now be accepted instead of that the ioctl fails with -EINVAL. This seems to be acceptable, given that this interface is most likely not used anymore, and this is in addition the same behaviour implemented with the memory mapped interface (replace invalid values with zero) - see sync_regs() in kvm-s390.c. Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Heiko Carstens Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- arch/s390/kvm/kvm-s390.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 3775363471f0..f604946ab2c8 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -4138,10 +4138,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) vcpu_load(vcpu); - if (test_fp_ctl(fpu->fpc)) { - ret = -EINVAL; - goto out; - } vcpu->run->s.regs.fpc = fpu->fpc; if (MACHINE_HAS_VX) convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs, @@ -4149,7 +4145,6 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) else memcpy(vcpu->run->s.regs.fprs, &fpu->fprs, sizeof(fpu->fprs)); -out: vcpu_put(vcpu); return ret; } -- 2.43.0