All of lore.kernel.org
 help / color / mirror / Atom feed
* Add zicboz support for riscv kvmtool
@ 2023-04-18 14:22 ` Ben Dooks
  0 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones

This is two simple patches, the first to sync the defines to ensure
that the struct kvm_riscv_config is sync with upstream and the second
to allow zicboz support into the guest.

[PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync
[PATCH kvmtool 2/2] riscv: add zicboz support


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Add zicboz support for riscv kvmtool
@ 2023-04-18 14:22 ` Ben Dooks
  0 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones

This is two simple patches, the first to sync the defines to ensure
that the struct kvm_riscv_config is sync with upstream and the second
to allow zicboz support into the guest.

[PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync
[PATCH kvmtool 2/2] riscv: add zicboz support


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync kvm_riscv_config
  2023-04-18 14:22 ` Ben Dooks
@ 2023-04-18 14:22   ` Ben Dooks
  -1 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones, Ben Dooks

Add the ONE_REG for the mvendorid/marchid/mimpid from the kernel
commit 6ebbdecff6ae00557a52539287b681641f4f0d33, to ensure the
struct is in sync with newer kernels for adding zicboz.

Ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/id=6ebbdecff6ae00557a52539287b681641f4f0d33

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 riscv/include/asm/kvm.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index 8985ff2..92af6f3 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -49,6 +49,9 @@ struct kvm_sregs {
 struct kvm_riscv_config {
 	unsigned long isa;
 	unsigned long zicbom_block_size;
+	unsigned long mvendorid;
+	unsigned long marchid;
+	unsigned long mimpid;
 };
 
 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
-- 
2.39.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync kvm_riscv_config
@ 2023-04-18 14:22   ` Ben Dooks
  0 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones, Ben Dooks

Add the ONE_REG for the mvendorid/marchid/mimpid from the kernel
commit 6ebbdecff6ae00557a52539287b681641f4f0d33, to ensure the
struct is in sync with newer kernels for adding zicboz.

Ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/id=6ebbdecff6ae00557a52539287b681641f4f0d33

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 riscv/include/asm/kvm.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index 8985ff2..92af6f3 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -49,6 +49,9 @@ struct kvm_sregs {
 struct kvm_riscv_config {
 	unsigned long isa;
 	unsigned long zicbom_block_size;
+	unsigned long mvendorid;
+	unsigned long marchid;
+	unsigned long mimpid;
 };
 
 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH kvmtool 2/2] riscv: add zicboz support
  2023-04-18 14:22 ` Ben Dooks
@ 2023-04-18 14:22   ` Ben Dooks
  -1 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones, Ben Dooks

Like ZICBOM, the ZICBOZ extension requires passing extra information to
the guest. Add the control to pass the information to the guest, get it
from the kvm ioctl and pass into the guest via the device-tree info.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 riscv/fdt.c                         | 11 +++++++++++
 riscv/include/asm/kvm.h             |  2 ++
 riscv/include/kvm/kvm-config-arch.h |  3 +++
 3 files changed, 16 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index 3cdb95c..fa6d153 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
 	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
 	{"zihintpause", KVM_RISCV_ISA_EXT_ZIHINTPAUSE},
 	{"zicbom", KVM_RISCV_ISA_EXT_ZICBOM},
+	{"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ},
 };
 
 static void dump_fdt(const char *dtb_file, void *fdt)
@@ -46,6 +47,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 	const char *valid_isa_order = "IEMAFDQCLBJTPVNSUHKORWXYZG";
 	int arr_sz = ARRAY_SIZE(isa_info_arr);
 	unsigned long cbom_blksz = 0;
+	unsigned long cboz_blksz = 0;
 
 	_FDT(fdt_begin_node(fdt, "cpus"));
 	_FDT(fdt_property_cell(fdt, "#address-cells", 0x1));
@@ -95,6 +97,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 					die("KVM_GET_ONE_REG failed (config.zicbom_block_size)");
 			}
 
+			if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOZ && !cboz_blksz) {
+				reg.id = RISCV_CONFIG_REG(zicboz_block_size);
+				reg.addr = (unsigned long)&cboz_blksz;
+				if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
+					die("KVM_GET_ONE_REG failed (config.zicboz_block_size)");
+			}
+
 			if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) {
 				pr_warning("Insufficient space to append ISA exension\n");
 				break;
@@ -116,6 +125,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 		_FDT(fdt_property_string(fdt, "riscv,isa", cpu_isa));
 		if (cbom_blksz)
 			_FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz));
+		if (cboz_blksz)
+			_FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz));
 		_FDT(fdt_property_cell(fdt, "reg", cpu));
 		_FDT(fdt_property_string(fdt, "status", "okay"));
 
diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index 92af6f3..e44c1e9 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -52,6 +52,7 @@ struct kvm_riscv_config {
 	unsigned long mvendorid;
 	unsigned long marchid;
 	unsigned long mimpid;
+	unsigned long zicboz_block_size;
 };
 
 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
@@ -105,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID {
 	KVM_RISCV_ISA_EXT_SVINVAL,
 	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
 	KVM_RISCV_ISA_EXT_ZICBOM,
+	KVM_RISCV_ISA_EXT_ZICBOZ,
 	KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 188125c..46a774e 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -24,6 +24,9 @@ struct kvm_config_arch {
 	OPT_BOOLEAN('\0', "disable-zicbom",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM],	\
 		    "Disable Zicbom Extension"),			\
+	OPT_BOOLEAN('\0', "disable-zicboz",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ],	\
+		    "Disable Zicboz Extension"),			\
 	OPT_BOOLEAN('\0', "disable-zihintpause",			\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
 		    "Disable Zihintpause Extension"),
-- 
2.39.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH kvmtool 2/2] riscv: add zicboz support
@ 2023-04-18 14:22   ` Ben Dooks
  0 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 14:22 UTC (permalink / raw)
  To: kvm; +Cc: linux-riscv, ajones, Ben Dooks

Like ZICBOM, the ZICBOZ extension requires passing extra information to
the guest. Add the control to pass the information to the guest, get it
from the kvm ioctl and pass into the guest via the device-tree info.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 riscv/fdt.c                         | 11 +++++++++++
 riscv/include/asm/kvm.h             |  2 ++
 riscv/include/kvm/kvm-config-arch.h |  3 +++
 3 files changed, 16 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index 3cdb95c..fa6d153 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
 	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
 	{"zihintpause", KVM_RISCV_ISA_EXT_ZIHINTPAUSE},
 	{"zicbom", KVM_RISCV_ISA_EXT_ZICBOM},
+	{"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ},
 };
 
 static void dump_fdt(const char *dtb_file, void *fdt)
@@ -46,6 +47,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 	const char *valid_isa_order = "IEMAFDQCLBJTPVNSUHKORWXYZG";
 	int arr_sz = ARRAY_SIZE(isa_info_arr);
 	unsigned long cbom_blksz = 0;
+	unsigned long cboz_blksz = 0;
 
 	_FDT(fdt_begin_node(fdt, "cpus"));
 	_FDT(fdt_property_cell(fdt, "#address-cells", 0x1));
@@ -95,6 +97,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 					die("KVM_GET_ONE_REG failed (config.zicbom_block_size)");
 			}
 
+			if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOZ && !cboz_blksz) {
+				reg.id = RISCV_CONFIG_REG(zicboz_block_size);
+				reg.addr = (unsigned long)&cboz_blksz;
+				if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
+					die("KVM_GET_ONE_REG failed (config.zicboz_block_size)");
+			}
+
 			if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) {
 				pr_warning("Insufficient space to append ISA exension\n");
 				break;
@@ -116,6 +125,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
 		_FDT(fdt_property_string(fdt, "riscv,isa", cpu_isa));
 		if (cbom_blksz)
 			_FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz));
+		if (cboz_blksz)
+			_FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz));
 		_FDT(fdt_property_cell(fdt, "reg", cpu));
 		_FDT(fdt_property_string(fdt, "status", "okay"));
 
diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index 92af6f3..e44c1e9 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -52,6 +52,7 @@ struct kvm_riscv_config {
 	unsigned long mvendorid;
 	unsigned long marchid;
 	unsigned long mimpid;
+	unsigned long zicboz_block_size;
 };
 
 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
@@ -105,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID {
 	KVM_RISCV_ISA_EXT_SVINVAL,
 	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
 	KVM_RISCV_ISA_EXT_ZICBOM,
+	KVM_RISCV_ISA_EXT_ZICBOZ,
 	KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 188125c..46a774e 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -24,6 +24,9 @@ struct kvm_config_arch {
 	OPT_BOOLEAN('\0', "disable-zicbom",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM],	\
 		    "Disable Zicbom Extension"),			\
+	OPT_BOOLEAN('\0', "disable-zicboz",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ],	\
+		    "Disable Zicboz Extension"),			\
 	OPT_BOOLEAN('\0', "disable-zihintpause",			\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
 		    "Disable Zihintpause Extension"),
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
  2023-04-18 14:22   ` Ben Dooks
@ 2023-04-18 15:00     ` Andrew Jones
  -1 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 15:00 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
> Like ZICBOM, the ZICBOZ extension requires passing extra information to
> the guest. Add the control to pass the information to the guest, get it
> from the kvm ioctl and pass into the guest via the device-tree info.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  riscv/fdt.c                         | 11 +++++++++++
>  riscv/include/asm/kvm.h             |  2 ++
>  riscv/include/kvm/kvm-config-arch.h |  3 +++
>  3 files changed, 16 insertions(+)

Hi Ben,

I have a patch almost identical to this one here

https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c

The differences are that I don't add the header changes in this patch
(as they'll come with a proper header update after Linux patches get
merged), and I forgot to add the disable-zicboz, which you have.

I was planning on posting after the Linux patches get merged so
I could do the proper header update first.

Thanks,
drew


> 
> diff --git a/riscv/fdt.c b/riscv/fdt.c
> index 3cdb95c..fa6d153 100644
> --- a/riscv/fdt.c
> +++ b/riscv/fdt.c
> @@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
>  	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
>  	{"zihintpause", KVM_RISCV_ISA_EXT_ZIHINTPAUSE},
>  	{"zicbom", KVM_RISCV_ISA_EXT_ZICBOM},
> +	{"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ},
>  };
>  
>  static void dump_fdt(const char *dtb_file, void *fdt)
> @@ -46,6 +47,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  	const char *valid_isa_order = "IEMAFDQCLBJTPVNSUHKORWXYZG";
>  	int arr_sz = ARRAY_SIZE(isa_info_arr);
>  	unsigned long cbom_blksz = 0;
> +	unsigned long cboz_blksz = 0;
>  
>  	_FDT(fdt_begin_node(fdt, "cpus"));
>  	_FDT(fdt_property_cell(fdt, "#address-cells", 0x1));
> @@ -95,6 +97,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  					die("KVM_GET_ONE_REG failed (config.zicbom_block_size)");
>  			}
>  
> +			if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOZ && !cboz_blksz) {
> +				reg.id = RISCV_CONFIG_REG(zicboz_block_size);
> +				reg.addr = (unsigned long)&cboz_blksz;
> +				if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
> +					die("KVM_GET_ONE_REG failed (config.zicboz_block_size)");
> +			}
> +
>  			if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) {
>  				pr_warning("Insufficient space to append ISA exension\n");
>  				break;
> @@ -116,6 +125,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  		_FDT(fdt_property_string(fdt, "riscv,isa", cpu_isa));
>  		if (cbom_blksz)
>  			_FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz));
> +		if (cboz_blksz)
> +			_FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz));
>  		_FDT(fdt_property_cell(fdt, "reg", cpu));
>  		_FDT(fdt_property_string(fdt, "status", "okay"));
>  
> diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
> index 92af6f3..e44c1e9 100644
> --- a/riscv/include/asm/kvm.h
> +++ b/riscv/include/asm/kvm.h
> @@ -52,6 +52,7 @@ struct kvm_riscv_config {
>  	unsigned long mvendorid;
>  	unsigned long marchid;
>  	unsigned long mimpid;
> +	unsigned long zicboz_block_size;
>  };
>  
>  /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> @@ -105,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID {
>  	KVM_RISCV_ISA_EXT_SVINVAL,
>  	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
>  	KVM_RISCV_ISA_EXT_ZICBOM,
> +	KVM_RISCV_ISA_EXT_ZICBOZ,
>  	KVM_RISCV_ISA_EXT_MAX,
>  };
>  
> diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
> index 188125c..46a774e 100644
> --- a/riscv/include/kvm/kvm-config-arch.h
> +++ b/riscv/include/kvm/kvm-config-arch.h
> @@ -24,6 +24,9 @@ struct kvm_config_arch {
>  	OPT_BOOLEAN('\0', "disable-zicbom",				\
>  		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM],	\
>  		    "Disable Zicbom Extension"),			\
> +	OPT_BOOLEAN('\0', "disable-zicboz",				\
> +		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ],	\
> +		    "Disable Zicboz Extension"),			\
>  	OPT_BOOLEAN('\0', "disable-zihintpause",			\
>  		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
>  		    "Disable Zihintpause Extension"),
> -- 
> 2.39.2
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
@ 2023-04-18 15:00     ` Andrew Jones
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 15:00 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
> Like ZICBOM, the ZICBOZ extension requires passing extra information to
> the guest. Add the control to pass the information to the guest, get it
> from the kvm ioctl and pass into the guest via the device-tree info.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  riscv/fdt.c                         | 11 +++++++++++
>  riscv/include/asm/kvm.h             |  2 ++
>  riscv/include/kvm/kvm-config-arch.h |  3 +++
>  3 files changed, 16 insertions(+)

Hi Ben,

I have a patch almost identical to this one here

https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c

The differences are that I don't add the header changes in this patch
(as they'll come with a proper header update after Linux patches get
merged), and I forgot to add the disable-zicboz, which you have.

I was planning on posting after the Linux patches get merged so
I could do the proper header update first.

Thanks,
drew


> 
> diff --git a/riscv/fdt.c b/riscv/fdt.c
> index 3cdb95c..fa6d153 100644
> --- a/riscv/fdt.c
> +++ b/riscv/fdt.c
> @@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
>  	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
>  	{"zihintpause", KVM_RISCV_ISA_EXT_ZIHINTPAUSE},
>  	{"zicbom", KVM_RISCV_ISA_EXT_ZICBOM},
> +	{"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ},
>  };
>  
>  static void dump_fdt(const char *dtb_file, void *fdt)
> @@ -46,6 +47,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  	const char *valid_isa_order = "IEMAFDQCLBJTPVNSUHKORWXYZG";
>  	int arr_sz = ARRAY_SIZE(isa_info_arr);
>  	unsigned long cbom_blksz = 0;
> +	unsigned long cboz_blksz = 0;
>  
>  	_FDT(fdt_begin_node(fdt, "cpus"));
>  	_FDT(fdt_property_cell(fdt, "#address-cells", 0x1));
> @@ -95,6 +97,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  					die("KVM_GET_ONE_REG failed (config.zicbom_block_size)");
>  			}
>  
> +			if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOZ && !cboz_blksz) {
> +				reg.id = RISCV_CONFIG_REG(zicboz_block_size);
> +				reg.addr = (unsigned long)&cboz_blksz;
> +				if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
> +					die("KVM_GET_ONE_REG failed (config.zicboz_block_size)");
> +			}
> +
>  			if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) {
>  				pr_warning("Insufficient space to append ISA exension\n");
>  				break;
> @@ -116,6 +125,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
>  		_FDT(fdt_property_string(fdt, "riscv,isa", cpu_isa));
>  		if (cbom_blksz)
>  			_FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz));
> +		if (cboz_blksz)
> +			_FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz));
>  		_FDT(fdt_property_cell(fdt, "reg", cpu));
>  		_FDT(fdt_property_string(fdt, "status", "okay"));
>  
> diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
> index 92af6f3..e44c1e9 100644
> --- a/riscv/include/asm/kvm.h
> +++ b/riscv/include/asm/kvm.h
> @@ -52,6 +52,7 @@ struct kvm_riscv_config {
>  	unsigned long mvendorid;
>  	unsigned long marchid;
>  	unsigned long mimpid;
> +	unsigned long zicboz_block_size;
>  };
>  
>  /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> @@ -105,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID {
>  	KVM_RISCV_ISA_EXT_SVINVAL,
>  	KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
>  	KVM_RISCV_ISA_EXT_ZICBOM,
> +	KVM_RISCV_ISA_EXT_ZICBOZ,
>  	KVM_RISCV_ISA_EXT_MAX,
>  };
>  
> diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
> index 188125c..46a774e 100644
> --- a/riscv/include/kvm/kvm-config-arch.h
> +++ b/riscv/include/kvm/kvm-config-arch.h
> @@ -24,6 +24,9 @@ struct kvm_config_arch {
>  	OPT_BOOLEAN('\0', "disable-zicbom",				\
>  		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM],	\
>  		    "Disable Zicbom Extension"),			\
> +	OPT_BOOLEAN('\0', "disable-zicboz",				\
> +		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ],	\
> +		    "Disable Zicboz Extension"),			\
>  	OPT_BOOLEAN('\0', "disable-zihintpause",			\
>  		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
>  		    "Disable Zihintpause Extension"),
> -- 
> 2.39.2
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync kvm_riscv_config
  2023-04-18 14:22   ` Ben Dooks
@ 2023-04-18 15:02     ` Andrew Jones
  -1 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 15:02 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 03:22:40PM +0100, Ben Dooks wrote:
> Add the ONE_REG for the mvendorid/marchid/mimpid from the kernel
> commit 6ebbdecff6ae00557a52539287b681641f4f0d33, to ensure the
> struct is in sync with newer kernels for adding zicboz.
> 
> Ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/id=6ebbdecff6ae00557a52539287b681641f4f0d33
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  riscv/include/asm/kvm.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
> index 8985ff2..92af6f3 100644
> --- a/riscv/include/asm/kvm.h
> +++ b/riscv/include/asm/kvm.h
> @@ -49,6 +49,9 @@ struct kvm_sregs {
>  struct kvm_riscv_config {
>  	unsigned long isa;
>  	unsigned long zicbom_block_size;
> +	unsigned long mvendorid;
> +	unsigned long marchid;
> +	unsigned long mimpid;
>  };
>  
>  /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> -- 
> 2.39.2
>

These should get updated with a proper header update using
util/update_headers.sh

Thanks,
drew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync kvm_riscv_config
@ 2023-04-18 15:02     ` Andrew Jones
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 15:02 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 03:22:40PM +0100, Ben Dooks wrote:
> Add the ONE_REG for the mvendorid/marchid/mimpid from the kernel
> commit 6ebbdecff6ae00557a52539287b681641f4f0d33, to ensure the
> struct is in sync with newer kernels for adding zicboz.
> 
> Ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/id=6ebbdecff6ae00557a52539287b681641f4f0d33
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  riscv/include/asm/kvm.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
> index 8985ff2..92af6f3 100644
> --- a/riscv/include/asm/kvm.h
> +++ b/riscv/include/asm/kvm.h
> @@ -49,6 +49,9 @@ struct kvm_sregs {
>  struct kvm_riscv_config {
>  	unsigned long isa;
>  	unsigned long zicbom_block_size;
> +	unsigned long mvendorid;
> +	unsigned long marchid;
> +	unsigned long mimpid;
>  };
>  
>  /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
> -- 
> 2.39.2
>

These should get updated with a proper header update using
util/update_headers.sh

Thanks,
drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
  2023-04-18 15:00     ` Andrew Jones
@ 2023-04-18 17:05       ` Ben Dooks
  -1 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 17:05 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, linux-riscv

On 18/04/2023 16:00, Andrew Jones wrote:
> On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
>> Like ZICBOM, the ZICBOZ extension requires passing extra information to
>> the guest. Add the control to pass the information to the guest, get it
>> from the kvm ioctl and pass into the guest via the device-tree info.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>>   riscv/fdt.c                         | 11 +++++++++++
>>   riscv/include/asm/kvm.h             |  2 ++
>>   riscv/include/kvm/kvm-config-arch.h |  3 +++
>>   3 files changed, 16 insertions(+)
> 
> Hi Ben,
> 
> I have a patch almost identical to this one here
> 
> https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c
> 
> The differences are that I don't add the header changes in this patch
> (as they'll come with a proper header update after Linux patches get
> merged), and I forgot to add the disable-zicboz, which you have.
> 
> I was planning on posting after the Linux patches get merged so
> I could do the proper header update first.
>

I thought they had been, I just cherry-picked them (although I may
have just used linux-next instead of linux-upstream). I've been testing
this under qemu so it seems to be working so far with what i've been
doing.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
@ 2023-04-18 17:05       ` Ben Dooks
  0 siblings, 0 replies; 14+ messages in thread
From: Ben Dooks @ 2023-04-18 17:05 UTC (permalink / raw)
  To: Andrew Jones; +Cc: kvm, linux-riscv

On 18/04/2023 16:00, Andrew Jones wrote:
> On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
>> Like ZICBOM, the ZICBOZ extension requires passing extra information to
>> the guest. Add the control to pass the information to the guest, get it
>> from the kvm ioctl and pass into the guest via the device-tree info.
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>>   riscv/fdt.c                         | 11 +++++++++++
>>   riscv/include/asm/kvm.h             |  2 ++
>>   riscv/include/kvm/kvm-config-arch.h |  3 +++
>>   3 files changed, 16 insertions(+)
> 
> Hi Ben,
> 
> I have a patch almost identical to this one here
> 
> https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c
> 
> The differences are that I don't add the header changes in this patch
> (as they'll come with a proper header update after Linux patches get
> merged), and I forgot to add the disable-zicboz, which you have.
> 
> I was planning on posting after the Linux patches get merged so
> I could do the proper header update first.
>

I thought they had been, I just cherry-picked them (although I may
have just used linux-next instead of linux-upstream). I've been testing
this under qemu so it seems to be working so far with what i've been
doing.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
  2023-04-18 17:05       ` Ben Dooks
@ 2023-04-18 17:14         ` Andrew Jones
  -1 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 17:14 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 06:05:57PM +0100, Ben Dooks wrote:
> On 18/04/2023 16:00, Andrew Jones wrote:
> > On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
> > > Like ZICBOM, the ZICBOZ extension requires passing extra information to
> > > the guest. Add the control to pass the information to the guest, get it
> > > from the kvm ioctl and pass into the guest via the device-tree info.
> > > 
> > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> > > ---
> > >   riscv/fdt.c                         | 11 +++++++++++
> > >   riscv/include/asm/kvm.h             |  2 ++
> > >   riscv/include/kvm/kvm-config-arch.h |  3 +++
> > >   3 files changed, 16 insertions(+)
> > 
> > Hi Ben,
> > 
> > I have a patch almost identical to this one here
> > 
> > https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c
> > 
> > The differences are that I don't add the header changes in this patch
> > (as they'll come with a proper header update after Linux patches get
> > merged), and I forgot to add the disable-zicboz, which you have.
> > 
> > I was planning on posting after the Linux patches get merged so
> > I could do the proper header update first.
> > 
> 
> I thought they had been, I just cherry-picked them (although I may
> have just used linux-next instead of linux-upstream). I've been testing
> this under qemu so it seems to be working so far with what i've been
> doing.

Yeah, just -next, so far. Thanks for the testing!

drew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH kvmtool 2/2] riscv: add zicboz support
@ 2023-04-18 17:14         ` Andrew Jones
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2023-04-18 17:14 UTC (permalink / raw)
  To: Ben Dooks; +Cc: kvm, linux-riscv

On Tue, Apr 18, 2023 at 06:05:57PM +0100, Ben Dooks wrote:
> On 18/04/2023 16:00, Andrew Jones wrote:
> > On Tue, Apr 18, 2023 at 03:22:41PM +0100, Ben Dooks wrote:
> > > Like ZICBOM, the ZICBOZ extension requires passing extra information to
> > > the guest. Add the control to pass the information to the guest, get it
> > > from the kvm ioctl and pass into the guest via the device-tree info.
> > > 
> > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> > > ---
> > >   riscv/fdt.c                         | 11 +++++++++++
> > >   riscv/include/asm/kvm.h             |  2 ++
> > >   riscv/include/kvm/kvm-config-arch.h |  3 +++
> > >   3 files changed, 16 insertions(+)
> > 
> > Hi Ben,
> > 
> > I have a patch almost identical to this one here
> > 
> > https://github.com/jones-drew/kvmtool/commit/f44010451e023b204bb1ef9767de20e0f20aca1c
> > 
> > The differences are that I don't add the header changes in this patch
> > (as they'll come with a proper header update after Linux patches get
> > merged), and I forgot to add the disable-zicboz, which you have.
> > 
> > I was planning on posting after the Linux patches get merged so
> > I could do the proper header update first.
> > 
> 
> I thought they had been, I just cherry-picked them (although I may
> have just used linux-next instead of linux-upstream). I've been testing
> this under qemu so it seems to be working so far with what i've been
> doing.

Yeah, just -next, so far. Thanks for the testing!

drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-18 17:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 14:22 Add zicboz support for riscv kvmtool Ben Dooks
2023-04-18 14:22 ` Ben Dooks
2023-04-18 14:22 ` [PATCH kvmtool 1/2] riscv: add mvendorid/marchid/mimpid to sync kvm_riscv_config Ben Dooks
2023-04-18 14:22   ` Ben Dooks
2023-04-18 15:02   ` Andrew Jones
2023-04-18 15:02     ` Andrew Jones
2023-04-18 14:22 ` [PATCH kvmtool 2/2] riscv: add zicboz support Ben Dooks
2023-04-18 14:22   ` Ben Dooks
2023-04-18 15:00   ` Andrew Jones
2023-04-18 15:00     ` Andrew Jones
2023-04-18 17:05     ` Ben Dooks
2023-04-18 17:05       ` Ben Dooks
2023-04-18 17:14       ` Andrew Jones
2023-04-18 17:14         ` Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.