* [PATCH] KVM/VMX/SVM: Move kvm_machine_check function to x86.h
@ 2020-10-29 13:56 Uros Bizjak
2020-12-12 16:27 ` Uros Bizjak
0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2020-10-29 13:56 UTC (permalink / raw)
To: kvm; +Cc: Uros Bizjak, Paolo Bonzini, Sean Christopherson
Move kvm_machine_check to x86.h to avoid two exact copies
of the same function in kvm.c and svm.c.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
arch/x86/kvm/svm/svm.c | 20 --------------------
arch/x86/kvm/vmx/vmx.c | 20 --------------------
arch/x86/kvm/x86.h | 20 ++++++++++++++++++++
3 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 2f32fd09e259..f2ad59d19040 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -33,7 +33,6 @@
#include <asm/debugreg.h>
#include <asm/kvm_para.h>
#include <asm/irq_remapping.h>
-#include <asm/mce.h>
#include <asm/spec-ctrl.h>
#include <asm/cpu_device_id.h>
@@ -1929,25 +1928,6 @@ static bool is_erratum_383(void)
return true;
}
-/*
- * Trigger machine check on the host. We assume all the MSRs are already set up
- * by the CPU and that we still run on the same CPU as the MCE occurred on.
- * We pass a fake environment to the machine check handler because we want
- * the guest to be always treated like user space, no matter what context
- * it used internally.
- */
-static void kvm_machine_check(void)
-{
-#if defined(CONFIG_X86_MCE)
- struct pt_regs regs = {
- .cs = 3, /* Fake ring 3 no matter what the guest ran on */
- .flags = X86_EFLAGS_IF,
- };
-
- do_machine_check(®s);
-#endif
-}
-
static void svm_handle_mce(struct vcpu_svm *svm)
{
if (is_erratum_383()) {
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0f390c748b18..0329f09a2ca6 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -40,7 +40,6 @@
#include <asm/irq_remapping.h>
#include <asm/kexec.h>
#include <asm/perf_event.h>
-#include <asm/mce.h>
#include <asm/mmu_context.h>
#include <asm/mshyperv.h>
#include <asm/mwait.h>
@@ -4714,25 +4713,6 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
return 1;
}
-/*
- * Trigger machine check on the host. We assume all the MSRs are already set up
- * by the CPU and that we still run on the same CPU as the MCE occurred on.
- * We pass a fake environment to the machine check handler because we want
- * the guest to be always treated like user space, no matter what context
- * it used internally.
- */
-static void kvm_machine_check(void)
-{
-#if defined(CONFIG_X86_MCE)
- struct pt_regs regs = {
- .cs = 3, /* Fake ring 3 no matter what the guest ran on */
- .flags = X86_EFLAGS_IF,
- };
-
- do_machine_check(®s);
-#endif
-}
-
static int handle_machine_check(struct kvm_vcpu *vcpu)
{
/* handled by vmx_vcpu_run() */
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 3900ab0c6004..e1bde3f3f2d5 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -3,6 +3,7 @@
#define ARCH_X86_KVM_X86_H
#include <linux/kvm_host.h>
+#include <asm/mce.h>
#include <asm/pvclock.h>
#include "kvm_cache_regs.h"
#include "kvm_emulate.h"
@@ -366,6 +367,25 @@ static inline bool kvm_dr6_valid(u64 data)
return !(data >> 32);
}
+/*
+ * Trigger machine check on the host. We assume all the MSRs are already set up
+ * by the CPU and that we still run on the same CPU as the MCE occurred on.
+ * We pass a fake environment to the machine check handler because we want
+ * the guest to be always treated like user space, no matter what context
+ * it used internally.
+ */
+static inline void kvm_machine_check(void)
+{
+#if defined(CONFIG_X86_MCE)
+ struct pt_regs regs = {
+ .cs = 3, /* Fake ring 3 no matter what the guest ran on */
+ .flags = X86_EFLAGS_IF,
+ };
+
+ do_machine_check(®s);
+#endif
+}
+
void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu);
void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu);
int kvm_spec_ctrl_test_value(u64 value);
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM/VMX/SVM: Move kvm_machine_check function to x86.h
2020-10-29 13:56 [PATCH] KVM/VMX/SVM: Move kvm_machine_check function to x86.h Uros Bizjak
@ 2020-12-12 16:27 ` Uros Bizjak
2020-12-14 11:36 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2020-12-12 16:27 UTC (permalink / raw)
To: kvm; +Cc: Paolo Bonzini, Sean Christopherson
Ping. This relatively simple patch didn't receive any feedback.
Uros.
On Thu, Oct 29, 2020 at 2:56 PM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> Move kvm_machine_check to x86.h to avoid two exact copies
> of the same function in kvm.c and svm.c.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> ---
> arch/x86/kvm/svm/svm.c | 20 --------------------
> arch/x86/kvm/vmx/vmx.c | 20 --------------------
> arch/x86/kvm/x86.h | 20 ++++++++++++++++++++
> 3 files changed, 20 insertions(+), 40 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 2f32fd09e259..f2ad59d19040 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -33,7 +33,6 @@
> #include <asm/debugreg.h>
> #include <asm/kvm_para.h>
> #include <asm/irq_remapping.h>
> -#include <asm/mce.h>
> #include <asm/spec-ctrl.h>
> #include <asm/cpu_device_id.h>
>
> @@ -1929,25 +1928,6 @@ static bool is_erratum_383(void)
> return true;
> }
>
> -/*
> - * Trigger machine check on the host. We assume all the MSRs are already set up
> - * by the CPU and that we still run on the same CPU as the MCE occurred on.
> - * We pass a fake environment to the machine check handler because we want
> - * the guest to be always treated like user space, no matter what context
> - * it used internally.
> - */
> -static void kvm_machine_check(void)
> -{
> -#if defined(CONFIG_X86_MCE)
> - struct pt_regs regs = {
> - .cs = 3, /* Fake ring 3 no matter what the guest ran on */
> - .flags = X86_EFLAGS_IF,
> - };
> -
> - do_machine_check(®s);
> -#endif
> -}
> -
> static void svm_handle_mce(struct vcpu_svm *svm)
> {
> if (is_erratum_383()) {
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 0f390c748b18..0329f09a2ca6 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -40,7 +40,6 @@
> #include <asm/irq_remapping.h>
> #include <asm/kexec.h>
> #include <asm/perf_event.h>
> -#include <asm/mce.h>
> #include <asm/mmu_context.h>
> #include <asm/mshyperv.h>
> #include <asm/mwait.h>
> @@ -4714,25 +4713,6 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
> return 1;
> }
>
> -/*
> - * Trigger machine check on the host. We assume all the MSRs are already set up
> - * by the CPU and that we still run on the same CPU as the MCE occurred on.
> - * We pass a fake environment to the machine check handler because we want
> - * the guest to be always treated like user space, no matter what context
> - * it used internally.
> - */
> -static void kvm_machine_check(void)
> -{
> -#if defined(CONFIG_X86_MCE)
> - struct pt_regs regs = {
> - .cs = 3, /* Fake ring 3 no matter what the guest ran on */
> - .flags = X86_EFLAGS_IF,
> - };
> -
> - do_machine_check(®s);
> -#endif
> -}
> -
> static int handle_machine_check(struct kvm_vcpu *vcpu)
> {
> /* handled by vmx_vcpu_run() */
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index 3900ab0c6004..e1bde3f3f2d5 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -3,6 +3,7 @@
> #define ARCH_X86_KVM_X86_H
>
> #include <linux/kvm_host.h>
> +#include <asm/mce.h>
> #include <asm/pvclock.h>
> #include "kvm_cache_regs.h"
> #include "kvm_emulate.h"
> @@ -366,6 +367,25 @@ static inline bool kvm_dr6_valid(u64 data)
> return !(data >> 32);
> }
>
> +/*
> + * Trigger machine check on the host. We assume all the MSRs are already set up
> + * by the CPU and that we still run on the same CPU as the MCE occurred on.
> + * We pass a fake environment to the machine check handler because we want
> + * the guest to be always treated like user space, no matter what context
> + * it used internally.
> + */
> +static inline void kvm_machine_check(void)
> +{
> +#if defined(CONFIG_X86_MCE)
> + struct pt_regs regs = {
> + .cs = 3, /* Fake ring 3 no matter what the guest ran on */
> + .flags = X86_EFLAGS_IF,
> + };
> +
> + do_machine_check(®s);
> +#endif
> +}
> +
> void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu);
> void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu);
> int kvm_spec_ctrl_test_value(u64 value);
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM/VMX/SVM: Move kvm_machine_check function to x86.h
2020-12-12 16:27 ` Uros Bizjak
@ 2020-12-14 11:36 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-12-14 11:36 UTC (permalink / raw)
To: Uros Bizjak, kvm; +Cc: Sean Christopherson
On 12/12/20 17:27, Uros Bizjak wrote:
> Move kvm_machine_check to x86.h to avoid two exact copies
Queued, thanks for your patience.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-14 11:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 13:56 [PATCH] KVM/VMX/SVM: Move kvm_machine_check function to x86.h Uros Bizjak
2020-12-12 16:27 ` Uros Bizjak
2020-12-14 11:36 ` Paolo Bonzini
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.