Message ID | 20220204155349.63238-10-imbrenda@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: pv: implement lazy destroy for reboot | expand |
On 2/4/22 16:53, Claudio Imbrenda wrote: > Do not use memset to clean the whole struct kvm_s390_pv; instead, > explicitly clear the fields that need to be cleared. > > Upcoming patches will introduce new fields in the struct kvm_s390_pv > that will not need to be cleared. > > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> > --- > arch/s390/kvm/pv.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c > index 9e900ce7387d..f1e812a45acb 100644 > --- a/arch/s390/kvm/pv.c > +++ b/arch/s390/kvm/pv.c > @@ -16,6 +16,15 @@ > #include <linux/sched/mm.h> > #include "kvm-s390.h" > > +static void kvm_s390_clear_pv_state(struct kvm *kvm) > +{ > + kvm->arch.pv.handle = 0; > + kvm->arch.pv.guest_len = 0; > + kvm->arch.pv.stor_base = 0; > + kvm->arch.pv.stor_var = NULL; > + kvm->arch.pv.handle = 0; You really want to make sure the handle is zero :) With this fixed: Reviewed-by: Janosch Frank <frankja@linux.ibm.com> > +} > + > int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc) > { > int cc; > @@ -110,7 +119,7 @@ static void kvm_s390_pv_dealloc_vm(struct kvm *kvm) > vfree(kvm->arch.pv.stor_var); > free_pages(kvm->arch.pv.stor_base, > get_order(uv_info.guest_base_stor_len)); > - memset(&kvm->arch.pv, 0, sizeof(kvm->arch.pv)); > + kvm_s390_clear_pv_state(kvm); > } > > static int kvm_s390_pv_alloc_vm(struct kvm *kvm) >
diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c index 9e900ce7387d..f1e812a45acb 100644 --- a/arch/s390/kvm/pv.c +++ b/arch/s390/kvm/pv.c @@ -16,6 +16,15 @@ #include <linux/sched/mm.h> #include "kvm-s390.h" +static void kvm_s390_clear_pv_state(struct kvm *kvm) +{ + kvm->arch.pv.handle = 0; + kvm->arch.pv.guest_len = 0; + kvm->arch.pv.stor_base = 0; + kvm->arch.pv.stor_var = NULL; + kvm->arch.pv.handle = 0; +} + int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc) { int cc; @@ -110,7 +119,7 @@ static void kvm_s390_pv_dealloc_vm(struct kvm *kvm) vfree(kvm->arch.pv.stor_var); free_pages(kvm->arch.pv.stor_base, get_order(uv_info.guest_base_stor_len)); - memset(&kvm->arch.pv, 0, sizeof(kvm->arch.pv)); + kvm_s390_clear_pv_state(kvm); } static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
Do not use memset to clean the whole struct kvm_s390_pv; instead, explicitly clear the fields that need to be cleared. Upcoming patches will introduce new fields in the struct kvm_s390_pv that will not need to be cleared. Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> --- arch/s390/kvm/pv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)