Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp871825pxf; Wed, 7 Apr 2021 13:48:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz/V9cKyAYk4qmn1VRzWsTRz3DH402AgKzhFLSeRtAj4uhqCMBZX9O32HJnSaND5RvMCAe X-Received: by 2002:a05:6402:a4a:: with SMTP id bt10mr5929031edb.39.1617828529454; Wed, 07 Apr 2021 13:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617828529; cv=none; d=google.com; s=arc-20160816; b=favUhcPpIsxxggjtET3zMWtbjpi2Vw36AFTYtYkOguEdkKx+vvYhSE2vUHEMHhA+mN 0Toy6YjyVYqkwnyUcXfj0uMJ4+4yWFMJLzgMPkGuLihlfD5jdXvL+2S62o4U4ySh3OzD zw94FbhcPs6vYODDUhs8joDHGWRiVr+fb3UwOhU9oFRYk6yN3SfSIi+53O/i/GBItUtE ngc7GrKzxLtIjjrjaF26EMBOY8+k5g+svFMBpP0Nv60nMb61MN0k9uIIw/YY7Tduzb/A mVeoTZKAL+8fktylTh7y3E+w37LcJQKh1H/1ocldlmwPsELImfQiUyWp93pLxXSqk1Jw 1VQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5K6PQSwMlmpqkVBby3SZQhMRRj0pj0xAgwi1gYcze9c=; b=V3SqwVuBBOJ36wUl97GSx0SBDplPELGK7yxCmT3kaVXXl3t30sO9EzZqZI6uD49UZD F6FrjVZPYYsQQo6dPBksgeMoYBTpZrje5OCjNNnJCb2dYyD5fyB9DLWaGAt/DybCuu72 k0wa7uo9VzQwMp01jbvljAqzB2VJppqrbh1ys4ZPDs+xpP2pgOBr246Nf+m4TzgLBiN7 YtsyYqj30Ki41Zf6NGdWsnEFITIBI9ic/JKpk5dkYLIHVAICisYFq+yS8i/W+JaPDutQ gsQJTqbr/+849uxWAu8GpPyr2lFK0Vc1onBLaBv9KCMopUGBe2l3AvoCK8lReI3RXEvz zlpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si7474529edc.429.2021.04.07.13.48.25; Wed, 07 Apr 2021 13:48:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351067AbhDGKZC (ORCPT + 99 others); Wed, 7 Apr 2021 06:25:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:42386 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351008AbhDGKYy (ORCPT ); Wed, 7 Apr 2021 06:24:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 28651B0B6; Wed, 7 Apr 2021 10:24:44 +0000 (UTC) Date: Wed, 7 Apr 2021 12:24:40 +0200 From: Borislav Petkov To: Christophe Leroy Cc: Sean Christopherson , Paolo Bonzini , Brijesh Singh , Tom Lendacky , John Allen , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 8/8] KVM: SVM: Allocate SEV command structures on local stack Message-ID: <20210407102440.GA25732@zn.tnic> References: <20210406224952.4177376-1-seanjc@google.com> <20210406224952.4177376-9-seanjc@google.com> <9df3b755-d71a-bfdf-8bee-f2cd2883ea2f@csgroup.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9df3b755-d71a-bfdf-8bee-f2cd2883ea2f@csgroup.eu> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 [(void *)_561] movq $0, 112(%rsp) #, MEM [(void *)_561] movq $0, 120(%rsp) #, MEM [(void *)_561] movq $0, 128(%rsp) #, MEM [(void *)_561] movl $0, 136(%rsp) #, MEM [(void *)_561] Ok? -- Regards/Gruss, Boris. SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg