Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1661187ybi; Thu, 20 Jun 2019 01:26:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyOJW2Xukb0dGNf+gu+EB0A40s7LWL4zxQwYDdfvmvUYRxYpjb3elcyFMaXoAyuzwPpw/2 X-Received: by 2002:aa7:9f1c:: with SMTP id g28mr105248613pfr.81.1561019199018; Thu, 20 Jun 2019 01:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561019199; cv=none; d=google.com; s=arc-20160816; b=yQhK/VG06p8PklODiPm8DNgA5vsX0DtQjqqQPQ7h4CO8qT2MRVrrPUQQM/IhQtdTLJ tYnZWXmL30OMBG7aKpFqHmsrllWvsd5rq2Ra5Y3sQuVJI0w0k3T/Ds1qQbpK2uopop39 YtKT8Q8U8Hmr013dX9V6Gf3+SyZtUOHELEJqWOaLPLZC26H6g2XDq373ALZiY5o3/IBL jAMbFlGo2w9Tu+efZLcl7ykRhelONHDSatcZO7yK0gbSu+NtKfWrTJhnltRxGdm6LiiP oYKo1LWIYC9A6RUaX8/xLZCdRx9pdQHj/tNG4wdeZFud7Wz3f7MHp5yuzYxjgBc2eoPj Azrg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZK1UlhpuLZcyd9XHAbHKg7Weff0O7Oy2YAd/unLoi4A=; b=bpGHCtwTdX9yYvZcgnqmhfr4H8QPaxMHpS9AS/8BdZv4hiOfs4iZJhpVhdCqf7qNzV 7/f2GWR1FNtiBtq0QdbLImj4Qu7dS3XqYy5dgHJpupu6wCAyR4jEVYPSF8X8DNyKWDyF dq9wntDkAfH3pMjLlPJ8H5VTH9X9OKQsUPSNvsMC04rpMpKXYZBt3PYZBuvaRX8RK7MD eH2Wj/O+qLx31618uwVL4jOOTRBwgOH4xcD+VR48QzujhmkiJF44pQFOSdF82kvgfuBz EYoSeKxFcTM75m+F3nhlXoFuCeVI3H9KyjikanDqYQ8zSSg892s0C8s2u25/yX4dlCfM 4nVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nnkUIanp; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si18497441pfn.182.2019.06.20.01.26.23; Thu, 20 Jun 2019 01:26:39 -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=@gmail.com header.s=20161025 header.b=nnkUIanp; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726246AbfFTI0N (ORCPT + 99 others); Thu, 20 Jun 2019 04:26:13 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:42483 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfFTI0N (ORCPT ); Thu, 20 Jun 2019 04:26:13 -0400 Received: by mail-ot1-f66.google.com with SMTP id l15so1897860otn.9; Thu, 20 Jun 2019 01:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZK1UlhpuLZcyd9XHAbHKg7Weff0O7Oy2YAd/unLoi4A=; b=nnkUIanp3lEYXFV2dbxujXD0AQeroq9ociTuT+GxtG8gtFJXGYMoHcUilcC4RSZ7OJ hG0ZY//LJgvtWdXTsokVukM7VguGsy3isqA+ZOeRjvEeaaM029H6ldMIX1ChluloTShY 5eU8bXCkjGwnLsGiZTaDwjIxyxGkmkN3XjqwHH01J6Rb2VRQ5HTrtf6fL/t6fFDk4u6+ oiruNtmCYiBqn63++HlmWjBM15gpHHZn2uJsyYSMuSylVRvs37U+UHaTmir2DAPFas6o CYjMq3cI+XEqJLrqkbrLUu3ckaN1aQQsSpTIpJB//PcD/Ofh7p4grVB/hi2Xtt8NdAGt zvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZK1UlhpuLZcyd9XHAbHKg7Weff0O7Oy2YAd/unLoi4A=; b=QasyKwcHf9zffXsC6bq9Iy3bntOxsaf1k3O/z9JO+C3QOXUaXdme1Oqw2FNfcbEFWS NCeOTusqFsmbSjgD4+ibNk9Hle94iGvlOczsX5CwKHJbcdpJH6BW5MZLaQWQyMRdcxII PFumLpwNvUTVuYcMf/gOHaEqSBPzNIOtcJgUFgmD4FN1VcjHMZTcGoPxT/Do8uQcG8NI RSc2hZnQWZXazzartrIgoGYMO2l8IFdkVELBD6nVcfUW08PmIxdGhMi6tt5ZUbQ/OLjL +B1WbpaFF12YfawZFxTjLgnBBfpwNRH98pNTM26O71KXEc+qpsHHED1ztaLEB8Oq9pqx WPHg== X-Gm-Message-State: APjAAAUlOXTh55egG8ne50RNQAYhRSBynU+PJbuIsh2SB6kTCBvFuDT5 y25LmiFTKWWbFaw4G3TvSOiJVljxowShAye3F9M= X-Received: by 2002:a9d:6959:: with SMTP id p25mr48678695oto.118.1561019172278; Thu, 20 Jun 2019 01:26:12 -0700 (PDT) MIME-Version: 1.0 References: <20190620050301.1149-1-tao3.xu@intel.com> In-Reply-To: From: Wanpeng Li Date: Thu, 20 Jun 2019 16:27:26 +0800 Message-ID: Subject: Re: [PATCH] KVM: vmx: Fix the broken usage of vmx_xsaves_supported To: Paolo Bonzini Cc: Xiaoyao Li , Tao Xu , Radim Krcmar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , kvm , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Jun 2019 at 16:17, Paolo Bonzini wrote: > > On 20/06/19 08:46, Xiaoyao Li wrote: > >> > >> It depends on whether or not processors support the 1-setting instead > >> of =E2=80=9Cenable XSAVES/XRSTORS=E2=80=9D is 1 in VM-exection control= field. Anyway, > > > > Yes, whether this field exist or not depends on whether processors > > support the 1-setting. > > > > But if "enable XSAVES/XRSTORS" is clear to 0, XSS_EXIT_BITMAP doesn't > > work. I think in this case, there is no need to set this vmcs field? > > vmx->secondary_exec_control can change; you are making the code more > complex by relying on the value of the field at the point of vmx_vcpu_set= up. > > I do _think_ your version is incorrect, because at this point CPUID has > not been initialized yet and therefore > vmx_compute_secondary_exec_control has not set SECONDARY_EXEC_XSAVES. > However I may be wrong because I didn't review the code very closely: > the old code is obvious and so there is no point in changing it. Agreed, in addition, guest can enable/disable cpuid bits by grub parameter, should we call kvm_x86_ops->cpuid_update() in kvm_vcpu_reset() path to reflect the new guest cpuid influence to exec_control? e.g. the first boot guest disable xsaves in grub, kvm disables xsaves in exec_control; then guest reboot w/ xsaves enabled, it still get an #UD when executing. Regards, Wanpeng Li