Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2759539rwb; Wed, 30 Nov 2022 10:27:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jTIC/xFoulCOjKfrohlPsXtWn5/JCC707eMFgZ8EUSlUngLmqmy29la79beRZrRQyCnWk X-Received: by 2002:a05:6402:ea8:b0:462:67bf:c64e with SMTP id h40-20020a0564020ea800b0046267bfc64emr43989985eda.20.1669832836947; Wed, 30 Nov 2022 10:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669832836; cv=none; d=google.com; s=arc-20160816; b=yzGdyzpaoa/FexCs9YTJ/xzlPB5vWywLeKXNzimsAVGL/EHjr5tLAhgKJouFOmWatd jJ7lDnz0i8/4SbFQ1AaolSxyUt4QKS3qnb45ZWVApupzPmrNSWIrAqJcz8CrAm+5pQ09 BcNaLg7cxh1TQ/1O7aQ6f5kK6n7I7aMHVX5JeEoS/q4/15dO//7jUJGHuLMTH7qMmXLF /jImPEGgA6eOLL/CEGUdsU7NNcY4IaZ/wWvqc4kR3aYcM44ntKPfggcFgeiEii76Nqa4 Fh8C17WolgdS8gY8dFo9sLhjRkHQZjkk+mipsq9O4c7gotOJx8q6dm3W5iU/2nycSOLo 7ZGg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v27-20020aa7cd5b000000b00461f44d7bfcsi1609392edw.573.2022.11.30.10.26.56; Wed, 30 Nov 2022 10:27:16 -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 + 83 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 ); 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 ; 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 To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Vitaly Kuznetsov 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Paolo Bonzini --- .../kvm/x86_64/svm_nested_soft_inject_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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(); -- 2.31.1