Re: [PATCH v2 09/13] KVM: x86: Move kvm_emulate.h into KVM's private directory

From: Vitaly Kuznetsov
Date: Wed Feb 26 2020 - 12:38:16 EST


Sean Christopherson <sean.j.christopherson@xxxxxxxxx> writes:

> Now that the emulation context is dynamically allocated and not embedded
> in struct kvm_vcpu, move its header, kvm_emulate.h, out of the public
> asm directory and into KVM's private x86 directory.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> ---
> arch/x86/include/asm/kvm_host.h | 5 ++++-
> arch/x86/kvm/emulate.c | 2 +-
> arch/x86/{include/asm => kvm}/kvm_emulate.h | 0
> arch/x86/kvm/mmu/mmu.c | 1 +
> arch/x86/kvm/x86.c | 1 +
> arch/x86/kvm/x86.h | 1 +
> 6 files changed, 8 insertions(+), 2 deletions(-)
> rename arch/x86/{include/asm => kvm}/kvm_emulate.h (100%)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index e069f71667b1..0dfe11f30d7f 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -182,7 +182,10 @@ enum exit_fastpath_completion {
> EXIT_FASTPATH_SKIP_EMUL_INS,
> };
>
> -#include <asm/kvm_emulate.h>
> +struct x86_emulate_ctxt;

Not this patchset's problem (and particular forward declaration is
likely needed), but

$ grep 'struct x86_emulate_ctxt' arch/x86/include/asm/kvm_host.h
struct x86_emulate_ctxt;
struct x86_emulate_ctxt *emulate_ctxt;
struct x86_emulate_ctxt;

The second forward declaration is not needed and this patch (or
patchset) may be a good place to get rid of it)

> +struct x86_exception;
> +enum x86_intercept;
> +enum x86_intercept_stage;
>
> #define KVM_NR_MEM_OBJS 40
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 1e394cb190ce..0bceb3f71220 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -20,7 +20,7 @@
>
> #include <linux/kvm_host.h>
> #include "kvm_cache_regs.h"
> -#include <asm/kvm_emulate.h>
> +#include "kvm_emulate.h"
> #include <linux/stringify.h>
> #include <asm/fpu/api.h>
> #include <asm/debugreg.h>
> diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
> similarity index 100%
> rename from arch/x86/include/asm/kvm_emulate.h
> rename to arch/x86/kvm/kvm_emulate.h
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 7011a4e54866..d9064be28089 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -19,6 +19,7 @@
> #include "mmu.h"
> #include "x86.h"
> #include "kvm_cache_regs.h"
> +#include "kvm_emulate.h"
> #include "cpuid.h"
>
> #include <linux/kvm_host.h>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 5ab7d4283185..370af9fe0f5b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -22,6 +22,7 @@
> #include "i8254.h"
> #include "tss.h"
> #include "kvm_cache_regs.h"
> +#include "kvm_emulate.h"
> #include "x86.h"
> #include "cpuid.h"
> #include "pmu.h"
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index 8409842a25d9..f3c6e55eb5d9 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -5,6 +5,7 @@
> #include <linux/kvm_host.h>
> #include <asm/pvclock.h>
> #include "kvm_cache_regs.h"
> +#include "kvm_emulate.h"
>
> #define KVM_DEFAULT_PLE_GAP 128
> #define KVM_VMX_DEFAULT_PLE_WINDOW 4096

Reviewed-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>

--
Vitaly