From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2732C7618F for ; Tue, 16 Jul 2019 19:45:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2E962145D for ; Tue, 16 Jul 2019 19:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbfGPTpg (ORCPT ); Tue, 16 Jul 2019 15:45:36 -0400 Received: from mga12.intel.com ([192.55.52.136]:45443 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbfGPTpg (ORCPT ); Tue, 16 Jul 2019 15:45:36 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2019 12:45:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,271,1559545200"; d="scan'208";a="366771520" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.165]) by fmsmga006.fm.intel.com with ESMTP; 16 Jul 2019 12:45:35 -0700 Date: Tue, 16 Jul 2019 12:45:35 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Liran Alon , "Singh, Brijesh" , "rkrcmar@redhat.com" , "kvm@vger.kernel.org" , Boris Ostrovsky Subject: Re: [PATCH 1/2] KVM: SVM: Fix workaround for AMD Errata 1096 Message-ID: <20190716194535.GB28096@linux.intel.com> References: <20190716164151.GC1987@linux.intel.com> <60D01C4B-EC2E-453E-B5F6-BBE8FA94E31D@oracle.com> <015b03bc-8518-2066-c916-f5e12dd2d506@amd.com> <174F27B9-2C6B-4B9F-8091-56FA85B32BB2@oracle.com> <3cdd12c4-c3fa-5157-1a91-69e333750152@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3cdd12c4-c3fa-5157-1a91-69e333750152@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Jul 16, 2019 at 09:39:48PM +0200, Paolo Bonzini wrote: > On 16/07/19 21:34, Liran Alon wrote: > >> When this errata is hit, the CPU will be at CPL3. From hardware > >> point-of-view the below sequence happens: > >> > >> 1. CPL3 guest hits reserved bit NPT fault (MMIO access) > > Why CPU needs to be at CPL3? > > The requirement for SMAP should be that this page is user-accessible in guest page-tables. > > Think on a case where guest have CR4.SMAP=1 and CR4.SMEP=0. > > > > If you are not at CPL3, you'd get a SMAP NPF, not a RSVD NPF. I think Liran is right. When software is executing, the %rip access is a code fetch (SMEP), but the ucode assist is a data access (SMAP). This likely has only been observed in a CPL3 scenario because no sane OS exercises the case of the kernel executing from a user page with SMAP=1 and SMEP=0.