Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754973AbdIHHXJ (ORCPT ); Fri, 8 Sep 2017 03:23:09 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5575 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754539AbdIHHXH (ORCPT ); Fri, 8 Sep 2017 03:23:07 -0400 Subject: Re: [PATCH] arm64: KVM: VHE: reset PSTATE.UAO when switch to host To: Marc Zyngier , James Morse References: <0184EA26B2509940AA629AE1405DD7F2015EF473@DGGEMA503-MBX.china.huawei.com> CC: "christoffer.dall@linaro.org" , "vladimir.murzin@arm.com" , "rkrcmar@redhat.com" , "catalin.marinas@arm.com" , "shankerd@codeaurora.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Zhanghaibin (Euler)" , Huangshaoyu From: gengdongjiu Message-ID: <1bcd0c1e-c3b5-aac4-bb4f-83ee14b1d1ab@huawei.com> Date: Fri, 8 Sep 2017 15:19:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.68.147] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0204.59B2448B.0065,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d79aa3ffdbfe3823a77530b4628e2356 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1455 Lines: 30 On 2017/9/7 23:23, Marc Zyngier wrote: > On 07/09/17 16:03, gengdongjiu wrote: >>> On 07/09/17 12:49, gengdongjiu wrote: >>>> [...] > > I really cannot think of a good reason why we'd want to do that. Playing > with set_fs() is almost universally wrong, and I'm certainly going to > oppose to any change in that area unless the code that calls set_fs() > has been made public and properly reviewed. Until then, UAO/PAN will > stay as they are unless you prove that our current code is wrong. Marc, sorry I have another question for the PAN. In the non-VHE mode, The host kernel is running in the EL1. Before host kernel enter guest, host OS will call 'HVC' instruction to do the world-switch, and the pstate.PAN will be saved into the SPSR_EL2. When world-switch back to host kernel from EL2, it will call 'eret' instruction to EL1 host, this 'eret' instruction will restore the SPSR_EL2 to the PSTATE. so the PSTATE.PAN will be restored. For the Non-VHE mode, in the EL2 where mainly have word-switch code, do you think it needs to reset the PSTATE.PAN? From the spec, it does not provide SCTLR_EL2.SPAN bit for non-VHE mode, so reset the PSTATE.PAN does not sure whether it is needed or whether affects the performance. If you think it is needed for El2 in Non-VHE mode, moving the reset PSTATE.PAN to the exception entry to EL2 may be better, such as "el1_sync", because host can also call 'hvc' instruction without guest running. > > M. >