Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751584AbdILPdM convert rfc822-to-8bit (ORCPT ); Tue, 12 Sep 2017 11:33:12 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:11834 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751445AbdILPdJ (ORCPT ); Tue, 12 Sep 2017 11:33:09 -0400 From: gengdongjiu To: Marc Zyngier CC: "christoffer.dall@linaro.org" , "vladimir.murzin@arm.com" , "james.morse@arm.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: KVM: Skip PSTATE.PAN reest at EL2 in non-VHE Thread-Topic: [PATCH] arm64: KVM: Skip PSTATE.PAN reest at EL2 in non-VHE Thread-Index: AdMr089LeEk7M5svReOrVZwF2GJ/Ng== Date: Tue, 12 Sep 2017 15:32:53 +0000 Message-ID: <0184EA26B2509940AA629AE1405DD7F201601FE5@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.91.42] 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.0A0B0203.59B7FE2C.00B8,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: d591f3243583e957105ab312b880035a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3182 Lines: 68 > On Mon, Sep 11 2017 at 7:16:52 pm BST, Dongjiu Geng wrote: > > PSTATE.PAN disables reading and/or writing to a userspace virtual > > address from EL1 in non-VHE or from EL2 in VHE. In non-VHE, there is > > no any userspace mapping at EL2, so no need to reest the PSTATE.PAN. > > > > Signed-off-by: Dongjiu Geng > > Signed-off-by: Haibin Zhang > > --- > > arch/arm64/kvm/hyp/entry.S | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S > > index 12ee62d6d410..86a7549b1b4c 100644 > > --- a/arch/arm64/kvm/hyp/entry.S > > +++ b/arch/arm64/kvm/hyp/entry.S > > @@ -96,8 +96,12 @@ ENTRY(__guest_exit) > > > > add x1, x1, #VCPU_CONTEXT > > > > - ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) > > +alternative_if_not ARM64_HAS_VIRT_HOST_EXTN > > + b 2f // skip PAN at EL2 in non-VHE > > +alternative_else_nop_endif > > > > + ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) > > +2: > > // Store the guest regs x2 and x3 > > stp x2, x3, [x1, #CPU_XREG_OFFSET(2)] > Hi Marc, I need to say why I found this issue. In my test, I found the PAN feature did not work in my platform for VHE, but it works for the no-VHE. 1. After checking the code, I found I missed this patch " arm64: KVM: VHE: reset PSTATE.PAN on entry to EL2", and then thought of UAO feature. because UAO feature is similar with the PAN which all control the access address permit. After discussed with you, you think usually we do not always call set_fs(KERNEL_DS), so leave it alone. 2. After checking the PAN and discussing with you, we think PAN does not needed at EL2 for the non-VHE, so make this change. > Aside from Vladimir's comment about why this may not be an important change in practice (both features are v8.1, and expected to be > implemented at the same time as VHE), I'm not sure this brings us much. I agree that using VHE is the usual case if CPU supports VHE. but we cannot sure other people must not use non-VHE, since the pstate.PAN is not needed, why we still enabled it > > We're just trading a write to PSTATE (which will have no effect other than storing a bit in PSTATE) for a branch, and I'm not sure what is the > worse. Your patch definitely makes the code less readable, and I value ease of maintenance very much. This place will check two CAP feature ARM64_HAS_PAN and ARM64_HAS_VIRT_HOST_EXTN, the best way is using "ALTERNATIVE" instruction, as shown below. But I found it will report error when build, to avoid changing " ALTERNATIVE " macro. so I use the 'branch' instruction. alternative_if ARM64_HAS_VIRT_HOST_EXTN ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) alternative_else_nop_endif > > Do you have any data coming from a non-VHE, PAN-enabled system that shows a measurable, significant performance improvement with > this patch? > Because that would be the only reason why I'd consider such a change. Frankly speaking, I do not test the performance. > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny.