Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4426187ybe; Mon, 9 Sep 2019 09:06:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqydVuFvRgaUsaUOH8uq9GSW5irjOfIEyp/rN3iKHofLtEQ+hxNMRMJIyR3Cmm7jTCILcXM5 X-Received: by 2002:a17:906:8158:: with SMTP id z24mr20016086ejw.54.1568045210278; Mon, 09 Sep 2019 09:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568045210; cv=none; d=google.com; s=arc-20160816; b=IXBGRcaBgwzsJYPeoxhn44PzCys/Pw8qDaC7YgKaBwzdp+1k7GOV8ZGxVPCZ31v+F/ PhJyp1m6w1GTuQeF3JbcsPujVQipOYusomuIKf2g1tWERHKl1Adqso6CeDUqvHt0BQLR NmQ0dini3bE9UiApHzabZ55zHcTuhePgrm23O9GCBNvvlDXDQ7petyQXITLWQ8IuskXO RIODNE4+LppBHCcWwbCIzi87aOKRhdhtR9ptukI//6DyA3hwBm+zFgcUTpGvhSuB6G9E jKq46QGpUfm2ucyojRmjZn5XH3kV7DuonnEjbxhKnuV1Wc+gw2OH8pQ9qBjr0UpFU3tr DytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s7hrK66Efstzu7kJlRH410znsQFoMCEyxKBoWIhj76w=; b=TepHFRFlS0wLk4hTCDcfIYScA6JhhFYGpiOodBmPBQwStfRF0fgqoMNiXRvBQIA+jJ pPemQm9pQ046djzqsd4RBwFTBuAftdZiSpvhOYcMcglhmfJ+L9d1Zc2NMNbf+HBmt3YZ DyigsxMr/bDGDnfAeShlHAkYSrhm1ay0PIoaF7qYN/d3kbn3b/bUt8Uamhz675vJtVOs 2/xSAUFsFqERyJYUxpO3V1Bb/4uvotTENtFBqvzCO9zUWeleju4rU+6gS632iwcaB/I/ dNRt5QCryabkVWVR4c/MosttQ4zagDJ8CsKBYrLomvAu0prI4012mxSDqZFNYWKVflkm dqog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lBsqlfO7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba7si4221511edb.76.2019.09.09.09.06.25; Mon, 09 Sep 2019 09:06:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lBsqlfO7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387705AbfIHMyT (ORCPT + 99 others); Sun, 8 Sep 2019 08:54:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732994AbfIHMwW (ORCPT ); Sun, 8 Sep 2019 08:52:22 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C81821924; Sun, 8 Sep 2019 12:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947141; bh=6h8UT0E/yYp4objGQC8hRgVp1sgY83CoKIH+u/tnTqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBsqlfO7xafO//0h85uzx4vDRAcM0EqN5pH1uzyUD7ah9Zk4qum19ihQMF9OL1glz gSoURqFjtPbmMtf6M7h+Ym46KbgTI0w+iaXCwXUTgjXDRrgNSKRuUSQ6Wvdxj6HxdR W4J8bxe+HQi6vERhlJo4UdqbGAogCGlY3txtSCD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Sasha Levin Subject: [PATCH 5.2 77/94] selftests: kvm: fix state save/load on processors without XSAVE Date: Sun, 8 Sep 2019 13:42:13 +0100 Message-Id: <20190908121152.641769775@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 54577e5018a8c0cb79c9a0fa118a55c68715d398 ] state_test and smm_test are failing on older processors that do not have xcr0. This is because on those processor KVM does provide support for KVM_GET/SET_XSAVE (to avoid having to rely on the older KVM_GET/SET_FPU) but not for KVM_GET/SET_XCRS. Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- .../testing/selftests/kvm/lib/x86_64/processor.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index d2ad85fb01ac0..5f1ba3da2dbd3 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -1059,9 +1059,11 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid) TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XSAVE, r: %i", r); - r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs); - TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i", - r); + if (kvm_check_cap(KVM_CAP_XCRS)) { + r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs); + TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i", + r); + } r = ioctl(vcpu->fd, KVM_GET_SREGS, &state->sregs); TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_SREGS, r: %i", @@ -1102,9 +1104,11 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XSAVE, r: %i", r); - r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs); - TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i", - r); + if (kvm_check_cap(KVM_CAP_XCRS)) { + r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs); + TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i", + r); + } r = ioctl(vcpu->fd, KVM_SET_SREGS, &state->sregs); TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_SREGS, r: %i", -- 2.20.1