Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3826070imj; Tue, 12 Feb 2019 05:24:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IY+Q6oXHMgF1nCjQZOV+y6aUlcsUAoiktAyQQkZW/hbuRyBZGUOL/vmZcu8NY/N8pl4NVuO X-Received: by 2002:a17:902:4827:: with SMTP id s36mr3944868pld.168.1549977891287; Tue, 12 Feb 2019 05:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549977891; cv=none; d=google.com; s=arc-20160816; b=h+cxYFhz2Y+qzbkRj766UcJ4PQGGUzQy1PZJmm64CzmqfBKnwzobrWN/qM2Gx0hFDg w5d4DiLCrDkNpO6HDWvqL7+KaRY5hp8OLajbQe+yTTmlMgXNaKVQUqLMyOLpmeCrVNdf Hg/B8ZKYNxZKsIBMJ7aABlvQGRjdIkId5pwYhNiIkGNzt4VU5kdUdi9Siu3A8Wb/aXEM k2/wPoIC8MCySzdkGRa0uPfyEZURNVOkIvQSlH29YA87urTsI70UTDIsbzYekntC+naI cZ17npQIJr5E5jUjtcZfSd7br3J/GiHZ/k3iO3CDqdJ7TURbJ4DLq4s0Lvh6DGvi9DNw qX7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=G0jidUg5d6gJlIq+oKUNqVQmqODA+FqVgSEbsJIj7Mc=; b=JBoxi90C37zBHHf2wcV71Ud5i9Mm8rBSjm9mUKp1jq7MybVwaE1GwqikTs3xG+xKlF z+RRbTpJ2k76CkRtcYqL6S1KAqUsdrJ3hNxPA3asoktBvsvmOPZzBx9N5Wkrd/AR8WfL CAF32XSkGVEx0bbmovcEOXAin8Yk0L55ZG1Sel4EoZ8UK6YXIfU53o+9FUi7srZM2H9Y DD87Hyv/wXjLOcj/fX+yMCMyDm18vmphCpNY5FP9YCmmbLx/+Ge74fbleyjOmnA+ETcW OtaQcZr7L4RDtvcz3DdDCxOtABtGftpuEjih6oZBeaGXJ3yKbk8HPD14Mj0xxdm2xI/D IkYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=OMC9mDd2; 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 d33si13381615pla.359.2019.02.12.05.24.34; Tue, 12 Feb 2019 05:24:51 -0800 (PST) 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=OMC9mDd2; 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 S1729594AbfBLNYE (ORCPT + 99 others); Tue, 12 Feb 2019 08:24:04 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:56413 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbfBLNYD (ORCPT ); Tue, 12 Feb 2019 08:24:03 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43zNf83L7sz9vBGW; Tue, 12 Feb 2019 14:24:00 +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=OMC9mDd2; 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 R6-zuh5ph3Pa; Tue, 12 Feb 2019 14:24:00 +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 43zNf82GSdz9vBGV; Tue, 12 Feb 2019 14:24:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1549977840; bh=G0jidUg5d6gJlIq+oKUNqVQmqODA+FqVgSEbsJIj7Mc=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=OMC9mDd2V9IQqv0XUY/Gzph638uMO2n2HMxuqVhLfgXzQobMosX8/iet0cyriUXmR I4H5fJJLL1Bcj0FKPRsxrIZ1nCddAlCwfJp2G0EhrMIqWEQGxuylzxhIdI0tc1e6ef UgxP1yjMgwAppYh8Aj2D7lmJ956NrwPIQMg7Jw+k= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A418B8B7F7; Tue, 12 Feb 2019 14:24:01 +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 BodTgny8Iun2; Tue, 12 Feb 2019 14:24:01 +0100 (CET) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1E2978B7EB; Tue, 12 Feb 2019 14:24:01 +0100 (CET) Subject: Re: [RFC PATCH] powerpc/6xx: Don't set back MSR_RI before reenabling MMU From: Christophe Leroy To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <9f9dd859d571e324c7412ed9db9da8cfba678257.1548956511.git.christophe.leroy@c-s.fr> <87lg2zojbt.fsf@concordia.ellerman.id.au> <17b00097-a807-e9b9-3dce-198df4a3153f@c-s.fr> Message-ID: Date: Tue, 12 Feb 2019 14:24:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <17b00097-a807-e9b9-3dce-198df4a3153f@c-s.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 01/02/2019 à 12:51, Christophe Leroy a écrit : > > > Le 01/02/2019 à 12:10, Michael Ellerman a écrit : >> Christophe Leroy writes: >> >>> By delaying the setting of MSR_RI, a 1% improvment is optained on >>> null_syscall selftest on an mpc8321. >>> >>> Without this patch: >>> >>> root@vgoippro:~# ./null_syscall >>>     1134.33 ns     378.11 cycles >>> >>> With this patch: >>> >>> root@vgoippro:~# ./null_syscall >>>     1121.85 ns     373.95 cycles >>> >>> The drawback is that a machine check during that period >>> would be unrecoverable, but as only main memory is accessed >>> during that period, it shouldn't be a concern. >> >> On 64-bit server CPUs accessing main memory can cause a UE >> (Uncorrectable Error) which can trigger a machine check. >> >> So it may still be a concern, it depends how paranoid you are. >> >>> diff --git a/arch/powerpc/kernel/head_32.S >>> b/arch/powerpc/kernel/head_32.S >>> index 146385b1c2da..ea28a6ab56ec 100644 >>> --- a/arch/powerpc/kernel/head_32.S >>> +++ b/arch/powerpc/kernel/head_32.S >>> @@ -282,8 +282,6 @@ __secondary_hold_acknowledge: >>>       stw    r1,GPR1(r11);    \ >>>       stw    r1,0(r11);    \ >>>       tovirt(r1,r11);            /* set new kernel sp */    \ >>> -    li    r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions >>> */ \ >>> -    MTMSRD(r10);            /* (except for mach check in rtas) */ \ >>>       stw    r0,GPR0(r11);    \ >>>       lis    r10,STACK_FRAME_REGS_MARKER@ha; /* exception frame >>> marker */ \ >>>       addi    r10,r10,STACK_FRAME_REGS_MARKER@l; \ >> >> Where does RI get enabled? I don't see it anywhere obvious. > > MSR_RI is part of MSR_KERNEL, it gets then enabled when reenabling MMU > when calling the exception handler. > > #define EXC_XFER_TEMPLATE(n, hdlr, trap, copyee, tfer, ret)    \ >     li    r10,trap;                    \ >     stw    r10,_TRAP(r11);                    \ >     li    r10,MSR_KERNEL;                    \ >     copyee(r10, r9);                    \ >     bl    tfer;                        \ > i##n:                                \ >     .long    hdlr;                        \ >     .long    ret > > where tfer = transfer_to_handler. > > In transfer_to_handler (kernel/entry_32.S) you have: > > transfer_to_handler_cont: > 3: >     mflr    r9 >     lwz    r11,0(r9)        /* virtual address of handler */ >     lwz    r9,4(r9)        /* where to go when done */ > [...] >     mtspr    SPRN_SRR0,r11 >     mtspr    SPRN_SRR1,r10 >     mtlr    r9 >     SYNC >     RFI                /* jump to handler, enable MMU */ > > So MSR_RI is restored above as r10 contains MSR_KERNEL [ | MSR_EE ] > Looks like fast_exception_return, which is called by hash page handlers at least, expects MSR_RI to be set. Allthough it works well on 603 (because it doesn't hash), I would most likely not work on others. This 1% improvment is not worth it, I give up for now.