Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1969933ybh; Tue, 14 Jul 2020 11:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeKFt40V3A+hzVWb02EYQpmzpPBkIouVgrmiTRweoylU8xwjU1dF2ucTZBW6BQs0h2kJEH X-Received: by 2002:aa7:cfc8:: with SMTP id r8mr6140937edy.125.1594753047473; Tue, 14 Jul 2020 11:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594753047; cv=none; d=google.com; s=arc-20160816; b=qDQj12owYZaidLLBtmBu3J93lts/TgGImSnK5GdCbM0uvRFhJYhmtIGJTQgUJXpFz6 ZE3c3Mbwr8R9xVmvsWmpOHbY2sPY92gi6Vb+dcdA1A0WIy+WgWxyI3uTsEE4NRSOLPch W8hq4wX7+XIpLQvuBKOdw32sdwUFMBLBQI5ccEsl5l7Ik6YhwFGFnmg29bJNXPMHr5wd oPRVyOPo3Xr8Ajl9jNPIrQtRiLqWkZKmBeoXzY1qdoMa65KrOVT5d5WKrsu1AJE60+dX s7MRMocrpn33NHejThzntqKCXzhepcAEoOl5qPoeRANX7EMi7Pvw8oWZ+RgB6CBxk6FB iVfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IwJUAiA8BpGrXQ3dlTzGVWDeFkGjuEAAOtgnYtpstag=; b=N8823y0JUPHcptcqaqpv6jBTb9A7lw51xU6zHnHYHYEsBSgxnQ+wZTO11DH0ev61ZF ZOnpidC1GgRpXzGh1g299rCPXBAyxTc+udV0UxNQx/YmbNx6xu98ZrpB2ex0vQQbytIN OSP1+srgsV0VulQQaYnXxr31u9erKQm1mc1foeWBTh/waGpVQNF2/nWDi3MnlJmPiTWs Zh5gGyzkjyRAnWiLphtTcxyd1k1pSDP5BIDr8ZpXmE1nQ3xlHl9umGj9Ymgh7KlXlmMj a9PkEaxlip1XGc8ZR/y4FSwSqol5R7w2k/4o8AiILJrNMxF1md354h8eYySGT0P1weTu HpkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=r4bMcrj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t27si11042898eji.205.2020.07.14.11.57.03; Tue, 14 Jul 2020 11:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=r4bMcrj+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730943AbgGNS4F (ORCPT + 99 others); Tue, 14 Jul 2020 14:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730930AbgGNSz6 (ORCPT ); Tue, 14 Jul 2020 14:55:58 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFDDCC061794 for ; Tue, 14 Jul 2020 11:55:57 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id d18so18460579ion.0 for ; Tue, 14 Jul 2020 11:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IwJUAiA8BpGrXQ3dlTzGVWDeFkGjuEAAOtgnYtpstag=; b=r4bMcrj+DSWRX7zW5bEHa64p7BZKCexjM5C4F9d6hvYG8IFfMmB4cCzIi/uwzjXpLL 2wIMBo0RJEmz/dP13ZjdgKfDTzbgglyD/ChLlc75bmsM+GfDL4uaBba7dmOrzsimJ2fv mYX8o5YlWF67g7gb04WcxMWJ5IybOK47ZP8FKo2YoDzLx3o2rkgVxpIcC2Is+ZmU5bg+ H2lNsMgB33s6V5s5pSj4VGXILNQRkaRYYMTQG0pqRiCtDNKIKER0bBcnz1s2ntTyM3rV n812s2eeZ2rB9k++XZb556z2QXI9NauLo9sgEZEFt9JX7DQRPwdOR6nRt2Sx73ojA0Fz oulg== 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; bh=IwJUAiA8BpGrXQ3dlTzGVWDeFkGjuEAAOtgnYtpstag=; b=uMW/O90C59OpovZmAze7BFu+WSXsL366WX3BgbPhsMcwdRB0APck9y9VL+b/judNYQ wEyHQhq1tjNTrkFGezmWBWD2mtSbqrLV4NvU/MK6uzVPYs9ubnqq10KSAM2aKm76WlYV KFhY0HXH8SFDlVpY/1GTbDyRVPo0wygZE+jALx+7nCBZNWRn+1szVMFjhMO25x7WgH8V /rdjQhrmT8w6zFgs75N092gyPVlhGaHcyH/Wh+SZ/849kmhfAoiKbCuxnjXwi8q0lkho X9hB5snFSsBkbFBQ0lKHxyXC3dg4h039496W3urEseP4jfL6AHbsre4c348wN+oh6yIV 4nRg== X-Gm-Message-State: AOAM5307MoYboUTrPEJ29HBr6BhMjOU6MBRgaXuZtACwJSfL8YGKo+Sp ear3TuEBenj5b/wFhEnnnTYEKamMgJnycYbHdjHBkA== X-Received: by 2002:a05:6638:118:: with SMTP id x24mr7612352jao.48.1594752956875; Tue, 14 Jul 2020 11:55:56 -0700 (PDT) MIME-Version: 1.0 References: <20200714015732.32426-1-sean.j.christopherson@intel.com> In-Reply-To: <20200714015732.32426-1-sean.j.christopherson@intel.com> From: Jim Mattson Date: Tue, 14 Jul 2020 11:55:45 -0700 Message-ID: Subject: Re: [PATCH] KVM: x86: Don't attempt to load PDPTRs when 64-bit mode is enabled To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Oliver Upton , Peter Shier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 13, 2020 at 6:57 PM Sean Christopherson wrote: > > Don't attempt to load PDPTRs if EFER.LME=1, i.e. if 64-bit mode is > enabled. A recent change to reload the PDTPRs when CR0.CD or CR0.NW is > toggled botched the EFER.LME handling and sends KVM down the PDTPR path > when is_paging() is true, i.e. when the guest toggles CD/NW in 64-bit > mode. Oops! I don't think "is_paging()" is relevant here, so much as "EFER.LME=1." As you note below, KVM *should* go down the PDPTR path when is_paging() is true and EFER.LME=0. > Split the CR0 checks for 64-bit vs. 32-bit PAE into separate paths. The > 64-bit path is specifically checking state when paging is toggled on, > i.e. CR0.PG transititions from 0->1. The PDPTR path now needs to run if > the new CR0 state has paging enabled, irrespective of whether paging was > already enabled. Trying to shave a few cycles to make the PDPTR path an > "else if" case is a mess. > > Fixes: d42e3fae6faed ("kvm: x86: Read PDPTEs on CR0.CD and CR0.NW changes") > Cc: Jim Mattson > Cc: Oliver Upton > Cc: Peter Shier > Signed-off-by: Sean Christopherson Reviewed-by: Jim Mattson