Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2253406yba; Fri, 17 May 2019 13:25:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAh/6dpb75iCUPVD3Oqu9nOA6UaV9zUP+N9q1xS74qvAa8Y3NMQRaTcR6bFtDloXh/yz9s X-Received: by 2002:a63:c64a:: with SMTP id x10mr58934556pgg.195.1558124743741; Fri, 17 May 2019 13:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558124743; cv=none; d=google.com; s=arc-20160816; b=HnYsh6s0fP2WCCX3deYGrwiiKZlU5sqUCWr75Fqh1vg2IP4iTAJ67XfUy0yh5FepTQ 7B0gFPdDix+gMcIDZDpjBE7WXMdMMcvrZ4LfSISiyK2vy1cjFVXAX+zb6tWs6wTfcZHb DX94+Yd0VVjNyKn9hsyJ1iY/exTpBxe/oW1wPO1kzxo7KnOqVAO/w9wCx/S0h4+VmaA3 rgW1+MqFJW1TtC242W/n8AJwarfKH8IGvEwoTNxwBV/JSDB67/CCplhtgOuPe1LaU1/H G2vunhDJQlNhmKzNho9gx4heO3tLf7N6hq2ByD7/5mCh7NXIfKzr3B3ARkgXkniEz1vw RTCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8nGpBxGsFD5VEjjShFSR39ENJpcjJTDZ9DL/dz2T1FI=; b=XOZXJwjUV3WySebrhwzw7pxFWBWIgtJITZe93E2pmTUIJpBPOOTr6+O9h2MzrDCGIN FsCr2r2O2E0RLt5CwyFo9KZ6948qTYvqlEjycC406TC7r/cDV7TzgOGhGLap0yYTGq0B W33CDpDqwXKVK6UR5AgkbSd6SBg8iGWdWBPH+qC33w3950Rrt9LPKLaQIxRhRQka0HCn Zxiom6A4IYueD00ndN0v2Ygfvntcg2aP4lgITekl8BAVqhgqQYgMbhG68aIuZ0HrPZyo xbezw1BtFkU4hBR4XjUncg59oDDZURuH0Dtvjl4Iz55eKO6PDkp6a+Cnrel7jDaUxcRU y7GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=EdkjMnpo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f66si8434616pgc.449.2019.05.17.13.25.28; Fri, 17 May 2019 13:25:43 -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; dkim=pass header.i=@synopsys.com header.s=mail header.b=EdkjMnpo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbfEQTca (ORCPT + 99 others); Fri, 17 May 2019 15:32:30 -0400 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:34288 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727714AbfEQTc3 (ORCPT ); Fri, 17 May 2019 15:32:29 -0400 Received: from mailhost.synopsys.com (dc2-mailhost1.synopsys.com [10.12.135.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id C93D4C00F9; Fri, 17 May 2019 19:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1558121554; bh=xj+F4rfsxPPtbg7rvu15yyPc1Q9tuWTngEt3T6FetdM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=EdkjMnpoDQjbzQh9Nt1lWDwpjgJn7PF8Q0X8Qm7hR9yByETbeVGrEbpzO2hJSLQLN OrVITMgb/R71E4gqztetiyedpqIKRru2BdS7NdvXckcALDmkpuiPMb1FrYwwGxiclO rFbpyYZQJ26NamI5LHoeqig/J3izFeXYKJ26xrk7XU3bYSOAN0sjd8uUV/EWLnWgKG xyvcjk7ft/AhGMiUEQq3afsoHPRSXJl49OFp7CwHd95fpXQGrZ2uU49aaFtj5y5UD2 iWNNtUXeGHW/1XnZ/smxcyvYfXSHmjwsQoERQ8/eQRjzXmXSdxhcyOV/mKkIiL/QbQ 1eki3IkRM3SLg== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id AE188A009C; Fri, 17 May 2019 19:32:27 +0000 (UTC) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 17 May 2019 12:32:26 -0700 Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.105) by IN01WEHTCA.internal.synopsys.com (10.144.199.103) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 18 May 2019 01:02:37 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.89) by IN01WEHTCB.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 18 May 2019 01:02:25 +0530 From: Vineet Gupta To: CC: , Vineet Gupta Subject: [PATCH 2/5] ARCv2: entry: push out the Z flag unclobber from common EXCEPTION_PROLOGUE Date: Fri, 17 May 2019 12:32:05 -0700 Message-ID: <1558121528-30184-3-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558121528-30184-1-git-send-email-vgupta@synopsys.com> References: <1558121528-30184-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.10.161.89] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Upon a taken interrupt/exception from User mode, HS hardware auto sets Z flag. This helps shave a few instructions from EXCEPTION_PROLOGUE by eliding re-reading ERSTATUS and some bit fiddling. However TLB Miss Exception handler can clobber the CPU flags and still end up in EXCEPTION_PROLOGUE in the slow path handling TLB handling case: EV_TLBMissD do_slow_path_pf EV_TLBProtV (aliased to call_do_page_fault) EXCEPTION_PROLOGUE As a result, EXCEPTION_PROLOGUE need to "unclobber" the Z flag which this patch changes. It is now pushed out to TLB Miss Exception handler. The reasons beings: - The flag restoration is only needed for slowpath TLB Miss Exception handling, but currently being in EXCEPTION_PROLOGUE penalizes all exceptions such as ProtV and syscall Trap, where Z flag is already as expected. - Pushing unclobber out to where it was clobbered is much cleaner and also serves to document the fact. - Makes EXCEPTION_PROLGUE similar to INTERRUPT_PROLOGUE so easier to refactor the common parts which is what this series aims to do Signed-off-by: Vineet Gupta --- arch/arc/include/asm/entry-arcv2.h | 8 -------- arch/arc/mm/tlbex.S | 11 +++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/arc/include/asm/entry-arcv2.h b/arch/arc/include/asm/entry-arcv2.h index 1c3520d1fa42..3209a6762960 100644 --- a/arch/arc/include/asm/entry-arcv2.h +++ b/arch/arc/include/asm/entry-arcv2.h @@ -225,14 +225,6 @@ ; -- for interrupts, regs above are auto-saved by h/w in that order -- ; Now do what ISR prologue does (manually save r12, sp, fp, gp, r25) - ; - ; Set Z flag if this was from U mode (expected by INTERRUPT_PROLOGUE) - ; Although H/w exception micro-ops do set Z flag for U mode (just like - ; for interrupts), it could get clobbered in case we soft land here from - ; a TLB Miss exception handler (tlbex.S) - - and r10, r10, STATUS_U_MASK - xor.f 0, r10, STATUS_U_MASK INTERRUPT_PROLOGUE exception diff --git a/arch/arc/mm/tlbex.S b/arch/arc/mm/tlbex.S index 0e1e47a67c73..e50cac799a51 100644 --- a/arch/arc/mm/tlbex.S +++ b/arch/arc/mm/tlbex.S @@ -396,6 +396,17 @@ EV_TLBMissD_fast_ret: ; additional label for VDK OS-kit instrumentation ;-------- Common routine to call Linux Page Fault Handler ----------- do_slow_path_pf: +#ifdef CONFIG_ISA_ARCV2 + ; Set Z flag if exception in U mode. Hardware micro-ops do this on any + ; taken interrupt/exception, and thus is already the case at the entry + ; above, but ensuing code would have already clobbered. + ; EXCEPTION_PROLOGUE called in slow path, relies on correct Z flag set + + lr r2, [erstatus] + and r2, r2, STATUS_U_MASK + bxor.f 0, r2, STATUS_U_BIT +#endif + ; Restore the 4-scratch regs saved by fast path miss handler TLBMISS_RESTORE_REGS -- 2.7.4