Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp364234ybt; Fri, 10 Jul 2020 01:39:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf36vBrY7BTO7syY0sR0j9I9hr9rLL1Opa5UqUbqxG52tvSIHpaT0e2q1LJuekozLSR0k+ X-Received: by 2002:a17:906:ce3c:: with SMTP id sd28mr56431167ejb.382.1594370399071; Fri, 10 Jul 2020 01:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594370399; cv=none; d=google.com; s=arc-20160816; b=1FX65lXnEBGWPmngx94/+5ofaB95NfvQgy9ZTL51cjcBQHxYnHFT+4rBfYESONka1D HA9kGmTFCUydxZiFmni41XX54rEwk1B6IC9wjkVZUzQkDIxSkJuYrpBcmf8VO2BLjA2x 25MkgFq7n24rjecCoYERsVtCeBFbVuEI3vQrdSIRu8+h7scdxXb1Z1TBC1zGPvAsLzLm 4t3d70Yvr+nJVFEa30mqcqL2NcsDwQBvtu0/EraMZaMKnx292OM4sb384Ra2Ve5blku8 mOb8xtAbI+WAj1gUfDMWD1i5LbrXn2FTnJTlPz0R5+PXhlrCwMZ8PknrFTwN4Tf0wGv9 9xOw== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=wihF8WgATGrzyjCcakRoNJsvdCqcYtomuBAUafeVICc=; b=v17zokiHuIPCBViB5KmNqTM4NzKQnOBqRsY6sb8znEcsuwFvqHnng+EBX4NiPN3sf/ Eb/wxyIabC/wOXCeqk3OAuibHal4zh7eEs3TW0U2VKW7LwakgvrVZyHg9xrp+Y8Jtizt c4MUy1gC4tylXz0IdZ7wJW1hxkas5nBoOTE/ttxgSE0h2moh+5jVV0CJftJlCWJyYDyj mpctuGKIXRL3ElZgVsHcG2DBME3dFxLZWQzspaVfKI53KGi80VxM4L2F3NGcuvsbShjS W5cUgbgwZGg4fUmwPjbo9UVZjQBo1S+ieCEYIkP7ggK7KSmGa4oaKi3vcbvCba/22ti6 X7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vfv11znn; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si3673966ejx.92.2020.07.10.01.39.35; Fri, 10 Jul 2020 01:39:59 -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=@redhat.com header.s=mimecast20190719 header.b=Vfv11znn; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgGJIhU (ORCPT + 99 others); Fri, 10 Jul 2020 04:37:20 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51377 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726757AbgGJIhU (ORCPT ); Fri, 10 Jul 2020 04:37:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594370239; 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=wihF8WgATGrzyjCcakRoNJsvdCqcYtomuBAUafeVICc=; b=Vfv11znnE45vaP5pntmuiAX+PymCuuqbvlqG8oA+CFBVZVmPMxegdZqfbrUbDt7nkuZj6a IVLEN+DDEZkL7xyBfQwTXszbAVV1u+VOXDYqQbpdXQSbDJ+/2kzgaz1/GQ4q2QvgRdcBa7 MKcwRTGLY2HU47J2GipvpQ2f02vxbCg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-W7aywa_sPQq_whhAoxJ7jg-1; Fri, 10 Jul 2020 04:37:17 -0400 X-MC-Unique: W7aywa_sPQq_whhAoxJ7jg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 639DC107ACCA; Fri, 10 Jul 2020 08:37:16 +0000 (UTC) Received: from starship (unknown [10.35.206.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D0F35C1D3; Fri, 10 Jul 2020 08:37:14 +0000 (UTC) Message-ID: Subject: Re: [PATCH] KVM: nSVM: vmentry ignores EFER.LMA and possibly RFLAGS.VM From: Maxim Levitsky To: Paolo Bonzini , Jim Mattson Cc: LKML , kvm list Date: Fri, 10 Jul 2020 11:37:13 +0300 In-Reply-To: References: <20200709095525.907771-1-pbonzini@redhat.com> <782fdf92-38f8-c081-9796-5344ab3050d5@redhat.com> <717a1b5d-1bf3-5f72-147a-faccd4611b87@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-07-09 at 20:41 +0200, Paolo Bonzini wrote: > On 09/07/20 20:40, Jim Mattson wrote: > > On Thu, Jul 9, 2020 at 11:31 AM Paolo Bonzini wrote: > > > On 09/07/20 20:28, Jim Mattson wrote: > > > > > That said, the VMCB here is guest memory and it can change under our > > > > > feet between nested_vmcb_checks and nested_prepare_vmcb_save. Copying > > > > > the whole save area is overkill, but we probably should copy at least > > > > > EFER/CR0/CR3/CR4 in a struct at the beginning of nested_svm_vmrun; this > > > > > way there'd be no TOC/TOU issues between nested_vmcb_checks and > > > > > nested_svm_vmrun. This would also make it easier to reuse the checks in > > > > > svm_set_nested_state. Maybe Maxim can look at it while I'm on vacation, > > > > > as he's eager to do more nSVM stuff. :D > > > > > > > > I fear that nested SVM is rife with TOCTTOU issues. > > > > > > I am pretty sure about that, actually. :) > > > > > > Another possibility to stomp them in a more efficient manner could be to > > > rely on the dirty flags, and use them to set up an in-memory copy of the > > > VMCB. > > > > That sounds like a great idea! Is Maxim going to look into that? > > > > Now he is! Yep :-) Best regards, Maxim Levitsky > > Paolo >