Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755492AbdIGPFK convert rfc822-to-8bit (ORCPT ); Thu, 7 Sep 2017 11:05:10 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:10903 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbdIGPFJ (ORCPT ); Thu, 7 Sep 2017 11:05:09 -0400 From: gengdongjiu To: Marc Zyngier , James Morse 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 Subject: Re: [PATCH] arm64: KVM: VHE: reset PSTATE.UAO when switch to host Thread-Topic: [PATCH] arm64: KVM: VHE: reset PSTATE.UAO when switch to host Thread-Index: AdMn53+cw186Ln3mSg+sX1bkFCBFew== Date: Thu, 7 Sep 2017 15:03:49 +0000 Message-ID: <0184EA26B2509940AA629AE1405DD7F2015EF473@DGGEMA503-MBX.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.45.56.117] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.59B15FDD.0013,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=169.254.1.143, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d3b3dc5cd4564948ff631acb166002b2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2478 Lines: 50 > On 07/09/17 12:49, gengdongjiu wrote: > > > > > > On 2017/9/7 18:13, Marc Zyngier wrote: > >> On 07/09/17 11:05, gengdongjiu wrote: > >>> Hi James, > >>> > >>> On 2017/9/7 17:20, James Morse wrote: > >>>> Hi Dongjiu Geng, > >>>> > >>>> On 07/09/17 06:54, Dongjiu Geng wrote: > >>>>> In VHE mode, host kernel runs in the EL2 and can enable 'User > >>>>> Access Override' when fs==KERNEL_DS so that it can access kernel > >>>>> memory. However, PSTATE.UAO is set to 0 on an exception taken from > >>>>> EL1 to EL2. Thus when VHE is used and exception taken from a guest > >>>>> UAO will be disabled and host will use the incorrect PSTATE.UAO. > >>>>> So check and reset the PSTATE.UAO when switching to host. > >>>> > >>>> This would only be a problem if KVM were calling into world-switch > >>>> with fs==KERNEL_DS. I can't see where this happens. > >>> Not only KVM, may also kernel sets the fs == KERNEL_DS before > >>> calling into world-switch > >> > >> How? Please describe the exact sequence of event that lead to this > >> situation with the current code base. > > > > Hi Marc, > > > > Different tasks have different fs, such as USER_DS or KERNEL_DS. In > > the context switch, it will restore the task's fs. Thus, that depends > > on task itself, as shown below code. UAO is different with PAN, PAN will be always enabled if hardware CPU supports PAN feature, but > UAO is dynamical change. > > You haven't answered my question: There is exactly one point where we enter the world-switch. Show me that, at this point, PSTATE.UAO > *before* the call is different from PSTATE.UAO after the call. Give me the exact sequence of event that leads to this situation. Show me a > stack trace. Hi Marc, If using current mainline KVM code + Qemu and modify nothing, may not exist broken issue, because the Qemu progress FS should be USER_DS. But if I make a modification for user space( Qemu or KVM tools) to change its FS property to KERNEL_DS or use third party application with KERNEL_DS FS to run the guest, it will have problem(the KERNEL_DS is cleared). If you think my case is reasonable and should support, I can show you the calling stack trace. If you think, my case is not reasonable and KVM should not support the application with KERNEL_DS fs to run guest. You can ignore this patch, thanks. > > Until you do this, I will ignore any further comment coming from you on this subject. > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny...