Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp264256imm; Wed, 18 Jul 2018 01:34:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeKqfC/Xje/5Og0N0o+WwhO7ufiIZDqmST1MQlaYbOWXmqx+HKTqyCR4zq+bfHvouh2y8Uv X-Received: by 2002:a63:da04:: with SMTP id c4-v6mr4680196pgh.398.1531902856591; Wed, 18 Jul 2018 01:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531902856; cv=none; d=google.com; s=arc-20160816; b=ztN5Xu+KB+py8m9UMT0U9m9jMOtmZDaHxZ5jGV5eqTctxBN0OQ4YwQUvG4VQxgS1jg hRTUXAWxovuKFw5E8lMiK2anMm7ucBheMjJ1P96LrW11w2VOlIb/4TOI0yvV5zwd4aWx hjU7Qv5/+3k85EYsUfbs+nFx5K4C4cSACtbG1fYovsSdzW4ma1WNQEwucD4Z6aHWVYpJ gQrq2dGulAy3LT/XySSGcKnOYVmODo/uG9WBX917zqK79AI25mU6hScHeL/ML4zHyenZ wd/wp7NG9VjP0h3w+NA5hir/PoHYFYzdzf5H1iE6NkmgfAh1F3KxXyk7KcfR1+Hd34lo 5XMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=IikH5VL091J/r07qxBEMlmG17OEE/aLTFOSmFwgbb6c=; b=td4nL0ILPeB/KCJYQzFNARPChEzkUrSfSXnn1bS1wOUjQJteR8lO0nblKSw0rRYvp3 /6iGz4FXR95xAkSeOas/CcqXZnslwKwZ2xrBg7gaeiV0P0CYzuc5Uugnyv2PcWSBUbdm pJIjR5lnysbJuhMByDep1QcYiTaaZERLbnFKnFGYdL3XbesYjrrfJK8TMu2WfsU9G3Ln SJs+wBYNbGQnh2wcPnafEAwlA/zZBDOw/0E811k/BA6hecT/XUCS9+y1Jmch7r3Ew2IM 3sZopJhcqU+nc2g1DrMx87sWuyRtAbrgC1POVsSMefoaaP24vtmcIlPqCWjJ/p+oEim3 jX6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f24-v6si2934059pgh.287.2018.07.18.01.34.00; Wed, 18 Jul 2018 01:34:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730093AbeGRJKM (ORCPT + 99 others); Wed, 18 Jul 2018 05:10:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52326 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729209AbeGRJKM (ORCPT ); Wed, 18 Jul 2018 05:10:12 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6I8U9Tv139871 for ; Wed, 18 Jul 2018 04:33:25 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ka0aq4a9e-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 Jul 2018 04:33:24 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2018 04:33:23 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 18 Jul 2018 04:33:20 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6I8XJkl9568564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Jul 2018 08:33:19 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44273AC060; Wed, 18 Jul 2018 04:34:10 -0400 (EDT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 030DCAC066; Wed, 18 Jul 2018 04:34:09 -0400 (EDT) Received: from sofia.ibm.com (unknown [9.124.35.39]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 18 Jul 2018 04:34:09 -0400 (EDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 6EF952E2F57; Wed, 18 Jul 2018 14:03:17 +0530 (IST) From: "Gautham R. Shenoy" To: Michael Ellerman , Benjamin Herrenschmidt , Michael Neuling , Vaidyanathan Srinivasan Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Florian Weimer , "Gautham R. Shenoy" , , Oleg Nesterov Subject: [PATCH v2] powerpc/powernv : Save/Restore SPRG3 on entry/exit from stop. Date: Wed, 18 Jul 2018 14:03:16 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 18071808-0068-0000-0000-00000319F33B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009385; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01062485; UDB=6.00545522; IPR=6.00840342; MB=3.00022184; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-18 08:33:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071808-0069-0000-0000-00004512AFCC Message-Id: <1531902796-32294-1-git-send-email-ego@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-18_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807180098 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" On 64-bit servers, SPRN_SPRG3 and its userspace read-only mirror SPRN_USPRG3 are used as userspace VDSO write and read registers respectively. SPRN_SPRG3 is lost when we enter stop4 and above, and is currently not restored. As a result, any read from SPRN_USPRG3 returns zero on an exit from stop4 and above. Thus in this situation, on POWER9, any call from sched_getcpu() always returns zero, as on powerpc, we call __kernel_getcpu() which relies upon SPRN_USPRG3 to report the CPU and NUMA node information. Fix this by restoring SPRN_SPRG3 on wake up from a deep stop state with the sprg_vdso value that is cached in PACA. Fixes: e1c1cfed5432 ("powerpc/powernv: Save/Restore additional SPRs for stop4 cpuidle") Reported-by: Florian Weimer Cc: # 4.14 Cc: Oleg Nesterov Cc: Michael Neuling Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Vaidyanathan Srinivasan Signed-off-by: Gautham R. Shenoy --- Change from v1: Restoring the SPRG3 from paca->sprg_vdso instead of saving it separately during stop-entry, as suggested by Mikey. arch/powerpc/kernel/idle_book3s.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index d85d551..672ead8 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -144,7 +144,9 @@ power9_restore_additional_sprs: mtspr SPRN_MMCR1, r4 ld r3, STOP_MMCR2(r13) + ld r4, PACA_SPRG_VDSO(r13) mtspr SPRN_MMCR2, r3 + mtspr SPRN_SPRG3, r4 blr /* -- 1.8.3.1