Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp193186pxb; Tue, 29 Mar 2022 02:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz/1Z5dEj6aXFL1X8kbhngIxPP+DL9bj8pLke1I8Xff+YZpNnwQjgGYl3hh171bKaunSLl X-Received: by 2002:a17:907:6296:b0:6da:745b:7b40 with SMTP id nd22-20020a170907629600b006da745b7b40mr33686497ejc.750.1648546090052; Tue, 29 Mar 2022 02:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648546090; cv=none; d=google.com; s=arc-20160816; b=GxQz5Dxgi8InivbJM6yqQe76KQ1HbxmR1F25rOkeRhapoScsZvMdR7a3qceif6BqMe 3BlZj3Lwx08UoqTipK2YUGHUF7j3mKy1sWzLVY/5fdLNISRQQNpN0TKd2Qmw5jz7ALEq QVRLNesq9kPV/5qXluktGxCKD+hwniL/0jFbMso6eCSGJvrhxBoadsRxuoxkMMIC77gr QYhhpJzfNdvSqimRUJVTRv9pkPnq3/i8Q6CkKbBHqp7CyBGWK7tmANhmG0VlsZWvDrzB 7Pzz3aE/TmIZ5kkQw/GjhZhW0YLiAH6EvPWw3Ak62mpptrOU8x2xCxYiJtFxXV6PkfBT nSJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XhbyMF01RWE5DxN12vKMZdGXrh17xeQHHHna3vJ8fjc=; b=zAq2BDSRWwe++/dUKyRSd8L/ZtVpMBa+8sVjHfe1IXNx+ezloynF6/deDfnO53UMyd RhQJAlEYsAw5jbvicu4mytwlG2m26XsUrvalT76BdbTRdA9M2taTyvgUoVibJnkhEtwd r5O86M/cw1a20JzM6/1sJr7vduX3T8VwF1EjbTvRO3PLeqEeXb8R0hnAuR9QmGVLY9lS 5ioRLObj0WXsBbbbQKEpWdLMQw+Tmo/fDvC6VE21fYA7ADAYARRf012XJkWqRtLuzIND WSyyNi96O1JWEDBPK/THf+R+N9kjbCtDzB2/1KVj4WH4Nmypxo/1SjXigAqCosdxt4C5 5QdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a1709064cd900b006df76385e6csi16550189ejt.780.2022.03.29.02.27.43; Tue, 29 Mar 2022 02:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231416AbiC2DDB (ORCPT + 99 others); Mon, 28 Mar 2022 23:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiC2DC5 (ORCPT ); Mon, 28 Mar 2022 23:02:57 -0400 Received: from out0-138.mail.aliyun.com (out0-138.mail.aliyun.com [140.205.0.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EADE4243151; Mon, 28 Mar 2022 20:01:14 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047198;MF=darcy.sh@antgroup.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---.NF075Bn_1648522871; Received: from localhost(mailfrom:darcy.sh@antgroup.com fp:SMTPD_---.NF075Bn_1648522871) by smtp.aliyun-inc.com(127.0.0.1); Tue, 29 Mar 2022 11:01:11 +0800 From: "SU Hang" To: seanjc@google.com, kvm@vger.kernel.org Cc: "Lai Jiangshan" , "SU Hang" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H. Peter Anvin" , , "Paolo Bonzini" , "=?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?=" , Subject: [PATCH v2 1/2] KVM: VMX: replace 0x180 with EPT_VIOLATION_* definition Date: Tue, 29 Mar 2022 11:01:06 +0800 Message-Id: <20220329030108.97341-2-darcy.sh@antgroup.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20220329030108.97341-1-darcy.sh@antgroup.com> References: <20220329030108.97341-1-darcy.sh@antgroup.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using self-expressing macro definition EPT_VIOLATION_GVA_VALIDATION and EPT_VIOLATION_GVA_TRANSLATED instead of 0x180 in FNAME(walk_addr_generic)(). Signed-off-by: SU Hang --- arch/x86/include/asm/vmx.h | 2 ++ arch/x86/kvm/mmu/paging_tmpl.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 0ffaa3156a4e..3586d4aeaac7 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -546,6 +546,7 @@ enum vm_entry_failure_code { #define EPT_VIOLATION_READABLE_BIT 3 #define EPT_VIOLATION_WRITABLE_BIT 4 #define EPT_VIOLATION_EXECUTABLE_BIT 5 +#define EPT_VIOLATION_GVA_IS_VALID_BIT 7 #define EPT_VIOLATION_GVA_TRANSLATED_BIT 8 #define EPT_VIOLATION_ACC_READ (1 << EPT_VIOLATION_ACC_READ_BIT) #define EPT_VIOLATION_ACC_WRITE (1 << EPT_VIOLATION_ACC_WRITE_BIT) @@ -553,6 +554,7 @@ enum vm_entry_failure_code { #define EPT_VIOLATION_READABLE (1 << EPT_VIOLATION_READABLE_BIT) #define EPT_VIOLATION_WRITABLE (1 << EPT_VIOLATION_WRITABLE_BIT) #define EPT_VIOLATION_EXECUTABLE (1 << EPT_VIOLATION_EXECUTABLE_BIT) +#define EPT_VIOLATION_GVA_IS_VALID (1 << EPT_VIOLATION_GVA_IS_VALID_BIT) #define EPT_VIOLATION_GVA_TRANSLATED (1 << EPT_VIOLATION_GVA_TRANSLATED_BIT) /* diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 95367f5ca998..db594366f60c 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -523,7 +523,8 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, * The other bits are set to 0. */ if (!(errcode & PFERR_RSVD_MASK)) { - vcpu->arch.exit_qualification &= 0x180; + vcpu->arch.exit_qualification &= (EPT_VIOLATION_GVA_IS_VALID | + EPT_VIOLATION_GVA_TRANSLATED); if (write_fault) vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_WRITE; if (user_fault) -- 2.32.0.3.g01195cf9f