[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YxDDxKEdqEORDz72@google.com>
Date: Thu, 1 Sep 2022 14:37:56 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Isaku Yamahata <isaku.yamahata@...il.com>
Cc: Sagi Shahar <sagis@...gle.com>, linux-kselftest@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Isaku Yamahata <isaku.yamahata@...el.com>,
Erdem Aktas <erdemaktas@...gle.com>,
Ryan Afranji <afranji@...gle.com>,
Roger Wang <runanwang@...gle.com>,
Shuah Khan <shuah@...nel.org>,
Andrew Jones <drjones@...hat.com>,
Marc Zyngier <maz@...nel.org>, Ben Gardon <bgardon@...gle.com>,
Jim Mattson <jmattson@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Peter Xu <peterx@...hat.com>, Oliver Upton <oupton@...gle.com>,
Ricardo Koller <ricarkol@...gle.com>,
Yang Zhong <yang.zhong@...el.com>,
Wei Wang <wei.w.wang@...el.com>,
Xiaoyao Li <xiaoyao.li@...el.com>,
Peter Gonda <pgonda@...gle.com>, Marc Orr <marcorr@...gle.com>,
Emanuele Giuseppe Esposito <eesposit@...hat.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
Eric Auger <eric.auger@...hat.com>,
Yanan Wang <wangyanan55@...wei.com>,
Aaron Lewis <aaronlewis@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Peter Shier <pshier@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Zhenzhong Duan <zhenzhong.duan@...el.com>,
"Maciej S . Szmigiero" <maciej.szmigiero@...cle.com>,
Like Xu <like.xu@...ux.intel.com>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [RFC PATCH v2 03/17] KVM: selftest: Adding TDX life cycle test.
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.
Powered by blists - more mailing lists