Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4082064ybl; Tue, 20 Aug 2019 06:47:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqztxgLMeF1D85QY8JWQKb/ClvCj+bR1w/CSzxVQ17NppYKGlBs1IfFkBGxmIjnqMA1iyUkZ X-Received: by 2002:a63:5807:: with SMTP id m7mr24677956pgb.371.1566308857478; Tue, 20 Aug 2019 06:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566308857; cv=none; d=google.com; s=arc-20160816; b=bg8ZtEdzuhf9vyq9a0ps3dR5gBque1B+Flu7eCwCYYyboU1vWAYxTx3BbAYAr0mjLJ bZUACMjf2Z442M7c0i65jMdCbwaBwW76ZYY3IcZ+9tbZKQ0h7zsddMIVNCtsqevie0N5 HfA8c/39ou8ThYX5DTmfw4e/wt1McIbH7xZ2WsZ16X/pXqRdBJ/AEqiCIZYUjfQ+iLxp kICIWFf+6Nrqr+36NsPrU1zOxElea5dfEEwnyM7YkAIK3AVC+/MHoyd+MFFlmZv87pDh I/30gY3PZN8h0Nnj9x+pS1ySop2LiTn11fiPyq921053CLRYr91EihkiWgBv+2A9C6r3 yPng== 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=g5CD+ilUGGZiw0k0wZGwBZJ0+wt5yqVaLFIkLax+NVw=; b=jm3I8PiYA//nyTteUu8xqkvLslY0oti/mOSZHCsMr/rGB9WGLjT3aDC//hkeEz7ajE AXRDSD5lKcSRKWYKziFHyxqSOjlXvXT/TTWhoQ4h8LxAOw9pG18veoGhlF0vGu2s+ntr JdJOm/Dzi3BQWIJ95dRAmpQdhwXkaA9E4HrQoOCa96dUn6zVWm79CX7/Ca37v+eXLaQl zrPJq1vbyXwoUtvx9Zu5O9Amgca5QuFpqtQxjEobVAGhV8xxPU+msi1LKUetpfEOYhwb dIB5IJMkP1ZF286dKPSh/WAN2ImFi2Vpfu+OEA6Mf3oQk4kzyFzpkm3yYE3+aQwHx7V2 IuuQ== 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 r8si12102383pgr.243.2019.08.20.06.47.22; Tue, 20 Aug 2019 06:47:37 -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 S1730636AbfHTNo3 (ORCPT + 99 others); Tue, 20 Aug 2019 09:44:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:8998 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730789AbfHTNnI (ORCPT ); Tue, 20 Aug 2019 09:43:08 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 06:43:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,408,1559545200"; d="scan'208";a="172453032" Received: from unknown (HELO localhost) ([10.239.159.128]) by orsmga008.jf.intel.com with ESMTP; 20 Aug 2019 06:43:05 -0700 Date: Tue, 20 Aug 2019 21:44:35 +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: <20190820134435.GE4828@local-michael-cet-test.sh.intel.com> References: <20190814070403.6588-1-weijiang.yang@intel.com> <20190814070403.6588-8-weijiang.yang@intel.com> <5f6ba406-17c4-a552-2352-2ff50569aac0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. > > Paolo