From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 469E437B022 for ; Wed, 26 Aug 2026 23:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787787569; cv=none; b=DBTs7ubzV/MRsq4BFg/0g0wTS0dZzLcLvucQG1YLAMrlmRJElCWXtP6CsVQ8KUEHNxiAsBeynWQ/G9IRszu4ppjypf2QYSA2tHyt+aNrxBGiKf6tc31R+KnMMMmmxCSNSRvoENU9Cbb5SwAB7q0rbecFMh3RIJ6Wn28VykeZhJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787787569; c=relaxed/simple; bh=CkRIS9u8AusztvWTvPzOWFGQYsyZZzKW1ZZus+mQkq4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OzXbJxQZXOzjiiahYftQx/OpJ3+nizYZfYfIaZI/CUN2lpNFyk9DC+l8iVA7FRKXS6ZWA4ToBQA5cd3l027Xan4k0EgLikuEsv8VUYz65icFNge+lbrV8865mQJKGJ7vp49tUXoEg+lcKkBlraS33mGt/bMLD+XJJXcGtlzeC7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TahZQetJ; arc=none smtp.client-ip=209.85.214.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TahZQetJ" Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2d7151120d6so2063315ad.3 for ; Wed, 26 Aug 2026 16:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787787566; x=1788392366; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FfB1TPfB01BkpCh74isHXlJBf/gfFyIKtvCvmm75NxA=; b=TahZQetJz5ZuCHjt3IPtvow3OAVijwGfi3Wse56JqfR2nG13Pi7OV2SIEzsRuUaFeQ oA0YaoVlabsCqpyz7Rc84gDvR6KtNM1eYUJiFgRllEdmvwqnto6dPAxQTbY1bSE7MIhu rgkRN1APdOYoIaL4kymMwZDiLoHLvS5yp9Fzoflt0bJo5cAY96TTo+1yfDFqTK7QCgck kxxRJJcdwo8xg/xdeLck/4QJDKy+fAguhwSipU0tmMO9PO0Pk+kmAwoFo7O7DfWhQKMq Z+fXvysodB4wl5hpPX8Q+bugOTLJnbtPvcx+0chpQ+iD1mb37TCZHsinMz2xtDEeWul0 xMPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787787566; x=1788392366; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=FfB1TPfB01BkpCh74isHXlJBf/gfFyIKtvCvmm75NxA=; b=hURtj0HzzITZlf+t/WzvnSD+vwriIsoN+IPR9Di0aXLalvDoqZ2/2XGrVbKG6NiN6d yI/GqZVKBrW/797C9ieYsdHtvnn7XtbaW1EhCa76SikVkBDDQ2ojiw41yflcMQm8BG7m m5bwg0x2ir6b6WOWhxJ5A7Embidzrd5jH8mvueEBG2qZVdIp9NLNnpaKVDCG8gX34iNt GAZnYJ+qZXjEfXmC5a7UhDJHO39nidMQgv6dTvsO1t2lc1fPIIaz+8oGABpHBkM9GRnH wUGi9Mbqja0QoWNXkJZ+8Es+3g/VGocn2K8cLrBJRvNN3mmcq0SuMgT/aYi3e8f6WYpX msyw== X-Forwarded-Encrypted: i=1; AHgh+Ro6xv4EkM4Xzdfq9S2iEJBd0/DGl0wRAKz9ht0iAz8DxLFY70oKn7HHGfvIgMkhzVs+PNOErUTPQoWoeik=@vger.kernel.org X-Gm-Message-State: AFuF++lTAcRJF2QKkms3N7+g9sc1EV98oe9X5pu1jJbhZU/NSg4RVImD znYPFSB1JBOTbq5L8YOz1/swIuSj/eWzLFoyySPQESlUU/Yscyv5uOUgbvKI48WVrq8VPcIcSIh +g8TObg== X-Received: from plbkn16.prod.google.com ([2002:a17:903:790:b0:2d6:e484:2160]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:324f:b0:2cc:f5b8:4c2e with SMTP id d9443c01a7336-2d707b45a87mr197320385ad.9.1787787565494; Wed, 26 Aug 2026 16:39:25 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 16:39:10 -0700 In-Reply-To: <20260826233919.998904-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260826233919.998904-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826233919.998904-5-seanjc@google.com> Subject: [PATCH v3 04/13] KVM: selftests: Adapt to the updated VMPTRST behavior when eVMCS is used From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, f734222792@gmail.com, Vitaly Kuznetsov , Sashiko Bot , Yosry Ahmed Content-Type: text/plain; charset="UTF-8" From: Vitaly Kuznetsov Previously, VMPTRST was forbidden with eVMCS and selftests were mocking the correct behavior in vmptrst() by returning enlightened vmptr directly. Since KVM's behavior has changed to match genuine Hyper-V, adjust evmcs test accordingly. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/x86/evmcs.h | 8 -------- tools/testing/selftests/kvm/include/x86/vmx.h | 3 --- tools/testing/selftests/kvm/x86/hyperv_evmcs.c | 5 ++--- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86/evmcs.h b/tools/testing/selftests/kvm/include/x86/evmcs.h index 82a8ea6b661f..c5b9d26f6cdb 100644 --- a/tools/testing/selftests/kvm/include/x86/evmcs.h +++ b/tools/testing/selftests/kvm/include/x86/evmcs.h @@ -265,14 +265,6 @@ static inline bool load_evmcs(struct hyperv_test_pages *hv) return true; } -static inline int evmcs_vmptrst(u64 *value) -{ - *value = current_vp_assist->current_nested_vmcs & - ~HV_X64_MSR_VP_ASSIST_PAGE_ENABLE; - - return 0; -} - static inline int evmcs_vmread(u64 encoding, u64 *value) { switch (encoding) { diff --git a/tools/testing/selftests/kvm/include/x86/vmx.h b/tools/testing/selftests/kvm/include/x86/vmx.h index 04f5e34dea3a..ac7d48d1387e 100644 --- a/tools/testing/selftests/kvm/include/x86/vmx.h +++ b/tools/testing/selftests/kvm/include/x86/vmx.h @@ -358,9 +358,6 @@ static inline int vmptrst(u64 *value) u64 tmp; u8 ret; - if (enable_evmcs) - return evmcs_vmptrst(value); - __asm__ __volatile__("vmptrst %[value]; setna %[ret]" : [value]"=m"(tmp), [ret]"=rm"(ret) : : "cc", "memory"); diff --git a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c index 63ea1533e4ea..6224d859d7bb 100644 --- a/tools/testing/selftests/kvm/x86/hyperv_evmcs.c +++ b/tools/testing/selftests/kvm/x86/hyperv_evmcs.c @@ -92,15 +92,14 @@ void guest_code(struct vmx_pages *vmx_pages, struct hyperv_test_pages *hv_pages, GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages)); GUEST_SYNC(3); GUEST_ASSERT(load_evmcs(hv_pages)); - GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa); + /* VMPTRST returns -1 until VMLAUNCH with eVMCS ptr set */ + GUEST_ASSERT(vmptrstz() == -1); GUEST_SYNC(4); - GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa); prepare_vmcs(vmx_pages, l2_guest_code); GUEST_SYNC(5); - GUEST_ASSERT(vmptrstz() == hv_pages->enlightened_vmcs_gpa); current_evmcs->revision_id = -1u; GUEST_ASSERT(vmlaunch()); current_evmcs->revision_id = EVMCS_VERSION; -- 2.55.0.887.g758fc8c411-goog