Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4153213imu; Mon, 12 Nov 2018 06:40:26 -0800 (PST) X-Google-Smtp-Source: AJdET5cGUorJtlyPl1GK5C9BoVHzB8qYUwUz9dzhL4PvHz4hF0nGncemkREy08SY9y7tHS5UrNcu X-Received: by 2002:a17:902:4d46:: with SMTP id o6-v6mr1227409plh.104.1542033626419; Mon, 12 Nov 2018 06:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542033626; cv=none; d=google.com; s=arc-20160816; b=FmTkmYgexwZ96KC8lmofjEXJrooND48fvTy9jd5Qc/d/jYO8oPkKuhKWiqMe0YM+Bq u1a8wTPxQzxXDY9jkOCMmZ7YOKoPpy28ebvREbWQHo/bjN+u+hl7Bjc3lBadn0UZjObx aC7c+zT1Lgiy/TbI7D416YI/D7uMN0xj5zlXjjaxIXoKDVxdCGL4k14KnA80V+omKdHQ VDo2okeGf+PTdgyUWC9+41ILweF2K/uIW9nNVB+YGIHE+TEEJ5Jm5MRw93xLd3HDCDpU cImHUeP2peLx0g6NOiyK4BUM14lfM381pIXml5RDDdIhygDEx6bPUc2iR7gS4obc0FeX dzsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=gocOSikIKWympMOSCc8HktmkEkLiE/tmEXvgUtBJ4go=; b=o5Zar8g6q6+FqKDNGmkF3nwKmh2lu66lY4hsJ8dn604YR8H7vZHSL4yb/pk3cV3WtU 4nj2YnB8mFhvg68o1ssbKy8Yg79qN7C6dXKlmzmQlFW0Fnr67f1Ui7OBo6zPd1SAtv35 U2jp7H/D9ckgi34rNrWs8fpaCfGz3u1gZj68BcqIcoiR79UcU8TQyUKvW4ior3gEA0l5 NQpYBy87fFJ4gbnqSznrff68Mr1ZS3INItPcWlWMoOPxQVLnrFKzV4etExzKRaC4PiPB ID5MJ9EsB+cyasdW8Myo99RwHcuNSjCmo+dWctJ0I/VwtcqNHa0dYpQAOa3kMlkgS6oY haLw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 n13si12326324pgp.307.2018.11.12.06.40.10; Mon, 12 Nov 2018 06:40:26 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbeKMAdQ (ORCPT + 99 others); Mon, 12 Nov 2018 19:33:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37175 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727030AbeKMAdP (ORCPT ); Mon, 12 Nov 2018 19:33:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13B8CC0C0562; Mon, 12 Nov 2018 14:39:43 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD60D1019632; Mon, 12 Nov 2018 14:39:41 +0000 (UTC) From: Vitaly Kuznetsov To: Jim Mattson , Paolo Bonzini Cc: kvm list , Radim =?utf-8?B?S3LEjW3DocWZ?= , Liran Alon , LKML Subject: Re: [PATCH] x86/kvm/nVMX: tweak shadow fields In-Reply-To: References: <20181019141603.15995-1-vkuznets@redhat.com> <31279dfd-d0a1-3720-46a2-52395a124057@redhat.com> Date: Mon, 12 Nov 2018 15:39:40 +0100 Message-ID: <87pnvas6kz.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 12 Nov 2018 14:39:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jim Mattson writes: > I'm not convinced that the "one size fits all" and "context-free" > approaches to VMCS shadowing are terribly effective. > > For example, we never shadow VMX_INSTRUCTION_INFO, but if we just > reflected an exit to L1 for which that field is defined, there's > probably a good chance that L1 will use it. We always shadow > VM_EXIT_INTR_INFO, but if we didn't just reflect exit reason 0 to L1, > it's not likely to be read. If the L2 guest is in legacy mode or > compatibility mode, L1 is much more likely to be interested in the > contents of the descriptor cache than if the guest is in 64-bit mode. > > Some hypervisors write TSC_OFFSET quite frequently. Others rarely. > Last time I checked (it's been a while), VirtualBox was always > interested in everything. :-) Kvm, Hyper-V, VMware, VirtualBox, > Parallels...they all have different patterns, and they change from > release to release. > > Is it worth having a set of VMCS shadowing bitmaps per-vCPU, in order > to make better use of this feature? Per CPU or not, to improve the feature we'll probably need some sort of an 'adaptive' algorithm picking which fields to shadow. I haven't thought this through, especially read/write shadowing, but we can probably start with an empty bitmap and later shadow it when we get over some threshold of vmread/vmwrite exits we enabling shadowing. The question is when we un-shadow it. For example, we can un-shadow a field for writing every time we see it was not changed between two exits to L0 (so we're trying to write the same value to vmcs12). -- Vitaly