Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2233590pxb; Fri, 17 Sep 2021 05:29:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfSQc1e6OmMCvh5VoscBKJsG3J2U/nP7x+oDMt7rtAhHgJ4x7VIzE1laBZs8pS97tEa/51 X-Received: by 2002:a5d:8b17:: with SMTP id k23mr8499551ion.17.1631881790022; Fri, 17 Sep 2021 05:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631881790; cv=none; d=google.com; s=arc-20160816; b=rGDuXV5h66Bgfp1pTIfgQSIR08GGB3gqI4b/t7MEI0YeZDqsrlt/sPyHtQlhCXSIKz WBbKnmY52DooVJlqYTl9gch06LHEpDlGj6OPUzo8w/qKeQxpVqYU2NzFqOvyjCi/eC9n LNszvHA6S+VYdKmdkMuEW+0djU8gd8EA1Swi8GI4Dn0SkgO/Jk0ljXIuZcPodS2tOsIJ MarLFRQPAygKmSK13ATVrEJbLAuvb3NLuVQ8hxkyBo6XXYAgH0ZTyJJEaBmwJlXadHWK Ikk45oeQUByGbO/uHACvS1T13pa9cbY1U9RV1i+afUUpz4qSljXsfG2CUsswGMVUABrB lexA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=zO/MbLVO6QOgI8EyKpxsFOAPtegRjN5v7YLVResRUAw=; b=QcnExEOnEKCpo0EzK09HfqZUY7yixLwCSmmKep9B1/Uiy1G9zuxmaBjMPYQ2ZSpwmy Aez1LEKYWHFaAV3T9aNAfo4MFVvGKAo7eaJt6jwzV58vKCC+WEJth4nf27Ow6DyFes7k JFHxwZUeOz8/+w5g0bQ98sOY3RUMDs5Xfo151TIiNg3lV1xAq4CfUs3LOw4sP1AO3A8Z LGzl0sOUp2kmrnA9H4/gP7lT07+Lb/6RzNdwaNsBYfUCzP0JcpPmXa8gkqCHP/Baz9m6 Bfn1K9ksFl2g/ghWMYj4xTj8WrbzgxmRs8W3hYvsHeGLSqYB3CruW2N6l1NGZsC6Nruc Eu1g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si5187709ilr.112.2021.09.17.05.29.37; Fri, 17 Sep 2021 05:29:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241742AbhIQF7o (ORCPT + 99 others); Fri, 17 Sep 2021 01:59:44 -0400 Received: from foss.arm.com ([217.140.110.172]:48300 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbhIQF7o (ORCPT ); Fri, 17 Sep 2021 01:59:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 738F331B; Thu, 16 Sep 2021 22:58:22 -0700 (PDT) Received: from a077416.arm.com (unknown [10.163.42.222]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 595343F5A1; Thu, 16 Sep 2021 22:58:19 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Mark Rutland , Vincenzo Frascino , Kevin Brodsky , Amit Daniel Kachhap , Catalin Marinas , Will Deacon Subject: [PATCH v2] arm64/traps: Avoid unnecessary kernel/user pointer conversion Date: Fri, 17 Sep 2021 11:28:11 +0530 Message-Id: <20210917055811.22341-1-amit.kachhap@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Annotating a pointer from kernel to __user and then back again requires an extra __force annotation to silent sparse warning. In call_undef_hook() this unnecessary complexity can be avoided by modifying the intermediate user pointer to unsigned long. This way there is no inter-changeable use of user and kernel pointers and the code is consistent. Note: This patch adds no functional changes to code. Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Amit Daniel Kachhap --- Changes from v1: * Instead of directly using instruction_pointer() for kernel pointers, modified the pc type from void __user * to unsigned long as suggested by Mark Rutland. arch/arm64/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index b03e383d944a..09236751283e 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -400,11 +400,11 @@ static int call_undef_hook(struct pt_regs *regs) unsigned long flags; u32 instr; int (*fn)(struct pt_regs *regs, u32 instr) = NULL; - void __user *pc = (void __user *)instruction_pointer(regs); + unsigned long pc = instruction_pointer(regs); if (!user_mode(regs)) { __le32 instr_le; - if (get_kernel_nofault(instr_le, (__force __le32 *)pc)) + if (get_kernel_nofault(instr_le, (__le32 *)pc)) goto exit; instr = le32_to_cpu(instr_le); } else if (compat_thumb_mode(regs)) { -- 2.17.1