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=-13.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 4EF54C388F9 for ; Tue, 27 Oct 2020 10:56:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 D918D22258 for ; Tue, 27 Oct 2020 10:56:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D/ZGCgHP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D918D22258 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1hi6Mfhk0Ao+2Bq6kvd/H/9IW24Kw5clyT/MvgpI9zM=; b=D/ZGCgHP1PDdB2uH6Zzdi8FtA IY9Am9c6qR3jaK6GlrnpLfl2bOCkA9gfg91iV4hdLiOYzQvWBigMaz0L9Y6hVfH/IbXy7d5HKP7R6 FeOXkJUJDtrUKVvTYNQ56Xkv6aFznTC5ONDpcDGyd2N6Tk/OLLHzBFR2ujyQutGeg+8r3Buhh2mrU cizigPkPNCY+8eLGZGd6E5K3vc/czRbjhjV8dr4qfpYBIPNc0j1iaZzWwfzK5Bi8+IIr/Dc49sqAG TzXui+TT6OYxTdKD6f9n6rbgEX2pipIbJRAMljJYJouprsYnobLw59I0wx1p/8zwlsnA14Q3046oa LNeVqkQvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXMdl-000592-KE; Tue, 27 Oct 2020 10:55:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXMdi-00058N-Bw for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2020 10:55:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B5CCC30E; Tue, 27 Oct 2020 03:55:40 -0700 (PDT) Received: from [10.57.18.142] (unknown [10.57.18.142]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E91A53F66E; Tue, 27 Oct 2020 03:55:38 -0700 (PDT) Subject: Re: [PATCH 03/11] KVM: arm64: Make kvm_skip_instr() and co private to HYP To: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org References: <20201026133450.73304-1-maz@kernel.org> <20201026133450.73304-4-maz@kernel.org> From: Suzuki K Poulose Message-ID: Date: Tue, 27 Oct 2020 10:55:37 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201026133450.73304-4-maz@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201027_065542_543284_9BD3FFF6 X-CRM114-Status: GOOD ( 27.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Quentin Perret , kernel-team@android.com, James Morse , Andrew Scull , David Brazdil , Will Deacon , Julien Thierry Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/26/20 1:34 PM, Marc Zyngier wrote: > In an effort to remove the vcpu PC manipulations from EL1 on nVHE > systems, move kvm_skip_instr() to be HYP-specific. EL1's intent > to increment PC post emulation is now signalled via a flag in the > vcpu structure. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/include/asm/kvm_emulate.h | 27 +---------- > arch/arm64/include/asm/kvm_host.h | 1 + > arch/arm64/kvm/handle_exit.c | 6 +-- > arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 56 ++++++++++++++++++++++ > arch/arm64/kvm/hyp/include/hyp/switch.h | 2 + > arch/arm64/kvm/hyp/nvhe/switch.c | 3 ++ > arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 + > arch/arm64/kvm/hyp/vgic-v3-sr.c | 2 + > arch/arm64/kvm/hyp/vhe/switch.c | 3 ++ > arch/arm64/kvm/mmio.c | 2 +- > arch/arm64/kvm/mmu.c | 2 +- > arch/arm64/kvm/sys_regs.c | 2 +- > 12 files changed, 77 insertions(+), 31 deletions(-) > create mode 100644 arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > > diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h > index 0864f425547d..6d2b5d1aa7b3 100644 > --- a/arch/arm64/include/asm/kvm_emulate.h > +++ b/arch/arm64/include/asm/kvm_emulate.h > @@ -472,32 +472,9 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, > return data; /* Leave LE untouched */ > } > > -static __always_inline void kvm_skip_instr(struct kvm_vcpu *vcpu) > +static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu) > { > - if (vcpu_mode_is_32bit(vcpu)) { > - kvm_skip_instr32(vcpu); > - } else { > - *vcpu_pc(vcpu) += 4; > - *vcpu_cpsr(vcpu) &= ~PSR_BTYPE_MASK; > - } > - > - /* advance the singlestep state machine */ > - *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS; > -} > - > -/* > - * Skip an instruction which has been emulated at hyp while most guest sysregs > - * are live. > - */ > -static __always_inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) > -{ > - *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); > - vcpu_gp_regs(vcpu)->pstate = read_sysreg_el2(SYS_SPSR); > - > - kvm_skip_instr(vcpu); > - > - write_sysreg_el2(vcpu_gp_regs(vcpu)->pstate, SYS_SPSR); > - write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); > + vcpu->arch.flags |= KVM_ARM64_INCREMENT_PC; > } > > #endif /* __ARM64_KVM_EMULATE_H__ */ > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 0aecbab6a7fb..9a75de3ad8da 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -406,6 +406,7 @@ struct kvm_vcpu_arch { > #define KVM_ARM64_GUEST_HAS_SVE (1 << 5) /* SVE exposed to guest */ > #define KVM_ARM64_VCPU_SVE_FINALIZED (1 << 6) /* SVE config completed */ > #define KVM_ARM64_GUEST_HAS_PTRAUTH (1 << 7) /* PTRAUTH exposed to guest */ > +#define KVM_ARM64_INCREMENT_PC (1 << 8) /* Increment PC */ > > #define vcpu_has_sve(vcpu) (system_supports_sve() && \ > ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE)) > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index 30bf8e22df54..d4e00a864ee6 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -61,7 +61,7 @@ static int handle_smc(struct kvm_vcpu *vcpu) > * otherwise return to the same address... > */ > vcpu_set_reg(vcpu, 0, ~0UL); > - kvm_skip_instr(vcpu); > + kvm_incr_pc(vcpu); > return 1; > } > > @@ -100,7 +100,7 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu) > kvm_clear_request(KVM_REQ_UNHALT, vcpu); > } > > - kvm_skip_instr(vcpu); > + kvm_incr_pc(vcpu); > > return 1; > } > @@ -221,7 +221,7 @@ static int handle_trap_exceptions(struct kvm_vcpu *vcpu) > * that fail their condition code check" > */ > if (!kvm_condition_valid(vcpu)) { > - kvm_skip_instr(vcpu); > + kvm_incr_pc(vcpu); > handled = 1; > } else { > exit_handle_fn exit_handler; > diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > new file mode 100644 > index 000000000000..4ecaf5cb2633 > --- /dev/null > +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h > @@ -0,0 +1,56 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Guest PC manipulation helpers > + * > + * Copyright (C) 2012,2013 - ARM Ltd > + * Copyright (C) 2020 - Google LLC > + * Author: Marc Zyngier > + */ > + > +#ifndef __ARM64_KVM_HYP_ADJUST_PC_H__ > +#define __ARM64_KVM_HYP_ADJUST_PC_H__ > + > +#include > +#include > + > +static inline void kvm_skip_instr(struct kvm_vcpu *vcpu) > +{ > + if (vcpu_mode_is_32bit(vcpu)) { > + kvm_skip_instr32(vcpu); > + } else { > + *vcpu_pc(vcpu) += 4; > + *vcpu_cpsr(vcpu) &= ~PSR_BTYPE_MASK; > + } > + > + /* advance the singlestep state machine */ > + *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS; > +} > + > +/* > + * Skip an instruction which has been emulated at hyp while most guest sysregs > + * are live. > + */ > +static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) > +{ > + *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); > + vcpu_gp_regs(vcpu)->pstate = read_sysreg_el2(SYS_SPSR); > + > + __kvm_skip_instr(vcpu); Did you mean kvm_skip_instr() instead ? Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel