Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448009yba; Fri, 17 May 2019 17:49:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzo+ITJbl82SUcmOkg0GiMTWpMET0OGV7gSZSwfBPCjlhWY4oPYmMwt0+kOTnaeAlt0viam X-Received: by 2002:aa7:980e:: with SMTP id e14mr64325145pfl.142.1558140560008; Fri, 17 May 2019 17:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558140560; cv=none; d=google.com; s=arc-20160816; b=VnDRJB43BjdXoijqOvlwjvQfx0gCYkRwfLFIDND3O/cEGAzg/SauumcOMykYwjNPAP DyByhVf0Vq18jTTFzKtNOnTQkxT/lpKPLRt4Vd1pMIPOcJVA8NiqUfYEcg+pyN5WlXr8 kim9Iy88h0zZcVFfuWhFZ/dQEtUKchELpZhYHYatKKFFvQ1AzsSAafaOFmlK0bLSYOHm lddQORdUR78fET9WW8WGPVprAIpFouaHr0VFBe7W/p6os5XJK9QRGIZKAVuMzU4t1XC9 u+wIl/KjNRYxhDGl+9LqB5Aw0uuEB8di51rHNrEojQ/+QhHVWxgl/LplLdDXvvKNizvZ fqjA== 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=qUU/PCHJ10Cnm4pEYGt2NYLBE8MczWcaqgp3zO0rTb0=; b=Bqt+cCnmaXRnmOh82UP/lyxDx68D6wIIxNuLoRzeJWkZ/kNXkTK22gnq8Imu3KPKGE G4EPqx8yMZtPU419Shng3eesoxvj5PjMhQlTJzZaNF92TWjBuHM/q507XFgq2Lfv8Bm/ KOcr0eDK3lyB+WQY099Cj2rPh0eQ40iZcFrWIaexevvYHSrnytEDDIlzfSgZaa2p+Tbb MkVBCoP4/e6m6ReyTYt3rD8Mufe8Q2z7E2xPVQOj0BaU7qgTvft5lJKZmbcgmeOqFoN2 MpAfZrYzhBY5nCKAJAjGGgzEvsn3flOquEAPbZKV5M76dVwA6yg2Q9QaY7o01C87vdsD mWhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XpHCXZ0v; 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=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x123si11003574pfx.157.2019.05.17.17.49.02; Fri, 17 May 2019 17:49:19 -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=@google.com header.s=20161025 header.b=XpHCXZ0v; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729012AbfERAGK (ORCPT + 99 others); Fri, 17 May 2019 20:06:10 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:42736 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbfERAGK (ORCPT ); Fri, 17 May 2019 20:06:10 -0400 Received: by mail-qk1-f196.google.com with SMTP id d4so5510744qkc.9 for ; Fri, 17 May 2019 17:06:09 -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:content-transfer-encoding; bh=qUU/PCHJ10Cnm4pEYGt2NYLBE8MczWcaqgp3zO0rTb0=; b=XpHCXZ0vlW6ZB0LjNM3gSWk+gqE+tUaKl7t5x0Uy0r30UxhLbJy+WPkVwwq+x9/KQw +CRNhMn/4++Gq8rK/DF2O3PN4lwDVocPTCjf90D6TQL/JFiByl1VKPohza0LgoggQUBz PBQbfib83VzeF6lJ7d6/ERQaZw7rah61nnorKe+b9YXK0B+pXNDa5VZsNEEl7foC4tjD 1/Bh+WHotDx8JFM0DJ3sa09ujJ/a8zWFMl0O2QphX/caCiFP54RYDbSlvUZFlGbJK594 7fySsbMJ780nVzcYMRutROAriGZ/5rGlAuaXRPOzLRCsbglNSZkVH0rCdmrEB4TiipDl cTYg== 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=qUU/PCHJ10Cnm4pEYGt2NYLBE8MczWcaqgp3zO0rTb0=; b=d726qp1ocScQEqe1YGpXEo6K4wq4OCTa/nwYiWanRNFENyBESL3ABOeqfCZvxzwyEq EgHE9V/UveoHVRstQ4ktZVUIQYXZ6f9tUCk36glL6LJxiHw1aXMsrZvxyqsWAuXVZtCh 6w/7NejZ/iTSJVwJvwFeKPe9Ostn/y9CijrknBDiYJ7iS/2LrHLikd/KjPfQ7/OTOP0+ wARHS0Z3/hfHjw+msIlSYo3kacIo63K1DDmGiVVjzGLx24g6KCGRimtQOVCpTMskMUIz vNp/iDYz+nN4NkxKJVwtWB/tJbhuZ5ORsgtGagjW94AvOI1BPRdc5IG9SiJtX2pbL5p/ GYXg== X-Gm-Message-State: APjAAAVWINa0Z5zFEuiKmKU8zn3ToQ//DjOnx+OyNrG6Ap3Cg1Gd/tjB GmhOO9mkBxHPQFFyIOaYNwYXiQXGykMS8kWpg43y X-Received: by 2002:a37:4948:: with SMTP id w69mr49213504qka.122.1558137968878; Fri, 17 May 2019 17:06:08 -0700 (PDT) MIME-Version: 1.0 References: <4e7d52d7-d4d2-3008-b967-c40676ed15d2@oracle.com> <20190514170522.GW2623@hirez.programming.kicks-ass.net> <20190514180936.GA1977@linux.intel.com> <20190514210603.GD1977@linux.intel.com> <20190514223823.GE1977@linux.intel.com> In-Reply-To: <20190514223823.GE1977@linux.intel.com> From: Jonathan Adams Date: Fri, 17 May 2019 17:05:32 -0700 Message-ID: Subject: Re: [RFC KVM 18/27] kvm/isolation: function to copy page table entries for percpu buffer To: Sean Christopherson Cc: Andy Lutomirski , Andy Lutomirski , Peter Zijlstra , Alexandre Chartre , Paolo Bonzini , Radim Krcmar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , kvm list , X86 ML , Linux-MM , LKML , Konrad Rzeszutek Wilk , Jan Setje-Eilers , Liran Alon 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 Tue, May 14, 2019 at 3:38 PM Sean Christopherson wrote: > On Tue, May 14, 2019 at 02:55:18PM -0700, Andy Lutomirski wrote: > > > On May 14, 2019, at 2:06 PM, Sean Christopherson wrote: > > >> On Tue, May 14, 2019 at 01:33:21PM -0700, Andy Lutomirski wrote: > > >> I suspect that the context switch is a bit of a red herring. A > > >> PCID-don't-flush CR3 write is IIRC under 300 cycles. Sure, it's slo= w, > > >> but it's probably minor compared to the full cost of the vm exit. T= he > > >> pain point is kicking the sibling thread. > > > > > > Speaking of PCIDs, a separate mm for KVM would mean consuming another > > > ASID, which isn't good. > > > > I=E2=80=99m not sure we care. We have many logical address spaces (two = per mm plus a > > few more). We have 4096 PCIDs, but we only use ten or so. And we have= some > > undocumented number of *physical* ASIDs with some undocumented mechanis= m by > > which PCID maps to a physical ASID. > > Yeah, I was referring to physical ASIDs. > > > I don=E2=80=99t suppose you know how many physical ASIDs we have? > > Limited number of physical ASIDs. I'll leave it at that so as not to > disclose something I shouldn't. > > > And how it interacts with the VPID stuff? > > VPID and PCID get factored into the final ASID, i.e. changing either one > results in a new ASID. The SDM's oblique way of saying that: > > VPIDs and PCIDs (see Section 4.10.1) can be used concurrently. When thi= s > is done, the processor associates cached information with both a VPID a= nd > a PCID. Such information is used only if the current VPID and PCID both > match those associated with the cached information. > > E.g. enabling PTI in both the host and guest consumes four ASIDs just to > run a single task in the guest: > > - VPID=3D0, PCID=3Dkernel > - VPID=3D0, PCID=3Duser > - VPID=3D1, PCID=3Dkernel > - VPID=3D1, PCID=3Duser > > The impact of consuming another ASID for KVM would likely depend on both > the guest and host configurations/worloads, e.g. if the guest is using a > lot of PCIDs then it's probably a moot point. It's something to keep in > mind though if we go down this path. One answer to that would be to have the KVM page tables use the same PCID as the normal user-mode PTI page tables. It's not ideal (since the qemu/whatever process can see some kernel data via meltdown it wouldn't be able to normally see), but might be an option to investigate. Cheers, - jonathan