Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp7196996imm; Sun, 20 May 2018 21:23:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp0k3Mgh8bh09PXueqLG3zHTBCRu3YFvBZqBc/+OqWhN0FrtjucD7vX1IzDFAmCLwoDOAsh X-Received: by 2002:a62:3085:: with SMTP id w127-v6mr18531622pfw.224.1526876586117; Sun, 20 May 2018 21:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526876586; cv=none; d=google.com; s=arc-20160816; b=Xq9IVvtuq7PaiTC87JMJFtvBBfgExoj0kO5D6oAJiWf8QikVwUfcNihRzIXmH3uaIj wLlEQnAL6AEDuRm2MhiXXP8hG+KhIuKIb1LhreoMWVV8ZI9QubTFnYYPp45LMm4kaQ0O KoIL0dwyuvTCccmBsHYzQT2duEmMBcO6VUolJRMx/XmIAm5hK6EeCVmMG0WnlSADd1MS WpgWak2BtK2X8qICyAN/ZdvERcOgYBG3qw3nzx+AijGuZ0iSn8GiycrD9CW4/J7rY+Mf 5IjtsS5kBU3DFBi6CxylWmG+2L9OgizVDZ9bURRNwlb72TcI5P0rBTCUBjmdIEQFs8eb SqVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=JCBMK31Bzr5U7uI1YwPI6OaHOeNWRuEA3jeMMRWoBGM=; b=j2KWdeV0NNpJBYI/P+Vwa83YIglgLHDmM8EQ12K9Ft24UMSolH41rIAbmGWQkkSsKC aE4bFfhsQF+2xjQgw6aVe85Qvm3FgEh3lHx+Y5eEi0aEcyAygEp39ziD8u4BX+BQ+Zk5 SYyZHwmtVNbOAeqiajdnBcbSzVPOWChliABjsaRSfOEdQ+HpvUmxT4S2FBKiPvHCR/yn V6J/xRjFz4lQP2GLl9iYwfJjNwva1ljqEXxEHO3sX8TMUo+vvFR/iaMTZfln+bDqVqaG eJRnhN3kHhCi5EEjI4qt1YiybU+bD+xtMO7exhRKd9Kv+Tl9XC/HYLovmDztQvECAB0n HOMA== 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 z5-v6si12724570pln.562.2018.05.20.21.22.51; Sun, 20 May 2018 21:23:06 -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 S1751148AbeEUEVz (ORCPT + 99 others); Mon, 21 May 2018 00:21:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60644 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751050AbeEUEVb (ORCPT ); Mon, 21 May 2018 00:21:31 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4L4J92K117997 for ; Mon, 21 May 2018 00:21:31 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j3jtf7uc0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 May 2018 00:21:30 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 May 2018 05:21:29 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 May 2018 05:21:24 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4L4LNmL6816032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 May 2018 04:21:23 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD841AE04D; Mon, 21 May 2018 05:10:38 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60F65AE045; Mon, 21 May 2018 05:10:36 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.109.219.149]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 21 May 2018 05:10:36 +0100 (BST) From: Ravi Bangoria To: mpe@ellerman.id.au, mikey@neuling.org Cc: benh@kernel.crashing.org, paulus@samba.org, naveen.n.rao@linux.vnet.ibm.com, matthew.brown.dev@gmail.com, cyrilbur@gmail.com, anton@samba.org, sandipan@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Ravi Bangoria Subject: [PATCH 2/3] powerpc/sstep: Fix kernel crash if VSX is not present Date: Mon, 21 May 2018 09:51:07 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180521042108.8318-1-ravi.bangoria@linux.ibm.com> References: <20180521042108.8318-1-ravi.bangoria@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052104-0008-0000-0000-000004F8A56F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052104-0009-0000-0000-00001E8D2B40 Message-Id: <20180521042108.8318-3-ravi.bangoria@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-21_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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805210051 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org emulate_step() is not checking runtime VSX feature flag before emulating an instruction. This is causing kernel crash when kernel is compiled with CONFIG_VSX=y but running on a machine where VSX is not supported or disabled. Ex, while running emulate_step tests on P6 machine: Oops: Exception in kernel mode, sig: 4 [#1] NIP [c000000000095c24] .load_vsrn+0x28/0x54 LR [c000000000094bdc] .emulate_loadstore+0x167c/0x17b0 Call Trace: 0x40fe240c7ae147ae (unreliable) .emulate_loadstore+0x167c/0x17b0 .emulate_step+0x25c/0x5bc .test_lxvd2x_stxvd2x+0x64/0x154 .test_emulate_step+0x38/0x4c .do_one_initcall+0x5c/0x2c0 .kernel_init_freeable+0x314/0x4cc .kernel_init+0x24/0x160 .ret_from_kernel_thread+0x58/0xb4 With fix: emulate_step_test: lxvd2x : FAIL emulate_step_test: stxvd2x : FAIL Fixes: https://github.com/linuxppc/linux/issues/148 Reported-by: Michael Ellerman Signed-off-by: Ravi Bangoria --- arch/powerpc/lib/sstep.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index db6bba259d91..23b7ddf04521 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c @@ -2544,6 +2544,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs, #endif /* __powerpc64__ */ } + +#ifdef CONFIG_VSX + if ((GETTYPE(op->type) == LOAD_VSX || + GETTYPE(op->type) == STORE_VSX) && + !cpu_has_feature(CPU_FTR_VSX)) { + return -1; + } +#endif /* CONFIG_VSX */ + return 0; logical_done: -- 2.16.2