Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3850016pxv; Mon, 19 Jul 2021 10:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3eGZHa5iPCvHM582LItd3cwOAFQB0mf1H3p3rY9HJJYZLwYAVmpQWp8WQ7Vpx5XCJgX8 X-Received: by 2002:a17:906:a0ce:: with SMTP id bh14mr27457240ejb.434.1626714777641; Mon, 19 Jul 2021 10:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626714777; cv=none; d=google.com; s=arc-20160816; b=HKZzrIFxjbKs0mv6VKhoscOo+o+H0t3u3ODrRcKTwUiC85lGgtrDvmP1XGE6eQBnX6 lFwiil+YpobGf1FVkC2B0eN9bx6VBETemcdWqGORfhjEv9ixiHeMVCm0+iuF4J9lUshf MzBAmZ7x30EClmrqh2o2rp7QuH4lTXVjo/Wcf5ChZZmGUkkcMJWC+gA3do0mJLZR7TIt VUShqtTwY3rFy4rX9e4pE1cgX1q2HG7Av6+ACUUId/SIDbPAmwWUKwNyVd3+jQ7ZiX2/ izW0b+dAHLPJCDlGqUoohnEBXaid+nIYjakxK2wmAF0arSgFsiLlHNbLp+mBkbfMzRue 7XfQ== 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=xBhsfBTkIb6dghZO64g9TeI2WTAbhlX5CsCv7CAjLi8=; b=Vw7jqenDVVhOrfhJOTlIvkIUSHgj62YKh/f2SdOhFTU7VgrQJSUFmxXfuPkOeP5d8g xsG3LnmySPRYdQI1xmVs2PhgFfJLZ+WDvBA8eAa9g6IrJIfT9fLRRB+V24ItQnOUjxj2 pA8W+BWEU/rPHwTrUKnd2l7t8VdLmF5AdQwwlO94PRDyun9fctMmLqDsllmRmj8ab372 5hAxOTDLno+5BWMpKDEmMVewjWKtsi1ivTNt30oqY0nmc7qQlP8DSkLRgyi7ATUKYxlx ny75GyjC0Tun6D/80BupMXS91afw9apmBe1jYQz1G/WEkJjIPA5aVRhYUDFcJj3RCkD+ Y6Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Agsfnxl1; 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 a20si6632031ejg.350.2021.07.19.10.12.35; Mon, 19 Jul 2021 10:12:57 -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=Agsfnxl1; 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 S1348149AbhGSQ1W (ORCPT + 99 others); Mon, 19 Jul 2021 12:27:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346613AbhGSPO5 (ORCPT ); Mon, 19 Jul 2021 11:14:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0175060FED; Mon, 19 Jul 2021 15:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710129; bh=UtV+5Mfb4ddK6eXEUtXr8DMtasuEylQWx52zy2Y8cig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Agsfnxl1vnEWRustp6qVuW7MM2K8U2Sl+XGjeDi9IA7ffwlD+vpdOIww51Lf/z3Nz lGGHqNAjo2TIHxEKnsLQnRwyvZnEREHD9eN6tbFPT0D738yt4MZc/dCdZt/txin2hu +SrQt+j4WQgU0/YAM8sWlECgOuIP3nM3ItC1hdUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.10 089/243] s390/mem_detect: fix diag260() program check new psw handling Date: Mon, 19 Jul 2021 16:51:58 +0200 Message-Id: <20210719144943.768594986@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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 [ Upstream commit 86807f348f418a84970eebb8f9912a7eea16b497 ] The __diag260() inline asm temporarily changes the program check new psw to redirect a potential program check on the diag instruction. Restoring of the program check new psw is done in C code behind the inline asm. This can be problematic, especially if the function is inlined, since the compiler can reorder instructions in such a way that a different instruction, which may result in a program check, might be executed before the program check new psw has been restored. To avoid such a scenario move restoring into the inline asm. For consistency reasons move also saving of the original program check new psw into the inline asm. Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/boot/mem_detect.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/s390/boot/mem_detect.c b/arch/s390/boot/mem_detect.c index 62e7c13ce85c..032d68165216 100644 --- a/arch/s390/boot/mem_detect.c +++ b/arch/s390/boot/mem_detect.c @@ -70,24 +70,27 @@ static int __diag260(unsigned long rx1, unsigned long rx2) register unsigned long _ry asm("4") = 0x10; /* storage configuration */ int rc = -1; /* fail */ unsigned long reg1, reg2; - psw_t old = S390_lowcore.program_new_psw; + psw_t old; asm volatile( + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n" " epsw %0,%1\n" - " st %0,%[psw_pgm]\n" - " st %1,%[psw_pgm]+4\n" + " st %0,0(%[psw_pgm])\n" + " st %1,4(%[psw_pgm])\n" " larl %0,1f\n" - " stg %0,%[psw_pgm]+8\n" + " stg %0,8(%[psw_pgm])\n" " diag %[rx],%[ry],0x260\n" " ipm %[rc]\n" " srl %[rc],28\n" - "1:\n" + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n" : "=&d" (reg1), "=&a" (reg2), - [psw_pgm] "=Q" (S390_lowcore.program_new_psw), + "+Q" (S390_lowcore.program_new_psw), + "=Q" (old), [rc] "+&d" (rc), [ry] "+d" (_ry) - : [rx] "d" (_rx1), "d" (_rx2) + : [rx] "d" (_rx1), "d" (_rx2), + [psw_old] "a" (&old), + [psw_pgm] "a" (&S390_lowcore.program_new_psw) : "cc", "memory"); - S390_lowcore.program_new_psw = old; return rc == 0 ? _ry : -1; } -- 2.30.2