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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AA81C433FE for ; Mon, 27 Sep 2021 16:12:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 48A5460F4A for ; Mon, 27 Sep 2021 16:12:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 48A5460F4A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zPssnG7VSZ5viSkIQ2tLy2omUgSvO6tfjM+FRfam5x0=; b=i2scecfCTXhYQK jxf93JWp/7UT1Z2/jGEBCdXMr7GUJ3FxtO3/NPmCzDLuqMrIVDd1eMQLYw7mlYDmPYAsekTO6BzMA zX/G7NzuqVgMzYEPEeqamwiXqZYfmAzh8LYxBHjSPDjaOtKa9Kpz8HIi7flbZZw4TRkAKcu2twYm0 7d+Mf8yweeC/NlOxGMkfaIrGNPipp/wQfwTqHRrH5tcOvg/btqgvA4LAoAmB2KGusu3EOC2IA7Ej/ T/WR8U8VPTw8lBYAdmAa/yAcVIGOHb4i0bRanrThL78+Ht0e/vEaZBFSir5gM2b0LyZ6LG4xRUFO7 HHEJbAzUQP+nBdD7nmcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUtDV-003KHW-DH; Mon, 27 Sep 2021 16:10:57 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUtDR-003KGj-B4 for linux-arm-kernel@lists.infradead.org; Mon, 27 Sep 2021 16:10:54 +0000 Received: by mail-wr1-x435.google.com with SMTP id g16so52911749wrb.3 for ; Mon, 27 Sep 2021 09:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tzYLDWLzrX157HH12ds8As0JD+WbAz+wC4M9zHAPsb0=; b=n0w9qX8LHDnB4PmprGBttwqCfsRmgViG9pnT1tI3UB/RLI5V7pij8YoHVV1N96Csx3 5Oc3pgzbN1YsZLtwHhz7lHqpzGmUb1rlPFGT6EIyKQlmv9gzFIZa8Ey4Yn+R2LqrJJTI M+dcjV+aVR6gcSrrQNMAoxHr0QZwy/7gtFK6Q6z+I5Aev7Dvzg1gZrtMBUJ9U8Rv8Yaf KXKtquvuyLYSRk610QxpffujK0GUfZKg3WEdjTkao6KXksFMF/wPxw6L6SOpkaag1XWb Dz9Wt8S/mNzE+ojf1Cjv+Hs5wEogMohRrUI4EW5xYi89Pe8I2NiGwOWvMVjyFs6oBoPT 78UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tzYLDWLzrX157HH12ds8As0JD+WbAz+wC4M9zHAPsb0=; b=KzvCdObGJ//uoS1Vc3ZWo4FlKEELSicmwN2iBCNWiHHSSg5BQ3iXq+sBtF8FdaJ2cw Z6xO0veN3ZQf7PzqPTJQIQtPhs6GNoVJnChPhNvOImxN1zUFuk3uoh99+anEEM8dqB5j e7HPbXgHvlQbMfM8ouBzQsTWF3SO2USBUuJ2dsJeMLDBEywQqbH9EjAs36p5S03p5b7z qnTscVFYwM5cR+3/CytlR6141+OWrDWZ7uS8SEKtFSAZhsIQZqq0gW2A9U76QfdbJ6HZ JKkE6R9461n0OcBa39xvnt9Tzctm+alR0detPjDUBLtrIIR314RZfc6+phH3qbKGAqW5 wbEQ== X-Gm-Message-State: AOAM533K75CdiBTmuepQ5vDjVwaTyKpXjruflNloDshjGnZkeOZN5DY1 kcq2RqiKlN/sfyhzfEZa2TMV0w== X-Google-Smtp-Source: ABdhPJzK6sQGveEJG3lj86y73aLzjzcH6Iuz+0g1A3pJ41wIOKXBBXYwNJkzpO76TGfOUgstN+/AYw== X-Received: by 2002:adf:dd42:: with SMTP id u2mr750952wrm.39.1632759051410; Mon, 27 Sep 2021 09:10:51 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:fa68:b369:184:c5a]) by smtp.gmail.com with ESMTPSA id n14sm15314452wmc.38.2021.09.27.09.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 09:10:51 -0700 (PDT) Date: Mon, 27 Sep 2021 17:10:48 +0100 From: Quentin Perret To: Fuad Tabba Cc: kvmarm@lists.cs.columbia.edu, maz@kernel.org, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, christoffer.dall@arm.com, drjones@redhat.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com Subject: Re: [RFC PATCH v1 10/30] KVM: arm64: Add accessors for hypervisor state in kvm_vcpu_arch Message-ID: References: <20210924125359.2587041-1-tabba@google.com> <20210924125359.2587041-11-tabba@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210924125359.2587041-11-tabba@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210927_091053_408388_4086B796 X-CRM114-Status: GOOD ( 21.08 ) 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 Friday 24 Sep 2021 at 13:53:39 (+0100), Fuad Tabba wrote: > Some of the members of vcpu_arch represent state that belongs to > the hypervisor. Future patches will factor these out into their > own structure. To simplify the refactoring and make it easier to > read, add accessors for the members of kvm_vcpu_arch that > represent the hypervisor state. > > Signed-off-by: Fuad Tabba > --- > arch/arm64/include/asm/kvm_emulate.h | 182 ++++++++++++++++++++++----- > arch/arm64/include/asm/kvm_host.h | 38 ++++-- > 2 files changed, 181 insertions(+), 39 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h > index 7d09a9356d89..e095afeecd10 100644 > --- a/arch/arm64/include/asm/kvm_emulate.h > +++ b/arch/arm64/include/asm/kvm_emulate.h > @@ -41,9 +41,14 @@ void kvm_inject_vabt(struct kvm_vcpu *vcpu); > void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr); > void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr); > > +static __always_inline bool hyp_state_el1_is_32bit(struct vcpu_hyp_state *vcpu_hyps) > +{ > + return !(hyp_state_hcr_el2(vcpu_hyps) & HCR_RW); > +} > + > static __always_inline bool vcpu_el1_is_32bit(struct kvm_vcpu *vcpu) > { > - return !(vcpu_hcr_el2(vcpu) & HCR_RW); > + return hyp_state_el1_is_32bit(&hyp_state(vcpu)); > } > > static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu) > @@ -252,14 +257,19 @@ static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu) > return mode != PSR_MODE_EL0t; > } > > +static __always_inline u32 kvm_hyp_state_get_esr(const struct vcpu_hyp_state *vcpu_hyps) > +{ > + return hyp_state_fault(vcpu_hyps).esr_el2; > +} > + > static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu) > { > - return vcpu_fault(vcpu).esr_el2; > + return kvm_hyp_state_get_esr(&hyp_state(vcpu)); > } > > -static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > +static __always_inline u32 kvm_hyp_state_get_condition(const struct vcpu_hyp_state *vcpu_hyps) > { > - u32 esr = kvm_vcpu_get_esr(vcpu); > + u32 esr = kvm_hyp_state_get_esr(vcpu_hyps); > > if (esr & ESR_ELx_CV) > return (esr & ESR_ELx_COND_MASK) >> ESR_ELx_COND_SHIFT; > @@ -267,111 +277,216 @@ static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > return -1; > } > > +static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > +{ > + return kvm_hyp_state_get_condition(&hyp_state(vcpu)); > +} > + > +static __always_inline phys_addr_t kvm_hyp_state_get_hfar(const struct vcpu_hyp_state *vcpu_hyps) > +{ > + return hyp_state_fault(vcpu_hyps).far_el2; > +} > + > static __always_inline unsigned long kvm_vcpu_get_hfar(const struct kvm_vcpu *vcpu) > { > - return vcpu_fault(vcpu).far_el2; > + return kvm_hyp_state_get_hfar(&hyp_state(vcpu)); > +} > + > +static __always_inline phys_addr_t kvm_hyp_state_get_fault_ipa(const struct vcpu_hyp_state *vcpu_hyps) > +{ > + return ((phys_addr_t) hyp_state_fault(vcpu_hyps).hpfar_el2 & HPFAR_MASK) << 8; > } > > static __always_inline phys_addr_t kvm_vcpu_get_fault_ipa(const struct kvm_vcpu *vcpu) > { > - return ((phys_addr_t) vcpu_fault(vcpu).hpfar_el2 & HPFAR_MASK) << 8; > + return kvm_hyp_state_get_fault_ipa(&hyp_state(vcpu)); > +} > + > +static __always_inline u32 kvm_hyp_state_get_disr(const struct vcpu_hyp_state *vcpu_hyps) > +{ > + return hyp_state_fault(vcpu_hyps).disr_el1; > } Looks like kvm_hyp_state_get_disr() (as well as most of the kvm_hyp_state_*() helpers below) are never used outside of their kvm_vcpu_*() counterparts, so maybe let's merge them for now? This series is really quite large, so I'm just hoping we can trim a bit the bits that aren't strictly necessary :) Cheers, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel