Message ID | 20221130181147.9911-1-pbonzini@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1077631wrr; Wed, 30 Nov 2022 10:14:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5OLzjMZBNs45/w4KUeBm9g7kP0601/9g7SC9sElGTfYxX3e3pKDLNo/EP/2R+0dh3pAbNd X-Received: by 2002:a17:906:c1d0:b0:7b4:64d3:e6f4 with SMTP id bw16-20020a170906c1d000b007b464d3e6f4mr5343727ejb.594.1669832077642; Wed, 30 Nov 2022 10:14:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669832077; cv=none; d=google.com; s=arc-20160816; b=flyw/eWvdnzUq+lLBQzB/NIAGKRG0Vuad4V4qXL4K8ceSoneZ8e9UwRftCegntu8p2 kqOnFWTs7+cdSSjEL8OeKHUcPuabot/aAleFlgBGDU7x3ZQMBiyw4aWorgEa6fJ+8FFy yU2woQvVuFniQbzAcqa4czNxT5j0HHH/4gk3YIgctfPspwPW5eAYY2kJZnF9+RplUidJ 1PZ93ujtQRjH8u+eK/DH/yZsHE74jIqdzjdkXvpL5UDaPAiK2STYW6WkQKvMt1xOkucv e6zI7bZP24o/VLa2CophrqMdrg4VCD/AdWu+2/jRp7SURyiaElDTLnWYtlLRXmNOd/0G 1qWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=B7880sx1PBKIRMoPqg1DQCmkSSWjOmoGVrCc4UdhdjQ=; b=Ummf927IB6Da0aWyXm0+rojNWSLWrVfs1E+PClw0h2ckvbZmN1nYBj+hO7+Sp7lG9u aBRY1AYkjNEVjxbvuBC1htUPWd6aCn9TZWJ5Kn65W+4mSufZj2OBtMKTvzc67YYihUHM oNkAck7ZFyhYxNMwJMk59sJb+PMTjKc2FQPKg3qca2lM3TE+qBpnxBuDS6a3i9WCjs/z b3lmDMOSxnm0DpgHYT2SXe0W6xfKIyTuGp8H+7SnfmblMIFTnLM8+BZ/cyVm33Hl3m7k IxAbenPwxkq2tLbMlffFjxrbg+Cgp0fMY98Eyn+9kTr1aj07bDnjL+TZGsDjkcFHlG8E iz4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZyibTgM1; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw9-20020a170907a0c900b00781c9c3b6f5si1984093ejc.474.2022.11.30.10.14.13; Wed, 30 Nov 2022 10:14:37 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=ZyibTgM1; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbiK3SNC (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Wed, 30 Nov 2022 13:13:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiK3SMs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 30 Nov 2022 13:12:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221BE83EBC for <linux-kernel@vger.kernel.org>; Wed, 30 Nov 2022 10:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669831910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B7880sx1PBKIRMoPqg1DQCmkSSWjOmoGVrCc4UdhdjQ=; b=ZyibTgM1R1lLJOiu7SOK6fxdGPGglIpG5Z+jZu+5ExjT+a98HPIpAeQlqgoEtu+l/+F1FW SaMzKXNhMPOf+my3C4fIMPcnrKUo+zc0Dtw9tQX/euPmRpsdcxeWAKRUwuBal0y0lbrGPl te+ITYkw5cJmpU2phi7SNAidMrO4BlE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-ru1VOQKMNS2NUueERxvF0A-1; Wed, 30 Nov 2022 13:11:48 -0500 X-MC-Unique: ru1VOQKMNS2NUueERxvF0A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC811857F90; Wed, 30 Nov 2022 18:11:47 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF82C40C6EC4; Wed, 30 Nov 2022 18:11:47 +0000 (UTC) From: Paolo Bonzini <pbonzini@redhat.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Subject: [PATCH] KVM: selftests: restore special vmmcall code layout needed by the harness Date: Wed, 30 Nov 2022 13:11:47 -0500 Message-Id: <20221130181147.9911-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750945840645508528?= X-GMAIL-MSGID: =?utf-8?q?1750945840645508528?= |
Series |
KVM: selftests: restore special vmmcall code layout needed by the harness
|
|
Commit Message
Paolo Bonzini
Nov. 30, 2022, 6:11 p.m. UTC
Commit 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values
in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test
because it placed a "pop rbp" instruction after vmmcall. While this is
correct and mimics what is done in the VMX case, this particular test
expects a ud2 instruction right after the vmmcall, so that it can skip
over it in the L1 part of the test.
Inline a suitably-modified version of vmmcall() to restore the
functionality of the test.
Fixes: 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()"
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
.../kvm/x86_64/svm_nested_soft_inject_test.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
Comments
On Wed, Nov 30, 2022, Paolo Bonzini wrote: > Commit 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values > in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test > because it placed a "pop rbp" instruction after vmmcall. While this is > correct and mimics what is done in the VMX case, this particular test > expects a ud2 instruction right after the vmmcall, so that it can skip > over it in the L1 part of the test. > > Inline a suitably-modified version of vmmcall() to restore the > functionality of the test. > > Fixes: 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()" > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- We really, really need to save/restore guest GPRs in L1 when handling exits from L2. For now, Reviewed-by: Sean Christopherson <seanjc@google.com>
Sean Christopherson <seanjc@google.com> writes: > On Wed, Nov 30, 2022, Paolo Bonzini wrote: >> Commit 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values >> in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test >> because it placed a "pop rbp" instruction after vmmcall. While this is >> correct and mimics what is done in the VMX case, this particular test >> expects a ud2 instruction right after the vmmcall, so that it can skip >> over it in the L1 part of the test. >> >> Inline a suitably-modified version of vmmcall() to restore the >> functionality of the test. >> >> Fixes: 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()" >> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> >> --- > > We really, really need to save/restore guest GPRs in L1 when handling exits from L2. +1, the amount of stuff we do to workaround the shortcoming (and time we waste debugging) is getting ridiculously high. > > For now, > > Reviewed-by: Sean Christopherson <seanjc@google.com> > Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
On Thu, 2022-12-01 at 10:28 +0100, Vitaly Kuznetsov wrote: > Sean Christopherson <seanjc@google.com> writes: > > > On Wed, Nov 30, 2022, Paolo Bonzini wrote: > > > Commit 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values > > > in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test > > > because it placed a "pop rbp" instruction after vmmcall. While this is > > > correct and mimics what is done in the VMX case, this particular test > > > expects a ud2 instruction right after the vmmcall, so that it can skip > > > over it in the L1 part of the test. > > > > > > Inline a suitably-modified version of vmmcall() to restore the > > > functionality of the test. > > > > > > Fixes: 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()" > > > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > > > --- > > > > We really, really need to save/restore guest GPRs in L1 when handling exits from L2. > > +1, the amount of stuff we do to workaround the shortcoming (and time > we waste debugging) is getting ridiculously high. > > > For now, > > > > Reviewed-by: Sean Christopherson <seanjc@google.com> > > > > Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> > I didn't notice this fix and also found this issue. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
On Thu, 2022-12-01 at 15:48 +0200, Maxim Levitsky wrote: > On Thu, 2022-12-01 at 10:28 +0100, Vitaly Kuznetsov wrote: > > Sean Christopherson <seanjc@google.com> writes: > > > > > On Wed, Nov 30, 2022, Paolo Bonzini wrote: > > > > Commit 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values > > > > in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test > > > > because it placed a "pop rbp" instruction after vmmcall. While this is > > > > correct and mimics what is done in the VMX case, this particular test > > > > expects a ud2 instruction right after the vmmcall, so that it can skip > > > > over it in the L1 part of the test. > > > > > > > > Inline a suitably-modified version of vmmcall() to restore the > > > > functionality of the test. > > > > > > > > Fixes: 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()" > > > > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > > > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > > > > --- > > > > > > We really, really need to save/restore guest GPRs in L1 when handling exits from L2. > > > > +1, the amount of stuff we do to workaround the shortcoming (and time > > we waste debugging) is getting ridiculously high. > > > > > For now, > > > > > > Reviewed-by: Sean Christopherson <seanjc@google.com> > > > > > > > Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> > > > > I didn't notice this fix and also found this issue. > > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > > Best regards, > Maxim Levitsky Seems that this patch got through the cracks, pinging so someone else won't need to debug this test too. Best regards, Maxim Levitsky
diff --git a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c index e497ace629c1..b34980d45648 100644 --- a/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c +++ b/tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c @@ -41,8 +41,17 @@ static void guest_int_handler(struct ex_regs *regs) static void l2_guest_code_int(void) { GUEST_ASSERT_1(int_fired == 1, int_fired); - vmmcall(); - ud2(); + + /* + * Same as the vmmcall() function, but with a ud2 sneaked after the + * vmmcall. The caller injects an exception with the return address + * increased by 2, so the "pop rbp" must be after the ud2 and we cannot + * use vmmcall() directly. + */ + __asm__ __volatile__("push %%rbp; vmmcall; ud2; pop %%rbp" + : : "a"(0xdeadbeef), "c"(0xbeefdead) + : "rbx", "rdx", "rsi", "rdi", "r8", "r9", + "r10", "r11", "r12", "r13", "r14", "r15"); GUEST_ASSERT_1(bp_fired == 1, bp_fired); hlt();