Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp415908pxj; Thu, 20 May 2021 12:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3D4V1IpZ/2zUJ1T1fxp9HEwktyygb2rxJwI9H02PhEtKors5jCO1mUt8i2eMk6pVYQztb X-Received: by 2002:a05:6402:270c:: with SMTP id y12mr2088559edd.249.1621538275494; Thu, 20 May 2021 12:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538275; cv=none; d=google.com; s=arc-20160816; b=qBQplVkX4q/5spfwweVYaacgNPN4ha47eW36+4wQhUP6AKgoot5AwD6zSnda2UEJJ/ z7YkIptuiBwe8pHqJHPnKtumEjVHT+kqXGzEnck9JSWCzty+gQrZ2LrzYcdrtrCcoVU9 AnTl7zNshPajsF4D9vi7fGvJNDQZft3+3sr9Op2dyUWKOBFBDnqHvyAenqhAkGPU6zJt t6YfEIpni5q3KNkOfKR7b+NiN91dBg7nZFJAeRp5FRx1NezTcM1qkKZC24rDX+yS+0BE DMksbnlkN2nF7hIbyBowREhZaABe5s5FRx1SAMeqaIavMJRe0gNSp3tgtpfz4vXwYOj8 9Ntg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/s/9w967Up2u8/pROO29ZnyNXcoiv53R48Y2/I4hh9I=; b=IvCztdCaWaV1XlVqgXLTzjPpnU6FFDl0wRz3WoxNAzBCiLbXERE3sqgO9GE1Zd4XtR Jx+phqEr0bpUJN6jVYl5djcXW5qRs2JnLkN40VRkQ08xVztAWWhKpl2XVefK7prhcUJH sTzhtz5ZTw/PxUCF+ivLa5k8CA/8OUqKAH0WLSZ9zTM+e+snmAKyP3dLlAVV7C/Xn3Eh 2KZWTLuvEUg5qYdErEujZK/IkSt+SBU7C/kqzxUxY+6X+dmXHY/obAl/GVuwEMBhco+E A7V1bpPKOZu7cyGVb6C0tQTVAl5pcpMFkhttCrYlm8BtD/A2j5vV2VyspUz1bABBIHfc bhdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qO8sGcht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si3399890edq.499.2021.05.20.12.17.31; Thu, 20 May 2021 12:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qO8sGcht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237955AbhETKoL (ORCPT + 99 others); Thu, 20 May 2021 06:44:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:55508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236659AbhETK3A (ORCPT ); Thu, 20 May 2021 06:29:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17F0261C2E; Thu, 20 May 2021 09:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504270; bh=ONUvG69htUK3IfTeZ8iBDJdzdN4TErSqN6rWACDy5b8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qO8sGchtj0UDLxcraSwL91ZiGXzt42Q6e44QNLJUFwJB66nyC9OQbjrWyUDsi1mzG 9XUtrnh0wjbs8qJSKIjOZtbCXrw/d6u/fdmtms4Ah+EhEN33vHXGynqMfnMOzXHHnv B+qIk+UaXjVrIdilRmiowpRKl5ZlurzvEYl7W2zg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Christian Borntraeger , David Hildenbrand , Janosch Frank , Cornelia Huck Subject: [PATCH 4.14 135/323] KVM: s390: fix guarded storage control register handling Date: Thu, 20 May 2021 11:20:27 +0200 Message-Id: <20210520092124.743840407@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Carstens commit 44bada28219031f9e8e86b84460606efa57b871e upstream. store_regs_fmt2() has an ordering problem: first the guarded storage facility is enabled on the local cpu, then preemption disabled, and then the STGSC (store guarded storage controls) instruction is executed. If the process gets scheduled away between enabling the guarded storage facility and before preemption is disabled, this might lead to a special operation exception and therefore kernel crash as soon as the process is scheduled back and the STGSC instruction is executed. Fixes: 4e0b1ab72b8a ("KVM: s390: gs support for kvm guests") Signed-off-by: Heiko Carstens Reviewed-by: Christian Borntraeger Reviewed-by: David Hildenbrand Reviewed-by: Janosch Frank Reviewed-by: Cornelia Huck Cc: # 4.12 Link: https://lore.kernel.org/r/20210415080127.1061275-1-hca@linux.ibm.com Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/kvm-s390.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -3395,16 +3395,16 @@ static void store_regs(struct kvm_vcpu * current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; if (MACHINE_HAS_GS) { + preempt_disable(); __ctl_set_bit(2, 4); if (vcpu->arch.gs_enabled) save_gs_cb(current->thread.gs_cb); - preempt_disable(); current->thread.gs_cb = vcpu->arch.host_gscb; restore_gs_cb(vcpu->arch.host_gscb); - preempt_enable(); if (!vcpu->arch.host_gscb) __ctl_clear_bit(2, 4); vcpu->arch.host_gscb = NULL; + preempt_enable(); } }