From 7580cddf9f3066f0eba7041bd242409369d015d4 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 2 Apr 2019 12:41:45 +0800 Subject: [PATCH] HV: add scenario for logical partition In this scenario, hypervisor will run two logical partition VMs. Please note that the Kconfig of Hypervisor mode will be removed gradually. In current Kconfig setting, the CONFIG_PARTITION_MODE is still kept for now for back-compatibility. Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/Makefile | 9 +-- hypervisor/arch/x86/Kconfig | 5 ++ .../x86/configs/apl-mrb/partition_config.h | 44 ------------ .../x86/configs/dnv-cb2/partition_config.h | 46 ------------- hypervisor/arch/x86/configs/vm_config.c | 4 -- .../scenarios/logical_partition/pt_dev.c | 39 +++++++++++ .../logical_partition/vm_configurations.h | 69 +++++++++++++++++++ 7 files changed, 116 insertions(+), 100 deletions(-) delete mode 100644 hypervisor/arch/x86/configs/apl-mrb/partition_config.h delete mode 100644 hypervisor/arch/x86/configs/dnv-cb2/partition_config.h create mode 100644 hypervisor/scenarios/logical_partition/pt_dev.c create mode 100644 hypervisor/scenarios/logical_partition/vm_configurations.h diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 9aea1ef05..2f8fb6349 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -42,6 +42,8 @@ include scripts/kconfig/kconfig.mk #initialize scenarios name ifeq ($(CONFIG_SDC),y) SCENARIO_NAME := sdc +else ifeq ($(CONFIG_LOGICAL_PARTITION),y) +SCENARIO_NAME := logical_partition endif LD_IN_TOOL = scripts/genld.sh @@ -144,13 +146,8 @@ C_SRCS += arch/x86/seed/seed_sbl.c # configuration component C_SRCS += arch/x86/configs/vm_config.c C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c -ifeq ($(CONFIG_PARTITION_MODE),y) -C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/pt_dev.c -else -C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c -endif - C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c +C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c C_SRCS += boot/acpi.c C_SRCS += boot/dmar_parse.c diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 373d4ac57..a34a3c25e 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -10,6 +10,11 @@ config SDC SDC (Software Defined Cockpit) is a typical scenario that ACRN supported. SDC will have one pre-launched SOS VM and one post-launched NORMAL VM. +config LOGICAL_PARTITION + bool "Logical Partition VMs" + help + This scenario will run two pre-launched VMs. + endchoice choice diff --git a/hypervisor/arch/x86/configs/apl-mrb/partition_config.h b/hypervisor/arch/x86/configs/apl-mrb/partition_config.h deleted file mode 100644 index 87f1749f2..000000000 --- a/hypervisor/arch/x86/configs/apl-mrb/partition_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef PARTITION_CONFIG_H -#define PARTITION_CONFIG_H - -#define VM0_CONFIGURED - -#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for APL-MRB" -#define VM0_CONFIG_TYPE PRE_LAUNCHED_VM -#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2)) -#define VM0_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING -#define VM0_CONFIG_MEM_START_HPA 0x100000000UL -#define VM0_CONFIG_MEM_SIZE 0x20000000UL - -#define VM0_CONFIG_OS_NAME "ClearLinux 26600" -#define VM0_CONFIG_OS_BOOTARGS "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ - console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable xapic_phys" - -#define VM1_CONFIGURED - -#define VM1_CONFIG_NAME "PRE-LAUNCHED VM2 for APL-MRB" -#define VM1_CONFIG_TYPE PRE_LAUNCHED_VM -#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3)) -#define VM1_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING -#define VM1_CONFIG_MEM_START_HPA 0x120000000UL -#define VM1_CONFIG_MEM_SIZE 0x20000000UL - -#define VM1_CONFIG_OS_NAME "ClearLinux 26600" -#define VM1_CONFIG_OS_BOOTARGS "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ - console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable xapic_phys" - -#define VM0_CONFIG_PCI_PTDEV_NUM 3U -#define VM1_CONFIG_PCI_PTDEV_NUM 3U - -extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; -extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM]; - -#endif /* PARTITION_CONFIG_H */ diff --git a/hypervisor/arch/x86/configs/dnv-cb2/partition_config.h b/hypervisor/arch/x86/configs/dnv-cb2/partition_config.h deleted file mode 100644 index a8947d2fb..000000000 --- a/hypervisor/arch/x86/configs/dnv-cb2/partition_config.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef PARTITION_CONFIG_H -#define PARTITION_CONFIG_H - -#define VM0_CONFIGURED - -#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for DNV-CB2" -#define VM0_CONFIG_TYPE PRE_LAUNCHED_VM -#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2) | PLUG_CPU(4) | PLUG_CPU(6)) -#define VM0_CONFIG_FLAGS (GUEST_FLAG_LAPIC_PASSTHROUGH | GUEST_FLAG_IO_COMPLETION_POLLING | \ - GUEST_FLAG_RT) -#define VM0_CONFIG_MEM_START_HPA 0x100000000UL -#define VM0_CONFIG_MEM_SIZE 0x80000000UL - -#define VM0_CONFIG_OS_NAME "ClearLinux 26600" -#define VM0_CONFIG_OS_BOOTARGS "root=/dev/sda rw rootwait noxsave maxcpus=4 nohpet console=hvc0 " \ - "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ - "consoleblank=0 tsc=reliable xapic_phys apic_debug" - -#define VM1_CONFIGURED - -#define VM1_CONFIG_NAME "PRE-LAUNCHED VM2 for DNV-CB2" -#define VM1_CONFIG_TYPE PRE_LAUNCHED_VM -#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3) | PLUG_CPU(5) | PLUG_CPU(7)) -#define VM1_CONFIG_FLAGS (GUEST_FLAG_LAPIC_PASSTHROUGH | GUEST_FLAG_IO_COMPLETION_POLLING | \ - GUEST_FLAG_RT) -#define VM1_CONFIG_MEM_START_HPA 0x180000000UL -#define VM1_CONFIG_MEM_SIZE 0x80000000UL - -#define VM1_CONFIG_OS_NAME "ClearLinux 26600" -#define VM1_CONFIG_OS_BOOTARGS "root=/dev/sda2 rw rootwait noxsave maxcpus=4 nohpet console=hvc0 "\ - "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ - "consoleblank=0 tsc=reliable xapic_phys apic_debug" - -#define VM0_CONFIG_PCI_PTDEV_NUM 3U -#define VM1_CONFIG_PCI_PTDEV_NUM 3U - -extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; -extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM]; - -#endif /* PARTITION_CONFIG_H */ diff --git a/hypervisor/arch/x86/configs/vm_config.c b/hypervisor/arch/x86/configs/vm_config.c index dee0c1a6c..c410cc2b8 100644 --- a/hypervisor/arch/x86/configs/vm_config.c +++ b/hypervisor/arch/x86/configs/vm_config.c @@ -11,11 +11,7 @@ #include #include #include -#ifndef CONFIG_PARTITION_MODE #include -#else -#include -#endif #define INIT_VM_CONFIG(idx) \ { \ diff --git a/hypervisor/scenarios/logical_partition/pt_dev.c b/hypervisor/scenarios/logical_partition/pt_dev.c new file mode 100644 index 000000000..d1bfa6267 --- /dev/null +++ b/hypervisor/scenarios/logical_partition/pt_dev.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = { + { + .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE + }, + { + .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, + STORAGE_CONTROLLER_0 + }, + { + .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, + ETHERNET_CONTROLLER_0 + }, +}; + +struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = { + { + .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE + }, + { + .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, + STORAGE_CONTROLLER_1 + }, + { + .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, + ETHERNET_CONTROLLER_1 + }, +}; diff --git a/hypervisor/scenarios/logical_partition/vm_configurations.h b/hypervisor/scenarios/logical_partition/vm_configurations.h new file mode 100644 index 000000000..49d736c80 --- /dev/null +++ b/hypervisor/scenarios/logical_partition/vm_configurations.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef VM_CONFIGURATIONS_H +#define VM_CONFIGURATIONS_H + +#include + +/* The VM CONFIGs like: + * VMX_CONFIG_PCPU_BITMAP + * VMX_CONFIG_MEM_START_HPA + * VMX_CONFIG_MEM_SIZE + * VMX_CONFIG_OS_BOOTARG_ROOT + * VMX_CONFIG_OS_BOOTARG_MAX_CPUS + * VMX_CONFIG_OS_BOOTARG_CONSOLE + * might be different on your board, please modify them per your needs. + */ + +#define VM0_CONFIGURED + +#define VM0_CONFIG_NAME "ACRN PRE-LAUNCHED VM0" +#define VM0_CONFIG_TYPE PRE_LAUNCHED_VM +#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2)) +#define VM0_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING +#define VM0_CONFIG_MEM_START_HPA 0x100000000UL +#define VM0_CONFIG_MEM_SIZE 0x20000000UL + +#define VM0_CONFIG_OS_NAME "ClearLinux" +#define VM0_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 " +#define VM0_CONFIG_OS_BOOTARG_MAX_CPUS "max_cpus=2 " +#define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 " +#define VM0_CONFIG_OS_BOOTARGS VM0_CONFIG_OS_BOOTARG_CONSOLE \ + VM0_CONFIG_OS_BOOTARG_ROOT \ + VM0_CONFIG_OS_BOOTARG_MAX_CPUS \ + "rw rootwait noxsave nohpet console=hvc0 \ + no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable xapic_phys" + +#define VM1_CONFIGURED + +#define VM1_CONFIG_NAME "ACRN PRE-LAUNCHED VM1" +#define VM1_CONFIG_TYPE PRE_LAUNCHED_VM +#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3)) +#define VM1_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING +#define VM1_CONFIG_MEM_START_HPA 0x120000000UL +#define VM1_CONFIG_MEM_SIZE 0x20000000UL + +#define VM1_CONFIG_OS_NAME "ClearLinux" +#define VM1_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 " +#define VM1_CONFIG_OS_BOOTARG_MAX_CPUS "max_cpus=2 " +#define VM1_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 " +#define VM1_CONFIG_OS_BOOTARGS VM1_CONFIG_OS_BOOTARG_CONSOLE \ + VM1_CONFIG_OS_BOOTARG_ROOT \ + VM1_CONFIG_OS_BOOTARG_MAX_CPUS \ + "rw rootwait noxsave nohpet console=hvc0 \ + no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable xapic_phys" + + +#define VM0_CONFIG_PCI_PTDEV_NUM 3U +extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; + +#define VM1_CONFIG_PCI_PTDEV_NUM 3U +extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; + +#endif /* VM_CONFIGURATIONS_H */