Re: [PATCH v2 8/8] KVM: SVM: Allocate SEV command structures on local stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First of all, I'd strongly suggest you trim your emails when you reply -
that would be much appreciated.

On Wed, Apr 07, 2021 at 07:24:54AM +0200, Christophe Leroy wrote:
> > @@ -258,7 +240,7 @@ static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error)
> >   static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
> >   {
> >   	struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
> > -	struct sev_data_launch_start *start;
> > +	struct sev_data_launch_start start;
> 
> struct sev_data_launch_start start = {0, 0, 0, 0, 0, 0, 0};

I don't know how this is any better than using memset...

Also, you can do

	... start = { };

which is certainly the only other alternative to memset, AFAIK.

But whatever you do, you need to look at the resulting asm the compiler
generates. So let's do that:

Your version:

# arch/x86/kvm/svm/sev.c:261:   struct sev_data_launch_start _tmp = {0, 0, 0, 0, 0, 0, 0};
        movq    $0, 104(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 112(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 120(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 128(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movl    $0, 136(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]


my version:

# arch/x86/kvm/svm/sev.c:261:   struct sev_data_launch_start _tmp = {};
        movq    $0, 104(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 112(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 120(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movq    $0, 128(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]
        movl    $0, 136(%rsp)   #, MEM[(struct sev_data_launch_start *)_561]


the memset version:

# arch/x86/kvm/svm/sev.c:269: 	memset(&_tmp, 0, sizeof(_tmp));
#NO_APP
	movq	$0, 104(%rsp)	#, MEM <char[1:36]> [(void *)_561]
	movq	$0, 112(%rsp)	#, MEM <char[1:36]> [(void *)_561]
	movq	$0, 120(%rsp)	#, MEM <char[1:36]> [(void *)_561]
	movq	$0, 128(%rsp)	#, MEM <char[1:36]> [(void *)_561]
	movl	$0, 136(%rsp)	#, MEM <char[1:36]> [(void *)_561]

Ok?

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux