From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB6F9C433B4 for ; Mon, 10 May 2021 15:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5D3161409 for ; Mon, 10 May 2021 15:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbhEJPKW (ORCPT ); Mon, 10 May 2021 11:10:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:57116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbhEJPJ7 (ORCPT ); Mon, 10 May 2021 11:09:59 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C5C861152; Mon, 10 May 2021 15:08:54 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lg7We-000TGn-3n; Mon, 10 May 2021 16:08:52 +0100 Date: Mon, 10 May 2021 16:08:51 +0100 Message-ID: <87tunaoccc.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Zenghui Yu , James Morse , Suzuki K Poulose , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH 1/2] KVM: arm64: Move __adjust_pc out of line In-Reply-To: <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-2-maz@kernel.org> <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com, james.morse@arm.com, suzuki.poulose@arm.com, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, 10 May 2021 15:55:16 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 5/10/21 10:49 AM, Marc Zyngier wrote: > > In order to make it easy to call __adjust_pc() from the EL1 code > > (in the case of nVHE), rename it to __kvm_adjust_pc() and move > > it out of line. > > > > No expected functional change. > > It does look to me like they're functionally identical. Minor comments below. > > > > > Signed-off-by: Marc Zyngier > > Cc: stable@vger.kernel.org # 5.11 > > --- > > arch/arm64/include/asm/kvm_asm.h | 2 ++ > > arch/arm64/kvm/hyp/exception.c | 18 +++++++++++++++++- > > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 18 ------------------ > > arch/arm64/kvm/hyp/nvhe/switch.c | 2 +- > > arch/arm64/kvm/hyp/vhe/switch.c | 2 +- > > 5 files changed, 21 insertions(+), 21 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h > > index cf8df032b9c3..d5b11037401d 100644 > > --- a/arch/arm64/include/asm/kvm_asm.h > > +++ b/arch/arm64/include/asm/kvm_asm.h > > @@ -201,6 +201,8 @@ extern void __kvm_timer_set_cntvoff(u64 cntvoff); > > > > extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); > > > > +extern void __kvm_adjust_pc(struct kvm_vcpu *vcpu); > > It looks pretty strange to have the file > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h, but the function > __kvm_adjust_pc() in another header. I guess this was done because > arch/arm64/kvm/arm.c will use the function in the next patch. That's mostly it. __kvm_adjust_pc() is very similar to __kvm_vcpu_run() in its usage, and I want to keep the patch as small as possible given that this is a candidate for a stable backport. > I was thinking that maybe renaming adjust_pc.h->skip_instr.h would > make more sense, what do you think? I can send a patch on top of > this series with the rename if you prefer. Yes, that'd probably be a good cleanup now that __adjust_pc() is gone. > > > + > > extern u64 __vgic_v3_get_gic_config(void); > > extern u64 __vgic_v3_read_vmcr(void); > > extern void __vgic_v3_write_vmcr(u32 vmcr); > > diff --git a/arch/arm64/kvm/hyp/exception.c b/arch/arm64/kvm/hyp/exception.c > > index 73629094f903..0812a496725f 100644 > > --- a/arch/arm64/kvm/hyp/exception.c > > +++ b/arch/arm64/kvm/hyp/exception.c > > @@ -296,7 +296,7 @@ static void enter_exception32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) > > *vcpu_pc(vcpu) = vect_offset; > > } > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu) > > +static void kvm_inject_exception(struct kvm_vcpu *vcpu) > > { > > if (vcpu_el1_is_32bit(vcpu)) { > > switch (vcpu->arch.flags & KVM_ARM64_EXCEPT_MASK) { > > @@ -329,3 +329,19 @@ void kvm_inject_exception(struct kvm_vcpu *vcpu) > > } > > } > > } > > + > > +/* > > + * Adjust the guest PC on entry, depending on flags provided by EL1 > > This is also called by the VHE code running at EL2, but the comment is reworded in > the next patch, so it doesn't really matter, and keeping the diff a straight move > makes it easier to read. > > > + * for the purpose of emulation (MMIO, sysreg) or exception injection. > > + */ > > +void __kvm_adjust_pc(struct kvm_vcpu *vcpu) > > +{ > > + if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > + kvm_inject_exception(vcpu); > > + vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > + KVM_ARM64_EXCEPT_MASK); > > + } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > + kvm_skip_instr(vcpu); > > + vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > + } > > +} > > diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > index 61716359035d..4fdfeabefeb4 100644 > > --- a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > @@ -13,8 +13,6 @@ > > #include > > #include > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu); > > - > > static inline void kvm_skip_instr(struct kvm_vcpu *vcpu) > > { > > if (vcpu_mode_is_32bit(vcpu)) { > > @@ -43,22 +41,6 @@ static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) > > write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); > > } > > > > -/* > > - * Adjust the guest PC on entry, depending on flags provided by EL1 > > - * for the purpose of emulation (MMIO, sysreg) or exception injection. > > - */ > > -static inline void __adjust_pc(struct kvm_vcpu *vcpu) > > -{ > > - if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > - kvm_inject_exception(vcpu); > > - vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > - KVM_ARM64_EXCEPT_MASK); > > - } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > - kvm_skip_instr(vcpu); > > - vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > - } > > -} > > - > > /* > > * Skip an instruction while host sysregs are live. > > * Assumes host is always 64-bit. > > diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c > > index e9f6ea704d07..b8ac123c3419 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/switch.c > > +++ b/arch/arm64/kvm/hyp/nvhe/switch.c > > @@ -201,7 +201,7 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu) > > */ > > __debug_save_host_buffers_nvhe(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > > > /* > > * We must restore the 32-bit state before the sysregs, thanks > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > > index 7b8f7db5c1ed..3eafed0431f5 100644 > > --- a/arch/arm64/kvm/hyp/vhe/switch.c > > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > > @@ -132,7 +132,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) > > __load_guest_stage2(vcpu->arch.hw_mmu); > > __activate_traps(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > With the function now moved to kvm_asm.h, the header include > adjust_pc.h is not needed. Same for the nvhe version of switch.c. Well spotted. I'll clean that up. Thanks, M. -- Without deviation from the norm, progress is not possible. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC78BC433ED for ; Mon, 10 May 2021 15:09:00 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 3A5E561409 for ; Mon, 10 May 2021 15:09:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A5E561409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A9C0D4B3BF; Mon, 10 May 2021 11:08:59 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 89DcD0z6pBpj; Mon, 10 May 2021 11:08:57 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E2EBD4B3AD; Mon, 10 May 2021 11:08:57 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C22604B3AD for ; Mon, 10 May 2021 11:08:56 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8clWAOU49gY0 for ; Mon, 10 May 2021 11:08:55 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 4B2F34B332 for ; Mon, 10 May 2021 11:08:55 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C5C861152; Mon, 10 May 2021 15:08:54 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lg7We-000TGn-3n; Mon, 10 May 2021 16:08:52 +0100 Date: Mon, 10 May 2021 16:08:51 +0100 Message-ID: <87tunaoccc.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Subject: Re: [PATCH 1/2] KVM: arm64: Move __adjust_pc out of line In-Reply-To: <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-2-maz@kernel.org> <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com, james.morse@arm.com, suzuki.poulose@arm.com, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kvm@vger.kernel.org, stable@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Mon, 10 May 2021 15:55:16 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 5/10/21 10:49 AM, Marc Zyngier wrote: > > In order to make it easy to call __adjust_pc() from the EL1 code > > (in the case of nVHE), rename it to __kvm_adjust_pc() and move > > it out of line. > > > > No expected functional change. > > It does look to me like they're functionally identical. Minor comments below. > > > > > Signed-off-by: Marc Zyngier > > Cc: stable@vger.kernel.org # 5.11 > > --- > > arch/arm64/include/asm/kvm_asm.h | 2 ++ > > arch/arm64/kvm/hyp/exception.c | 18 +++++++++++++++++- > > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 18 ------------------ > > arch/arm64/kvm/hyp/nvhe/switch.c | 2 +- > > arch/arm64/kvm/hyp/vhe/switch.c | 2 +- > > 5 files changed, 21 insertions(+), 21 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h > > index cf8df032b9c3..d5b11037401d 100644 > > --- a/arch/arm64/include/asm/kvm_asm.h > > +++ b/arch/arm64/include/asm/kvm_asm.h > > @@ -201,6 +201,8 @@ extern void __kvm_timer_set_cntvoff(u64 cntvoff); > > > > extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); > > > > +extern void __kvm_adjust_pc(struct kvm_vcpu *vcpu); > > It looks pretty strange to have the file > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h, but the function > __kvm_adjust_pc() in another header. I guess this was done because > arch/arm64/kvm/arm.c will use the function in the next patch. That's mostly it. __kvm_adjust_pc() is very similar to __kvm_vcpu_run() in its usage, and I want to keep the patch as small as possible given that this is a candidate for a stable backport. > I was thinking that maybe renaming adjust_pc.h->skip_instr.h would > make more sense, what do you think? I can send a patch on top of > this series with the rename if you prefer. Yes, that'd probably be a good cleanup now that __adjust_pc() is gone. > > > + > > extern u64 __vgic_v3_get_gic_config(void); > > extern u64 __vgic_v3_read_vmcr(void); > > extern void __vgic_v3_write_vmcr(u32 vmcr); > > diff --git a/arch/arm64/kvm/hyp/exception.c b/arch/arm64/kvm/hyp/exception.c > > index 73629094f903..0812a496725f 100644 > > --- a/arch/arm64/kvm/hyp/exception.c > > +++ b/arch/arm64/kvm/hyp/exception.c > > @@ -296,7 +296,7 @@ static void enter_exception32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) > > *vcpu_pc(vcpu) = vect_offset; > > } > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu) > > +static void kvm_inject_exception(struct kvm_vcpu *vcpu) > > { > > if (vcpu_el1_is_32bit(vcpu)) { > > switch (vcpu->arch.flags & KVM_ARM64_EXCEPT_MASK) { > > @@ -329,3 +329,19 @@ void kvm_inject_exception(struct kvm_vcpu *vcpu) > > } > > } > > } > > + > > +/* > > + * Adjust the guest PC on entry, depending on flags provided by EL1 > > This is also called by the VHE code running at EL2, but the comment is reworded in > the next patch, so it doesn't really matter, and keeping the diff a straight move > makes it easier to read. > > > + * for the purpose of emulation (MMIO, sysreg) or exception injection. > > + */ > > +void __kvm_adjust_pc(struct kvm_vcpu *vcpu) > > +{ > > + if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > + kvm_inject_exception(vcpu); > > + vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > + KVM_ARM64_EXCEPT_MASK); > > + } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > + kvm_skip_instr(vcpu); > > + vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > + } > > +} > > diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > index 61716359035d..4fdfeabefeb4 100644 > > --- a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > @@ -13,8 +13,6 @@ > > #include > > #include > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu); > > - > > static inline void kvm_skip_instr(struct kvm_vcpu *vcpu) > > { > > if (vcpu_mode_is_32bit(vcpu)) { > > @@ -43,22 +41,6 @@ static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) > > write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); > > } > > > > -/* > > - * Adjust the guest PC on entry, depending on flags provided by EL1 > > - * for the purpose of emulation (MMIO, sysreg) or exception injection. > > - */ > > -static inline void __adjust_pc(struct kvm_vcpu *vcpu) > > -{ > > - if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > - kvm_inject_exception(vcpu); > > - vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > - KVM_ARM64_EXCEPT_MASK); > > - } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > - kvm_skip_instr(vcpu); > > - vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > - } > > -} > > - > > /* > > * Skip an instruction while host sysregs are live. > > * Assumes host is always 64-bit. > > diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c > > index e9f6ea704d07..b8ac123c3419 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/switch.c > > +++ b/arch/arm64/kvm/hyp/nvhe/switch.c > > @@ -201,7 +201,7 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu) > > */ > > __debug_save_host_buffers_nvhe(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > > > /* > > * We must restore the 32-bit state before the sysregs, thanks > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > > index 7b8f7db5c1ed..3eafed0431f5 100644 > > --- a/arch/arm64/kvm/hyp/vhe/switch.c > > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > > @@ -132,7 +132,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) > > __load_guest_stage2(vcpu->arch.hw_mmu); > > __activate_traps(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > With the function now moved to kvm_asm.h, the header include > adjust_pc.h is not needed. Same for the nvhe version of switch.c. Well spotted. I'll clean that up. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7931DC433B4 for ; Mon, 10 May 2021 15:10:29 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD0BE61409 for ; Mon, 10 May 2021 15:10:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD0BE61409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:Cc:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Eie6J8NR4yW59phPCuzmb/iGzulzD8f5dASargmuk8U=; b=LDkDKGiiHiLAV5FjN8X/G3TiE jqYLxQX0daylNtIfoKktJMugFjk3nOC0xLNMO6Sc70DbUPZ6U5Zwt4c1LJ0K4tkXNKedONxvAcxKA lJ5ONCK1N4WN9C7XK/hGP7X+B+55tYtjjbGojqHnsXERr+ZRX5Z/bqe39l1iWRD2svqvYBVERvO7T aOMwBxZcBTFAeKjqBtqNBTDF1DDj0vlarOvIi7ucywa27fms1DmpspquZSOoe1npOHFFEGh7madZ+ BN3nseg/4dIVJH7Gu6znncfJxulT3ASs/XgSYFR9TPzMwVaqZ814r6FyqTdX2UwpEG/3X6EO1WxRa RLBOuRkIQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg7Wl-00Ekcd-SN; Mon, 10 May 2021 15:09:00 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg7Wj-00EkcV-Ew for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 15:08:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XtLXAPJPrgyZ67TwuKjILDoigUutWN8gA18iamaW2ao=; b=H2Ogiv0sd2t3FGsj8l6ueQf4LC EEUtnYaFk45OT1gWg7KyjS+CdGE8roN5K2+CGdHc1JOmJuyMMJ14EOKvOOVEG/y5TNfIUwVoEa5e3 F5wz2SZa4U33sEDuRVtQDdaM/6BuqZS5DsUmCHOfzie7ZwyYRB3C0pY/qhnnwzf5sqE/Ldkn5RwQF 6b2MnqJR2x8A+s0l4AwWfUUekE83XC7Bqw4hDJq+psBuDzOx/Y6bVHm9NnOrvN9+jO9ChkIOf7YMJ 9YVjNbaqUBRSH6Qn5jCEy4qvUxcbHh9y/Cu4I5QkGZctjSN42V+1/ikoFMewm2l2RHeWTPNL3JRSJ IBhjmAZg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg7Wg-008r17-JM for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 15:08:56 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C5C861152; Mon, 10 May 2021 15:08:54 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lg7We-000TGn-3n; Mon, 10 May 2021 16:08:52 +0100 Date: Mon, 10 May 2021 16:08:51 +0100 Message-ID: <87tunaoccc.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Zenghui Yu , James Morse , Suzuki K Poulose , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH 1/2] KVM: arm64: Move __adjust_pc out of line In-Reply-To: <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-2-maz@kernel.org> <01c646f1-e342-b9fc-39b3-e8649862b4ac@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com, james.morse@arm.com, suzuki.poulose@arm.com, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_080854_710061_6F2CE4DF X-CRM114-Status: GOOD ( 42.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 10 May 2021 15:55:16 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 5/10/21 10:49 AM, Marc Zyngier wrote: > > In order to make it easy to call __adjust_pc() from the EL1 code > > (in the case of nVHE), rename it to __kvm_adjust_pc() and move > > it out of line. > > > > No expected functional change. > > It does look to me like they're functionally identical. Minor comments below. > > > > > Signed-off-by: Marc Zyngier > > Cc: stable@vger.kernel.org # 5.11 > > --- > > arch/arm64/include/asm/kvm_asm.h | 2 ++ > > arch/arm64/kvm/hyp/exception.c | 18 +++++++++++++++++- > > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 18 ------------------ > > arch/arm64/kvm/hyp/nvhe/switch.c | 2 +- > > arch/arm64/kvm/hyp/vhe/switch.c | 2 +- > > 5 files changed, 21 insertions(+), 21 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h > > index cf8df032b9c3..d5b11037401d 100644 > > --- a/arch/arm64/include/asm/kvm_asm.h > > +++ b/arch/arm64/include/asm/kvm_asm.h > > @@ -201,6 +201,8 @@ extern void __kvm_timer_set_cntvoff(u64 cntvoff); > > > > extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); > > > > +extern void __kvm_adjust_pc(struct kvm_vcpu *vcpu); > > It looks pretty strange to have the file > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h, but the function > __kvm_adjust_pc() in another header. I guess this was done because > arch/arm64/kvm/arm.c will use the function in the next patch. That's mostly it. __kvm_adjust_pc() is very similar to __kvm_vcpu_run() in its usage, and I want to keep the patch as small as possible given that this is a candidate for a stable backport. > I was thinking that maybe renaming adjust_pc.h->skip_instr.h would > make more sense, what do you think? I can send a patch on top of > this series with the rename if you prefer. Yes, that'd probably be a good cleanup now that __adjust_pc() is gone. > > > + > > extern u64 __vgic_v3_get_gic_config(void); > > extern u64 __vgic_v3_read_vmcr(void); > > extern void __vgic_v3_write_vmcr(u32 vmcr); > > diff --git a/arch/arm64/kvm/hyp/exception.c b/arch/arm64/kvm/hyp/exception.c > > index 73629094f903..0812a496725f 100644 > > --- a/arch/arm64/kvm/hyp/exception.c > > +++ b/arch/arm64/kvm/hyp/exception.c > > @@ -296,7 +296,7 @@ static void enter_exception32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) > > *vcpu_pc(vcpu) = vect_offset; > > } > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu) > > +static void kvm_inject_exception(struct kvm_vcpu *vcpu) > > { > > if (vcpu_el1_is_32bit(vcpu)) { > > switch (vcpu->arch.flags & KVM_ARM64_EXCEPT_MASK) { > > @@ -329,3 +329,19 @@ void kvm_inject_exception(struct kvm_vcpu *vcpu) > > } > > } > > } > > + > > +/* > > + * Adjust the guest PC on entry, depending on flags provided by EL1 > > This is also called by the VHE code running at EL2, but the comment is reworded in > the next patch, so it doesn't really matter, and keeping the diff a straight move > makes it easier to read. > > > + * for the purpose of emulation (MMIO, sysreg) or exception injection. > > + */ > > +void __kvm_adjust_pc(struct kvm_vcpu *vcpu) > > +{ > > + if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > + kvm_inject_exception(vcpu); > > + vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > + KVM_ARM64_EXCEPT_MASK); > > + } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > + kvm_skip_instr(vcpu); > > + vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > + } > > +} > > diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > index 61716359035d..4fdfeabefeb4 100644 > > --- a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > @@ -13,8 +13,6 @@ > > #include > > #include > > > > -void kvm_inject_exception(struct kvm_vcpu *vcpu); > > - > > static inline void kvm_skip_instr(struct kvm_vcpu *vcpu) > > { > > if (vcpu_mode_is_32bit(vcpu)) { > > @@ -43,22 +41,6 @@ static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) > > write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); > > } > > > > -/* > > - * Adjust the guest PC on entry, depending on flags provided by EL1 > > - * for the purpose of emulation (MMIO, sysreg) or exception injection. > > - */ > > -static inline void __adjust_pc(struct kvm_vcpu *vcpu) > > -{ > > - if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) { > > - kvm_inject_exception(vcpu); > > - vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION | > > - KVM_ARM64_EXCEPT_MASK); > > - } else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) { > > - kvm_skip_instr(vcpu); > > - vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC; > > - } > > -} > > - > > /* > > * Skip an instruction while host sysregs are live. > > * Assumes host is always 64-bit. > > diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c > > index e9f6ea704d07..b8ac123c3419 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/switch.c > > +++ b/arch/arm64/kvm/hyp/nvhe/switch.c > > @@ -201,7 +201,7 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu) > > */ > > __debug_save_host_buffers_nvhe(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > > > /* > > * We must restore the 32-bit state before the sysregs, thanks > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > > index 7b8f7db5c1ed..3eafed0431f5 100644 > > --- a/arch/arm64/kvm/hyp/vhe/switch.c > > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > > @@ -132,7 +132,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) > > __load_guest_stage2(vcpu->arch.hw_mmu); > > __activate_traps(vcpu); > > > > - __adjust_pc(vcpu); > > + __kvm_adjust_pc(vcpu); > > With the function now moved to kvm_asm.h, the header include > adjust_pc.h is not needed. Same for the nvhe version of switch.c. Well spotted. I'll clean that up. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel