diff mbox series

[RFC,4/7] accel/kvm: Simplify kvm_set_sigmask_len()

Message ID 20200623105052.1700-5-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series accel/kvm: Simplify few functions that can use global kvm_state | expand

Commit Message

Philippe Mathieu-Daudé June 23, 2020, 10:50 a.m. UTC
The sigmask_len is a property of the accelerator, not the VM.
Simplify by directly using the global kvm_state, remove the
unnecessary KVMState* argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/sysemu/kvm.h | 2 +-
 accel/kvm/kvm-all.c  | 4 ++--
 target/mips/kvm.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Paolo Bonzini July 5, 2020, 7:12 a.m. UTC | #1
On 23/06/20 12:50, Philippe Mathieu-Daudé wrote:
> The sigmask_len is a property of the accelerator, not the VM.
> Simplify by directly using the global kvm_state, remove the
> unnecessary KVMState* argument.

This is not entirely true, if there were multiple KVMStates how would
you know which one to read from?  So it would have to be a global variable.

Paolo

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/sysemu/kvm.h | 2 +-
>  accel/kvm/kvm-all.c  | 4 ++--
>  target/mips/kvm.c    | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 3662641c99..44c1767a7f 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -469,7 +469,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
>  uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
>  
>  
> -void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
> +void kvm_set_sigmask_len(unsigned int sigmask_len);
>  
>  #if !defined(CONFIG_USER_ONLY)
>  int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index afd14492a0..7b3f76f23d 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -2240,9 +2240,9 @@ err:
>      return ret;
>  }
>  
> -void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
> +void kvm_set_sigmask_len(unsigned int sigmask_len)
>  {
> -    s->sigmask_len = sigmask_len;
> +    kvm_state->sigmask_len = sigmask_len;
>  }
>  
>  static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction,
> diff --git a/target/mips/kvm.c b/target/mips/kvm.c
> index 0adfa70210..cc3e09bdef 100644
> --- a/target/mips/kvm.c
> +++ b/target/mips/kvm.c
> @@ -48,7 +48,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)
>  int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      /* MIPS has 128 signals */
> -    kvm_set_sigmask_len(s, 16);
> +    kvm_set_sigmask_len(16);
>  
>      kvm_mips_fpu_cap = kvm_check_extension(KVM_CAP_MIPS_FPU);
>      kvm_mips_msa_cap = kvm_check_extension(KVM_CAP_MIPS_MSA);
>
Philippe Mathieu-Daudé July 5, 2020, 9:57 a.m. UTC | #2
On 7/5/20 9:12 AM, Paolo Bonzini wrote:
> On 23/06/20 12:50, Philippe Mathieu-Daudé wrote:
>> The sigmask_len is a property of the accelerator, not the VM.
>> Simplify by directly using the global kvm_state, remove the
>> unnecessary KVMState* argument.
> 
> This is not entirely true, if there were multiple KVMStates how would
> you know which one to read from?  So it would have to be a global variable.

Ah I guess I understand. Thanks for reviewing and queuing the rest!

> 
> Paolo
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  include/sysemu/kvm.h | 2 +-
>>  accel/kvm/kvm-all.c  | 4 ++--
>>  target/mips/kvm.c    | 2 +-
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
>> index 3662641c99..44c1767a7f 100644
>> --- a/include/sysemu/kvm.h
>> +++ b/include/sysemu/kvm.h
>> @@ -469,7 +469,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
>>  uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
>>  
>>  
>> -void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
>> +void kvm_set_sigmask_len(unsigned int sigmask_len);
>>  
>>  #if !defined(CONFIG_USER_ONLY)
>>  int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
>> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
>> index afd14492a0..7b3f76f23d 100644
>> --- a/accel/kvm/kvm-all.c
>> +++ b/accel/kvm/kvm-all.c
>> @@ -2240,9 +2240,9 @@ err:
>>      return ret;
>>  }
>>  
>> -void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
>> +void kvm_set_sigmask_len(unsigned int sigmask_len)
>>  {
>> -    s->sigmask_len = sigmask_len;
>> +    kvm_state->sigmask_len = sigmask_len;
>>  }
>>  
>>  static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction,
>> diff --git a/target/mips/kvm.c b/target/mips/kvm.c
>> index 0adfa70210..cc3e09bdef 100644
>> --- a/target/mips/kvm.c
>> +++ b/target/mips/kvm.c
>> @@ -48,7 +48,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)
>>  int kvm_arch_init(MachineState *ms, KVMState *s)
>>  {
>>      /* MIPS has 128 signals */
>> -    kvm_set_sigmask_len(s, 16);
>> +    kvm_set_sigmask_len(16);
>>  
>>      kvm_mips_fpu_cap = kvm_check_extension(KVM_CAP_MIPS_FPU);
>>      kvm_mips_msa_cap = kvm_check_extension(KVM_CAP_MIPS_MSA);
>>
>
diff mbox series

Patch

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 3662641c99..44c1767a7f 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -469,7 +469,7 @@  uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
 uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index);
 
 
-void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
+void kvm_set_sigmask_len(unsigned int sigmask_len);
 
 #if !defined(CONFIG_USER_ONLY)
 int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index afd14492a0..7b3f76f23d 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2240,9 +2240,9 @@  err:
     return ret;
 }
 
-void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
+void kvm_set_sigmask_len(unsigned int sigmask_len)
 {
-    s->sigmask_len = sigmask_len;
+    kvm_state->sigmask_len = sigmask_len;
 }
 
 static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction,
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 0adfa70210..cc3e09bdef 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -48,7 +48,7 @@  unsigned long kvm_arch_vcpu_id(CPUState *cs)
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     /* MIPS has 128 signals */
-    kvm_set_sigmask_len(s, 16);
+    kvm_set_sigmask_len(16);
 
     kvm_mips_fpu_cap = kvm_check_extension(KVM_CAP_MIPS_FPU);
     kvm_mips_msa_cap = kvm_check_extension(KVM_CAP_MIPS_MSA);