kvmtool, mips: Support more than 256 MB guest memory
Two guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)
tools/kvm/mips/include/kvm/kvm-arch.h +10 -0
@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used
tools/kvm/mips/kvm.c +30 -6
@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */ + phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start; -kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_SIZE ; + host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -0x10000000 ; + host_mem = kvm->ram_start +KVM_MMIO_SIZE ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)
@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_SIZE ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
Signature · 1 line
1.7.9.5
Quoted 47 lines · Andreas Herrmann
Two guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
Signed-off-by Andreas Herrmann <[email protected]>--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)tools/kvm/mips/include/kvm/kvm-arch.h +10
-0@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used tools/kvm/mips/kvm.c +2
-3@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */
tools/kvm/mips/kvm.c void kvm__init_ram(struct kvm *kvm) · line 35
Quoted 10 lines
tools/kvm/mips/kvm.c +8
-1+ phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start; -kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_SIZE ;
Here phys_size = KVM_MMIO_START is better to make more sense.
tools/kvm/mips/kvm.c void kvm__init_ram(struct kvm *kvm) · line 42
Quoted 7 lines
tools/kvm/mips/kvm.c +7
-0+ host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -0x10000000 ;
and, phys_size = kvm->ram_size - KVM_MMIO_START.
Tiejun
Quoted 26 lines
tools/kvm/mips/kvm.c +13
-2+ host_mem = kvm->ram_start +KVM_MMIO_SIZE ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_SIZE ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
Quoted 52 lines · Tiejun
Quoted 51 lines · Andreas Herrmann
Two guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
Signed-off-by Andreas Herrmann <[email protected]>--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)tools/kvm/mips/include/kvm/kvm-arch.h +10
-0@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used tools/kvm/mips/kvm.c +5
-3@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */ + phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start;
Quoted 8 lines
tools/kvm/mips/kvm.c void kvm__init_ram(struct kvm *kvm) · line 35
Quoted 6 lines
tools/kvm/mips/kvm.c +5
-1-kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_SIZE ;Here
phys_size=KVM_MMIO_STARTis better to make more sense.
Yep, you are right.
Quoted 9 lines
tools/kvm/mips/kvm.c void kvm__init_ram(struct kvm *kvm) · line 42
Quoted 7 lines
tools/kvm/mips/kvm.c +7
-0+ host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -0x10000000 ;and,
phys_size=kvm->ram_size-KVM_MMIO_START.
Dito.
I'll adapt the patch.
Thanks,
Andreas
Quoted 28 lines
Tiejun
Quoted 26 lines
tools/kvm/mips/kvm.c +13
-2+ host_mem = kvm->ram_start +KVM_MMIO_SIZE ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_SIZE ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
PATCH v2 1/1 kvmtool, mips: Support more than 256 MB guest memory
Two guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)
This version uses correct macros during calculation of memory parameters.
Andreas
tools/kvm/mips/include/kvm/kvm-arch.h +10 -0
@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used
tools/kvm/mips/kvm.c +30 -6
@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */ + phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start; -kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_START ; + host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -KVM_MMIO_START ; + host_mem = kvm->ram_start +KVM_MMIO_START ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)
@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_START ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
Signature · 1 line
1.7.9.5
Quoted 4 lines · Andreas Herrmann
Two guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
Cc Chen, Tiejun <[email protected]>
Looks fine to me.
Thanks
Tiejun
Quoted 94 lines
Signed-off-by Andreas Herrmann <[email protected]>--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)This version uses correct macros during calculation of memory parameters.
Andreas
tools/kvm/mips/include/kvm/kvm-arch.h +10
-0@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used tools/kvm/mips/kvm.c +30
-6@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */ + phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start; -kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_START ; + host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -KVM_MMIO_START ; + host_mem = kvm->ram_start +KVM_MMIO_START ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_START ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
PATCH v2 1/1 kvmtool, mips: Support more than 256 MB guest memory
In reply to Andreas HerrmannTwo guest memory regions need to be defined and two "mem=" parameters need to be passed to guest kernel to support more than 256 MB.
--- tools/kvm/mips/include/kvm/kvm-arch.h | 10 +++++++++ tools/kvm/mips/kvm.c | 36 +++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-)
This version uses correct macros during calculation of memory parameters.
Andreas
tools/kvm/mips/include/kvm/kvm-arch.h +10 -0
@@ -1,10 +1,20 @@#ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H + +/* +* Guest memory map is: +* 0x00000000-0x0fffffff : System RAM +* 0x10000000-0x1fffffff : I/O (defined by KVM_MMIO_START and KVM_MMIO_SIZE) +* 0x20000000- ... : System RAM +* See also kvm__init_ram(). +*/ +#define KVM_MMIO_START 0x10000000#define KVM_PCI_CFG_AREA KVM_MMIO_START#define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000)#define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define KVM_MMIO_SIZE 0x10000000/* * Just for reference. This and the above corresponds to what's used
tools/kvm/mips/kvm.c +30 -6
@@ -22,11 +22,28 @@ void kvm__init_ram(struct kvm *kvm)u64 phys_start, phys_size;void *host_mem; - phys_start =0 ; - phys_size = kvm->ram_size; - host_mem = kvm->ram_start; +if (kvm->ram_size <=KVM_MMIO_START ) { +/* one region for all memory */ + phys_start =0 ; + phys_size = kvm->ram_size; + host_mem = kvm->ram_start; -kvm__register_mem (kvm, phys_start, phys_size, host_mem); +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + }else { +/* one region for memory that fits below MMIO range */ + phys_start =0 ; + phys_size =KVM_MMIO_START ; + host_mem = kvm->ram_start; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + +/* one region for rest of memory */ + phys_start =KVM_MMIO_START +KVM_MMIO_SIZE ; + phys_size = kvm->ram_size -KVM_MMIO_START ; + host_mem = kvm->ram_start +KVM_MMIO_START ; + +kvm__register_mem (kvm, phys_start, phys_size, host_mem); + } }void kvm__arch_delete_ram (struct kvm *kvm)
@@ -108,8 +125,15 @@ static void kvm__mips_install_cmdline(struct kvm *kvm)u64 argv_offset = argv_start;u64 argc =0 ; -sprintf (p + cmdline_offset,"mem=0x%llx@0 " , - (unsigned long long )kvm->ram_size); + +if ((u64 ) kvm->ram_size <=KVM_MMIO_START ) +sprintf (p + cmdline_offset,"mem=0x%llx@0 " , + (unsigned long long )kvm->ram_size); +else +sprintf (p + cmdline_offset,"mem=0x%llx@0 mem=0x%llx@0x%llx " , + (unsigned long long )KVM_MMIO_START , + (unsigned long long )kvm->ram_size -KVM_MMIO_START , + (unsigned long long )(KVM_MMIO_START +KVM_MMIO_SIZE ));strcat (p + cmdline_offset, kvm->cfg.real_cmdline);/* maximum size is 2K */
Signature · 1 line
1.7.9.5