Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp825436rwe; Thu, 1 Sep 2022 08:10:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR58MM5RNGvR5w3lL9TbZec4jVMgnKNRHEkTRoPn9gfkhK4wc2z6/5hItv53uzhQhwIyax3y X-Received: by 2002:a63:8bc3:0:b0:42b:1bd2:9a6d with SMTP id j186-20020a638bc3000000b0042b1bd29a6dmr25332537pge.503.1662045019235; Thu, 01 Sep 2022 08:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662045019; cv=none; d=google.com; s=arc-20160816; b=nPZlDB7zuF/FmkMCPczWfuWkK1Mb5itywH/vdGJTuZvQZYH5zVvzYnQKFpw939r/Qg zqn781ACVaj+ewwGp559T7exEYpfxovPs39X71ROc3idxlSEPCQs1iZbwlAuhJApfh/w pMJvUcg5eIyQtJBHXxQlkC4kpsm9Ei8SgztUZDry3RqieQfVXSQM5K/nEdaDp+W0lB3v mgj1AMfhCGIf5AU7d1eyTaRry3fvfb6pcZcD9TvT3tp0Yil4H77c5ZYsMxdDQyth2R5n QWJIumrtNXqQwcZyG4fokWgvdM6wGeniWjq67vkJvohHUoSgNi+4eeYRCi++ob5dA7aW T8cw== 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:dkim-signature; bh=o6yMdDL9GGqHD1GiDwF9wfetaKhW1e9T/BEjpmKh4O4=; b=iw5UAs/sWzmoBI+/Qi8f+ps7KuSNyuzq3LKnxVgiMLnsFCIbve5Mu2Dc1hqX+DI2+A 7vYAgIVzBd5mcJ1B6Fe1ANiuEMjGabgADy04LkP3+vmX+ChkpK5ynKUWPuX4IeNkjecD 0+tdQebHrrhIPGmR+3Pvt3UOIbZi0+9MJvUtO/estYSdW/5dJ4q9sUurqs/ffRo20E0O Gf6jwiS33Is5eKCBZUT2nv7NAVVttziyYLxT4nXT5UFZ/3prAXXHGSO+KOOB6jTMjfwV xgWQkwlReCYV+eAVcoIY1GiN4uZQ3YlESgfcXYV7tv0uTCd2sjhbNAPZcmxNVdS0ATnK dMKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RDZEl+KU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a65-20020a639044000000b004128e9db273si7954412pge.587.2022.09.01.08.10.04; Thu, 01 Sep 2022 08:10:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RDZEl+KU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbiIAOie (ORCPT + 99 others); Thu, 1 Sep 2022 10:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234917AbiIAOiH (ORCPT ); Thu, 1 Sep 2022 10:38:07 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC617C1B8 for ; Thu, 1 Sep 2022 07:38:01 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id j9-20020a17090a3e0900b001fd9568b117so2792112pjc.3 for ; Thu, 01 Sep 2022 07:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=o6yMdDL9GGqHD1GiDwF9wfetaKhW1e9T/BEjpmKh4O4=; b=RDZEl+KUVoHh18UaGCBFBp6JNa0eHKGh8KzFzPTiwMrkR0u2OHp25dXSQKmA/jNamb IiKkrZ5lBVdWxnI/LcUkzPip6f0NQsONbHoVQih7x6c2N1mbmQFmzkeEBTpMRfn2ECBF U1TXJUawm//eU8tU0W9UgJfYC1lju6CfmO4Rio+cDZbgEy623Xx2rF2sTwVFq71diuz1 6vOhPgQsVmJ0Pgu6XzGZMfTos/Xw1mX1UvMKkKvUQcIcQSDc/1DxULEZ45lsw8Vzy8rK 8Q2aonNJ3cKN916WWywRB9QLD8716prsM5ubHbGMyH0BPo8/J4R1TR84ImBp3v7FOape 9I3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=o6yMdDL9GGqHD1GiDwF9wfetaKhW1e9T/BEjpmKh4O4=; b=eHJBkHuUGf5T8kSim6XoQ3GiEMViNlaKItXPuuChSwZR83GaYZcS44OeRDJ/SWYZwW yEv2BFJamJNJjqgQQeuerhV/tCd8nRRJXtZjH3FLf2jXDqV6pEIGlPodcR7EUOBKbiAx vejdEtz/NkWWyT/18FSYTz5o3QVNw5WVcF5u7RbKdj9kzOI0jK6chEkzcljmVSj6WWY5 hLjv6bDKr8Z1L1sSBevHLebBM1HJiJKZsNHm0ZXshKmNWPaUFMs8zks8cJf/Oo/33JSE neV52s/tm1XreE1gTutXpssbnmg63aiKP7RAgRclZgyVlgisICvHKXSmKH6s23AHY0wV bO9g== X-Gm-Message-State: ACgBeo1mD61CNL5XwumMPcomGU0Re4txMY77CoOkHaHI7mt0kc74O5FF jqvB7gJ1Xw7lXUIemruHcTSjmg== X-Received: by 2002:a17:90b:2c12:b0:1fd:78fa:5ea7 with SMTP id rv18-20020a17090b2c1200b001fd78fa5ea7mr9247426pjb.29.1662043080062; Thu, 01 Sep 2022 07:38:00 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f5-20020a170902684500b001635b86a790sm13788150pln.44.2022.09.01.07.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 07:37:59 -0700 (PDT) Date: Thu, 1 Sep 2022 14:37:56 +0000 From: Sean Christopherson To: Isaku Yamahata Cc: Sagi Shahar , linux-kselftest@vger.kernel.org, Paolo Bonzini , Isaku Yamahata , Erdem Aktas , Ryan Afranji , Roger Wang , Shuah Khan , Andrew Jones , Marc Zyngier , Ben Gardon , Jim Mattson , David Matlack , Peter Xu , Oliver Upton , Ricardo Koller , Yang Zhong , Wei Wang , Xiaoyao Li , Peter Gonda , Marc Orr , Emanuele Giuseppe Esposito , Christian Borntraeger , Eric Auger , Yanan Wang , Aaron Lewis , Vitaly Kuznetsov , Peter Shier , Axel Rasmussen , Zhenzhong Duan , "Maciej S . Szmigiero" , Like Xu , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC PATCH v2 03/17] KVM: selftest: Adding TDX life cycle test. Message-ID: References: <20220830222000.709028-1-sagis@google.com> <20220830222000.709028-4-sagis@google.com> <20220901004631.GC2711697@ls.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220901004631.GC2711697@ls.amr.corp.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 31, 2022, Isaku Yamahata wrote: > Sometimes compiler (my gcc is (Ubuntu 11.1.0-1ubuntu1~20.04) 11.1.0) doesn't like > clobering the frame pointer as follows. (I edited the caller site for other test.) > > x86_64/tdx_vm_tests.c:343:1: error: bp cannot be used in ‘asm’ here > > I ended up the following workaround. I didn't use pushq/popq pair because > I didn't want to play with offset in the stack of the caller. > > > diff --git a/tools/testing/selftests/kvm/lib/x86_64/tdx.h b/tools/testing/selftests/kvm/lib/x86_64/tdx.h > index aa6961c6f304..8ddf3b64f003 100644 > --- a/tools/testing/selftests/kvm/lib/x86_64/tdx.h > +++ b/tools/testing/selftests/kvm/lib/x86_64/tdx.h > @@ -122,7 +122,11 @@ void prepare_source_image(struct kvm_vm *vm, void *guest_code, > */ > static inline void tdcall(struct kvm_regs *regs) > { > + unsigned long saved_rbp = 0; > + > asm volatile ( > + /* gcc complains that frame pointer %rbp can't be clobbered. */ > + "movq %%rbp, %28;\n\t" > "mov %13, %%rax;\n\t" > "mov %14, %%rbx;\n\t" > "mov %15, %%rcx;\n\t" > @@ -152,6 +156,8 @@ static inline void tdcall(struct kvm_regs *regs) > "mov %%r15, %10;\n\t" > "mov %%rsi, %11;\n\t" > "mov %%rdi, %12;\n\t" > + "movq %28, %%rbp\n\t" > + "movq $0, %28\n\t" > : "=m" (regs->rax), "=m" (regs->rbx), "=m" (regs->rdx), > "=m" (regs->r8), "=m" (regs->r9), "=m" (regs->r10), > "=m" (regs->r11), "=m" (regs->r12), "=m" (regs->r13), > @@ -161,9 +167,10 @@ static inline void tdcall(struct kvm_regs *regs) > "m" (regs->rdx), "m" (regs->r8), "m" (regs->r9), > "m" (regs->r10), "m" (regs->r11), "m" (regs->r12), > "m" (regs->r13), "m" (regs->r14), "m" (regs->r15), > - "m" (regs->rbp), "m" (regs->rsi), "m" (regs->rdi) > + "m" (regs->rbp), "m" (regs->rsi), "m" (regs->rdi), > + "m" (saved_rbp) > : "rax", "rbx", "rcx", "rdx", "r8", "r9", "r10", "r11", > - "r12", "r13", "r14", "r15", "rbp", "rsi", "rdi"); > + "r12", "r13", "r14", "r15", "rsi", "rdi"); > } Inline assembly for TDCALL is going to be a mess. Assuming proper assembly doesn't Just Work for selftests, we should solve that problem and build this on top.