Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp589040ybp; Fri, 11 Oct 2019 00:49:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqykbK8PBfUwkxx5SvYD1cCdZRhKPI62yFRmJh3fi+EH3gmGDXImW6BLRMcrGZ8TQtnhL0gF X-Received: by 2002:a05:6402:8cf:: with SMTP id d15mr11757124edz.225.1570780167615; Fri, 11 Oct 2019 00:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570780167; cv=none; d=google.com; s=arc-20160816; b=nzpskxHe+MuW6CLpPPW8TRcrKMNjyZEPC2z0t/lRCRQZxe1d5iYMzFAprg/j2gwOr+ 89qY6W3HgvMK8k9DHJXuw8fv47vljVZrIa+mNEa2ldPJWiHmGWWqpIXc7oiPSqiqLm7w qK3zmkUrX5K3Y6dY0AT1LBvcjYNjPuG+ipN/Ipzhzv4LDumE57bzcMx+L4mnbkQjwO1a jdmZz4MQBiZ6SCYCM+mihMb3fa13+wf0JQ8CmevxeA2WAlGxzES5Ix2K1hz0hjx8iqV8 S9m+WYzPiKpY/cgdppv789T3Cq7C+1cjATFr7f+H9L9kHVTFC6EuyRWhxv3bpTjh55LO N6sw== 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=EIYtuBJ97FL9gvGQg0nxkY7sNsoD8jPaplZeGuH11yg=; b=vxpzdbE0B6/ZvVmtGBObJdzV2EkSQPDAp2geB56P50TxNM4BH+tmQGFU62b58ubKba rovyg3RibyvdDEsji8nFM42biL9QSrx3VzGSDeXNFTj9zg5yJUYd0WTYux8g8dRxEdgz BN+fq3T16aSaFUo1gDYJiVUFQgIiBiEPyMDaFLSq60TvOXt66nG6IbmsiKmDTl2Lk4Vf YHkWVFk9ldMBhn2KDD73afkJmm0cOYOwwtUFdHHUfNI6QAPBjm4LDl6UkLvMhXao2cWJ 7LoEU2n1smGWOV7d8fTRWB2XdJavN4H1SDksOjQF3dqVj9lSz77gnLP/DfMA/oZylRER bX4w== 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 a12si4598976ejp.425.2019.10.11.00.49.02; Fri, 11 Oct 2019 00:49:27 -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 S1727592AbfJKHsn (ORCPT + 99 others); Fri, 11 Oct 2019 03:48:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:51255 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbfJKHsm (ORCPT ); Fri, 11 Oct 2019 03:48:42 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2019 00:48:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,283,1566889200"; d="scan'208";a="224257084" Received: from unknown (HELO localhost) ([10.239.159.128]) by fmsmga002.fm.intel.com with ESMTP; 11 Oct 2019 00:48:40 -0700 Date: Fri, 11 Oct 2019 15:50:33 +0800 From: Yang Weijiang To: Jim Mattson Cc: Yang Weijiang , kvm list , LKML , Paolo Bonzini , Sean Christopherson , "Michael S. Tsirkin" , Radim =?utf-8?B?S3LEjW3DocWZ?= , yu.c.zhang@intel.com, alazar@bitdefender.com Subject: Re: [PATCH v5 0/9] Enable Sub-page Write Protection Support Message-ID: <20191011075033.GA11817@local-michael-cet-test> References: <20190917085304.16987-1-weijiang.yang@intel.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 Thu, Oct 10, 2019 at 02:42:51PM -0700, Jim Mattson wrote: > On Tue, Sep 17, 2019 at 1:52 AM Yang Weijiang wrote: > > > > EPT-Based Sub-Page write Protection(SPP)is a HW capability which allows > > Virtual Machine Monitor(VMM) to specify write-permission for guest > > physical memory at a sub-page(128 byte) granularity. When this > > capability is enabled, the CPU enforces write-access check for sub-pages > > within a 4KB page. > > > > The feature is targeted to provide fine-grained memory protection for > > usages such as device virtualization, memory check-point and VM > > introspection etc. > > > > SPP is active when the "sub-page write protection" (bit 23) is 1 in > > Secondary VM-Execution Controls. The feature is backed with a Sub-Page > > Permission Table(SPPT), SPPT is referenced via a 64-bit control field > > called Sub-Page Permission Table Pointer (SPPTP) which contains a > > 4K-aligned physical address. > > > > To enable SPP for certain physical page, the gfn should be first mapped > > to a 4KB entry, then set bit 61 of the corresponding EPT leaf entry. > > While HW walks EPT, if bit 61 is set, it traverses SPPT with the guset > > physical address to find out the sub-page permissions at the leaf entry. > > If the corresponding bit is set, write to sub-page is permitted, > > otherwise, SPP induced EPT violation is generated. > > How do you handle sub-page permissions for instructions emulated by kvm? How about checking if the gpa is SPP protected, if it is, inject some exception to guest?