Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp71209pxk; Wed, 30 Sep 2020 18:15:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2x5KMtzvI44lETbhjZvPbMBH5tM58RviPUmX16txCZe2Gb1o6F3Yek1fFPZp9632oKVrP X-Received: by 2002:aa7:c387:: with SMTP id k7mr5536427edq.242.1601514909767; Wed, 30 Sep 2020 18:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601514909; cv=none; d=google.com; s=arc-20160816; b=ab407bIQS7jeSdMENzhGrKyRzZBdcsiS6MEh0u7Uny8UbHK+DH/vmhH6t7V7tLK1J0 IMiSYV+fMvpLEldmr8MON5UjFDdW+brVcejnDtq3z8HeYlx4epUMiyzRG3e08ZU2QsjP Ge28K1eBO6sUXPXByxeaDMYYpX35owMeDAf+g+6c0zBA4URwIOw/9X8UvpqaxKp7OmXC F0R87iq73hYOctuZRb8MaK2k4Fy2zsUv8ZdV5+hmqZVPAp5RpzDx/6w61o5Q4/848yVV x1+NbuDUzlGt3gLCOmWF1mn5UsDFDDNGyilztke5H0EKSAWfMfukDr5MbiU7UJrOF/65 eI5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=jU3GnJ5VmlaDKAr0GaM/l0IQOtUb6Y5qpS9udCzWoos=; b=cLLpFa+5EJyZR4wY59jYkIkVTyQpRRtTXlvwUKjtdoAIPDq2/wo9JcvbULfXCbBElx CFiEJcz1OP70n9IMk2eCcrsTPoSvRVBnURTKgCR5zMk6IjKantdSCK1z0pALEA+Z3/uY jRLVRvohC1i4gxfl1HN7tA1Maj8sSLJ1EJgXyix4XgqxhFdN//icuwsGvOyPmHxn2gP7 nSRbvI48iI0trewy1/7h/MVXf+5yQV45MLfH956CBbeSA2IDvJus8UYln76U49a3AiNa c0ZLqwpo7k1VsDexZseZBUfV1RdXDXNwh87YkwQQjProt957mTFunOQWxiM0n1FWnOBq 069Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si2383476ejq.222.2020.09.30.18.14.46; Wed, 30 Sep 2020 18:15:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731903AbgJAAID (ORCPT + 99 others); Wed, 30 Sep 2020 20:08:03 -0400 Received: from mga07.intel.com ([134.134.136.100]:60234 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727210AbgJAAID (ORCPT ); Wed, 30 Sep 2020 20:08:03 -0400 IronPort-SDR: QOrSecTYfy1wNKpIgdRhPk/jXOqYdpaxwx/VhQnzsYMVjdkoRZq4fc0juNcSAy9qgu2ADjYlyC 9zx6nZZEQc9g== X-IronPort-AV: E=McAfee;i="6000,8403,9760"; a="226709898" X-IronPort-AV: E=Sophos;i="5.77,322,1596524400"; d="scan'208";a="226709898" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2020 17:07:54 -0700 IronPort-SDR: 1UJ+S4sgmJXexOZ5NPN/D3AT2O/fyuck9i4WqjCgWy/HEdJYwpfSfAqOPkDrBS0lCVlHuCz25h HJYdcPBr3few== X-IronPort-AV: E=Sophos;i="5.77,322,1596524400"; d="scan'208";a="341382868" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.160]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2020 17:07:54 -0700 Date: Wed, 30 Sep 2020 17:07:52 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Eric van Tassell , Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Cannon Matthews , Peter Xu , Peter Shier , Peter Feiner , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Subject: Re: [PATCH 02/22] kvm: mmu: Introduce tdp_iter Message-ID: <20201001000752.GB2988@linux.intel.com> References: <20200925212302.3979661-1-bgardon@google.com> <20200925212302.3979661-3-bgardon@google.com> <4a74aafe-9613-4bf2-47a1-cad0aad34323@amd.com> <2d43d29f-d29c-3dd7-1709-4414f34d27da@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2d43d29f-d29c-3dd7-1709-4414f34d27da@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 01, 2020 at 01:34:53AM +0200, Paolo Bonzini wrote: > On 01/10/20 01:20, Eric van Tassell wrote: > >> > >> +int is_shadow_present_pte(u64 pte) > >> ? { > >> ????? return (pte != 0) && !is_mmio_spte(pte); > > From
> the manual I don't have at my fingertips right now, I believe you should > > only check the low 3 bits(mask = 0x7). Since the upper bits are ignored, > > might that not mean they're not guaranteed to be 0? > > No, this a property of the KVM MMU (and how it builds its PTEs) rather > than the hardware present check. Ya, I found out the hard way that "present" in is_shadow_present_pte() really means "valid", or "may be present". The most notable case is EPT without A/D bits (I think this is the only case where a valid SPTE can be fully not-present in hardware). Accessed tracking will clear all RWX bits to make the EPT entry not-present, but from KVM's perspective it's treated as valid/present because it can be made present in hardware without taking the MMU lock.