Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp145451ybl; Wed, 11 Dec 2019 15:31:03 -0800 (PST) X-Google-Smtp-Source: APXvYqw2xpRFAuLdS9zzBlSEenyB1a8UClYbsKqlyAzFm7ap2zGgj/UHpLpQAfRy64+c5ym0TwC3 X-Received: by 2002:aca:c7cb:: with SMTP id x194mr4628444oif.157.1576107063036; Wed, 11 Dec 2019 15:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576107063; cv=none; d=google.com; s=arc-20160816; b=qAyrDLZsUq1+NgGH4/53jEJxcApNEYDCsszcK830zrk76NvmznqT8fcxzNrIw9vAyF HKkLy8bywLOnZesi/WLzT4b6hWqbHv7QADTCLROB2x2CQXje7b1iReerCo2T0gW98OXL VOKxVoNCeQSuVEHT2mkkczPyqoGLR48i7mY/rIRcyfB7sZGf2UhHp3uzv1wcu9DaWr7a q54fnyE5vSO3/4fOmJIt8VbFeC5pMS/JrLo4YLM6B3SqMLLxYVvd4SiAw6/e8ijPpWQi Z1Dh/T9iHEqEhgANaeCO4ORTUJjwq3GlBxEymypWnCJ3RjZCn+b2SH4ewMFxFc0Vx6tg Ekvw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=8N2VTWKYaoek2MhT9jeNFkodFByKtGdL7R1oeX08/MU=; b=PI1JzphfVWGgAiaYH7G84xUfhmiKGyPY+q8DHc2QUhK9LsU/twIsjLAstFl6GWN/AM fliN8cGAFxRlMQEJ7MhQqnDPVlwk3ixHOIeGM7+wcITHBDY/k26nyvIcoPkclzFtOW27 yw4ueAVX407dNu2ljsdQJsJzT3SmACjPISUGw3Ar6g4Sm5ikaBhJqLy31fom3k7mfz/2 hZDJl3IUMkk4AcAZ+sqVYya7l94I6Up1Q+o20Z+Yt/TGT+OCujZuSusWN89caDdwHvK/ To2c4tJQ6FD2EBlAhj/GWkvFaiJJjJEjeRC5UqXiRTDk56psRdAOO0yOC1msYTH5Wodi jhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gkhj8uzP; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si2068545oih.237.2019.12.11.15.30.49; Wed, 11 Dec 2019 15:31:03 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Gkhj8uzP; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727076AbfLKX2e (ORCPT + 99 others); Wed, 11 Dec 2019 18:28:34 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:34672 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726971AbfLKX2d (ORCPT ); Wed, 11 Dec 2019 18:28:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576106912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8N2VTWKYaoek2MhT9jeNFkodFByKtGdL7R1oeX08/MU=; b=Gkhj8uzPSk2wy0svmnPIzzDoqaQz+KeDI5j2D28sSES81l0Xvow4B5xlc7lq/Kv0quNC5g q2tARvZ4i3rUzB8SH5GcmoeaZU8q1rGMIQonoOZzWSZSNIX6sXOS3BrW1dB0A58dtFg+wE b3sQKRUjfw1UA6xwaLyX5HtPWV/BY/g= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-_GcopwOoPJqiqPZ5_iToKg-1; Wed, 11 Dec 2019 18:28:31 -0500 X-MC-Unique: _GcopwOoPJqiqPZ5_iToKg-1 Received: by mail-wr1-f69.google.com with SMTP id z14so252503wrs.4 for ; Wed, 11 Dec 2019 15:28:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8N2VTWKYaoek2MhT9jeNFkodFByKtGdL7R1oeX08/MU=; b=dUvuwdrdviOtd+pTdq2LQYX/nHDyEwKNgwuOr7GroNul2hg+cqK9/kaQJqAge+SB/y VV24bs/ccIk1Li1JZmOsWoBE86voMlL4+Vy/paa3L4LPunoWhVMdsOGXFKT9IZeHL6QI ZTGg1tdIuAGeuNE71rPkEk5P4XHfOmOAL5OPYmBJuTR5ltYFx8tbe9xFKhE7T9M2Pwq5 iB7QXIie0uYPEZN3ooMpkp6R6AQXVuyoGtSTHzB7FSg2wJ7WeDss8da+teL3Oe+97ZQ8 84dL6ZeWK2VQpm3v50GdZeqazJ+EmEnwPlav6Mq5d3UHH2QdRLwwI3OD2yOUA20EycHz JwRA== X-Gm-Message-State: APjAAAW5//Bi2dPoBIr0YKA8QVCcfmJOK1LZXReqWVLhOpnP4kDYUR/Q L/+GZt4eEDBCOTT+FKCAC9CH3HZ2X4jyBW7IfLb/2JFCnME+tuBhKB9rtOsfKBdxb7m/EUva18M xaDAuojjPwh5jgT5DfYWYOtzL X-Received: by 2002:a5d:4651:: with SMTP id j17mr2661082wrs.237.1576106909758; Wed, 11 Dec 2019 15:28:29 -0800 (PST) X-Received: by 2002:a5d:4651:: with SMTP id j17mr2661056wrs.237.1576106909460; Wed, 11 Dec 2019 15:28:29 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:e9bb:92e9:fcc3:7ba9? ([2001:b07:6468:f312:e9bb:92e9:fcc3:7ba9]) by smtp.gmail.com with ESMTPSA id j21sm4545674wmj.39.2019.12.11.15.28.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Dec 2019 15:28:29 -0800 (PST) Subject: Re: [PATCH v2 1/3] KVM: x86: assign two bits to track SPTE kinds To: Sean Christopherson , Ben Gardon Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vitaly Kuznetsov , Junaid Shahid References: <1569582943-13476-1-git-send-email-pbonzini@redhat.com> <1569582943-13476-2-git-send-email-pbonzini@redhat.com> <20191211191327.GI5044@linux.intel.com> From: Paolo Bonzini Message-ID: <4e850c10-ff14-d95e-df22-0d0fd7427509@redhat.com> Date: Thu, 12 Dec 2019 00:28:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191211191327.GI5044@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/19 20:13, Sean Christopherson wrote: > Assuming we haven't missed something, the easiest fix would be to reduce > the MMIO generation by one bit and use bits 62:54 for the MMIO generation. Yes, and I mistakenly thought it would be done just by adjusting PT64_SECOND_AVAIL_BITS_SHIFT. I will test and send formally something like this: diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6f92b40d798c..aa2d86f42b9a 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -405,11 +405,13 @@ static inline bool is_access_track_spte(u64 spte) } /* - * Due to limited space in PTEs, the MMIO generation is a 19 bit subset of + * Due to limited space in PTEs, the MMIO generation is a 18 bit subset of * the memslots generation and is derived as follows: * * Bits 0-8 of the MMIO generation are propagated to spte bits 3-11 - * Bits 9-18 of the MMIO generation are propagated to spte bits 52-61 + * Bits 9-17 of the MMIO generation are propagated to spte bits 54-62 * + * We don't use bit 63 to avoid conflicting with the SVE bit in EPT PTEs. + * * The KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS flag is intentionally not included in * the MMIO generation number, as doing so would require stealing a bit from @@ -418,15 +418,16 @@ static inline bool is_access_track_spte(u64 spte) * requires a full MMU zap). The flag is instead explicitly queried when * checking for MMIO spte cache hits. */ -#define MMIO_SPTE_GEN_MASK GENMASK_ULL(18, 0) +#define MMIO_SPTE_GEN_MASK GENMASK_ULL(17, 0) #define MMIO_SPTE_GEN_LOW_START 3 #define MMIO_SPTE_GEN_LOW_END 11 #define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \ MMIO_SPTE_GEN_LOW_START) -#define MMIO_SPTE_GEN_HIGH_START 52 -#define MMIO_SPTE_GEN_HIGH_END 61 +/* Leave room for SPTE_SPECIAL_MASK. */ +#define MMIO_SPTE_GEN_HIGH_START PT64_SECOND_AVAIL_BITS_SHIFT +#define MMIO_SPTE_GEN_HIGH_END 62 #define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \ MMIO_SPTE_GEN_HIGH_START) static u64 generation_mmio_spte_mask(u64 gen) Paolo