Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1157717ybl; Thu, 22 Aug 2019 10:09:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCt7l20jPaS2ocXqgaulekZU0xTUgwcLtzvlsa1XwDtZQi0YIObQqzNAec/6rAHpfhi2fJ X-Received: by 2002:a17:90a:eb18:: with SMTP id j24mr727625pjz.82.1566493775218; Thu, 22 Aug 2019 10:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566493775; cv=none; d=google.com; s=arc-20160816; b=D5DTSCbdWmBK5G25uGL6ziSmw80xzYknBh7jgrp1xrDR3uU+WWB5trN4Lg3oxAFw5k ungq6vmNJNnaC1AXZQUV/t1zIUKA75umV5ABmOKsU1PpISF3uTbxd+hPHm1kD2Vc+yqN hL2SAUkO0mC0j+uN46QOgs5tzDWmeFOhKshpjh8Rhyhos+z/IybHS8yupVdvI1HIX5uR a+GNqERkP/1YWWd23xwmvPhnuOT4EIq6guWtBitJ/NM/rgGBKjTuig/ABE/uelJXtigh +C4aaBKewgXIdJZ5JlCD6BpkFN5z8wWslz/rDsm1UjQQPChEABfFQe14LDi3+br/hUHa ykCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/SdWycwBbSIN9022jjhPxcS7tjktncUKSlww6q77f/g=; b=hSzZ4kAcW6hJirdFDG7BVhMyz2rZZnlEsfuEdxBKqF5XpkKVEHCWybtDvMGHYB0aDU eispEyKP/ZE2gS0o9jSFLKuYwmt9cGYUegpyeaTAaMozplZefdnj0nnR909umUpvDul9 wJRpX04VrqLMX/UcWqIXlSpIwX/xjzZkB8F4VDfCrDnGdiKt9cQARu5AUo0PzajBRXJ5 DTsdyUB/9Lp6L+Dw+/s4Ez26SWD3Yp5rGGMEkl1dgoLsV3jRxBuD7kYTWeQBzvlrt9Uo g7WJS4eH+nKxLaUEbhlNq/xLd52UULIFmTTXvj92YVxnjvO7hxYZSOYz+ga16j8zQDuI hY5g== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si187838pjv.67.2019.08.22.10.09.19; Thu, 22 Aug 2019 10:09:35 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732193AbfHVNQW (ORCPT + 99 others); Thu, 22 Aug 2019 09:16:22 -0400 Received: from mga12.intel.com ([192.55.52.136]:16964 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbfHVNQV (ORCPT ); Thu, 22 Aug 2019 09:16:21 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 06:16:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,416,1559545200"; d="scan'208";a="196245250" Received: from unknown (HELO localhost) ([10.239.159.128]) by fmsmga001.fm.intel.com with ESMTP; 22 Aug 2019 06:16:19 -0700 Date: Thu, 22 Aug 2019 21:17:45 +0800 From: Yang Weijiang To: Paolo Bonzini Cc: Yang Weijiang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, sean.j.christopherson@intel.com, mst@redhat.com, rkrcmar@redhat.com, jmattson@google.com, yu.c.zhang@intel.com, alazar@bitdefender.com Subject: Re: [PATCH RESEND v4 7/9] KVM: VMX: Handle SPP induced vmexit and page fault Message-ID: <20190822131745.GA20168@local-michael-cet-test> References: <20190814070403.6588-1-weijiang.yang@intel.com> <20190814070403.6588-8-weijiang.yang@intel.com> <5f6ba406-17c4-a552-2352-2ff50569aac0@redhat.com> <20190820134435.GE4828@local-michael-cet-test.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190820134435.GE4828@local-michael-cet-test.sh.intel.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 20, 2019 at 09:44:35PM +0800, Yang Weijiang wrote: > On Mon, Aug 19, 2019 at 05:04:23PM +0200, Paolo Bonzini wrote: > > On 19/08/19 16:43, Paolo Bonzini wrote: > > >> + /* > > >> + * Record write protect fault caused by > > >> + * Sub-page Protection, let VMI decide > > >> + * the next step. > > >> + */ > > >> + if (spte & PT_SPP_MASK) { > > > Should this be "if (spte & PT_WRITABLE_MASK)" instead? That is, if the > > > page is already writable, the fault must be an SPP fault. > > > > Hmm, no I forgot how SPP works; still, this is *not* correct. For > > example, if SPP marks part of a page as read-write, but KVM wants to > > write-protect the whole page for access or dirty tracking, that should > > not cause an SPP exit. > > > > So I think that when KVM wants to write-protect the whole page > > (wrprot_ad_disabled_spte) it must also clear PT_SPP_MASK; for example it > > could save it in bit 53 (PT64_SECOND_AVAIL_BITS_SHIFT + 1). If the > > saved bit is set, fast_page_fault must then set PT_SPP_MASK instead of > > PT_WRITABLE_MASK. > Sure, will change the processing flow. > > > On re-entry this will cause an SPP vmexit; > > fast_page_fault should never trigger an SPP userspace exit on its own, > > all the SPP handling should go through handle_spp. Hi, Paolo, According to the latest SDM(28.2.4), handle_spp only handles SPPT miss and SPPT misconfig(exit_reason==66), subpage write access violation causes EPT violation, so have to deal with the two cases into handlers. > > Paolo