Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp2837596pjo; Mon, 16 Mar 2020 05:39:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsQ1JupfJ2ynAzxj3YvvPEt6zujSEP51v2lLeJXdMWpmsqKvMWqF8qxtg2smgIYAgyO+JX1 X-Received: by 2002:a05:6808:b24:: with SMTP id t4mr17284683oij.72.1584362344693; Mon, 16 Mar 2020 05:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584362344; cv=none; d=google.com; s=arc-20160816; b=pLf0rPF3Cu8CPuFKUePz3LHiwzvATLEDi1lPxbuRibWuR/zpUvqt9tauiIe8QFKIbi dULXGdeV/c0doRBgt5SqfJ0XsiXu3l7XGnmdsstqRetVVoChCOKtL48+FH/OatiOcJlB Xkosc+tFDhi+ko+K+Uv71Z6ZfjfPiIF2oZ/m/pa+QflVjwfX41xkagL3QuE64CQixP3d qARhcdWC9gc3iZn2nwHUu8tlDCAWQe3nKV6o1lrWNolvbVlskECJ3aoJIJmr0xA4we6H w9p66Iakz1j+3LWRwTuMDcatTysIYuTFVpa7mTspIVNp5q4j42Kf9TPtvZWlDFgzB5aW UTaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=CdZwfArEauz62WETmDYTfQuV7IO+vN/4hsOwJJkocPg=; b=MhpVS3kzHG3iVOOQF91bu2HsHO2QhEu2HuZSW4vSpmkb1qjRzavzsDKhK/J9DtKR5a r/kI5rD1CJdlBGoPeorLrUInUld83bEAKQkLBwap2TV/HTIbHcy/RYWDDm6/bh/pfsga 6ti3VAYYpTi/fy7bUwgBXQAGWLs36N2z6/qZSXEJmF6mAKuoSxtw7niVaFq+NxiXowXA k611S9o4yWuW6QLozYeK0V0SzYwipluiMg1iknkKchKjuCL1+8+AxfQCI+RRgyd8WADL jpRwjLMez6/E13PwBMxsYrHm4oWX/D4IIqrm5IgYH+fNBQqk7rHINF9HEquywlyZ15+N oObg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=JwfJyVcZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si10108314otq.50.2020.03.16.05.38.52; Mon, 16 Mar 2020 05:39:04 -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=@c-s.fr header.s=mail header.b=JwfJyVcZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731328AbgCPMgc (ORCPT + 99 others); Mon, 16 Mar 2020 08:36:32 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:52502 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731203AbgCPMg0 (ORCPT ); Mon, 16 Mar 2020 08:36:26 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48gwlR4xFwz9v02l; Mon, 16 Mar 2020 13:36:19 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=JwfJyVcZ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id DxA4GsYKtVKH; Mon, 16 Mar 2020 13:36:19 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48gwlR3sBWz9v02f; Mon, 16 Mar 2020 13:36:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584362179; bh=CdZwfArEauz62WETmDYTfQuV7IO+vN/4hsOwJJkocPg=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=JwfJyVcZPjsrUY59A7jAQfPiEJoLBMDpREVF34qc3Cl4n/JaJYEjMAbRii6h2+NMV aOdgGVQ9534Ze10EkgAbRrL3WQuY+344DaOzhSI7Li4AoH3GrKDWXHh0BJP+Zp3vEy NeNwWxI8mOGUut+6MzIvnJv0ftu9Pw/amiyahHgQ= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 692348B7D0; Mon, 16 Mar 2020 13:36:24 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ISyzpdGQwtCf; Mon, 16 Mar 2020 13:36:24 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4B17F8B7CB; Mon, 16 Mar 2020 13:36:24 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 3EE1E65595; Mon, 16 Mar 2020 12:36:24 +0000 (UTC) Message-Id: <86e2192ff3d21fa6c8bdeb934cbd836f7e4f5ce4.1584360344.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 38/46] powerpc/8xx: Refactor kernel address boundary comparison To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Mar 2020 12:36:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that linear and IMMR dedicated TLB handling is gone, kernel boundary address comparison is similar in ITLB miss handler and in DTLB miss handler. Create a macro named compare_to_kernel_boundary. When TASK_SIZE is strictly below 0x80000000 and PAGE_OFFSET is above 0x80000000, it is enough to compare to 0x8000000, and this can be done with a single instruction. Using not. instruction, we get to use 'blt' conditional branch as when doing a regular comparison: 0x00000000 <= addr <= 0x7fffffff ==> 0xffffffff >= NOT(addr) >= 0x80000000 The above test corresponds to a 'blt' Otherwise, do a regular comparison using two instructions. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_8xx.S | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S index d12f5846d527..410cb48ab36f 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -31,10 +31,15 @@ #include "head_32.h" +.macro compare_to_kernel_boundary scratch, addr #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000 /* By simply checking Address >= 0x80000000, we know if its a kernel address */ -#define SIMPLE_KERNEL_ADDRESS 1 + not. \scratch, \addr +#else + rlwinm \scratch, \addr, 16, 0xfff8 + cmpli cr0, \scratch, PAGE_OFFSET@h #endif +.endm /* * We need an ITLB miss handler for kernel addresses if: @@ -208,20 +213,11 @@ InstructionTLBMiss: mtspr SPRN_MD_EPN, r10 #ifdef ITLB_MISS_KERNEL mfcr r11 -#if defined(SIMPLE_KERNEL_ADDRESS) - cmpi cr0, r10, 0 /* Address >= 0x80000000 */ -#else - rlwinm r10, r10, 16, 0xfff8 - cmpli cr0, r10, PAGE_OFFSET@h -#endif + compare_to_kernel_boundary r10, r10 #endif mfspr r10, SPRN_M_TWB /* Get level 1 table */ #ifdef ITLB_MISS_KERNEL -#if defined(SIMPLE_KERNEL_ADDRESS) - bge+ 3f -#else blt+ 3f -#endif rlwinm r10, r10, 0, 20, 31 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha 3: @@ -287,9 +283,7 @@ DataStoreTLBMiss: * kernel page tables. */ mfspr r10, SPRN_MD_EPN - rlwinm r10, r10, 16, 0xfff8 - cmpli cr0, r10, PAGE_OFFSET@h - + compare_to_kernel_boundary r10, r10 mfspr r10, SPRN_M_TWB /* Get level 1 table */ blt+ 3f rlwinm r10, r10, 0, 20, 31 -- 2.25.0