Add support for ppc64le in kvmtool
PATCH 1/5 Add basic little endian support.
In reply to Balbir SinghCurrently kvmtool works well/was designed for big endian ppc64 systems. This patch adds support for little endian systems
The system does not yet boot as support for h_set_mode is required to help with exceptions in big endian mode -- first page fault. The support comes in the next patch of the series
--- powerpc/kvm.c | 24 ++++++++++++------------ powerpc/spapr.h | 5 +++-- 2 files changed, 15 insertions(+), 14 deletions(-)
powerpc/kvm.c +12 -12
@@ -253,21 +253,21 @@ static void generate_segment_page_sizes(struct kvm_ppc_smmu_info *info, struct fif (sps->page_shift ==0 )break ; - *p++ = sps->page_shift; - *p++ = sps->slb_enc; + *p++ =cpu_to_be32 (sps->page_shift); + *p++ =cpu_to_be32 (sps->slb_enc);for (j =0 ; j <KVM_PPC_PAGE_SIZES_MAX_SZ ; j++)if (!info->sps[i].enc[j].page_shift)break ; - *p++ = j;/* count of enc */ + *p++ =cpu_to_be32 (j);/* count of enc */ for (j =0 ; j <KVM_PPC_PAGE_SIZES_MAX_SZ ; j++) {if (!info->sps[i].enc[j].page_shift)break ; - *p++ = info->sps[i].enc[j].page_shift; - *p++ = info->sps[i].enc[j].pte_enc; + *p++ =cpu_to_be32 (info->sps[i].enc[j].page_shift); + *p++ =cpu_to_be32 (info->sps[i].enc[j].pte_enc); } } }
@@ -292,7 +292,7 @@ static int setup_fdt(struct kvm *kvm)u8 staging_fdt[FDT_MAX_SIZE ];struct cpu_info *cpu_info =find_cpu_info (kvm);struct fdt_prop segment_page_sizes; -u32 segment_sizes_1T[] = {0x1c ,0x28 ,0xffffffff ,0xffffffff }; +u32 segment_sizes_1T[] = {cpu_to_be32 (0x1c ),cpu_to_be32 (0x28 ),0xffffffff ,0xffffffff };/* Generate an appropriate DT at kvm->arch.fdt_gra */ void *fdt_dest =guest_flat_to_host (kvm, kvm->arch.fdt_gra);
@@ -364,7 +364,7 @@ static int setup_fdt(struct kvm *kvm)_FDT (fdt_property_cell (fdt,"#size-cells" ,0x0 ));for (i =0 ; i < smp_cpus; i +=SMT_THREADS ) { -int32_t pft_size_prop[] = {0 ,HPT_ORDER }; +int32_t pft_size_prop[] = {0 ,cpu_to_be32 (HPT_ORDER ) };uint32_t servers_prop[SMT_THREADS ];uint32_t gservers_prop[SMT_THREADS *2 ]; int threads = (smp_cpus - i) >= SMT_THREADS ? SMT_THREADS :
@@ -503,11 +503,11 @@ int kvm__arch_setup_firmware(struct kvm *kvm)*/ uint32_t *rtas =guest_flat_to_host (kvm, kvm->arch.rtas_gra); - rtas[0 ] =0x7c641b78 ; - rtas[1 ] =0x3c600000 ; - rtas[2 ] =0x6063f000 ; - rtas[3 ] =0x44000022 ; - rtas[4 ] =0x4e800020 ; + rtas[0 ] =cpu_to_be32 (0x7c641b78 ); + rtas[1 ] =cpu_to_be32 (0x3c600000 ); + rtas[2 ] =cpu_to_be32 (0x6063f000 ); + rtas[3 ] =cpu_to_be32 (0x44000022 ); + rtas[4 ] =cpu_to_be32 (0x4e800020 ); kvm->arch.rtas_size =20 ; pr_info("Set up %ld bytes of RTAS at 0x%lx\n",
powerpc/spapr.h +3 -2
@@ -15,6 +15,7 @@#define __HW_SPAPR_H__#include <inttypes.h> +#include <linux/byteorder.h> #include "kvm/kvm.h" #include "kvm/kvm-cpu.h"
@@ -80,12 +81,12 @@ int spapr_rtas_fdt_setup(struct kvm *kvm, void *fdt);static inline uint32_t rtas_ld (struct kvm *kvm,target_ulong phys,int n) { -return *((uint32_t *)guest_flat_to_host (kvm, phys +4 *n)); +return cpu_to_be32 (*((uint32_t *)guest_flat_to_host (kvm, phys +4 *n))); }static inline void rtas_st (struct kvm *kvm,target_ulong phys,int n,uint32_t val) { - *((uint32_t *)guest_flat_to_host (kvm, phys +4 *n)) = val; + *((uint32_t *)guest_flat_to_host (kvm, phys +4 *n)) =cpu_to_be32 (val); } typedef void (*spapr_rtas_fn)(struct kvm_cpu *vcpu, uint32_t token,
Signature · 1 line
2.5.5
cover Add support for ppc64le in kvmtool
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4
This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces h_set_mode call to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixing spapr_pci to support little endian guests so that virtio-pci can be detected and virtio can work
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Balbir Singh (5):
Add basic little endian support.
Add basic infrastructure to run tasks on vCPUs
Implement H_SET_MODE for ppc64le
Fix a race during exit processing
Implement spapr pci for little endian systems.
arm/include/arm-common/kvm-cpu-arch.h | 1 + builtin-run.c | 3 ++ include/kvm/kvm-cpu.h | 6 +++ include/kvm/kvm.h | 1 + kvm-cpu.c | 73 +++++++++++++++++++++++++++++++++++ kvm.c | 5 +++ mips/include/kvm/kvm-cpu-arch.h | 1 + powerpc/include/kvm/kvm-cpu-arch.h | 3 ++ powerpc/kvm.c | 26 ++++++------- powerpc/spapr.h | 20 ++++++++-- powerpc/spapr_hcall.c | 66 +++++++++++++++++++++++++++++++ powerpc/spapr_pci.c | 25 ++++++------ x86/include/kvm/kvm-cpu-arch.h | 1 + 13 files changed, 203 insertions(+), 28 deletions(-)
Signature · 1 line
2.5.5
PATCH 4/5 Fix a race during exit processing
Fix a race, described below
lkvm stop ... handle_stop kvm_cpu__reboot kvm_cmd_run_exit vcpus exit ... dev_exit ... ioport__unregister ..serial... kvm__pause --> br_write_lock pthread_kill
But the thread is already dead above.
We mark the cpus as dying so that kvm_pause does nothing. This should not break any semantics
--- builtin-run.c | 3 +++ kvm.c | 5 +++++ 2 files changed, 8 insertions(+)
builtin-run.c +3 -0
@@ -58,6 +58,7 @@ __thread struct kvm_cpu *current_kvm_cpu;static int kvm_run_wrapper;bool do_debug_print = false; +int kvm_cmd_exit;static const char *const run_usage[] = {"lkvm run [<options>] [<kernel image>]" ,
@@ -648,6 +649,7 @@ static void kvm_cmd_run_exit(struct kvm *kvm, int guest_ret) {compat__print_all_messages (); + kvm_cmd_exit =1 ;init_list__exit (kvm);if (guest_ret ==0 && do_debug_print)
@@ -659,6 +661,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)int ret = -EFAULT ;struct kvm *kvm; + kvm_cmd_exit =0 ; kvm =kvm_cmd_run_init (argc, argv);if (IS_ERR (kvm))return PTR_ERR (kvm);
kvm.c +5 -0
@@ -33,6 +33,8 @@#define DEFINE_KVM_EXIT_REASON (reason) [reason] = #reason +extern int kvm_cmd_exit; +const char *kvm_exit_reasons[] = {DEFINE_KVM_EXIT_REASON (KVM_EXIT_UNKNOWN ),DEFINE_KVM_EXIT_REASON (KVM_EXIT_EXCEPTION ),
@@ -435,6 +437,9 @@ void kvm__pause(struct kvm *kvm)if (!kvm->cpus[0 ] || kvm->cpus[0 ]->thread ==0 )return ; +if (kvm_cmd_exit) +return ; +mutex_lock (&pause_lock); pause_event =eventfd (0 ,0 );
Signature · 1 line
2.5.5
PATCH 2/5 Add basic infrastructure to run tasks on vCPUs
In reply to Balbir SinghThis patch adds kvm_cpu__run_on_all_cpus() to run a task on each vCPU. This infrastructure uses signals to signal the vCPU to allow a task to be added to each vCPU's task. The vCPU executes any pending tasks in the cpu run loop
--- arm/include/arm-common/kvm-cpu-arch.h | 1 + include/kvm/kvm-cpu.h | 6 +++ include/kvm/kvm.h | 1 + kvm-cpu.c | 73 +++++++++++++++++++++++++++++++++++ mips/include/kvm/kvm-cpu-arch.h | 1 + powerpc/include/kvm/kvm-cpu-arch.h | 1 + x86/include/kvm/kvm-cpu-arch.h | 1 + 7 files changed, 84 insertions(+)
arm/include/arm-common/kvm-cpu-arch.h +1 -0
@@ -17,6 +17,7 @@ struct kvm_cpu {struct kvm *kvm;int vcpu_fd;struct kvm_run *kvm_run; +struct kvm_cpu_task *task;u8 is_running;u8 paused;
include/kvm/kvm-cpu.h +6 -0
@@ -4,6 +4,11 @@#include "kvm/kvm-cpu-arch.h" #include <stdbool.h> +struct kvm_cpu_task { +void (*func)(struct kvm_cpu *vcpu,void *data); +void *data; +}; +int kvm_cpu__init (struct kvm *kvm);int kvm_cpu__exit (struct kvm *kvm);struct kvm_cpu *kvm_cpu__arch_init (struct kvm *kvm,unsigned long cpu_id);
@@ -23,5 +28,6 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu);void kvm_cpu__show_registers (struct kvm_cpu *vcpu);void kvm_cpu__show_page_tables (struct kvm_cpu *vcpu);void kvm_cpu__arch_nmi (struct kvm_cpu *cpu); +void kvm_cpu__run_on_all_cpus (struct kvm *kvm,struct kvm_cpu_task *task);#endif /* KVM__KVM_CPU_H */
include/kvm/kvm.h +1 -0
@@ -15,6 +15,7 @@#define SIGKVMEXIT (SIGRTMIN + 0)#define SIGKVMPAUSE (SIGRTMIN + 1) +#define SIGKVMTASK (SIGRTMIN + 2)#define KVM_PID_FILE_PATH "/.lkvm/"#define HOME_DIR getenv("HOME")
kvm-cpu.c +73 -0
118 lines not on this page · raw message
mips/include/kvm/kvm-cpu-arch.h +1 -0
@@ -15,6 +15,7 @@ struct kvm_cpu {struct kvm *kvm;/* parent KVM */ int vcpu_fd;/* For VCPU ioctls() */ struct kvm_run *kvm_run; +struct kvm_cpu_task *task;struct kvm_regs regs;
powerpc/include/kvm/kvm-cpu-arch.h +1 -0
@@ -48,6 +48,7 @@ struct kvm_cpu {struct kvm *kvm;/* parent KVM */ int vcpu_fd;/* For VCPU ioctls() */ struct kvm_run *kvm_run; +struct kvm_cpu_task *task;struct kvm_regs regs;struct kvm_sregs sregs;
x86/include/kvm/kvm-cpu-arch.h +1 -0
@@ -18,6 +18,7 @@ struct kvm_cpu {struct kvm *kvm;/* parent KVM */ int vcpu_fd;/* For VCPU ioctls() */ struct kvm_run *kvm_run; +struct kvm_cpu_task *task;struct kvm_regs regs;struct kvm_sregs sregs;
Signature · 1 line
2.5.5
PATCH 3/5 Implement H_SET_MODE for ppc64le
In reply to Balbir SinghUse the infrastructure for queuing a task to a specific vCPU and sett ILE (Little Endian Interrupt Handling) on power via h_set_mode hypercall
--- powerpc/include/kvm/kvm-cpu-arch.h | 2 ++ powerpc/kvm.c | 2 +- powerpc/spapr.h | 15 +++++++-- powerpc/spapr_hcall.c | 66 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 3 deletions(-)
powerpc/include/kvm/kvm-cpu-arch.h +2 -0
@@ -38,6 +38,8 @@#define POWER7_EXT_IRQ 0 +#define LPCR_ILE (1 << (63-38)) +struct kvm ;struct kvm_cpu {
powerpc/kvm.c +1 -1
@@ -286,7 +286,7 @@ static int setup_fdt(struct kvm *kvm)uint32_t int_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)};char hypertas_prop_kvm[] ="hcall-pft\0hcall-term\0" "hcall-dabr\0hcall-interrupt\0hcall-tce\0hcall-vio\0" -"hcall-splpar\0hcall-bulk" ; +"hcall-splpar\0hcall-bulk\0hcall-set-mode" ;int i, j;char cpu_name[30 ];u8 staging_fdt[FDT_MAX_SIZE ];
powerpc/spapr.h +13 -2
@@ -27,7 +27,7 @@ typedef uintptr_t target_phys_addr_t;#define H_HARDWARE -1/* Hardware error */ #define H_FUNCTION -2/* Function not supported */ #define H_PARAMETER -4/* Parameter invalid, out-of-range or conflicting */ - +#define H_P2 -55#define H_SET_DABR 0x28#define H_LOGICAL_CI_LOAD 0x3c#define H_LOGICAL_CI_STORE 0x40
@@ -41,7 +41,18 @@ typedef uintptr_t target_phys_addr_t;#define H_EOI 0x64#define H_IPI 0x6c#define H_XIRR 0x74 -#define MAX_HCALL_OPCODE H_XIRR +#define H_SET_MODE 0x31C +#define MAX_HCALL_OPCODE H_SET_MODE + +/* Values for 2nd argument to H_SET_MODE */ +#define H_SET_MODE_RESOURCE_SET_CIABR 1 +#define H_SET_MODE_RESOURCE_SET_DAWR 2 +#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3 +#define H_SET_MODE_RESOURCE_LE 4 + +/* Flags for H_SET_MODE_RESOURCE_LE */ +#define H_SET_MODE_ENDIAN_BIG 0 +#define H_SET_MODE_ENDIAN_LITTLE 1/* * The hcalls above are standardized in PAPR and implemented by pHyp
powerpc/spapr_hcall.c +66 -0
84 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH 5/5 Implement spapr pci for little endian systems.
In reply to Balbir SinghPort the spapr_pci implementation for ppc64le. Based on suggestions by Alexey Kardashevskiy <[email protected]> We should have always used phys_hi and 64 bit addr and size.
--- powerpc/spapr_pci.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
powerpc/spapr_pci.c +14 -11
@@ -234,8 +234,11 @@ int spapr_populate_pci_devices(struct kvm *kvm,int bus_off, node_off =0 , devid, fn, i, n, devices;struct device_header *dev_hdr;char nodename[256 ]; -struct of_pci_unit_address reg[PCI_NUM_REGIONS +1 ], - assigned_addresses[PCI_NUM_REGIONS ]; +struct of_pci_unit64_address { +u32 phys_hi; +u64 addr; +u64 size; + } __attribute((packed)) reg[PCI_NUM_REGIONS +1 ], assigned_addresses[PCI_NUM_REGIONS ];uint32_t bus_range[] = {cpu_to_be32 (0 ),cpu_to_be32 (0xff ) };struct of_pci_ranges_entry ranges[] = { {
@@ -339,7 +342,7 @@ int spapr_populate_pci_devices(struct kvm *kvm, le16_to_cpu(hdr->subsys_vendor_id)));/* Config space region comes first */ - reg[0].hi = cpu_to_be32( + reg[0].phys_hi = cpu_to_be32( of_pci_b_n(0) | of_pci_b_p(0) | of_pci_b_t(0) |
@@ -347,8 +350,8 @@ int spapr_populate_pci_devices(struct kvm *kvm,of_pci_b_bbbbbbbb (0 ) |of_pci_b_ddddd (devid) | of_pci_b_fff(fn)); - reg[0 ].mid =0 ; - reg[0 ].lo =0 ; + reg[0 ].addr =0 ; + reg[0 ].size =0 ; n =0 ;/* Six BARs, no ROM supported, addresses are 32bit */
@@ -357,7 +360,7 @@ int spapr_populate_pci_devices(struct kvm *kvm,continue ; } - reg[n+1].hi = cpu_to_be32( + reg[n+1].phys_hi = cpu_to_be32( of_pci_b_n(0) | of_pci_b_p(0) | of_pci_b_t(0) |
@@ -366,10 +369,10 @@ int spapr_populate_pci_devices(struct kvm *kvm,of_pci_b_ddddd (devid) |of_pci_b_fff (fn) | of_pci_b_rrrrrrrr(bars[i])); - reg[n+1 ].mid =0 ; - reg[n+1 ].lo =cpu_to_be64 (hdr->bar_size[i]); + reg[n+1 ].size =cpu_to_be64 (hdr->bar_size[i]); + reg[n+1 ].addr =0 ; - assigned_addresses[n].hi = cpu_to_be32( + assigned_addresses[n].phys_hi = cpu_to_be32( of_pci_b_n(1) | of_pci_b_p(0) | of_pci_b_t(0) |
@@ -383,8 +386,8 @@ int spapr_populate_pci_devices(struct kvm *kvm,* Writing zeroes to assigned_addresses causes the guest kernel to * reassign BARs */ - assigned_addresses[n].mid =cpu_to_be64 (bar_to_addr (le32_to_cpu (hdr->bar[i]))); - assigned_addresses[n].lo = reg[n+1 ].lo; + assigned_addresses[n].addr =cpu_to_be64 (bar_to_addr (le32_to_cpu (hdr->bar[i]))); + assigned_addresses[n].size = reg[n+1 ].size; ++n; }
Signature · 1 line
2.5.5
Hi,
could you add "kvmtool" in the subject, next time, please? :) And it could be a good idea to send to kvm-ppc ML too.
Quoted 11 lines · Balbir Singh
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can work
Quoted 8 lines
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Balbir Singh (5):
Add basic little endian support.
Add basic infrastructure to run tasks on vCPUs
ImplementH_SET_MODEfor ppc64le
Fix a race during exit processing
Implement spapr pci for little endian systems.
I was trying to use kvmtool on ppc64, some days ago, and I was not able to run anything (yes, I'm stupid), So could you also update the README with some ppc64/ppc64le stuff explaining how to use kvmtool on POWER?
Or give me a link to the information, and I'll do.
Thanks,
Laurent
Quoted 5 lines · Laurent Vivier
Hi,
could you add "kvmtool" in the subject, next time, please? :) And it could be a good idea to send to kvm-ppc ML too.
You mean like in [kvmtool]? The cover letter does have kvmtool, I think adding [kvmtool] tag helps. I'll keep it in mind
Quoted 20 lines · Balbir Singh
Quoted 11 lines
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can workQuoted 8 lines
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Balbir Singh (5):
Add basic little endian support.
Add basic infrastructure to run tasks on vCPUs
ImplementH_SET_MODEfor ppc64le
Fix a race during exit processing
Implement spapr pci for little endian systems.
Quoted 3 lines
I was trying to use kvmtool on ppc64, some days ago, and I was not able to run anything (yes, I'm stupid), So could you also update the README with some ppc64/ppc64le stuff explaining how to use kvmtool on POWER?
No.. I don't think anyone is stupid, may be it just doesn't work. For ppc64le here are the steps. I'll write a README after this series is committed
1. Make sure you have this patchset
2. Compile a ppc64le_defconfig kernel
3. Strip the elf header from vmlinux (yes, we don't yet have an elf parser - TODO)
4. lkvm run -c <cpus> -m <mem{constrained to 4G}> -k <kernel from step 3> -i <initrd> -d <diskimage> -p <args> --console hv
There are two limitations that need to be fixed
1. memory is limited to 4G because of the way RTAS is currently setup in kvmtool, I have a brute force fix for it, I'll post it after this series is merged
2. HPT size is limited to 16MB, will post a patch after this series is merged
TODOs
1. Implement an elf parser so that we don't have to do step 3
Quoted 1 line
Or give me a link to the information, and I'll do.
I hope this helps, I can do some documentation once we get the limitations and TODOs resolved
Quoted 2 lines
Thanks,
Laurent
Thanks for looking into this
Balbir
Re: [PATCH 2/5] Add basic infrastructure to run tasks on vCPUs
In reply to Balbir SinghQuoted 7 lines · Balbir Singh
This patch adds
kvm_cpu__run_on_all_cpus()to run a task on each vCPU. This infrastructure uses signals to signal the vCPU to allow a task to be added to each vCPU's task. The vCPU executes any pending tasks in the cpu run loopSigned-off-by Balbir Singh <[email protected]>Signed-off-by Michael Ellerman <[email protected]>
This was based on your code, but I think I pretty much rewrote it. So this should probably be From me. So I get the blame for the inevitable bugs :)
cheers
Quoted 11 lines · Balbir Singh
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can work
Quoted 1 line
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Hi Will,
I'm pretty happy with this series. We still have plenty of warts in the ppc code but this is a definite improvement.
cheers
Quoted 13 lines · Michael Ellerman
Quoted 11 lines · Balbir Singh
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can work
Quoted 8 lines
Quoted 1 line
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Hi Will,
I'm pretty happy with this series. We still have plenty of warts in the ppc code but this is a definite improvement.
Acked-by Michael Ellerman <[email protected]>
Brill, thanks Michael. I need to take a closer look at the race condition fix, because it doesn't sit right with me, but I'll consider the PPC bits as good for merging.
Will
Re: [PATCH 2/5] Add basic infrastructure to run tasks on vCPUs
In reply to Michael EllermanAgreed
Will should I resend this bit with a new From?
Balbir
Quoted 15 lines · Michael Ellerman
Quoted 7 lines · Balbir Singh
This patch adds
kvm_cpu__run_on_all_cpus()to run a task on each vCPU. This infrastructure uses signals to signal the vCPU to allow a task to be added to each vCPU's task. The vCPU executes any pending tasks in the cpu run loopSigned-off-by Balbir Singh <[email protected]>Signed-off-by Michael Ellerman <[email protected]>This was based on your code, but I think I pretty much rewrote it. So this should probably be From me. So I get the blame for the inevitable bugs :)
cheers
Re: [PATCH 2/5] Add basic infrastructure to run tasks on vCPUs
Quoted 3 lines · Balbir Singh
Agreed
Will should I resend this bit with a new From?
Sure, feel free to repost the whole series with Michael's acks too.
Will
Quoted 50 lines · Balbir Singh
Quoted 5 lines · Laurent Vivier
Hi,
could you add "kvmtool" in the subject, next time, please? :) And it could be a good idea to send to kvm-ppc ML too.
You mean like in [kvmtool]? The cover letter does have kvmtool, I think adding [kvmtool] tag helps. I'll keep it in mind
Quoted 20 lines · Balbir Singh
Quoted 11 lines
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can workQuoted 8 lines
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Balbir Singh (5):
Add basic little endian support.
Add basic infrastructure to run tasks on vCPUs
ImplementH_SET_MODEfor ppc64le
Fix a race during exit processing
Implement spapr pci for little endian systems.Quoted 3 lines
I was trying to use kvmtool on ppc64, some days ago, and I was not able to run anything (yes, I'm stupid), So could you also update the README with some ppc64/ppc64le stuff explaining how to use kvmtool on POWER?
No.. I don't think anyone is stupid, may be it just doesn't work. For ppc64le here are the steps. I'll write a README after this series is committed
1. Make sure you have this patchset
2. Compile appc64le_defconfigkernel
3. Strip the elf header from vmlinux (yes, we don't yet have an elf parser - TODO)
4. lkvm run -c <cpus> -m <mem{constrained to 4G}> -k <kernel from step 3> -i <initrd> -d <diskimage> -p <args> --console hvThere are two limitations that need to be fixed
1. memory is limited to 4G because of the way RTAS is currently setup in kvmtool, I have a brute force fix for it, I'll post it after this series is merged
2. HPT size is limited to 16MB, will post a patch after this series is mergedTODOs
1. Implement an elf parser so that we don't have to do step 3
Quoted 7 lines
Quoted 1 line
Or give me a link to the information, and I'll do.
I hope this helps, I can do some documentation once we get the limitations and TODOs resolved
Quoted 2 lines
Thanks,
LaurentThanks for looking into this
Balbir
Hi,
Did the instructions help? Any luck with running kvmtool?
Balbir
Quoted 42 lines · Balbir Singh
Quoted 41 lines · Balbir Singh
Quoted 5 lines · Laurent Vivier
Hi,
could you add "kvmtool" in the subject, next time, please? :) And it could be a good idea to send to kvm-ppc ML too.
You mean like in [kvmtool]? The cover letter does have kvmtool, I think adding [kvmtool] tag helps. I'll keep it in mind
Quoted 20 lines · Balbir Singh
Quoted 11 lines
Changelog v2: Add support for running a task on all cpus by
Michael Ellerman. Large improvements to patch 2/4This patchset adds support for ppc64le. As a part of the support 1/4 converts key data structures in the fdt to big endian. 2/4 introduces
h_set_modecall to support little endian interrupt processing. This requires support to execute and queue commands to a particular vcpu and hence a generic infrastructure is added in patch 2/4. Patch 3/4 fixes a race condition found during exit. Patch 4/4 adds support for fixingspapr_pcito support little endian guests so that virtio-pci can be detected and virtio can workQuoted 8 lines
This patchset was tested on x64 (on my laptop) and on a ppc64le system.
Balbir Singh (5):
Add basic little endian support.
Add basic infrastructure to run tasks on vCPUs
ImplementH_SET_MODEfor ppc64le
Fix a race during exit processing
Implement spapr pci for little endian systems.Quoted 3 lines
I was trying to use kvmtool on ppc64, some days ago, and I was not able to run anything (yes, I'm stupid), So could you also update the README with some ppc64/ppc64le stuff explaining how to use kvmtool on POWER?
No.. I don't think anyone is stupid, may be it just doesn't work. For ppc64le here are the steps. I'll write a README after this series is committed
1. Make sure you have this patchset
2. Compile appc64le_defconfigkernel
3. Strip the elf header from vmlinux (yes, we don't yet have an elf parser - TODO)
4. lkvm run -c <cpus> -m <mem{constrained to 4G}> -k <kernel from step 3> -i <initrd> -d <diskimage> -p <args> --console hv
Quoted 4 lines
Quoted 4 lines
There are two limitations that need to be fixed
1. memory is limited to 4G because of the way RTAS is currently setup in kvmtool, I have a brute force fix for it, I'll post it after this series is merged
2. HPT size is limited to 16MB, will post a patch after this series is merged
Do you know David Gibson is working on a patch series for QEMU/KVM to change the size of the HPT while the guest is running?
http://patchwork.ozlabs.org/patch/599965/
Quoted 6 lines
Quoted 6 lines
TODOs
1. Implement an elf parser so that we don't have to do step 3Quoted 1 line
Or give me a link to the information, and I'll do.
Quoted 8 lines
Quoted 6 lines
I hope this helps, I can do some documentation once we get the limitations and TODOs resolved
Quoted 2 lines
Thanks,
LaurentThanks for looking into this
BalbirHi,
Hi,
Quoted 2 lines
Did the instructions help? Any luck with running kvmtool?
This is helpful but I didn't have the time to try again.
Just one more question: how do you strip the ELF header (step 3)?
Thanks,
Laurent
Quoted 5 lines
Quoted 1 line
This is helpful but I didn't have the time to try again.
Just one more question: how do you strip the ELF header (step 3)?
I use
objcopy -O binary vmlinux vmlinux.bin
Balbir
Quoted 9 lines · Balbir Singh
Quoted 5 lines
Quoted 1 line
This is helpful but I didn't have the time to try again.
Just one more question: how do you strip the ELF header (step 3)?
I use
objcopy -O binary vmlinux vmlinux.bin
Many thanks!
It was the missing part :)
I'm able to boot a big-endian kernel now, I'll test your patches as soon as I have access to a little-endian capable host.
Laurent
Re: [PATCH 2/5] Add basic infrastructure to run tasks on vCPUs
In reply to Will DeaconQuoted 7 lines · Will Deacon
Quoted 3 lines · Balbir Singh
Agreed
Will should I resend this bit with a new From?
Sure, feel free to repost the whole series with Michael's acks too.
Done a few days back
Balbir
Re: [PATCH 4/5] Fix a race during exit processing
In reply to Balbir SinghQuoted 14 lines · Balbir Singh
Fix a race, described below
lkvm stop ... handle_stop kvm_cpu__reboot kvm_cmd_run_exit vcpus exit ... dev_exit ... ioport__unregister ..serial... kvm__pause --> br_write_lock pthread_kill
Quoted 4 lines
But the thread is already dead above.
We mark the cpus as dying so that
kvm_pausedoes nothing. This should not break any semantics
I'm not convinced that this solves the whole problem. The fact of the matter is that we're tearing down the VM whilst there may still be active vcpus, so I'd much rather delay the teardown until we know that the vcpus are all dead.
Patch incoming.
Will