Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4582090pxj; Wed, 12 May 2021 08:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Xaepgb/d+tAb3hUok+ILd0KyTu5ItAv3E6JDwMDY7DV7RgWxcPqOXjfqWe+RlCAFY6yp X-Received: by 2002:a17:906:9141:: with SMTP id y1mr39935867ejw.111.1620833902166; Wed, 12 May 2021 08:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620833902; cv=none; d=google.com; s=arc-20160816; b=h3McFYKpTw0aVgnMGsMs312V3ukopaR0AMRgiZM8lUpiNT8bnWhQSZGmYEYQjGoBiv XILMGArut82rULjUTuXvvI/aw8lh3uLlXgjRnMRMJxPNDPOoS6tkN6yI5pk+CNXQDbQ0 5yRKw81y/1JqIpKmvEKECxR/OiJ/uy2UtctI2O8UI9kflGWeGAx2bpDiVtHC4fs54SXX AR1T5GeIG8dMTvFthT5LfTFR0/n/xdnHy1IUgh8ajhEyydwGvPNGJ54RGbhKV2ey4aff BDSfsIw4JV6F80qsOpoPbmSbnrhUxRB+t5oS1BsFcKGvlWuHc89i6XZ45Jdmko9IyHj7 2oEw== 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=PQbFpfE1Bovf2CnRwKQu9c4BXzmdXNzJiS448PcL5LY=; b=a//zZy3aAIww+POi2mPNWjU3M8Ufg2w9afxaVG1okpwxfdBx49FrwYcxq4nFFanJ4z 5fBfqE2ZLUsOOh1ISZhOgtrJgFOr34wboNz2Ym2AuhXIACg/sFsFol5MkC0dICHmJa3p BUGib6v1KiVRXOK9oom0TdOSpJDh02jChjIl46WIiUZmKyunArqGA3xQB/frOVsv8exf mnT9QMkJqIkUPFJwX05SF+O9fbj0AjWtyP0SEypYvbAXFMV46UyBa1pEp+4nKQrZIDbT BQQiFKXXOjVo9FSnfanAVMj+XujdAWGeuW7vAu53S72rU902NOY1tig5l/iIKU25tnsv RPPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aZ8rLyfR; 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 um1si134616ejb.327.2021.05.12.08.37.57; Wed, 12 May 2021 08:38:22 -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=aZ8rLyfR; 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 S235916AbhELPgJ (ORCPT + 99 others); Wed, 12 May 2021 11:36:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:50640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234256AbhELPQT (ORCPT ); Wed, 12 May 2021 11:16:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 957E161976; Wed, 12 May 2021 15:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831963; bh=DWseEqO+pcKPkjlPYTvqcq7OwtIBR67zRVCyoCpKeFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZ8rLyfRCVVPebLi/v+ChXzbvOAcoWSX+IQ4snY2aAie2/w8wpt/Ipqc0aZ5/67jy WSTi5qcRPspV90z04szkSU4jQfN+H6doTQXQSxTAB+pQOjI2LMjtOFdvDNDZOuQQ0+ 7npOTbMtZClJAtVmES3CvvThlj5pnymCPMM3KT+Y= 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 5.10 086/530] KVM: s390: fix guarded storage control register handling Date: Wed, 12 May 2021 16:43:16 +0200 Message-Id: <20210512144822.603518735@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 @@ -4308,16 +4308,16 @@ static void store_regs_fmt2(struct kvm_v kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC; kvm_run->s.regs.diag318 = vcpu->arch.diag318_info.val; 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(); } /* SIE will save etoken directly into SDNX and therefore kvm_run */ }