The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] kvm/vfio: Constify struct kvm_device_ops
@ 2024-09-28  9:52 Christophe JAILLET
  2024-11-01 14:37 ` Alex Williamson
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-09-28  9:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET, kvm

'struct kvm_device_ops' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   2605	    169	     16	   2790	    ae6	virt/kvm/vfio.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   2685	     89	     16	   2790	    ae6	virt/kvm/vfio.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 virt/kvm/vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c
index 388ae471d258..e72a6a1d5a20 100644
--- a/virt/kvm/vfio.c
+++ b/virt/kvm/vfio.c
@@ -353,7 +353,7 @@ static void kvm_vfio_release(struct kvm_device *dev)
 
 static int kvm_vfio_create(struct kvm_device *dev, u32 type);
 
-static struct kvm_device_ops kvm_vfio_ops = {
+static const struct kvm_device_ops kvm_vfio_ops = {
 	.name = "kvm-vfio",
 	.create = kvm_vfio_create,
 	.release = kvm_vfio_release,
-- 
2.46.1


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

* Re: [PATCH] kvm/vfio: Constify struct kvm_device_ops
  2024-09-28  9:52 [PATCH] kvm/vfio: Constify struct kvm_device_ops Christophe JAILLET
@ 2024-11-01 14:37 ` Alex Williamson
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2024-11-01 14:37 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: Paolo Bonzini, linux-kernel, kernel-janitors, kvm

On Sat, 28 Sep 2024 11:52:46 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> 'struct kvm_device_ops' is not modified in this driver.
> 
> Constifying this structure moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>    2605	    169	     16	   2790	    ae6	virt/kvm/vfio.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>    2685	     89	     16	   2790	    ae6	virt/kvm/vfio.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
>  virt/kvm/vfio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c
> index 388ae471d258..e72a6a1d5a20 100644
> --- a/virt/kvm/vfio.c
> +++ b/virt/kvm/vfio.c
> @@ -353,7 +353,7 @@ static void kvm_vfio_release(struct kvm_device *dev)
>  
>  static int kvm_vfio_create(struct kvm_device *dev, u32 type);
>  
> -static struct kvm_device_ops kvm_vfio_ops = {
> +static const struct kvm_device_ops kvm_vfio_ops = {
>  	.name = "kvm-vfio",
>  	.create = kvm_vfio_create,
>  	.release = kvm_vfio_release,

Applied to vfio next branch for v6.13.  Thanks,

Alex


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

end of thread, other threads:[~2024-11-01 14:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-28  9:52 [PATCH] kvm/vfio: Constify struct kvm_device_ops Christophe JAILLET
2024-11-01 14:37 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox