arch/x86: Add the support of ACRN hypervisor under arch/x86
Subsystems (2)
cover arch/x86: Add the support of ACRN hypervisor under arch/x86
ACRN is a flexible, lightweight reference hypervisor, built with real-time and safety-criticality in mind, optimized to streamline embedded development through an open source platform. It is built for embedded IOT with small footprint and real-time features. More details can be found
in https://projectacrn.org/
This is the patch set that allows the Linux to work on ACRN hypervisor and it can work with the following patch set to manage the Linux guest on acrn-hypervisor. It includes the detection of acrn_hypervisor, upcall notification vector from hypervisor, hypercall. The hypervisor detection is similar to Xen/VMWARE/Hyperv. ACRN also uses the upcall notification mechanism similar to that in Xen/Microsoft HyperV when it needs to send the notification to Linux OS. The hypercall provides the mechanism that can be used to query/configure the acrn-hypervisor by Linux guest.
Following this patch set, we will send acrn driver part, which provides the interface that can be used to manage the virtualized CPU/memory/device/interrupt for other guest OS after the acrn hypervisor is detected.
Zhao Yakui (3):
arch/x86: add ACRN hypervisor guest
arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector arch/x86/acrn: add hypercall for acrn_hypervisor
arch/x86/Kconfig | 8 ++++ arch/x86/entry/entry_64.S | 5 +++ arch/x86/include/asm/acrn_hypercall.h | 85 +++++++++++++++++++++++++++++++++++ arch/x86/include/asm/acrnhyper.h | 18 ++++++++ arch/x86/include/asm/hardirq.h | 2 +- arch/x86/include/asm/hypervisor.h | 1 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/acrn.c | 75 +++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/hypervisor.c | 4 ++ arch/x86/kernel/irq.c | 2 +- 10 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 arch/x86/include/asm/acrn_hypercall.h create mode 100644 arch/x86/include/asm/acrnhyper.h create mode 100644 arch/x86/kernel/cpu/acrn.c
Signature · 1 line
2.7.4
RFC PATCH 1/3 arch/x86: add ACRN hypervisor guest
ACRN is one open-source hypervisour, which is maintained by Linux foundation. This is to add the para-virtualization support so that it allows to enable the Linux guest on acrn-hypervisor.
This adds x86_hyper_acrn into supported hypervisors array, which enables ACRN services guest running on ACRN hypervisor. It is restricted to X86_64.
--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/hypervisor.h | 1 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/acrn.c | 36 ++++++++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/hypervisor.c | 4 ++++ 5 files changed, 50 insertions(+) create mode 100644 arch/x86/kernel/cpu/acrn.c
arch/x86/Kconfig +8 -0
@@ -843,6 +843,14 @@ config JAILHOUSE_GUEST cell. You can leave this option disabled if you only want to start Jailhouse and run Linux afterwards in the root cell. +config ACRN + bool "Enable services on ACRN hypervisor" + depends on X86_64 && PARAVIRT + help + This option allows to run Linux as guest in ACRN hypervisor. + It is needed if you want to run ACRN services linux on top of + ACRN hypervisor. + endif #HYPERVISOR_GUEST source "arch/x86/Kconfig.cpu"
arch/x86/include/asm/hypervisor.h +1 -0
@@ -29,6 +29,7 @@ enum x86_hypervisor_type {X86_HYPER_XEN_HVM ,X86_HYPER_KVM ,X86_HYPER_JAILHOUSE , + X86_HYPER_ACRN, };#ifdef CONFIG_HYPERVISOR_GUEST
arch/x86/kernel/cpu/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o +obj-$(CONFIG_ACRN) += acrn.o ifdef CONFIG_X86_FEATURE_NAMES quiet_cmd_mkcapflags = MKCAP $@
arch/x86/kernel/cpu/acrn.c new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ACRN hypervisor support +* +* Copyright (C) 2019 Intel Corporation. All rights reserved. +* +* Jason Chen CJ <[email protected]> +* Zhao Yakui <[email protected]> +* +*/ + +#include <asm/hypervisor.h> + +static uint32_t __init acrn_detect (void ) +{ +return hypervisor_cpuid_base ("ACRNACRNACRN\0\0" ,0 ); +} + +static void __init acrn_init_platform (void ) +{ +} + +static bool acrn_x2apic_available (void ) +{ +/* do not support x2apic */ +return false; +} + +const struct hypervisor_x86 x86_hyper_acrn = { + .name ="ACRN" , + .detect = acrn_detect, + .type =X86_HYPER_ACRN , + .init.init_platform = acrn_init_platform, + .init.x2apic_available = acrn_x2apic_available, +}; +EXPORT_SYMBOL (x86_hyper_acrn);
arch/x86/kernel/cpu/hypervisor.c +4 -0
@@ -32,6 +32,7 @@ extern const struct hypervisor_x86 x86_hyper_xen_pv;extern const struct hypervisor_x86 x86_hyper_xen_hvm;extern const struct hypervisor_x86 x86_hyper_kvm;extern const struct hypervisor_x86 x86_hyper_jailhouse; +extern const struct hypervisor_x86 x86_hyper_acrn;static const __initconst struct hypervisor_x86 *const hypervisors[] = {
@@ -49,6 +50,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =#ifdef CONFIG_JAILHOUSE_GUEST &x86_hyper_jailhouse,#endif +#ifdef CONFIG_ACRN + &x86_hyper_acrn, +#endif };enum x86_hypervisor_type x86_hyper_type;
Signature · 1 line
2.7.4
Re: [RFC PATCH 1/3] arch/x86: add ACRN hypervisor guest
Zhao,
Quoted 6 lines · Zhao Yakui
ACRN is one open-source hypervisour, which is maintained by Linux foundation. This is to add the para-virtualization support so that it allows to enable the Linux guest on acrn-hypervisor.
This adds
x86_hyper_acrninto supported hypervisors array, which enables ACRN services guest running on ACRN hypervisor. It is
What is a ACRN services guest?
Quoted 4 lines
restricted to
X86_64.Signed-off-by Jason Chen CJ <[email protected]>Signed-off-by Zhao Yakui <[email protected]>
This SOB chain is wrong. If Jason wrote the patch, then there should be a 'From: Jason ..' line at the top of the change log. If you both wrote it then Jason's SOB wants to be preceeded by a 'Co-developed-by: Jason....' line. See Documentation/process/
arch/x86/Kconfig config JAILHOUSE_GUEST · line 852
Quoted 7 lines
arch/x86/Kconfig +7
-0+config ACRN + bool "Enable services on ACRN hypervisor" + depends on X86_64 && PARAVIRT + help + This option allows to run Linux as guest in ACRN hypervisor. + It is needed if you want to run ACRN services linux on top of + ACRN hypervisor.
This help text does not make any sense to me.
arch/x86/kernel/cpu/acrn.c line 36
Quoted 8 lines
arch/x86/kernel/cpu/acrn.c new file +8
-0+const struct hypervisor_x86 x86_hyper_acrn = { + .name ="ACRN" , + .detect = acrn_detect, + .type =X86_HYPER_ACRN , + .init.init_platform = acrn_init_platform, + .init.x2apic_available = acrn_x2apic_available, +}; +EXPORT_SYMBOL (x86_hyper_acrn);
Whay is this exported? The only user of this is hypervisor.c and that is built in. Please remove.
Thanks,
tglx
RE: [RFC PATCH 1/3] arch/x86: add ACRN hypervisor guest
Hi, Tglx
Thanks for your nice review.
Quoted 12 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Friday, March 22, 2019 11:20 PM
To: Zhao, Yakui <[email protected]>
Cc: [email protected]; [email protected]; Chen, Jason CJ <[email protected]>
Subject: Re: [RFC PATCH 1/3]arch/x86: add ACRN hypervisor guestZhao,
On Thu, 7 Mar 2019, Zhao Yakui wrote:
Quoted 8 lines
Quoted 6 lines
ACRN is one open-source hypervisour, which is maintained by Linux foundation. This is to add the para-virtualization support so that it allows to enable the Linux guest on acrn-hypervisor.
This adds
x86_hyper_acrninto supported hypervisors array, which enables ACRN services guest running on ACRN hypervisor. It isWhat is a ACRN services guest?
It should be "ACRN guest".
Quoted 10 lines
Quoted 5 lines
restricted to
X86_64.Signed-off-by Jason Chen CJ <[email protected]>Signed-off-by Zhao Yakui <[email protected]>This SOB chain is wrong. If Jason wrote the patch, then there should be a 'From: Jason ..' line at the top of the change log. If you both wrote it then Jason's SOB wants to be preceeded by a 'Co-developed-by: Jason....' line. See
Documentation/process/
Sure. It will be updated to "Co-developed-by: Jason" in next version.
Quoted 10 lines
arch/x86/Kconfig config JAILHOUSE_GUEST · line 852
Quoted 8 lines
arch/x86/Kconfig +7
-0+config ACRN + bool "Enable services on ACRN hypervisor" + depends on X86_64 && PARAVIRT + help + This option allows to run Linux as guest in ACRN hypervisor. + It is needed if you want to run ACRN services linux on top of + ACRN hypervisor.This help text does not make any sense to me.
"Enable Services on ACRN hypervisor" is a little confusing.
In next version it will be changed to "ACRN_GUEST". How about the below:
config ACRN_GUEST
bool "ACRN Guest Support"
depends on X86_64 && PARAVIRT
help
This option allows to run Linux as guest in ACRN hypervisor. Enabling this will allow the kernel to boot in a paravirtualized environment under the ACRN hypervisor
Quoted 11 lines
arch/x86/kernel/cpu/acrn.c line 36
Quoted 8 lines
arch/x86/kernel/cpu/acrn.c new file +7
-0+const struct hypervisor_x86 x86_hyper_acrn = { + .name ="ACRN" , + .detect = acrn_detect, + .type =X86_HYPER_ACRN , + .init.init_platform = acrn_init_platform, + .init.x2apic_available = acrn_x2apic_available, }; +EXPORT_SYMBOL (x86_hyper_acrn);Whay is this exported? The only user of this is
hypervisor.cand that is built in. Please remove.
You are right.
It will be removed and the x86_hyper_acrn will also be added into "__initconst" section.
Quoted 4 lines
Thanks,
tglx
Re: [RFC PATCH 1/3] arch/x86: add ACRN hypervisor guest
In reply to Zhao YakuiQuoted 24 lines · Zhao Yakui
ACRN is one open-source hypervisour, which is maintained by Linux foundation. This is to add the para-virtualization support so that it allows to enable the Linux guest on acrn-hypervisor.
This adds
x86_hyper_acrninto supported hypervisors array, which enables ACRN services guest running on ACRN hypervisor. It is restricted toX86_64.Signed-off-by Jason Chen CJ <[email protected]>Signed-off-by Zhao Yakui <[email protected]>--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/hypervisor.h | 1 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/acrn.c | 36 ++++++++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/hypervisor.c | 4 ++++ 5 files changed, 50 insertions(+) create mode 100644 arch/x86/kernel/cpu/acrn.carch/x86/Kconfig +0
-0
arch/x86/Kconfig config JAILHOUSE_GUEST · line 846
Quoted 4 lines
arch/x86/Kconfig +1
-0@@ -843,6 +843,14 @@ config JAILHOUSE_GUEST cell. You can leave this option disabled if you only want to start Jailhouse and run Linux afterwards in the root cell. +config ACRN
My personal preference would be to use ACRN_GUEST. Inevitably there will be a need to wrap ACRN code with an ifdef, and seeing "GUEST" in such cases immediately lets readers know the code in question is related to running as a guest without having to remember that ACRN is a hypervisor. This is especially true for readers that have never heard of ACRN.
Quoted 101 lines
arch/x86/Kconfig +7
-0+ bool "Enable services on ACRN hypervisor" + depends on X86_64 && PARAVIRT + help + This option allows to run Linux as guest in ACRN hypervisor. + It is needed if you want to run ACRN services linux on top of + ACRN hypervisor. + endif #HYPERVISOR_GUEST source "arch/x86/Kconfig.cpu"arch/x86/include/asm/hypervisor.h +1
-0@@ -29,6 +29,7 @@ enum x86_hypervisor_type {X86_HYPER_XEN_HVM ,X86_HYPER_KVM ,X86_HYPER_JAILHOUSE , + X86_HYPER_ACRN, };#ifdef CONFIG_HYPERVISOR_GUEST arch/x86/kernel/cpu/Makefile +1
-0@@ -44,6 +44,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o +obj-$(CONFIG_ACRN) += acrn.o ifdef CONFIG_X86_FEATURE_NAMES quiet_cmd_mkcapflags = MKCAP $@arch/x86/kernel/cpu/acrn.c new file +36
-0@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ACRN hypervisor support +* +* Copyright (C) 2019 Intel Corporation. All rights reserved. +* +* Jason Chen CJ <[email protected]> +* Zhao Yakui <[email protected]> +* +*/ + +#include <asm/hypervisor.h> + +static uint32_t __init acrn_detect (void ) +{ +return hypervisor_cpuid_base ("ACRNACRNACRN\0\0" ,0 ); +} + +static void __init acrn_init_platform (void ) +{ +} + +static bool acrn_x2apic_available (void ) +{ +/* do not support x2apic */ +return false; +} + +const struct hypervisor_x86 x86_hyper_acrn = { + .name ="ACRN" , + .detect = acrn_detect, + .type =X86_HYPER_ACRN , + .init.init_platform = acrn_init_platform, + .init.x2apic_available = acrn_x2apic_available, +}; +EXPORT_SYMBOL (x86_hyper_acrn);arch/x86/kernel/cpu/hypervisor.c +4
-0@@ -32,6 +32,7 @@ extern const struct hypervisor_x86 x86_hyper_xen_pv;extern const struct hypervisor_x86 x86_hyper_xen_hvm;extern const struct hypervisor_x86 x86_hyper_kvm;extern const struct hypervisor_x86 x86_hyper_jailhouse; +extern const struct hypervisor_x86 x86_hyper_acrn;static const __initconst struct hypervisor_x86 *const hypervisors[] = {@@ -49,6 +50,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =#ifdef CONFIG_JAILHOUSE_GUEST &x86_hyper_jailhouse,#endif +#ifdef CONFIG_ACRN + &x86_hyper_acrn, +#endif };enum x86_hypervisor_type x86_hyper_type;Signature · 1 line
2.7.4
RFC PATCH 2/3 arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
In reply to Zhao YakuiWHen it works in hypervisor guest mode, Linux kernel uses the HYPERVISOR_CALLBACK_VECTOR for hypervisor upcall vector. And it is already used for Xen and HyperV. After Acrn hypervisor is detected, it will also use this defined vector as notify vector to kernel.
And two APIs are added so that the other module can add/remove the hypervisor callback irq handler.
--- arch/x86/entry/entry_64.S | 5 +++++ arch/x86/include/asm/acrnhyper.h | 16 ++++++++++++++++ arch/x86/include/asm/hardirq.h | 2 +- arch/x86/kernel/cpu/acrn.c | 38 ++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/irq.c | 2 +- 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 arch/x86/include/asm/acrnhyper.h
arch/x86/entry/entry_64.S +5 -0
@@ -1129,6 +1129,11 @@ apicinterrupt3 HYPERV_STIMER0_VECTOR \ hv_stimer0_callback_vector hv_stimer0_vector_handler #endif /* CONFIG_HYPERV */ +#if IS_ENABLED(CONFIG_ACRN) +apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \ + acrn_hv_callback_vector acrn_hv_vector_handler +#endif + idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK idtentry int3 do_int3 has_error_code=0 idtentry stack_segment do_stack_segment has_error_code=1
arch/x86/include/asm/acrnhyper.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_ACRNHYPER_H +#define _ASM_X86_ACRNHYPER_H + +#include <linux/types.h> +#include <asm/io.h> + +#ifdef CONFIG_ACRN +/* ACRN Hypervisor callback */ +void acrn_hv_callback_vector (void ); + +void acrn_setup_intr_irq (void (*handler)(void )); +void acrn_remove_intr_irq (void ); +#endif + +#endif
arch/x86/include/asm/hardirq.h +1 -1
@@ -37,7 +37,7 @@ typedef struct {#ifdef CONFIG_X86_MCE_AMD unsigned int irq_deferred_error_count;#endif -#if IS_ENABLED (CONFIG_HYPERV ) || defined(CONFIG_XEN ) +#if IS_ENABLED (CONFIG_HYPERV ) || defined(CONFIG_XEN ) || defined(CONFIG_ACRN )unsigned int irq_hv_callback_count;#endif #if IS_ENABLED (CONFIG_HYPERV )
arch/x86/kernel/cpu/acrn.c +38 -0
@@ -10,6 +10,11 @@*/ #include <asm/hypervisor.h> +#include <asm/acrnhyper.h> +#include <asm/irq_vectors.h> +#include <asm/irq_regs.h> +#include <asm/desc.h> +#include <linux/interrupt.h> static uint32_t __init acrn_detect (void ) {
@@ -18,6 +23,8 @@ static uint32_t __init acrn_detect(void)static void __init acrn_init_platform (void ) { +alloc_intr_gate (HYPERVISOR_CALLBACK_VECTOR , + acrn_hv_callback_vector); }static bool acrn_x2apic_available (void )
@@ -26,6 +33,37 @@ static bool acrn_x2apic_available(void)return false; } + +static void (*acrn_intr_handler)(void ); +/* +* Handler for ACRN_HV_CALLBACK. +*/ +__visible void __irq_entry acrn_hv_vector_handler(struct pt_regs *regs) +{ +struct pt_regs *old_regs =set_irq_regs (regs); + +entering_ack_irq (); +inc_irq_stat (irq_hv_callback_count); + +if (acrn_intr_handler) +acrn_intr_handler (); + +exiting_irq (); +set_irq_regs (old_regs); +} + +void acrn_setup_intr_irq (void (*handler)(void )) +{ + acrn_intr_handler = handler; +} +EXPORT_SYMBOL (acrn_setup_intr_irq); + +void acrn_remove_intr_irq (void ) +{ + acrn_intr_handler =NULL ; +} +EXPORT_SYMBOL (acrn_remove_intr_irq); +const struct hypervisor_x86 x86_hyper_acrn = { .name ="ACRN" , .detect = acrn_detect,
arch/x86/kernel/irq.c +1 -1
@@ -134,7 +134,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_printf (p,"%10u " ,per_cpu (mce_poll_count, j));seq_puts (p," Machine check polls\n" );#endif -#if IS_ENABLED (CONFIG_HYPERV ) || defined(CONFIG_XEN ) +#if IS_ENABLED (CONFIG_HYPERV ) || defined(CONFIG_XEN ) || defined(CONFIG_ACRN )if (test_bit (HYPERVISOR_CALLBACK_VECTOR , system_vectors)) {seq_printf (p,"%*s: " , prec,"HYP" );for_each_online_cpu (j)
Signature · 1 line
2.7.4
Re: [RFC PATCH 2/3] arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
Quoted 6 lines · Zhao Yakui
WHen it works in hypervisor guest mode, Linux kernel uses the
HYPERVISOR_CALLBACK_VECTORfor hypervisor upcall vector. And it is already used for Xen and HyperV. After Acrn hypervisor is detected, it will also use this defined vector as notify vector to kernel.
And two APIs are added so that the other module can add/remove the hypervisor callback irq handler.
Which other module?
Quoted 2 lines
Signed-off-by Jason Chen CJ <[email protected]>Signed-off-by Zhao Yakui <[email protected]>
Same SOB issue.
Quoted 14 lines
arch/x86/entry/entry_64.S +5
-0+#if IS_ENABLED(CONFIG_ACRN) +apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \ + acrn_hv_callback_vector acrn_hv_vector_handler +#endif + idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK idtentry int3 do_int3 has_error_code=0 idtentry stack_segment do_stack_segment has_error_code=1arch/x86/include/asm/acrnhyper.h new file +0
-0
arch/x86/include/asm/acrnhyper.h line 10
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h new file +10
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_ACRNHYPER_H +#define _ASM_X86_ACRNHYPER_H + +#include <linux/types.h> +#include <asm/io.h> + +#ifdef CONFIG_ACRN +/* ACRN Hypervisor callback */ +void acrn_hv_callback_vector (void );
What declares acrn_hv_vector_handler() ?
arch/x86/include/asm/acrnhyper.h
Quoted 6 lines
arch/x86/include/asm/acrnhyper.h new file +5
-0#include <asm/hypervisor.h> +#include <asm/acrnhyper.h> +#include <asm/irq_vectors.h> +#include <asm/irq_regs.h> +#include <asm/desc.h> +#include <linux/interrupt.h>
First of all the include order is always:
#include <linux/...>
#include <linux/...>
#include <asm/...>
Aside of that including 'linux/irq.h' should include everything you need. No need for gazillion of includes.
arch/x86/include/asm/acrnhyper.h static bool acrn_x2apic_available(void) · line 36
Quoted 6 lines
static bool
acrn_x2apic_available(void)arch/x86/include/asm/acrnhyper.h new file +1
-0@@ -26,6 +33,37 @@ static bool acrn_x2apic_available(void)return false; } +
Stray newline
arch/x86/include/asm/acrnhyper.h static bool acrn_x2apic_available(void) · line 38
Quoted 2 lines
arch/x86/include/asm/acrnhyper.h new file +2
-0+static void (*acrn_intr_handler)(void ); +/*
Which should have been above this comment. Glueing stuff together makes it unreadable.
arch/x86/include/asm/acrnhyper.h static bool acrn_x2apic_available(void) · line 39
Quoted 1 line
arch/x86/include/asm/acrnhyper.h new file +1
-0+* Handler for ACRN_HV_CALLBACK.
Err? This handles the HYPERVISOR_CALLBACK_VECTOR
Quoted 16 lines
arch/x86/include/asm/acrnhyper.h new file +16
-0+*/ +__visible void __irq_entry acrn_hv_vector_handler(struct pt_regs *regs) +{ +struct pt_regs *old_regs =set_irq_regs (regs); + +entering_ack_irq (); +inc_irq_stat (irq_hv_callback_count); + +if (acrn_intr_handler) +acrn_intr_handler (); + +exiting_irq (); +set_irq_regs (old_regs); +} + +void acrn_setup_intr_irq (void (*handler)(void ))
arch/x86/include/asm/acrnhyper.h static bool acrn_x2apic_available(void) · line 65
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h new file +10
-0+{ + acrn_intr_handler = handler; +} +EXPORT_SYMBOL (acrn_setup_intr_irq); + +void acrn_remove_intr_irq (void ) +{ + acrn_intr_handler =NULL ; +} +EXPORT_SYMBOL (acrn_remove_intr_irq);
Where is the code which uses these exports? We are not adding exports just because or for consumption by out of tree modules.
Thanks,
tglx
Borislav Petkov
maintainerRe: [RFC PATCH 2/3] arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
Quoted 4 lines · Thomas Gleixner
Quoted 1 line
+EXPORT_SYMBOL(acrn_remove_intr_irq);
Where is the code which uses these exports? We are not adding exports just because or for consumption by out of tree modules.
Right, if anything, all new exports should be _GPL.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.RE: [RFC PATCH 2/3] arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
In reply to Thomas GleixnerQuoted 13 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Friday, March 22, 2019 11:45 PM
To: Zhao, Yakui <[email protected]>
Cc: [email protected]; [email protected]; Chen, Jason CJ <[email protected]>
Subject: Re: [RFC PATCH 2/3]arch/x86/acrn: UseHYPERVISOR_CALLBACK_VECTORfor Acrn upcall vectorOn Thu, 7 Mar 2019, Zhao Yakui wrote:
Quoted 9 lines
Quoted 6 lines
WHen it works in hypervisor guest mode, Linux kernel uses the
HYPERVISOR_CALLBACK_VECTORfor hypervisor upcall vector. And it is already used for Xen and HyperV. After Acrn hypervisor is detected, it will also use this defined vector as notify vector to kernel. And two APIs are added so that the other module can add/remove the hypervisor callback irq handler.Which other module?
This work is divided into two steps. The first is to add the support of acrn-guest under arch/x86. The second is to add one driver that allows the acrn-guest to communicate with the acrn-hypervisor. As the second part has the dependency on the first part, we hope that the acrn-guest is added firstly and the required API is also added.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Jason Chen CJ <[email protected]>Signed-off-by Zhao Yakui <[email protected]>Same SOB issue.
Sure. It will be updated.
Quoted 20 lines
arch/x86/entry/entry_64.S apicinterrupt3 HYPERV_STIMER0_VECTOR \
Quoted 6 lines
arch/x86/entry/entry_64.S +4
-0+#if IS_ENABLED(CONFIG_ACRN) +apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \ + acrn_hv_callback_vector acrn_hv_vector_handler #endif + idtentry debug do_debughas_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
Quoted 2 lines
idtentry int3
do_int3has_error_code=0
idtentrystack_segmentdo_stack_segmenthas_error_code=1
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h new file +3
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_ACRNHYPER_H +#define _ASM_X86_ACRNHYPER_H +
Quoted 8 lines
arch/x86/include/asm/acrnhyper.h line 10
Quoted 6 lines
arch/x86/include/asm/acrnhyper.h new file +6
-0+#include <linux/types.h> +#include <asm/io.h> + +#ifdef CONFIG_ACRN +/* ACRN Hypervisor callback */ +void acrn_hv_callback_vector (void );What declares
acrn_hv_vector_handler()?
Acrn_hv_callback_vector is defined in arch/x86/entry/entry_64.S, which will be used as the parameter of alloc_intr_gate
Acrn_hv_vector_handler is the real ISR handler, which is defined in acrn.c.
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h
Quoted 7 lines
arch/x86/include/asm/acrnhyper.h new file +5
-0#include <asm/hypervisor.h> +#include <asm/acrnhyper.h> +#include <asm/irq_vectors.h> +#include <asm/irq_regs.h> +#include <asm/desc.h> +#include <linux/interrupt.h> First of all the include order is always:
Quoted 7 lines
#include <linux/...>
#include <linux/...>#include <asm/...>
Aside of that including '
linux/irq.h' should include everything you need. No need for gazillion of includes.
OK. The include order will be updated in next version.
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h
Quoted 7 lines
static bool
acrn_x2apic_available(void)@@ -26,6 +33,37 @@ static
boolacrn_x2apic_available(void)arch/x86/include/asm/acrnhyper.h new file +1
-0return false; } +Stray newline
Sure. The extra newline will be removed.
Quoted 10 lines
arch/x86/include/asm/acrnhyper.h
Quoted 2 lines
arch/x86/include/asm/acrnhyper.h new file +2
-0+static void (*acrn_intr_handler)(void ); +/* Which should have been above this comment. Glueing stuff together makes it unreadable.
Quoted 1 line
+ * Handler for
ACRN_HV_CALLBACK.Err? This handles the
HYPERVISOR_CALLBACK_VECTOR
I will remove the confusing comment.
In fact this acrn_intr_handle is similar to the vmbus_handler in arch/x86/kernel/cpu/mshyperv.c
Quoted 20 lines
Quoted 20 lines
+ */
arch/x86/include/asm/acrnhyper.h new file +19
-0+__visible void __irq_entry acrn_hv_vector_handler(struct pt_regs +*regs) { +struct pt_regs *old_regs =set_irq_regs (regs); + +entering_ack_irq (); +inc_irq_stat (irq_hv_callback_count); + +if (acrn_intr_handler) +acrn_intr_handler (); + +exiting_irq (); +set_irq_regs (old_regs); +} + +void acrn_setup_intr_irq (void (*handler)(void )) { + acrn_intr_handler = handler; +} +EXPORT_SYMBOL (acrn_setup_intr_irq); +
Quoted 8 lines
arch/x86/include/asm/acrnhyper.h
Quoted 5 lines
arch/x86/include/asm/acrnhyper.h new file +5
-0+void acrn_remove_intr_irq (void ) +{ + acrn_intr_handler =NULL ; +} +EXPORT_SYMBOL (acrn_remove_intr_irq);Where is the code which uses these exports? We are not adding exports just because or for consumption by out of tree modules.
Understand it.
Is it reasonable that the above two functions are added in the driver patch set?
Quoted 4 lines
Thanks,
tglx
RE: [RFC PATCH 2/3] arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
Quoted 12 lines · Yakui
Quoted 11 lines
arch/x86/include/asm/acrnhyper.h line 10
Quoted 9 lines
arch/x86/include/asm/acrnhyper.h new file +9
-0+/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_ACRNHYPER_H +#define _ASM_X86_ACRNHYPER_H + +#include <linux/types.h> +#include <asm/io.h> + +#ifdef CONFIG_ACRN +/* ACRN Hypervisor callback */ +void acrn_hv_callback_vector (void );What declares
acrn_hv_vector_handler()?
Quoted 4 lines
Acrn_hv_callback_vectoris defined inarch/x86/entry/entry_64.S, which will be used as the parameter ofalloc_intr_gate
Acrn_hv_vector_handleris the real ISR handler, which is defined inacrn.c.
I know how that works and I was not asking where stuff is defined. I was asking where it is declared. Global functions need a declaration in a header file.
Quoted 11 lines
Quoted 8 lines
arch/x86/kernel/cpu/acrn.c static bool acrn_x2apic_available(void) · line 65
Quoted 5 lines
arch/x86/kernel/cpu/acrn.c +5
-0+void acrn_remove_intr_irq (void ) +{ + acrn_intr_handler =NULL ; +} +EXPORT_SYMBOL (acrn_remove_intr_irq);Where is the code which uses these exports? We are not adding exports just because or for consumption by out of tree modules.
Understand it.
Is it reasonable that the above two functions are added in the driver patch set?
Yes, because then we see the context.
Thanks,
tglx
Re: [RFC PATCH 2/3] arch/x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for Acrn upcall vector
Quoted 13 lines · Thomas Gleixner
Quoted 12 lines · Yakui
Quoted 11 lines
arch/x86/include/asm/acrnhyper.h line 10
Quoted 9 lines
arch/x86/include/asm/acrnhyper.h new file +9
-0+/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _ASM_X86_ACRNHYPER_H +#define _ASM_X86_ACRNHYPER_H + +#include <linux/types.h> +#include <asm/io.h> + +#ifdef CONFIG_ACRN +/* ACRN Hypervisor callback */ +void acrn_hv_callback_vector (void );What declares
acrn_hv_vector_handler()?
Quoted 8 lines
Quoted 4 lines
Acrn_hv_callback_vectoris defined inarch/x86/entry/entry_64.S, which will be used as the parameter ofalloc_intr_gate
Acrn_hv_vector_handleris the real ISR handler, which is defined inacrn.c.I know how that works and I was not asking where stuff is defined. I was asking where it is declared. Global functions need a declaration in a header file.
Sure. It will be declared in next version.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
arch/x86/kernel/cpu/acrn.c static bool acrn_x2apic_available(void) · line 65
Quoted 6 lines
arch/x86/kernel/cpu/acrn.c +5
-0+void acrn_remove_intr_irq (void ) +{ + acrn_intr_handler =NULL ; +} +EXPORT_SYMBOL (acrn_remove_intr_irq);Where is the code which uses these exports? We are not adding exports just because or for consumption by out of tree modules.
Quoted 4 lines
Quoted 2 lines
Understand it.
Is it reasonable that the above two functions are added in the driver patch set?Yes, because then we see the context.
OK. They will be removed. And it will be included in driver patch set.
Quoted 5 lines
Thanks,
tglx
RFC PATCH 3/3 arch/x86/acrn: add hypercall for acrn_hypervisor
In reply to Zhao YakuiWhen acrn_hypervisor is detected, the other module may communicate with the hypervisor to query/config some settings. For example: it can be used to query the resources in hypervisor and manage the CPU/memory/device/ interrupt for Guest system.
So the hypercall is added so that the kernel can communicate with the low-level acrn-hypervisor. On x86 it is implemented by using vmacll when the acrn hypervisor is enabled.
--- arch/x86/include/asm/acrn_hypercall.h | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 arch/x86/include/asm/acrn_hypercall.h
arch/x86/include/asm/acrn_hypercall.h new file +85 -0
@@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/* +* acrn_hypercall.h : acrn hypervisor call API +*/ + +#ifndef __ACRN_HYPERCALL_H__ +#define __ACRN_HYPERCALL_H__ + +#include <linux/errno.h> + +#ifdef CONFIG_ACRN + +static inline long acrn_hypercall0 (unsigned long hcall_id) +{ + +/* x86-64 System V ABI register usage */ + registersigned long result asm("rax" ); + register unsigned long r8 asm("r8") = hcall_id; + +/* Execute vmcall */ + asmvolatile (".byte 0x0F,0x01,0xC1\n" + :"=r" (result) + :"r" (r8)); + +/* Return result to caller */ +return result; +} + +static inline long acrn_hypercall1 (unsigned long hcall_id, +unsigned long param1) +{ + +/* x86-64 System V ABI register usage */ + registersigned long result asm("rax" ); + register unsigned long r8 asm("r8") = hcall_id; + +/* Execute vmcall */ + asmvolatile (".byte 0x0F,0x01,0xC1\n" + :"=r" (result) + :"D" (param1),"r" (r8)); + +/* Return result to caller */ +return result; +} + +static inline long acrn_hypercall2 (unsigned long hcall_id, +unsigned long param1, +unsigned long param2) +{ + +/* x86-64 System V ABI register usage */ + registersigned long result asm("rax" ); + register unsigned long r8 asm("r8") = hcall_id; + +/* Execute vmcall */ + asmvolatile (".byte 0x0F,0x01,0xC1\n" + :"=r" (result) + :"D" (param1),"S" (param2),"r" (r8)); + +/* Return result to caller */ +return result; +} + +#else + +static inline long acrn_hypercall0 (unsigned long hcall_id) +{ +return -ENOTSUPP ; +} + +static inline long acrn_hypercall1 (unsigned long hcall_id, +unsigned long param1) +{ +return -ENOTSUPP ; +} + +static inline long acrn_hypercall2 (unsigned long hcall_id, +unsigned long param1, +unsigned long param2) +{ +return -ENOTSUPP ; +} +#endif + +#endif /* __ACRN_HYPERCALL_H__ */
Signature · 1 line
2.7.4
Re: [RFC PATCH 3/3] arch/x86/acrn: add hypercall for acrn_hypervisor
Quoted 1 line · Zhao Yakui
When
acrn_hypervisoris detected, the other module may communicate with
Which other module?
arch/x86/include/asm/acrn_hypercall.h line 1
Quoted 7 lines
the hypervisor to query/config some settings. For example: it can be used to query the resources in hypervisor and manage the CPU/memory/device/ interrupt for Guest system.
+++
b/arch/x86/include/asm/acrn_hypercall.harch/x86/include/asm/acrn_hypercall.h new file +1
-0@@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
So the hypercall header is GPL-2.0+ and the acrn.c file is GPL-2.0. Not that I personally care, but is this intended?
Quoted 5 lines
arch/x86/include/asm/acrn_hypercall.h new file +5
-0+/* +* acrn_hypercall.h : acrn hypervisor call API +*/ + +#ifndef __ACRN_HYPERCALL_H__
arch/x86/include/asm/acrn_hypercall.h line 16
Quoted 10 lines
arch/x86/include/asm/acrn_hypercall.h new file +10
-0+#define __ACRN_HYPERCALL_H__ + +#include <linux/errno.h> + +#ifdef CONFIG_ACRN + +static inline long acrn_hypercall0 (unsigned long hcall_id) +{ + +/* x86-64 System V ABI register usage */
Well, yes. But can you please provide a link to the hypercall specification in the changelog?
Also instead of repeating the same comment over and over, explain the calling convention in a top level comment.
Review line 18
Quoted 2 lines
(quoted diff) +2
-0+ register signed long result asm("rax"); + register unsigned long r8 asm("r8") = hcall_id;
I appreciate the attempt of making this tabular, but it's unreadable and has random white space in it. Also please use 'long' and not 'signed long'.
register unsigned long r8 asm("r8") = hcall_id;
register long result asm("rax");arch/x86/include/asm/acrn_hypercall.h line 25
Quoted 7 lines
arch/x86/include/asm/acrn_hypercall.h new file +7
-0+ +/* Execute vmcall */ + asmvolatile (".byte 0x0F,0x01,0xC1\n" + :"=r" (result) + :"r" (r8)); + +/* Return result to caller */
Please do not comment the obvious. It's entirely clear that this returns 'result' to the caller. Comments are there to explain what's not obvious.
Review line 27
Quoted 2 lines
(quoted diff) +2
-0+ return result; +}
Thanks,
tglx
RE: [RFC PATCH 3/3] arch/x86/acrn: add hypercall for acrn_hypervisor
Quoted 21 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Saturday, March 23, 2019 12:02 AM
To: Zhao, Yakui <[email protected]>
Cc: [email protected]; [email protected]; Chen, Jason CJ <[email protected]>
Subject: Re: [RFC PATCH 3/3]arch/x86/acrn: add hypercall foracrn_hypervisorQuoted 2 lines · Zhao Yakui
When
acrn_hypervisoris detected, the other module may communicate withWhich other module?
Quoted 3 lines
the hypervisor to query/config some settings. For example: it can be used to query the resources in hypervisor and manage the CPU/memory/device/ interrupt for Guest system.
Quoted 6 lines
arch/x86/include/asm/acrn_hypercall.h line 1
Quoted 3 lines
+++
b/arch/x86/include/asm/acrn_hypercall.harch/x86/include/asm/acrn_hypercall.h new file +1
-0@@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ So the hypercall header is GPL-2.0+ and the
acrn.cfile is GPL-2.0. Not that I personally care, but is this intended?
Sorry for my fault. It should be GPL-2.0
Quoted 18 lines
Quoted 4 lines
arch/x86/include/asm/acrn_hypercall.h new file +3
-0+/* +* acrn_hypercall.h : acrn hypervisor call API */ +arch/x86/include/asm/acrn_hypercall.h line 16
Quoted 10 lines
arch/x86/include/asm/acrn_hypercall.h new file +10
-0+#ifndef __ACRN_HYPERCALL_H__ +#define __ACRN_HYPERCALL_H__ + +#include <linux/errno.h> + +#ifdef CONFIG_ACRN + +static inline long acrn_hypercall0(unsigned long hcall_id) { + + /* x86-64 System V ABI register usage */Well, yes. But can you please provide a link to the hypercall specification in the changelog?
Quoted 2 lines
Also instead of repeating the same comment over and over, explain the calling convention in a top level comment.
This is the low-level implementation of low-level hypercall. It is similar to Kvm_hypercall1/2/3 in arch/x86/include/asm/kvm_para.h.
Does it make sense that the below comments are added before acrn_hypercall0/1/2? /*
* Hypercalls for ACRN Guest
*
* Hypercall number is passed in r8 register.
* Return value will be placed in rax.
* Up to 2 arguments are passed in rdi, rsi.
*/
Of course I will also remove the redundant comments.
Quoted 6 lines
Review line 16
Quoted 3 lines
(quoted diff) +2
-0+ register signed long result asm("rax"); + register unsigned long r8 asm("r8") = hcall_id;I appreciate the attempt of making this tabular, but it's unreadable and has random white space in it. Also please use 'long' and not 'signed long'.
Ok. The type will be refined.
Quoted 4 lines
register unsigned long r8 asm("r8") = hcall_id;
register long result asm("rax");Quoted 10 lines
arch/x86/include/asm/acrn_hypercall.h line 25
Quoted 7 lines
arch/x86/include/asm/acrn_hypercall.h new file +7
-0+ +/* Execute vmcall */ + asmvolatile (".byte 0x0F,0x01,0xC1\n" + :"=r" (result) + :"r" (r8)); + +/* Return result to caller */ Please do not comment the obvious. It's entirely clear that this returns 'result' to the caller. Comments are there to explain what's not obvious.
Thanks for pointing out the issue.
I will remove the redundant comment.
Quoted 7 lines
Review line 25
Quoted 3 lines
(quoted diff) +2
-0+ return result; +}Thanks,
tglx
RE: [RFC PATCH 3/3] arch/x86/acrn: add hypercall for acrn_hypervisor
Quoted 8 lines · Yakui
Quoted 8 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Saturday, March 23, 2019 12:02 AM
To: Zhao, Yakui <[email protected]>
Cc: [email protected]; [email protected]; Chen, Jason CJ <[email protected]>
Subject: Re: [RFC PATCH 3/3]arch/x86/acrn: add hypercall foracrn_hypervisor
Can you please fix your mail client not to copy the full email headers on the reply?
The simple: On $DATE, someone wrote: like the below is sufficient.
Quoted 10 lines
Quoted 9 lines
arch/x86/include/asm/acrn_hypercall.h line 16
Quoted 3 lines
arch/x86/include/asm/acrn_hypercall.h new file +3
-0+static inline long acrn_hypercall0 (unsigned long hcall_id) { + +/* x86-64 System V ABI register usage */ Well, yes. But can you please provide a link to the hypercall specification in the changelog?
Also instead of repeating the same comment over and over, explain the calling convention in a top level comment.
Quoted 10 lines
This is the low-level implementation of low-level hypercall. It is similar to Kvm_hypercall1/2/3 in
arch/x86/include/asm/kvm_para.h.
Does it make sense that the below comments are added before acrn_hypercall0/1/2? /*
* Hypercalls for ACRN Guest
*
* Hypercall number is passed in r8 register.
* Return value will be placed in rax.
* Up to 2 arguments are passed in rdi, rsi.
*/
Yes, that's much more helpful.
Thanks,
tglx
Re: [RFC PATCH 3/3] arch/x86/acrn: add hypercall for acrn_hypervisor
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Yakui
Quoted 8 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Saturday, March 23, 2019 12:02 AM
To: Zhao, Yakui <[email protected]>
Cc: [email protected]; [email protected]; Chen, Jason CJ <[email protected]>
Subject: Re: [RFC PATCH 3/3]arch/x86/acrn: add hypercall foracrn_hypervisor
Quoted 4 lines
Can you please fix your mail client not to copy the full email headers on the reply?
The simple: On $DATE, someone wrote: like the below is sufficient.
thanks for the reminder.
Quoted 28 lines
Quoted 11 lines
Quoted 10 lines
arch/x86/include/asm/acrn_hypercall.h line 16
Quoted 4 lines
arch/x86/include/asm/acrn_hypercall.h new file +3
-0+static inline long acrn_hypercall0 (unsigned long hcall_id) { + +/* x86-64 System V ABI register usage */ Well, yes. But can you please provide a link to the hypercall specification in the changelog?
Also instead of repeating the same comment over and over, explain the calling convention in a top level comment.
Quoted 10 lines
This is the low-level implementation of low-level hypercall. It is similar to Kvm_hypercall1/2/3 in
arch/x86/include/asm/kvm_para.h.
Does it make sense that the below comments are added before acrn_hypercall0/1/2? /*
* Hypercalls for ACRN Guest
*
* Hypercall number is passed in r8 register.
* Return value will be placed in rax.
* Up to 2 arguments are passed in rdi, rsi.
*/Yes, that's much more helpful.
Thanks,
tglx