Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5751763imm; Mon, 23 Jul 2018 05:34:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfbtx81pe1Q4FDslqweTXhor5EkYts8gNCdoH5iGWGPy1NS2Xry6ot+H765c5hwPHLpzVt8 X-Received: by 2002:a63:cf10:: with SMTP id j16-v6mr12119851pgg.238.1532349278582; Mon, 23 Jul 2018 05:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532349278; cv=none; d=google.com; s=arc-20160816; b=puJhGuXxkXm89rk7STQ2PH2TA0abDghGhuY1dEaEhqJWR9fWhfMq+q1x0Xq3r+PR7n j9q/DAmapyPpW/GcDszRa5enP/+GYAh6q0Fy4OwF5aSR4OE9jlATcArXL4jOrbcRwoeP rGa6xJZumes/5lRg2FED21vJ2zV9KWFeImYYbAqe1wADlxueEoGTzPqXp8piobV2kFfD 7+NRlNA4U6YwrSpeH8+rN7XVeuSbHnS6VsKaaWSonMxfJKYeRiHb8GSUZ8kdg50jwSCl 0NAr7YbDfGwYSNcfgvuOJaVrZmjzUoU/50SExsA3ynsTT2oVHp1S91KZ4e5wFWFBss9y N1rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:from:dkim-signature:arc-authentication-results; bh=3XT8Ldm/ZPmuJFNOrIS0TpEZiluhjKoPQ8WhOHN3UoI=; b=EUtnUCNKhZY8bYkF+M6XcXf38B4KrHPt2ezr6XXBIbC5DhJnVX65Q58lczDc6A4tMx kodEQnElfOfffNfbdZhQp/lCWYH8zQy1BCFhOU5XcKXdkGde34xBJWq9XkC5Xovjstqx Q4V+Im0E6XxuwObQUGtBfCToxHgamVe0jeVmF7em04M2sy+nfMvF3zB1euw15WzvB6ny Oe+/uwYJsoFv4CDB3mVTkrnBpgDYEUyjmoZUTHu7RABuaWcr+/7mpUMjqukSG8i7yjkX Z6mfjSXGEraDdBotCbicMjbwojvBrHkKHP7ePB/306bBPoxzHJH6nzR0nP7QwkqDbaUT WCnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=kqhB592v; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v38-v6si8552352pgn.431.2018.07.23.05.34.24; Mon, 23 Jul 2018 05:34:38 -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=@microsoft.com header.s=selector1 header.b=kqhB592v; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389542AbeGWNca (ORCPT + 99 others); Mon, 23 Jul 2018 09:32:30 -0400 Received: from mail-sg2apc01on0129.outbound.protection.outlook.com ([104.47.125.129]:33472 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389519AbeGWNc3 (ORCPT ); Mon, 23 Jul 2018 09:32:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3XT8Ldm/ZPmuJFNOrIS0TpEZiluhjKoPQ8WhOHN3UoI=; b=kqhB592vqORf0EOzZo3peE9yDjHZH02ojKXtRcHHNlnYSoo0vsUp1tm/mPtSoi8uX4bHGsIJN9tWkfkKRbWXQ7ArOBTagf0XWiSbHFNRLdYsowW5kF+4DVIRCr0+aSum0aKNHBIkSc18xebV29FM2IO9XpfXVld4z5lNh7r0GhU= Received: from SG2P15301MB0093.APCP153.PROD.OUTLOOK.COM (10.170.136.145) by SG2P15301MB0032.APCP153.PROD.OUTLOOK.COM (10.170.136.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.2; Mon, 23 Jul 2018 12:31:22 +0000 Received: from SG2P15301MB0093.APCP153.PROD.OUTLOOK.COM ([fe80::f916:a637:8730:be25]) by SG2P15301MB0093.APCP153.PROD.OUTLOOK.COM ([fe80::f916:a637:8730:be25%4]) with mapi id 15.20.1017.000; Mon, 23 Jul 2018 12:31:22 +0000 From: Tianyu Lan CC: Tianyu Lan , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [Resend PATCH] KVM/x86: Move X86_CR4_OSXSAVE check into kvm_valid_sregs() Thread-Topic: [Resend PATCH] KVM/x86: Move X86_CR4_OSXSAVE check into kvm_valid_sregs() Thread-Index: AQHUIoEQuP+K20xWXUS3BXuD3kRNIw== Date: Mon, 23 Jul 2018 12:31:21 +0000 Message-ID: <20180723123108.15685-1-Tianyu.Lan@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tianyu.Lan@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SG2P15301MB0032;6:MPJc3ikOj0LbulUmADASD2krV/RoZ0XvsuoPDcGnvPbvyCCChi1djl5JVKcxNo5/Oj7iXemJF1RbHIOJZa6zVRPbAvaAjGWjJ0dZtEsRP9bR4uVa1+fvUbup24u/1MPlTuBD4vxLt1+Y4danFgpH4Ewq5yG/qYEWmmOKXmQ7E5PLP7vFtb59HLFbI+5K5yC4Z8fin8y3/iX6Uqd3p6XkagaijGXIPE9JY8/SBZR0ozbzoVy/llYGVQM4rb7P+81x/D4UhwxH14R1HnJ6BKEl5L3IGT4S/p5A7HMqy9Oy39KtY/GbAqL+nwqXbsxupQ0q6h4xquu0UllhfgZ6rzqU08z0VDZfYg1R4qPNsuxzbXq69IwzotD9KtZ+aYhwO+UWwoB9lFpa4YrIWTYBpMSl6ZTSIsqKzmPI6jr8eoBumR1yy9dnOd3rKLDd4UaAZ7P71w5QNARlLBeq5R/M086JKg==;5:OYPYHQhpBDsMjAJUBlbTQVHJY7Lv0F2m6L81q6fHCA/q0GDp4Hvn8aEJ5t0dyjkZnsApwX+jAC1wx9kXujMH3U+Y64h4XLxTv1SWfSHiEg7tN4vZFYiYBFbuyY35U1KwhIZUnR+RRJQigsmddO/drdgLshZYFrnhsY9y9MnrbYQ=;7:uwRFoUjCaFDFDSZq9XyuZ82p9b75TrMLatNftGxm/vCv3LguBEr2N+nN4NovCbojSD5upEWggS7yTZKeRW4Fwl5iQY4bBDCZzz3nclhRkdp0WXfhgawQUfMuCDAF2shTjHy2wDfGlSz2z1TQo6sr38q198L6dqnSejoelDNbxms6h85Pcpac7I6Kw3BYeZ29hReQAXYXvfppZPhAmW2py2b18LQ6d1Agpfi4NAZl4E0ErEZtjvgqPBCAMzN+jKwE x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 8402507b-e47b-43f3-29fc-08d5f09832f5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7193020);SRVR:SG2P15301MB0032; x-ms-traffictypediagnostic: SG2P15301MB0032: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:SG2P15301MB0032;BCL:0;PCL:0;RULEID:;SRVR:SG2P15301MB0032; x-forefront-prvs: 0742443479 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(346002)(396003)(136003)(39860400002)(189003)(199004)(106356001)(3846002)(4326008)(5660300001)(486006)(97736004)(1076002)(1671002)(109986005)(2616005)(476003)(26005)(54906003)(86612001)(6116002)(316002)(256004)(22452003)(59246006)(99286004)(478600001)(53936002)(6506007)(6486002)(102836004)(86362001)(10290500003)(25786009)(72206003)(6436002)(2900100001)(7736002)(2906002)(68736007)(66066001)(10090500001)(8936002)(81166006)(305945005)(81156014)(14454004)(6512007)(36756003)(105586002)(5250100002)(8676002);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2P15301MB0032;H:SG2P15301MB0093.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HgLkme+4RLLHSj+1LKAR9RD+QEmc/g14uL9RbFYYL/xeE9b4AewLcKYBasJHHwIyh4UX1Si0arO3uzM5h6T39y62Fm5aadHt8KfVKF22jg0Qt7/PiD4TKOd94Mlu4SKl4xbS8Vw1hUIbGIY1FPC3gK0irY6+BVVOZegK2gc7w43trL4Q7/BwRwYL0VbCvef9bZp4SeKNTB7TQMLvI8ac+Oq2P7ia1r0iz/Ph2r81fJAsZlwdRHdbNw3SYGCxff0SGQvEAcVGJFwYOBWVcJqHXRyv5oleGOvCKXHkEke9Id6q52+y6KxGaOrxIw7wlVjTIcMjdDU/4BXcOVyPYEWwPJbLeQTsBCrMCvzhgs1nFxY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8402507b-e47b-43f3-29fc-08d5f09832f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jul 2018 12:31:21.8462 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2P15301MB0032 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X86_CR4_OSXSAVE check belongs to sregs check and so move into kvm_valid_sregs(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 153564db7980..5c9acdbb2020 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8045,6 +8045,10 @@ EXPORT_SYMBOL_GPL(kvm_task_switch); =20 static int kvm_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { + if (!guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) && + (sregs->cr4 & X86_CR4_OSXSAVE)) + return -EINVAL; + if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG)) { /* * When EFER.LME and CR0.PG are set, the processor is in @@ -8075,10 +8079,6 @@ static int __set_sregs(struct kvm_vcpu *vcpu, struct= kvm_sregs *sregs) struct desc_ptr dt; int ret =3D -EINVAL; =20 - if (!guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) && - (sregs->cr4 & X86_CR4_OSXSAVE)) - goto out; - if (kvm_valid_sregs(vcpu, sregs)) goto out; =20 --=20 2.14.3