From: Quentin Perret <qperret@google.com>
To: Fuad Tabba <tabba@google.com>
Cc: kernel-team@android.com, kvm@vger.kernel.org, maz@kernel.org,
will@kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC PATCH v1 11/30] KVM: arm64: create and use a new vcpu_hyp_state struct
Date: Mon, 27 Sep 2021 17:32:09 +0100 [thread overview]
Message-ID: <YVHyCW+D0M3U2Llu@google.com> (raw)
In-Reply-To: <20210924125359.2587041-12-tabba@google.com>
On Friday 24 Sep 2021 at 13:53:40 (+0100), Fuad Tabba wrote:
> Create a struct for the hypervisor state from the related fields
> in vcpu_arch. This is needed in future patches to reduce the
> scope of functions from the vcpu as a whole to only the relevant
> state, via this newly created struct.
>
> Create a new instance of this struct in vcpu_arch and fix the
> accessors to use the new fields. Remove the existing fields from
> vcpu_arch.
>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/include/asm/kvm_host.h | 35 ++++++++++++++++++-------------
> arch/arm64/kernel/asm-offsets.c | 2 +-
> 2 files changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 3e5c173d2360..dc4b5e133d86 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -269,27 +269,35 @@ struct vcpu_reset_state {
> bool reset;
> };
>
> +/* Holds the hyp-relevant data of a vcpu.*/
> +struct vcpu_hyp_state {
> + /* HYP configuration */
> + u64 hcr_el2;
> + u32 mdcr_el2;
> +
> + /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> + u64 vsesr_el2;
> +
> + /* Exception Information */
> + struct kvm_vcpu_fault_info fault;
> +
> + /* Miscellaneous vcpu state flags */
> + u64 flags;
> +};
> +
> struct kvm_vcpu_arch {
> struct kvm_cpu_context ctxt;
> void *sve_state;
> unsigned int sve_max_vl;
>
> + struct vcpu_hyp_state hyp_state;
> +
> /* Stage 2 paging state used by the hardware on next switch */
> struct kvm_s2_mmu *hw_mmu;
>
> - /* HYP configuration */
> - u64 hcr_el2;
> - u32 mdcr_el2;
> -
> - /* Exception Information */
> - struct kvm_vcpu_fault_info fault;
> -
> /* State of various workarounds, see kvm_asm.h for bit assignment */
> u64 workaround_flags;
>
> - /* Miscellaneous vcpu state flags */
> - u64 flags;
> -
> /*
> * We maintain more than a single set of debug registers to support
> * debugging the guest from the host and to maintain separate host and
> @@ -356,9 +364,6 @@ struct kvm_vcpu_arch {
> /* Detect first run of a vcpu */
> bool has_run_once;
>
> - /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> - u64 vsesr_el2;
> -
> /* Additional reset state */
> struct vcpu_reset_state reset_state;
>
> @@ -373,7 +378,7 @@ struct kvm_vcpu_arch {
> } steal;
> };
>
> -#define hyp_state(vcpu) ((vcpu)->arch)
> +#define hyp_state(vcpu) ((vcpu)->arch.hyp_state)
Aha, so _that_ is the nice thing about the previous patches ... I need
to stare at this series for a little longer, but wouldn't it be easier
to simply apply the struct kvm_vcpu_arch change and fixup all the users
at once instead of having all these preparatory patches? It's probably
personal preference at this point, but I must admit I'm finding all
these layers of accessors a little confusing. Happy to hear what others
think.
Thanks,
Quentin
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Quentin Perret <qperret@google.com>
To: Fuad Tabba <tabba@google.com>
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 11/30] KVM: arm64: create and use a new vcpu_hyp_state struct
Date: Mon, 27 Sep 2021 17:32:09 +0100 [thread overview]
Message-ID: <YVHyCW+D0M3U2Llu@google.com> (raw)
In-Reply-To: <20210924125359.2587041-12-tabba@google.com>
On Friday 24 Sep 2021 at 13:53:40 (+0100), Fuad Tabba wrote:
> Create a struct for the hypervisor state from the related fields
> in vcpu_arch. This is needed in future patches to reduce the
> scope of functions from the vcpu as a whole to only the relevant
> state, via this newly created struct.
>
> Create a new instance of this struct in vcpu_arch and fix the
> accessors to use the new fields. Remove the existing fields from
> vcpu_arch.
>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/include/asm/kvm_host.h | 35 ++++++++++++++++++-------------
> arch/arm64/kernel/asm-offsets.c | 2 +-
> 2 files changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 3e5c173d2360..dc4b5e133d86 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -269,27 +269,35 @@ struct vcpu_reset_state {
> bool reset;
> };
>
> +/* Holds the hyp-relevant data of a vcpu.*/
> +struct vcpu_hyp_state {
> + /* HYP configuration */
> + u64 hcr_el2;
> + u32 mdcr_el2;
> +
> + /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> + u64 vsesr_el2;
> +
> + /* Exception Information */
> + struct kvm_vcpu_fault_info fault;
> +
> + /* Miscellaneous vcpu state flags */
> + u64 flags;
> +};
> +
> struct kvm_vcpu_arch {
> struct kvm_cpu_context ctxt;
> void *sve_state;
> unsigned int sve_max_vl;
>
> + struct vcpu_hyp_state hyp_state;
> +
> /* Stage 2 paging state used by the hardware on next switch */
> struct kvm_s2_mmu *hw_mmu;
>
> - /* HYP configuration */
> - u64 hcr_el2;
> - u32 mdcr_el2;
> -
> - /* Exception Information */
> - struct kvm_vcpu_fault_info fault;
> -
> /* State of various workarounds, see kvm_asm.h for bit assignment */
> u64 workaround_flags;
>
> - /* Miscellaneous vcpu state flags */
> - u64 flags;
> -
> /*
> * We maintain more than a single set of debug registers to support
> * debugging the guest from the host and to maintain separate host and
> @@ -356,9 +364,6 @@ struct kvm_vcpu_arch {
> /* Detect first run of a vcpu */
> bool has_run_once;
>
> - /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> - u64 vsesr_el2;
> -
> /* Additional reset state */
> struct vcpu_reset_state reset_state;
>
> @@ -373,7 +378,7 @@ struct kvm_vcpu_arch {
> } steal;
> };
>
> -#define hyp_state(vcpu) ((vcpu)->arch)
> +#define hyp_state(vcpu) ((vcpu)->arch.hyp_state)
Aha, so _that_ is the nice thing about the previous patches ... I need
to stare at this series for a little longer, but wouldn't it be easier
to simply apply the struct kvm_vcpu_arch change and fixup all the users
at once instead of having all these preparatory patches? It's probably
personal preference at this point, but I must admit I'm finding all
these layers of accessors a little confusing. Happy to hear what others
think.
Thanks,
Quentin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Quentin Perret <qperret@google.com>
To: Fuad Tabba <tabba@google.com>
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 11/30] KVM: arm64: create and use a new vcpu_hyp_state struct
Date: Mon, 27 Sep 2021 17:32:09 +0100 [thread overview]
Message-ID: <YVHyCW+D0M3U2Llu@google.com> (raw)
In-Reply-To: <20210924125359.2587041-12-tabba@google.com>
On Friday 24 Sep 2021 at 13:53:40 (+0100), Fuad Tabba wrote:
> Create a struct for the hypervisor state from the related fields
> in vcpu_arch. This is needed in future patches to reduce the
> scope of functions from the vcpu as a whole to only the relevant
> state, via this newly created struct.
>
> Create a new instance of this struct in vcpu_arch and fix the
> accessors to use the new fields. Remove the existing fields from
> vcpu_arch.
>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/include/asm/kvm_host.h | 35 ++++++++++++++++++-------------
> arch/arm64/kernel/asm-offsets.c | 2 +-
> 2 files changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 3e5c173d2360..dc4b5e133d86 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -269,27 +269,35 @@ struct vcpu_reset_state {
> bool reset;
> };
>
> +/* Holds the hyp-relevant data of a vcpu.*/
> +struct vcpu_hyp_state {
> + /* HYP configuration */
> + u64 hcr_el2;
> + u32 mdcr_el2;
> +
> + /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> + u64 vsesr_el2;
> +
> + /* Exception Information */
> + struct kvm_vcpu_fault_info fault;
> +
> + /* Miscellaneous vcpu state flags */
> + u64 flags;
> +};
> +
> struct kvm_vcpu_arch {
> struct kvm_cpu_context ctxt;
> void *sve_state;
> unsigned int sve_max_vl;
>
> + struct vcpu_hyp_state hyp_state;
> +
> /* Stage 2 paging state used by the hardware on next switch */
> struct kvm_s2_mmu *hw_mmu;
>
> - /* HYP configuration */
> - u64 hcr_el2;
> - u32 mdcr_el2;
> -
> - /* Exception Information */
> - struct kvm_vcpu_fault_info fault;
> -
> /* State of various workarounds, see kvm_asm.h for bit assignment */
> u64 workaround_flags;
>
> - /* Miscellaneous vcpu state flags */
> - u64 flags;
> -
> /*
> * We maintain more than a single set of debug registers to support
> * debugging the guest from the host and to maintain separate host and
> @@ -356,9 +364,6 @@ struct kvm_vcpu_arch {
> /* Detect first run of a vcpu */
> bool has_run_once;
>
> - /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
> - u64 vsesr_el2;
> -
> /* Additional reset state */
> struct vcpu_reset_state reset_state;
>
> @@ -373,7 +378,7 @@ struct kvm_vcpu_arch {
> } steal;
> };
>
> -#define hyp_state(vcpu) ((vcpu)->arch)
> +#define hyp_state(vcpu) ((vcpu)->arch.hyp_state)
Aha, so _that_ is the nice thing about the previous patches ... I need
to stare at this series for a little longer, but wouldn't it be easier
to simply apply the struct kvm_vcpu_arch change and fixup all the users
at once instead of having all these preparatory patches? It's probably
personal preference at this point, but I must admit I'm finding all
these layers of accessors a little confusing. Happy to hear what others
think.
Thanks,
Quentin
next prev parent reply other threads:[~2021-09-27 16:32 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 12:53 [RFC PATCH v1 00/30] Reduce scope of vcpu state at hyp by refactoring out state hyp needs Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 01/30] KVM: arm64: placeholder to check if VM is protected Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-27 15:50 ` Quentin Perret
2021-09-27 15:50 ` Quentin Perret
2021-09-27 15:50 ` Quentin Perret
2021-09-24 12:53 ` [RFC PATCH v1 02/30] [DONOTMERGE] Temporarily disable unused variable warning Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 03/30] [DONOTMERGE] Coccinelle scripts for refactoring Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 04/30] KVM: arm64: remove unused parameters and asm offsets Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 05/30] KVM: arm64: add accessors for kvm_cpu_context Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-27 15:57 ` Quentin Perret
2021-09-27 15:57 ` Quentin Perret
2021-09-27 15:57 ` Quentin Perret
2021-09-24 12:53 ` [RFC PATCH v1 06/30] KVM: arm64: COCCI: use_ctxt_access.cocci: use kvm_cpu_context accessors Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 07/30] KVM: arm64: COCCI: add_ctxt.cocci use_ctxt.cocci: reduce scope of functions to kvm_cpu_ctxt Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 08/30] KVM: arm64: add hypervisor state accessors Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 09/30] KVM: arm64: COCCI: vcpu_hyp_accessors.cocci: use accessors for hypervisor state vcpu variables Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 10/30] KVM: arm64: Add accessors for hypervisor state in kvm_vcpu_arch Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-27 16:10 ` Quentin Perret
2021-09-27 16:10 ` Quentin Perret
2021-09-27 16:10 ` Quentin Perret
2021-09-24 12:53 ` [RFC PATCH v1 11/30] KVM: arm64: create and use a new vcpu_hyp_state struct Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-27 16:32 ` Quentin Perret [this message]
2021-09-27 16:32 ` Quentin Perret
2021-09-27 16:32 ` Quentin Perret
2021-09-24 12:53 ` [RFC PATCH v1 12/30] KVM: arm64: COCCI: add_hypstate.cocci use_hypstate.cocci: Reduce scope of functions to hyp_state Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-27 16:40 ` Quentin Perret
2021-09-27 16:40 ` Quentin Perret
2021-09-27 16:40 ` Quentin Perret
2021-09-24 12:53 ` [RFC PATCH v1 13/30] KVM: arm64: change function parameters to use kvm_cpu_ctxt and hyp_state Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 14/30] KVM: arm64: reduce scope of vgic v2 Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 15/30] KVM: arm64: COCCI: vgic3_cpu.cocci: reduce scope of vgic v3 Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 16/30] KVM: arm64: reduce scope of vgic_v3 access parameters Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 17/30] KVM: arm64: access __hyp_running_vcpu via accessors only Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 18/30] KVM: arm64: reduce scope of __guest_exit to only depend on kvm_cpu_context Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 19/30] KVM: arm64: change calls of get_loaded_vcpu to get_loaded_vcpu_ctxt Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 20/30] KVM: arm64: add __hyp_running_ctxt and __hyp_running_hyps Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 21/30] KVM: arm64: transition code to " Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 22/30] KVM: arm64: reduce scope of __guest_enter to depend only on kvm_cpu_ctxt Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 23/30] KVM: arm64: COCCI: remove_unused.cocci: remove unused ctxt and hypstate variables Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 24/30] KVM: arm64: remove unused functions Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 25/30] KVM: arm64: separate kvm_run() for protected VMs Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 26/30] KVM: arm64: pVM activate_traps to use vcpu_ctxt and vcpu_hyp_state Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 27/30] KVM: arm64: remove unsupported pVM features Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 28/30] KVM: arm64: reduce scope of pVM fixup_guest_exit to hyp_state and kvm_cpu_ctxt Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 29/30] [DONOTMERGE] Remove Coccinelle scripts added for refactoring Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` [RFC PATCH v1 30/30] [DONOTMERGE] Re-enable warnings Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
2021-09-24 12:53 ` Fuad Tabba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YVHyCW+D0M3U2Llu@google.com \
--to=qperret@google.com \
--cc=kernel-team@android.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=tabba@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.